Hi Yordy:

I'm sorry. The xdp module is one that was written here by my group to provide I/O for data files produced at our beamline. I have packaged it for Debian but it is not out there for the general public yet. In the program I sent you the xdp module is only used to write out the converted data is a file format that we call SFF (Simple File Format).

The xdp module is not necessary if you simply write out the converted data with a more normal set of commands.

Your email got me thinking though that I should finish the progrram and make it useful to others. What I did, therefore, is to rewrite the program without the use of xdp and making it a bit more user-friendly. It now also handles both of the filetypes that Matt mentioned on a previous post, and which are documented at

http://cars9.uchicago.edu/ifeffit/FAQ/Data_Handling#head-e7e2389af58d378379f3bbe2a827c73a6df2a42e

The program now runs fine under Python 2.5 (I don't know about 2.6 but let me know if it has problems!). It is used as a standard *nix filter, that is, rename it to "lytle_convert" (or make a link to it) and make sure it is executable and in the executing PATH so the system can find it.

The program is invoked from the command line as

$lytle_convert file0 [file1 file2 file3 ... fileN]

It does take wildcards so you can process a bunch of files at once. Since all the Lytle database files are of the form "name.ext", the output file name is made to be "name_ext.sff".

The program does its best to guess the steps per degree for the olert file type which does not include that information in the header. The d-spacing is assumed to be 1.92017. This may not work for all files (I have not checked and I didn't have time to put in more intelligence right now) so you might need to go in to modify the program to change these defaults. I am thinking that I will add options to let the d-spacing and steps per degree be set on the command line but that will have to wait for later.

Enjoy!

Carlo

On Sat, 31 Jan 2009, Yordy Licea Fonseca wrote:

Hi Carlo,

I´ve installed Python 2.6 for Windows XP to run your code. Latter I've
installed a numpy 1.2.1 compiled for 2.6. I did neither find the
*Numeric *module
nor the *xdp* module you initialized first in the code. So I've intalled Py
2.4 version and again numpy, but didn not work.
In 2.6 there is a *math* module that works similar to *Numeric*. As I did
not find what *Numeric.zeros* does in line 32 I could not implement (if it
were possible) with *math.*
Could I use *xdrlib* module instead of *xdp?*
**
Would you send me or tell me please where to find those modules and which
Python you recommend me to install?

Best wishes, Yordy




2009/1/29 Carlo Segre <se...@iit.edu>

Ah, just premature sending...

Carlo

On Thu, 29 Jan 2009, Yordy Licea Fonseca wrote:

  Hi Carlo and Matt,

Thank you very much for your help.

Best wishes,

Yordy


On 29/01/2009, ifeffit-requ...@millenia.cars.aps.anl.gov <
ifeffit-requ...@millenia.cars.aps.anl.gov> wrote:


Send Ifeffit mailing list submissions to
      ifeffit@millenia.cars.aps.anl.gov

To subscribe or unsubscribe via the World Wide Web, visit
      http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit
or, via email, send a message with subject or body 'help' to
      ifeffit-requ...@millenia.cars.aps.anl.gov

You can reach the person managing the list at
      ifeffit-ow...@millenia.cars.aps.anl.gov

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Ifeffit digest..."


Today's Topics:

 1. Trouble with fitting with Artemis (Juraci A. Sampaio)
 2. Re: Trouble with fitting with Artemis (Richard Mayes)
 3. about Farrel Lytle data of Na2WO4.2H2O (Yordy Licea Fonseca)
 4. Re: about Farrel Lytle data of Na2WO4.2H2O (Matt Newville)
 5. uncertainty in linear combination analysis (Pushan Shah)
 6. Artemis parameters (abhijeet gaur)
 7. Energy shift (Eugenio Otal)


----------------------------------------------------------------------

Message: 1
Date: Wed, 28 Jan 2009 15:34:55 -0300
From: "Juraci A. Sampaio" <jasamp...@hotmail.com>
Subject: [Ifeffit] Trouble with fitting with Artemis
To: <ifeffit@millenia.cars.aps.anl.gov>
Message-ID: <col107-w60310e438349ce1c72988aac...@phx.gbl>
Content-Type: text/plain; charset="iso-8859-1"


Hi there!I'm getting the following message when I try to fit my
data:WARNING.  The following variables had no effect on the fit:  !!  >>
amp                                                       !!  >>
enot                                                      !!  >>
delr                                                      !!  >> ss The
data
that I am trying to fit is the Cu metal example that come with the
iffefit
package. I am running Artemis on a Mac, OSX 10.4.11.I could run the
fitting
on a mac OSX 10.5 and it worked fine. I reinstall the IXAFS package but
it
didn't work.I am wondering what could be wrong with my
machine/software?Thanks a lot.Juraci Sampaio
_________________________________________________________________
Confira v?deos com not?cias do NY Times, gols direto do Lance,
videocassetadas e muito mais no MSN Video!
http://video.msn.com/?mkt=pt-br
-------------- next part --------------
An HTML attachment was scrubbed...
URL:

http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20090128/eb8f16cc/attachment-0001.html

------------------------------

Message: 2
Date: Wed, 28 Jan 2009 14:29:58 -0500
From: Richard Mayes <rtma...@gmail.com>
Subject: Re: [Ifeffit] Trouble with fitting with Artemis
To: XAFS Analysis using Ifeffit <ifeffit@millenia.cars.aps.anl.gov>
Message-ID:
      <5a2a54820901281129n2b0d8fc4ib02a2ed2faeca...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Juraci,

Can you please attach a project file so we can look at it and try to find
the problem.  My first guess would be the parameters are not defined in
the
"guess,def,set" page like they are in the path list but without seeing
the
project file, it's hard to be specific.

-Rich

On Wed, Jan 28, 2009 at 1:34 PM, Juraci A. Sampaio <
jasamp...@hotmail.com

wrote:


 Hi there!

I'm getting the following message when I try to fit my data:
WARNING.  The following variables had no effect on the fit:
!!  >> amp
!!  >> enot
!!  >> delr
!!  >> ss

The data that I am trying to fit is the Cu metal example that come with

the

iffefit package. I am running Artemis on a Mac, OSX 10.4.11.
I could run the fitting on a mac OSX 10.5 and it worked fine. I
reinstall
the IXAFS package but it didn't work.

I am wondering what could be wrong with my machine/software?

Thanks a lot.


Juraci Sampaio


------------------------------
Not?cias direto do New York Times, gols do Lance, videocassetadas e

muitos

outros v?deos no MSN Videos! Confira j?! <

http://video.msn.com/?mkt=pt-br>


_______________________________________________
Ifeffit mailing list
Ifeffit@millenia.cars.aps.anl.gov
http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit


-------------- next part --------------
An HTML attachment was scrubbed...
URL:

http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20090128/7f56b17f/attachment-0001.html

------------------------------

Message: 3
Date: Wed, 28 Jan 2009 18:18:00 -0200
From: Yordy Licea Fonseca <yliceafons...@gmail.com>
Subject: [Ifeffit] about Farrel Lytle data of Na2WO4.2H2O
To: ifeffit@millenia.cars.aps.anl.gov
Message-ID:
      <6bc7d27d0901281218t6eac4721o1922c155b95a1...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi,

Sorry, I could not find enough information.
Would any of you tell me, please, how is the EXAFS data tabulated in
Farrel
Lytle data base?
The first column is the energy, what about others?
I would like to obtain the absorption coefficient vs energy from this
file:

http://ixs.csrri.iit.edu/data/Farrel_Lytle_data/RAW/W/wna.095

Best wishes,

--
Yordy E. Licea Fonseca
Departamento de F?sico-Qu?mica
Instituto de Qu?mica-IQ/UFRJ
Laborat?rio de Cat?lise Heterog?nea
Rio de Janeiro, RJ, CEP 21.949-909
Brasil
Email: yliceafons...@gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:

http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20090128/cea4d817/attachment-0001.html

------------------------------

Message: 4
Date: Wed, 28 Jan 2009 14:24:22 -0600
From: Matt Newville <newvi...@cars.uchicago.edu>
Subject: Re: [Ifeffit] about Farrel Lytle data of Na2WO4.2H2O
To: XAFS Analysis using Ifeffit <ifeffit@millenia.cars.aps.anl.gov>
Message-ID:
      <b8522e3d0901281224v42f22a8cs6489a5792c458...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Yordy,

The first column for that file is not energy, it is angular steps.   See


http://cars9.uchicago.edu/ifeffit/FAQ/Data_Handling#head-e7e2389af58d378379f3bbe2a827c73a6df2a42e

and the other posts from earlier today for how to convert this data into
mu(E).

--Matt

On Wed, Jan 28, 2009 at 2:18 PM, Yordy Licea Fonseca
<yliceafons...@gmail.com> wrote:

Hi,

Sorry, I could not find enough information.
Would any of you tell me, please, how is the EXAFS data tabulated in

Farrel

Lytle data base?
The first column is the energy, what about others?
I would like to obtain the absorption coefficient vs energy from this
file:

http://ixs.csrri.iit.edu/data/Farrel_Lytle_data/RAW/W/wna.095

Best wishes,

--
Yordy E. Licea Fonseca
Departamento de F?sico-Qu?mica
Instituto de Qu?mica-IQ/UFRJ
Laborat?rio de Cat?lise Heterog?nea
Rio de Janeiro, RJ, CEP 21.949-909
Brasil
Email: yliceafons...@gmail.com

_______________________________________________
Ifeffit mailing list
Ifeffit@millenia.cars.aps.anl.gov
http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit





------------------------------

Message: 5
Date: Thu, 29 Jan 2009 13:33:08 +1100
From: "Pushan Shah" <ps...@gse.mq.edu.au>
Subject: [Ifeffit] uncertainty in linear combination analysis
To: <ifeffit@millenia.cars.aps.anl.gov>
Message-ID: <4981b014.0bbd.006...@gse.mq.edu.au>
Content-Type: text/plain; charset=US-ASCII

Hello Everyone!

How can I estimate an uncertainty in linear combination analysis and
calculate them in percentage error?

Many thanks,
Pushan






------------------------------

Message: 6
Date: Thu, 29 Jan 2009 15:41:55 +0530
From: abhijeet gaur <abhijeetga...@gmail.com>
Subject: [Ifeffit] Artemis parameters
To: ifeffit@millenia.cars.aps.anl.gov
Message-ID:
      <862a39070901290211s6a928d40yc902a09ff532f...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi
   I am fitting a copper foil whose data is taken at room temperature. So
do I need to change the guess value of parameters enot, ss,amp, delr to
some
other value or I should take them as the default guess value. Also what
should be the ideal fitting range in R for the copper foil.


With thanks

Abhijeet
-------------- next part --------------
An HTML attachment was scrubbed...
URL:

http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20090129/bd299a94/attachment-0001.html

------------------------------

Message: 7
Date: Thu, 29 Jan 2009 11:00:32 -0200
From: Eugenio Otal <eugen...@gmail.com>
Subject: [Ifeffit] Energy shift
To: ifeffit@millenia.cars.aps.anl.gov
Message-ID:
      <da22ad30901290500s14de8d2dy4cbaf8ec693e6...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi Matt,
Thanks for your time, the shift is between calculated and experiment. I
attach two figures with and without correction, it matchs really good if
I
change 5.5eV the energy.
Thanks, euG
-------------- next part --------------
An HTML attachment was scrubbed...
URL:

http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20090129/a2f94d00/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: without energy shift.jpg
Type: image/jpeg
Size: 58982 bytes
Desc: not available
Url :

http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20090129/a2f94d00/attachment.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: energy shift.jpg
Type: image/jpeg
Size: 69194 bytes
Desc: not available
Url :

http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20090129/a2f94d00/attachment-0001.jpg

------------------------------

_______________________________________________
Ifeffit mailing list
Ifeffit@millenia.cars.aps.anl.gov
http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit


End of Ifeffit Digest, Vol 71, Issue 32
***************************************






--
 Carlo U. Segre -- Professor of Physics
Associate Dean for Special Projects, Graduate College
Illinois Institute of Technology
Voice: 312.567.3498            Fax: 312.567.3494
se...@iit.edu   http://www.iit.edu/~segre   se...@debian.org






--
Carlo U. Segre -- Professor of Physics
Associate Dean for Special Projects, Graduate College
Illinois Institute of Technology
Voice: 312.567.3498            Fax: 312.567.3494
se...@iit.edu   http://www.iit.edu/~segre   se...@debian.org
#!/usr/bin/env python
# Name:		lytle_convert
# Purpose:	Convert Farrel Lytle data files from steps to energy
#           and output in SFF format.  This program supports
#			conversion of two different file types.  Those which 
#			have a header beginning with NPTS and containing DSPACE and 
#			the older files with begin with CUEDGE and do not contain
#			d-spacing information. 
# Author:	Carlo U. Segre <se...@iit.edu>
#
# Copyright 2009 Illinois Institute of Technology
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL ILLINOIS INSTITUTE OF TECHNOLOGY BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# 
# Except as contained in this notice, the name of Illinois Institute
# of Technology shall not be used in advertising or otherwise to promote
# the sale, use or other dealings in this Software without prior written
# authorization from Illinois Institute of Technology.
#

__version__ = '1.0'
__rcsid__ = '$Id$'
__source__ = '$Source$'

import os
import sys
import getopt
from string import *
from struct import *
import commands
import time
import Numeric

def usage(error=1):
	usage = """\
	
Usage: %s [OPTION]... INFILE0 [INFILE1 ... INFILEn]
Converts Farrel Lytle data files from steps to energy.

Options:
   -h, --help    Print this message
   
""" % os.path.basename(sys.argv[0])

	if error:
		sys.stderr.write(usage)
		sys.exit(1)
	else:
		sys.stdout.write(usage)
		sys.exit()


def main(rawFile, convFile):

    inFile = open(rawFile, "r")
    ouFile = open(convFile, "w")

    lines = inFile.readlines()

    vars = lines[0].split()
    if vars[0] == "NPTS" :
        fileType = "new"
        vals = lines[1].split()
    elif vars[0] == "CUEDGE" :
        fileType = "old"
        vals = vars[5:]
        vars = vars[:5]
    else :
        sys.stderr.write("Unknown file format!\n")
        sys.exit(1)
    
    pi = Numeric.arccos(-1.)
    hc = 12398.5
    energyCu = 8980.3
    edgeCu = float(vals[vars.index('CUEDGE')])
    if fileType == "new" :
        stepDegree = float(vals[vars.index('STPDEG')])
        d = float(vals[vars.index('DSPACE')])
        numPts = int(vals[vars.index('NPTS')])
        numScalers = int(vals[vars.index('NS')])
        scale = float(vals[vars.index('SCALE')])
    else:
#		For the "old" file type, the following assumptions are made:
#				dSpacing = 1.92017
#				stepDegree = 2000 * int(edgeCu / 42000)
#		make sure to change these if converted files do not have the
#		correct energy.
        stepDegree = int((edgeCu / 42000) + 0.5) * 2000
        d = 1.92017
        numPts = (len(lines) - 5) * 4
        numScalers = 1
    start = float(vals[vars.index('START')])
    stop = float(vals[vars.index('STOP')])
    thetaCu=Numeric.arcsin(hc/(2*d*energyCu))

    steps = Numeric.zeros((numPts), typecode='f')
    scalers = Numeric.zeros((numPts, numScalers), typecode='f')
    if fileType == "new" :
        i = 0
        while i < numPts :
            try :
                tmp = lines[i + 7].split()
            except IndexError :
                numPts = i
                break
            try :
                steps[i] = float(tmp[0])
            except IndexError :
                numPts = i
                break
            j = 0
            while j < numScalers :
                scalers[i,j] = float(tmp[j + 1])
                j = j + 1
            i = i + 1
    else :
        i = 0
        while i < numPts :
            try :
                tmp = lines[(i / 4) + 5].split()
            except IndexError :
                numPts = i
                break
            k = 0
            while k < 4 :
                try :
                    steps[i] = float(tmp[2 * k])
                    scalers[i,0] = float(tmp[(2 * k)+1])
                except IndexError :
                    numPts = i
                    break
                k = k + 1
                i = i + 1
                    
    theta = ((steps - edgeCu) / stepDegree) * (pi / 180.) + thetaCu
    energy = hc / (2 * d * Numeric.sin(theta))

    if fileType == "new" :
        ouFile.write('# SFF main_header 12\n')
    else :
        ouFile.write('# SFF main_header 11\n')
    ouFile.write('# raw_data_file = "' + rawFile +'";\n')
    ouFile.write('# source = "Farrel Lytle Database";\n')
    timestamp = time.strftime('%m-%d-%G %H:%M:%S').split()
    ouFile.write('# conversion_timestamp = ' + str(timestamp) + ';\n')
    ouFile.write('# d_spacing = "' + str(d) + '";\n')
    ouFile.write('# steps_per_degree = "' + str(stepDegree) + '";\n')
    ouFile.write('# step_start = "' + str(vals[vars.index('START')]) + '";\n')
    if fileType == "new" :
        ouFile.write('# step_deltas = "' + 
                lines[2][lines[2].find('DELTA:') + 6:].strip() + '";\n')
        ouFile.write('# region_ends = "' +
                lines[3][lines[3].find('DELEND:') + 7:].strip() + '";\n')
        ouFile.write('# count_times = "' + 
                lines[4][lines[4].find('SEC:') + 4:].strip() + '";\n')
        ouFile.write('# offsets = "' + 
                lines[5][lines[5].find('OFFSET:') + 7:].strip() + '";\n')
        ouFile.write('# sample = "' + lines[6].strip() + '";\n')
        scalerList = ""
        j = 0 
        while j < numScalers :
            scalerList = scalerList + 'scaler' + str(j) + ' '
            j = j + 1
        ouFile.write('# %devices = "energy ' + scalerList + 'steps";\n')
    else :
        ouFile.write('# step_deltas = "' + 
                lines[1][lines[1].find('DELTA:') + 6:].strip() + '";\n')
        ouFile.write('# region_ends = "' +
                lines[2][lines[2].find('DELEND:') + 7:].strip() + '";\n')
        ouFile.write('# count_times = "' + 
                lines[3][lines[3].find('SEC:') + 4:].strip() + '";\n')
        ouFile.write('# full_scale_counts = "' + 
                str(vals[vars.index('FSCTS:')]) + '";\n')
        ouFile.write('# sample = "' + lines[4].strip() + '";\n')
        ouFile.write('# %devices = "energy mu(E) steps";\n')

    i = 0
    while i < numPts :
        if energy[i] < 0 :
            break
        ouFile.write('%8.2f' % energy[i] + '\t')
        if fileType == "new" :
            j = 0 
            while j < numScalers :
                ouFile.write('%10.2f' % scalers[i,j] + '\t')
                j = j + 1
        else :
            ouFile.write('%10.6f' % scalers[i,0] + '\t')
        ouFile.write('%8.0f' % steps[i] + '\n')
        i = i + 1

    inFile.close()
    ouFile.close()

if __name__ == '__main__':

    try:
        opts, args = getopt.getopt(sys.argv[1:], 'h', ['help'])
    except getopt.error:
        sys.stderr.write("%s: %s \nTry `%s --help` for more informatIon\n"
            % (PROGNAME, e, PROGNAME))
        sys.exit(1)

    for o in opts:
        if o in ('-h', '--help'):
            usage(error=0)
	
    if len(args) == 0:
        usage()

    for infile in args:
        oufile = '_'.join(infile.split('.')) + '.sff'
        main(infile, oufile)
_______________________________________________
Ifeffit mailing list
Ifeffit@millenia.cars.aps.anl.gov
http://millenia.cars.aps.anl.gov/mailman/listinfo/ifeffit

Reply via email to