示例#1
0
    def __init__(self, kmin=0, kmax=20, kweight=2, dk=4, dk2=None,
                 window='kaiser', nfft=2048, kstep=0.05,
                 rmin = 0, rmax=10, dr=0, dr2=None, rwindow='hanning',
                 fitspace='r', wavelet_mask=None, _larch=None, **kws):
        Group.__init__(self, **kws)
        self.kmin = kmin
        self.kmax = kmax
        self.kweight = kweight
        if 'kw' in kws:
            self.kweight = kws['kw']

        self.dk = dk
        self.dk2 = dk2
        self.window = window
        self.rmin = rmin
        self.rmax = rmax
        self.dr = dr
        self.dr2 = dr2
        if dr2 is None: self.dr2 = self.dr
        self.rwindow = rwindow
        self.__nfft = 0
        self.__kstep = None
        self.nfft  = nfft
        self.kstep = kstep
        self.rstep = pi/(self.kstep*self.nfft)

        self.fitspace = fitspace
        self.wavelet_mask = wavelet_mask
        self._cauchymask = None

        self._larch = _larch

        self.kwin = None
        self.rwin = None
        self.make_karrays()
示例#2
0
 def __init__(self, filename=None, _larch=None, **kws):
     self._larch = _larch
     kwargs = dict(name='feff.dat: %s' % filename)
     kwargs.update(kws)
     Group.__init__(self, **kwargs)
     if filename is not None:
         self.__read(filename)
示例#3
0
    def __init__(self, kmin=0, kmax=20, kweight=2, dk=4, dk2=None,
                 window='kaiser', nfft=2048, kstep=0.05,
                 rmin = 0, rmax=10, dr=0, dr2=None, rwindow='hanning',
                 fitspace='r', wavelet_mask=None, _larch=None, **kws):
        Group.__init__(self, **kws)
        self.kmin = kmin
        self.kmax = kmax
        self.kweight = kweight
        if 'kw' in kws:
            self.kweight = kws['kw']

        self.dk = dk
        self.dk2 = dk2
        self.window = window
        self.rmin = rmin
        self.rmax = rmax
        self.dr = dr
        self.dr2 = dr2
        if dr2 is None: self.dr2 = self.dr
        self.rwindow = rwindow
        self.__nfft = 0
        self.__kstep = None
        self.nfft  = nfft
        self.kstep = kstep
        self.rstep = pi/(self.kstep*self.nfft)

        self.fitspace = fitspace
        self.wavelet_mask = wavelet_mask
        self._cauchymask = None

        self._larch = _larch

        self.kwin = None
        self.rwin = None
        self.make_karrays()
示例#4
0
    def __init__(self,
                 filename=None,
                 _larch=None,
                 label=None,
                 s02=None,
                 degen=None,
                 e0=None,
                 ei=None,
                 deltar=None,
                 sigma2=None,
                 third=None,
                 fourth=None,
                 **kws):

        kwargs = dict(name='FeffPath: %s' % filename)
        kwargs.update(kws)
        Group.__init__(self, **kwargs)
        self._larch = _larch
        self.filename = filename
        def_degen = 1
        if filename is not None:
            self._feffdat = FeffDatFile(filename=filename, _larch=_larch)
            self.geom = self._feffdat.geom
            def_degen = self._feffdat.degen
        self.degen = degen if degen is not None else def_degen
        self.label = label if label is not None else filename
        self.s02 = 1 if s02 is None else s02
        self.e0 = 0 if e0 is None else e0
        self.ei = 0 if ei is None else ei
        self.deltar = 0 if deltar is None else deltar
        self.sigma2 = 0 if sigma2 is None else sigma2
        self.third = 0 if third is None else third
        self.fourth = 0 if fourth is None else fourth
        self.k = None
        self.chi = None
示例#5
0
 def __init__(self, filename=None, _larch=None, **kws):
     self._larch = _larch
     kwargs = dict(name='feff.dat: %s' % filename)
     kwargs.update(kws)
     Group.__init__(self,  **kwargs)
     if filename is not None:
         self.__read(filename)
示例#6
0
    def __init__(self, filename=None, _larch=None,
                 label=None, s02=None, degen=None, e0=None,
                 ei=None, deltar=None, sigma2=None,
                 third=None, fourth=None,  **kws):

        kwargs = dict(name='FeffPath: %s' % filename)
        kwargs.update(kws)
        Group.__init__(self, **kwargs)
        self._larch = _larch
        self.filename = filename
        def_degen = 1
        if filename is not None:
            self._feffdat = FeffDatFile(filename=filename, _larch=_larch)
            self.geom  = self._feffdat.geom
            def_degen  = self._feffdat.degen
        self.degen = degen if degen is not None else def_degen
        self.label = label if label is not None else filename
        self.s02    = 1 if s02    is None else s02
        self.e0     = 0 if e0     is None else e0
        self.ei     = 0 if ei     is None else ei
        self.deltar = 0 if deltar is None else deltar
        self.sigma2 = 0 if sigma2 is None else sigma2
        self.third  = 0 if third  is None else third
        self.fourth = 0 if fourth is None else fourth
        self.k = None
        self.chi = None
示例#7
0
 def __init__(self, folder=None, _larch=None, **kws):
     kwargs = dict(name='Feff85exafs unit test: %s' % folder)
     kwargs.update(kws)
     Group.__init__(self,  **kwargs)
     self._larch     = Interpreter()
     self.doplot     = True  
     self.doscf      = False # True = use self-consistency
     self.verbose    = True  # True = print Feff's screen messages and other screenmessages
     self.feffran    = False # True = Feff calculation has been run
     self.count      = 0
     self.feffcount  = 0
     self.datacount  = 0
     self.failed     = list()
     self.folder     = folder
     if self.folder[-1] == '/': self.folder = self.folder[:-1]
     self.testrun    = realpath(join(self.folder, 'testrun'))
     self.testpaths()
     if not isdir(folder):
         print colored(folder + " is not one of the available tests", 'magenta', attrs=['bold'])
         return None
     self.path       = realpath(folder)
     self.repotop    = realpath(join('..','..'))
     # the f85e shell script emulates the behavior of the monolithic Feff application
     self.f85escript = join(self.repotop, 'bin', 'f85e')
     self.epsilon    = 0.00001
     self.epsfit     = 0.001
     self.wrapper_available = wrapper_available
     if wrapper_available:
         self.sp = scatpath()
示例#8
0
文件: xrd.py 项目: Chuban/xraylarch
    def __init__(self,
                 data2D=None,
                 xpixels=2048,
                 ypixels=2048,
                 data1D=None,
                 nwedge=0,
                 steps=5001,
                 name='xrd',
                 _larch=None,
                 **kws):

        self.name = name
        self.xpix = xpixels
        self.ypix = ypixels
        self.data2D = data2D
        self.nwedge = nwedge
        self.steps = steps
        self.data1D = data1D
        self.data2D = data2D
        self.cake = None

        self.energy = None
        self.wavelength = None
        self.calfile = None

        self.filename = None
        self.title = None
        self.npixels = None

        if HAS_larch:
            Group.__init__(self)
 def __init__(self, folder=None, _larch=None, **kws):
     kwargs = dict(name='FeffPath wrapper')
     kwargs.update(kws)
     Group.__init__(self,  **kwargs)
     self._larch     = Interpreter()
     self.wrapper    = feffpathwrapper.FEFFPATH()
     feffpathwrapper.create_path(self.wrapper)
     self.wrapper.phpad = ''
     self.ipot = []
     self.rat  = []
     self.geom = []
示例#10
0
 def __init__(self, name=None, shape='gaussian',
              amplitude=1, center=0, sigma=1,
              sigma_params=None, **kws):
     kwargs = {'name': name}
     kwargs.update(kws)
     self.amplitude = amplitude
     self.center   = center
     self.sigma = sigma
     Group.__init__(self)
     self.name = name
     if name is not None:
         self._define(name, shape=shape,
                      sigma_params=sigma_params)
示例#11
0
文件: spyk.py 项目: xraypy/xraylarch
 def __init__(self, filename='spykscan.001', configfile=None,
              auto_increment=True, _larch=None, **kwargs):
     Group.__init__(self, **kwargs)
     self.motors  = {}
     self.detectors = []
     self.bare_counters = []
     self._scan = LarchStepScan(filename=filename,
                                auto_increment=auto_increment,
                                _larch=_larch)
     self.datafilename = filename
     if configfile is not None:
         self.configfile = configfile
     self.read_config(filename=configfile)
     self.lup = self.dscan
示例#12
0
    def __init__(self, filename=None, bad=None, **kws):

        kwargs = {'name': 'GSE MCA File: %s' % filename}
        kwargs.update(kws)
        Group.__init__(self,  **kwargs)
        self.mcas   = []
        self.__mca0 = None
        self.bad    = bad
        if bad is None:
            self.bad = []

        self.filename = filename
        if filename:
            self.read(filename=filename)
示例#13
0
    def __init__(self, energy=None, mu=None, z=None, edge='K', mback_kws=None, _larch=None, **kws):
        kwargs = dict(name='diffKK')
        kwargs.update(kws)
        Group.__init__(self,  **kwargs)
        self.energy     = energy
        self.mu         = mu
        self.z          = z
        self.edge       = edge
        self.mback_kws  = mback_kws

        if _larch == None:
            self._larch   = Interpreter()
        else:
            self._larch = _larch
示例#14
0
    def __init__(self, energy=None, mu=None, z=None, edge='K', mback_kws=None, _larch=None, **kws):
        kwargs = dict(name='diffKK')
        kwargs.update(kws)
        Group.__init__(self,  **kwargs)
        self.energy     = energy
        self.mu         = mu
        self.z          = z
        self.edge       = edge
        self.mback_kws  = mback_kws

        if _larch == None:
            self._larch   = Interpreter()
        else:
            self._larch = _larch
示例#15
0
    def __init__(self, filename=None, bad=None, **kws):

        kwargs = {'name': 'GSE MCA File: %s' % filename}
        kwargs.update(kws)
        Group.__init__(self, **kwargs)
        self.mcas = []
        self.__mca0 = None
        self.bad = bad
        if bad is None:
            self.bad = []

        self.filename = filename
        if filename:
            self.read(filename=filename)
示例#16
0
    def __init__(self, data=None, pathlist=None, transform=None,
                 _larch=None, **kws):
        self._larch = _larch
        Group.__init__(self, **kws)

        self.pathlist = pathlist

        self.data = data
        if transform is None:
            transform = TransformGroup()
        self.transform = transform
        self.model = Group()
        self.model.k = None
        self.__chi = None
        self.__prepared = False
示例#17
0
 def __init__(self, feffinp=None, verbose=True, repo=None, _larch=None, **kws):
     kwargs = dict(name='Feff runner')
     kwargs.update(kws)
     Group.__init__(self,  **kwargs)
     if _larch == None:
         self._larch   = Interpreter()
     else:
         self._larch = _larch
     self.feffinp  = feffinp
     self.verbose  = verbose
     self.mpse     = False
     self.repo     = repo
     self.resolved = None
     self.threshold = []
     self.chargetransfer = []
示例#18
0
    def __init__(self, feffinp='feff.inp', folder=None, verbose=True,
                 repo=None, _larch=None, **kws):
        kwargs = dict(name='Feff runner')
        kwargs.update(kws)
        Group.__init__(self,  **kwargs)
        self._larch = _larch

        self.folder   = folder or '.'
        self.feffinp  = feffinp
        self.verbose  = verbose
        self.mpse     = False
        self.repo     = repo
        self.resolved = None
        self.threshold = []
        self.chargetransfer = []
示例#19
0
 def __init__(self,
              energy=None,
              mu=None,
              z=None,
              edge='K',
              mback_kws=None,
              **kws):
     kwargs = dict(name='diffKK')
     kwargs.update(kws)
     Group.__init__(self, **kwargs)
     self.energy = energy
     self.mu = mu
     self.z = z
     self.edge = edge
     self.mback_kws = mback_kws
示例#20
0
文件: mca.py 项目: yevgenyr/xraylarch
    def __init__(self,
                 counts=None,
                 nchans=2048,
                 start_time='',
                 offset=0,
                 slope=0,
                 quad=0,
                 name='mca',
                 dt_factor=1,
                 real_time=0,
                 live_time=0,
                 input_counts=0,
                 tau=0,
                 **kws):

        self.name = name
        self.nchans = nchans
        self.environ = []
        self.rois = []
        self.counts = counts

        # Calibration parameters
        self.offset = offset  # Offset
        self.slope = slope  # Slope
        self.quad = quad  # Quadratic

        # Counting parameters
        self.start_time = start_time
        self.real_time = real_time  # Elapsed real time in seconds (requested counting time)
        self.live_time = live_time  # Elapsed live time in seconds (time detector is live)
        self.input_counts = input_counts  # Actual total input counts (eg given by detector software)
        # Note total_counts and input counts ARE NOT time normalized
        #
        self.total_counts = 0.  # Total counts between the preset start and stop channels
        self.tau = tau  # Factor for deadtime/detector saturation calculations, ie
        #     ocr = icr * exp(-icr*tau)
        # Calculated correction values
        self.icr_calc = -1.0  # Calculated input count rate from above expression
        # corrected_counts = counts * dt_factor
        self.bgr = None
        self.dt_factor = float(dt_factor)
        if counts is not None:
            self.nchans = len(counts)
            self.total_counts = counts.sum()
        self.incident_energy = None
        self.get_energy()
        self._calc_correction()
        Group.__init__(self)
示例#21
0
    def __init__(self, data2D=None, xpixels=2048, ypixels=2048,
                 data1D=None, nwedge=2, nchan=5001, 
                 name='xrd',**kws):

        self.name    = name
        self.xpix    = xpixels
        self.ypix    = ypixels
        self.data2D  = data2D
        self.nwedge  = nwedge
        self.nchan   = nchan
        self.data1D  = data1D
        
        ## Also include calibration data file?
        ## mkak 2016.08.20

        Group.__init__(self)
示例#22
0
 def __init__(self,
              name=None,
              shape='gaussian',
              amplitude=1,
              center=0,
              sigma=1,
              sigma_params=None,
              **kws):
     kwargs = {'name': name}
     kwargs.update(kws)
     self.amplitude = amplitude
     self.center = center
     self.sigma = sigma
     Group.__init__(self)
     self.name = name
     if name is not None:
         self._define(name, shape=shape, sigma_params=sigma_params)
示例#23
0
    def __init__(self, data=None, pathlist=None, transform=None,
                 epsilon_k=None, _larch=None, **kws):
        self._larch = _larch
        Group.__init__(self, **kws)

        self.pathlist = pathlist

        self.data = data
        if transform is None:
            transform = TransformGroup()
        self.transform = transform
        if epsilon_k is not None:
            self.data.epsilon_k = epsilon_k

        self.model = Group()
        self.model.k = None
        self.__chi = None
        self.__prepared = False
示例#24
0
 def __init__(self,
              filename='spykscan.001',
              configfile=None,
              auto_increment=True,
              _larch=None,
              **kwargs):
     Group.__init__(self, **kwargs)
     self.motors = {}
     self.detectors = []
     self.bare_counters = []
     self._scan = LarchStepScan(filename=filename,
                                auto_increment=auto_increment,
                                _larch=_larch)
     self.datafilename = filename
     if configfile is not None:
         self.configfile = configfile
     self.read_config(filename=configfile)
     self.lup = self.dscan
示例#25
0
文件: roi.py 项目: znarthur/xraylarch
 def __init__(self, left=0, right=0, name='', bgr_width=3, counts=None,
              address=''):
     """
     Parameters:
     -----------
     * left      Left limit in index/channels numbers
     * right     Right limit in index/channels numbers
     * name     Name of the ROI
     * bgr_width Number of channels to use for background subtraction
     """
     self.name     = name
     self.address  = address
     self.bgr_width = int(bgr_width)
     self.total  = 0
     self.net    = 0
     self.set_bounds(left, right)
     if counts is not None:
         self.get_counts(counts)
     Group.__init__(self)
示例#26
0
    def __init__(self, folder=None, _larch=None, **kws):
        kwargs = dict(name='Feff85exafs unit test: %s' % folder)
        kwargs.update(kws)
        Group.__init__(self, **kwargs)
        self._larch = Interpreter()
        self.doplot = True
        self.doscf = False  # True = use self-consistency
        self.verbose = True  # True = print Feff's screen messages and other screen messages
        self.feffran = False  # True = Feff calculation has been run
        self.count = 0
        self.feffcount = 0
        self.datacount = 0
        self.failed = list()
        if folder[-1] == '/': folder = folder[:-1]  # strip trailing /
        self.folder = folder

        if not isdir(folder):
            folder = join('tests', folder)
        if not isdir(folder):
            print colored(folder + " isn't one of the available tests",
                          'magenta',
                          attrs=['bold'])
            return None

        self.path = realpath(folder)
        self.testrun = realpath(join(self.path, 'testrun'))
        self.fefflog = realpath(join(self.path, 'testrun', 'f85e.log'))
        self.__testpaths()
        self.repotop = getcwd()
        if not self.repotop.endswith('feff85exafs'):
            self.repotop = realpath(join('..'))
        # the f85e shell script emulates the behavior of the monolithic Feff application
        self.eps5 = 0.00001
        self.eps4 = 0.0001
        self.eps3 = 0.001
        self.epsilon = self.eps4
        self.epsfit = self.eps3
        self.firstshell = False
        self.fittest = None
        self.wrapper_available = wrapper_available
        if wrapper_available:
            self.sp = scatpath()
示例#27
0
    def __init__(self,
                 feffinp='feff.inp',
                 folder=None,
                 verbose=True,
                 repo=None,
                 _larch=None,
                 **kws):
        kwargs = dict(name='Feff runner')
        kwargs.update(kws)
        Group.__init__(self, **kwargs)
        self._larch = _larch

        self.folder = folder or '.'
        self.feffinp = feffinp
        self.verbose = verbose
        self.mpse = False
        self.repo = repo
        self.resolved = None
        self.threshold = []
        self.chargetransfer = []
示例#28
0
 def __init__(self,
              feffinp=None,
              verbose=True,
              repo=None,
              _larch=None,
              **kws):
     kwargs = dict(name='Feff runner')
     kwargs.update(kws)
     Group.__init__(self, **kwargs)
     if _larch == None:
         self._larch = Interpreter()
     else:
         self._larch = _larch
     self.feffinp = feffinp
     self.verbose = verbose
     self.mpse = False
     self.repo = repo
     self.resolved = None
     self.threshold = []
     self.chargetransfer = []
示例#29
0
    def __init__(self, folder=None, _larch=None, **kws):
        kwargs = dict(name='Feff85exafs unit test: %s' % folder)
        kwargs.update(kws)
        Group.__init__(self,  **kwargs)
        self._larch     = Interpreter()
        self.doplot     = True
        self.doscf      = False # True = use self-consistency
        self.verbose    = True  # True = print Feff's screen messages and other screen messages
        self.feffran    = False # True = Feff calculation has been run
        self.count      = 0
        self.feffcount  = 0
        self.datacount  = 0
        self.failed     = list()
        if folder[-1] == '/': folder = folder[:-1] # strip trailing /
        self.folder     = folder

        if not isdir(folder):
            folder = join('tests', folder)
        if not isdir(folder):
            print_error(folder + " isn't one of the available tests")
            return None

        self.path       = realpath(folder)
        self.testrun    = realpath(join(self.path, 'testrun'))
        self.fefflog    = realpath(join(self.path, 'testrun', 'feff8l.log'))
        self.__testpaths()
        self.repotop    = getcwd()
        if not self.repotop.endswith('feff85exafs'):  self.repotop = realpath(join('..'))
        # the f85e shell script emulates the behavior of the monolithic Feff application
        self.eps5       = 0.00001
        self.eps4       = 0.0001
        self.eps3       = 0.001
        self.epsilon    = self.eps4
        self.epsfit     = self.eps3
        self.epserr     = 5.0 * self.epsfit
        self.firstshell = False
        self.fittest    = None
        if WRAPPER_AVAILABLE:
            self.sp = Feff8L_XAFSPath(_larch=self._larch)
示例#30
0
    def __init__(self, counts=None, nchans=2048, start_time='',
                 offset=0, slope=0, quad=0, name='mca', dt_factor=1,
                 real_time=0, live_time = 0, input_counts=0, tau=0, **kws):

        self.name    = name
        self.nchans  = nchans
        self.environ = []
        self.rois    = []
        self.counts  = counts

        # Calibration parameters
        self.offset       = offset # Offset
        self.slope        = slope  # Slope
        self.quad         = quad   # Quadratic

        # Counting parameters
        self.start_time   = start_time
        self.real_time    = real_time  # Elapsed real time in seconds (requested counting time)
        self.live_time    = live_time  # Elapsed live time in seconds (time detector is live)
        self.input_counts = input_counts # Actual total input counts (eg given by detector software)
                                  # Note total_counts and input counts ARE NOT time normalized
                                  #
        self.total_counts = 0.    # Total counts between the preset start and stop channels
        self.tau          = tau   # Factor for deadtime/detector saturation calculations, ie
                                  #     ocr = icr * exp(-icr*tau)
        # Calculated correction values
        self.icr_calc    = -1.0  # Calculated input count rate from above expression
        # corrected_counts = counts * dt_factor
        self.bgr = None
        self.dt_factor   = float(dt_factor)
        if counts is not None:
            self.nchans      = len(counts)
            self.total_counts =  counts.sum()
        self.get_energy()
        self._calc_correction()
        Group.__init__(self)
示例#31
0
    def __init__(self, _larch=None, **kws):
        kwargs = dict(name='Feff test framework')
        kwargs.update(kws)
        Group.__init__(self,  **kwargs)
        self._larch       = Interpreter()
        self.materials    = ("Copper", "NiO", "FeS2", "UO2", "BaZrO3", "bromoadamantane", "uranyl")
        self.tests        = ('scf', 'iorder', 'mpse')
        self.__material   = None
        self.__test       = None
        self.testmodule   = None

        self.json         = None
        self.mustache     = None
        self.dryrun       = False
        self.dopathfinder = False
        self.tableformat  = 'pipe' # 'plain', 'simple', 'grid', 'fancy_grid', 'pipe', 'orgtbl'
                                   # 'rst', 'mediawiki', 'html', 'latex', 'latex_booktabs'

        ## some things to make the cohabitation with f85ut happy
        self.doplot       = False
        self.verbose      = False
        self.firstshell   = False
        self.folder       = None
        self.path         = None
示例#32
0
文件: xrd.py 项目: Chuban/xraylarch
    def __init__(self,
                 file=None,
                 label=None,
                 x=None,
                 xtype=None,
                 I=None,
                 wavelength=None,
                 energy=None):

        self.filename = file
        self.label = label

        self.energy = energy
        self.wavelength = wavelength

        if energy is None and wavelength is None:
            self.energy = 19.0
            self.wavelength = lambda_from_E(self.energy)
        else:
            if self.energy is None:
                self.energy = E_from_lambda(self.wavelength)
            if self.wavelength is None:
                self.wavelength = lambda_from_E(self.energy)

        if file is not None:
            self.xrd_from_file(file)
        else:

            ## Default values
            self.distance = None
            self.poni = None
            self.rotation = None
            self.pixelsize = None
            self.splinefile = None
            self.polarization = None
            self.normalization = None

            if I is not None and x is not None:
                self.xrd_from_2d([x, I], xtype)
                self.bkgd = np.zeros(np.shape(self.I))
            else:
                self.q = None
                self.twth = None
                self.d = None
                self.I = None
                self.bkgd = None

        ## Analysis parameters - set defaults
        self.uvw = None
        self.D = None
        self.pki = []

        self.imin = None
        self.imax = None

        self.matches = None

        self.xrd2d = None
        self.cake = None

        if HAS_larch:
            Group.__init__(self)