コード例 #1
0
from os.path import realpath, exists, join

from larch import (Group, Parameter, isParameter, param_value, use_plugin_path,
                   isNamedClass)
use_plugin_path('io')
from xdi import read_xdi
from columnfile import write_ascii
use_plugin_path('xafs')
from feffit import feffit_dataset, feffit_transform, feffit, feffit_report
from feffdat import feffpath
use_plugin_path('wx')
from plotter import (_newplot, _plot)

import pystache


def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'NiO.chik'), _larch=self._larch)
    if hasattr(data, 'wavenumber'):
        data.k = data.wavenumber

    gds = Group(amp=Parameter(1, vary=True, _larch=self._larch),
コード例 #2
0
ファイル: larch_interface.py プロジェクト: imewei/stepscan
import json
import numpy as np
import glob
from .file_utils import nativepath
from .site_config import get_fileroot, LARCH_SCANDB, LARCH_INSTDB
from .utils import plain_ascii
from .scandb import InstrumentDB
from . import scandb

import epics

import larch
from larch.utils import OrderedDict
larch_site_config = larch.site_config

larch.use_plugin_path('epics')
from stepscan_utils import EpicsScanDB


class LarchScanDBWriter(object):
    """Writer for Larch Interface that writes to both Stdout
    and Messages table of scandb
    """
    def __init__(self, stdout=None, scandb=None, _larch=None):
        if stdout is None:
            stdout = sys.stdout
        self.scandb = scandb
        self.writer = stdout
        self._larch = _larch

    def write(self, text, color=None, bkg=None, **kws):
コード例 #3
0
ファイル: viewerApp.py プロジェクト: pyepics/stepscan
import wx.lib.agw.flatnotebook as flat_nb
import wx.lib.scrolledpanel as scrolled
import wx.lib.mixins.inspection
try:
    from wx._core import PyDeadObjectError
except:
    PyDeadObjectError = Exception


import epics
from epics.wx import DelayedEpicsCallback, EpicsFunction

from larch import Interpreter, use_plugin_path, isParameter
from larch.fitting import fit_report

use_plugin_path('math')
from fitpeak import fit_peak

from wxmplot import PlotFrame, PlotPanel
from ..datafile import StepScanData
from ..scandb import ScanDB
from ..file_utils import fix_filename

from .gui_utils import (SimpleText, FloatCtrl, Closure, pack, add_button,
                        add_menu, add_choice, add_menu, check,
                        CEN, RCEN, LCEN, FRAMESTYLE, Font)

CEN |=  wx.ALL
FILE_WILDCARDS = "Scan Data Files(*.0*,*.dat,*.xdi)|*.0*;*.dat;*.xdi|All files (*.*)|*.*"
FNB_STYLE = flat_nb.FNB_NO_X_BUTTON|flat_nb.FNB_SMART_TABS|flat_nb.FNB_NO_NAV_BUTTONS
コード例 #4
0
ファイル: NiO.py プロジェクト: bruceravel/SCFtests


from os.path import realpath, exists, join

from larch import (Group, Parameter, isParameter, param_value, use_plugin_path, isNamedClass)
use_plugin_path('io')
from xdi import read_xdi
from columnfile import write_ascii
use_plugin_path('xafs')
from feffit import feffit_dataset, feffit_transform, feffit, feffit_report
from feffdat import feffpath
use_plugin_path('wx')
from plotter import (_newplot, _plot)

import pystache

def do_fit(self, which, firstshell=False, fittest='baseline'):

    if which == 'testrun':
        folder = self.testrun
    elif which == 'baseline':
        folder = self.baseline
    else:
        folder = realpath(join(self.folder, fittest, which))
    #endif

    data = read_xdi(join(self.path, 'NiO.chik'), _larch=self._larch)
    if hasattr(data, 'wavenumber'):
        data.k = data.wavenumber
コード例 #5
0
ファイル: UO2.py プロジェクト: ryanspletzer/feff85exafs
from os.path import realpath, exists, join

from larch import Group, Parameter, isParameter, param_value, use_plugin_path, isNamedClass

use_plugin_path("io")
from xdi import read_xdi

use_plugin_path("xafs")
from feffit import feffit_dataset, feffit_transform, feffit, feffit_report
from feffdat import feffpath

use_plugin_path("wx")
from plotter import _newplot, _plot


def do_fit(self, which):

    if which == "testrun":
        folder = self.testrun
    else:
        folder = self.baseline

    data = read_xdi(join(self.path, "UO2.chik"), _larch=self._larch)

    gds = Group(
        amp=Parameter(1, vary=True, _larch=self._larch),
        enot=Parameter(0.01, vary=True, _larch=self._larch),
        sso=Parameter(0.003, vary=True, _larch=self._larch),
        ssu=Parameter(0.003, vary=True, _larch=self._larch),
        sso2=Parameter(0.003, vary=True, _larch=self._larch),
        dro=Parameter(0.0001, vary=True, _larch=self._larch),
コード例 #6
0
import sys
import time
import numpy as np
from collections import OrderedDict

if sys.version_info[0] > 2:  # Python2 only, for now
    from io import StringIO
    from configparser import ConfigParser

else:
    from ConfigParser import ConfigParser
    from cStringIO import StringIO

from larch import use_plugin_path, Group

use_plugin_path('io')
from fileutils import get_homedir, get_timestamp

try:
    from epics import PV, caget, caput, get_pv, poll
    HAS_EPICS = True
except ImportError:
    HAS_EPICS = False

try:
    use_plugin_path('epics')
    from larch_plugins.epics.larchscan import LarchStepScan

    import epicsscan
    from epicsscan.positioner import Positioner
    from epicsscan.detectors import get_detector, Counter
コード例 #7
0
    import wx.dataview as dv
    HAS_DV = True
except:
    pass

from wxutils import (SimpleText, EditableListBox, Font, FloatCtrl, pack, Popup,
                     Button, get_icon, Check, MenuItem, Choice, FileOpen,
                     FileSave, fix_filename, HLine, GridPanel, CEN, LEFT,
                     RIGHT)

import larch
from larch_plugins.wx import (PeriodicTablePanel, XRFDisplayFrame,
                              FILE_WILDCARDS, CalibrationFrame)

ROI_WILDCARD = 'Data files (*.dat)|*.dat|ROI files (*.roi)|*.roi|All files (*.*)|*.*'
larch.use_plugin_path('epics')
try:
    from larch_plugins.epics import Epics_MultiXMAP, Epics_Xspress3
    from scandb import ScanDB
except:
    pass


class DetectorSelectDialog(wx.Dialog):
    """Connect to an Epics MCA detector
    Can be either XIA xMAP  or Quantum XSPress3
    """
    msg = '''Select XIA xMAP or Quantum XSPress3 MultiElement MCA detector'''
    det_types = ('ME-4', 'other')
    def_prefix = '13QX4:'  # SDD1:'
    def_nelem = 4
コード例 #8
0
ファイル: fluo_det.py プロジェクト: tacaswell/xraylarch
4/14/2011:  fluo_det.py: detection dependent part in fluorescence yield.
            Original fluo.py was modified to fluo_new.py.
            readf1f2a.py is used instead of original readf1f2.py
            fluo_new.py is being split into two.
            fluo_elem.py is for elemtnal dependence: fluorescenc yield, crosssection.
            fluo_det.py is for detection dependnece: detector efficiency, attenuation, sample
            * for attenuation, total cross-section([4]) is used instead of photoelectric ([2]).
            ** for fluorescence yield, photoelectric is used.
"""

import math
import numpy
import sys
from larch import use_plugin_path

use_plugin_path('xray')
use_plugin_path('xsw')

from physical_constants import AVOGADRO, BARN

pre_edge_margin = 150.  # FY calculated from 150 eV below the absorption edge.
fluo_emit_min = 500.  # minimum energy for emitted fluorescence.  ignore fluorescence emissions below 500eV
det_res = 100.  # detector resoltuion in eV, used in sim_GaussPeaks
'''
----------------------------------------------------------------------------------------------------------
class: Material, ElemFY, SampleMatrix2
----------------------------------------------------------------------------------------------------------
'''


class Material:
コード例 #9
0
# make up the Python Interface to the feffpath library.  While information
# about Authorship may be retained in some files for historical reasons,
# this work is hereby placed in the Public Domain.  This work is
# published from: United States.
#
# Note that the onepath and feffpath libraries themselves are NOT
# public domain, nor is the Fortran source code for Feff that it
# relies upon.
#
# Author: Bruce Ravel (bravel AT bnl DOT gov).
# Last update: 12 December, 2014

import larch
from larch import (Group, Parameter, isParameter, ValidateLarchPlugin, param_value,
                   use_plugin_path, isNamedClass, Interpreter)
use_plugin_path('xafs')
use_plugin_path('xray')
from   xraydb_plugin import atomic_symbol

import sys
from   os            import name
from   os.path       import isfile
from   numpy         import array

#installdir = larch.site_config.larchdir
installdir = larch.larchlib.larchdir
dlldir     = larch.larchlib.get_dlldir()


dllfile=installdir+'/dlls/'+dlldir
if not dllfile in sys.path:
コード例 #10
0
ファイル: fluo_det.py プロジェクト: bruceravel/xraylarch
4/14/2011:  fluo_det.py: detection dependent part in fluorescence yield.
            Original fluo.py was modified to fluo_new.py.
            readf1f2a.py is used instead of original readf1f2.py
            fluo_new.py is being split into two.
            fluo_elem.py is for elemtnal dependence: fluorescenc yield, crosssection.
            fluo_det.py is for detection dependnece: detector efficiency, attenuation, sample
            * for attenuation, total cross-section([4]) is used instead of photoelectric ([2]).
            ** for fluorescence yield, photoelectric is used.
"""


import math
import numpy
import sys
from larch import use_plugin_path
use_plugin_path('xray')
use_plugin_path('xsw')

from physical_constants import AVOGADRO, BARN

pre_edge_margin=150.    # FY calculated from 150 eV below the absorption edge.
fluo_emit_min=500.      # minimum energy for emitted fluorescence.  ignore fluorescence emissions below 500eV
det_res=100.            # detector resoltuion in eV, used in sim_GaussPeaks

'''
----------------------------------------------------------------------------------------------------------
class: Material, ElemFY, SampleMatrix2
----------------------------------------------------------------------------------------------------------
'''
class Material:
    def __init__(self, composition, density, thickness=1,_larch=None):
コード例 #11
0
ファイル: gse_xdiscan.py プロジェクト: Henry0422/xraylarch
#!/usr/bin/env python

import os
import sys
import copy
import time
import gc

import numpy as np
from larch import Group, ValidateLarchPlugin, use_plugin_path
from larch.utils import OrderedDict

from larch_plugins.io import XDIFile, XDIFileException, iso8601_time

use_plugin_path('xrfmap')
from xsp3_hdf5 import XSPRESS3_TAUS, estimate_icr

@ValidateLarchPlugin
def read_gsexdi(fname, _larch=None, nmca=4, bad=None, **kws):
    """Read GSE XDI Scan Data to larch group,
    summing ROI data for MCAs and apply deadtime corrections
    """
    group = _larch.symtable.create_group()
    group.__name__ ='GSE XDI Data file %s' % fname
    xdi = XDIFile(str(fname))

    group._xdi = xdi
    group.filename = fname
    group.npts = xdi.npts
    group.bad_channels = bad
    group.dtc_taus = XSPRESS3_TAUS
コード例 #12
0
ファイル: detectors.py プロジェクト: imewei/stepscan
"""
Triggers, Counters, Detectors for Step Scan
"""

import time
from ordereddict import OrderedDict

from epics_interface import PV, caget, caput, poll
from epics.devices import Scaler, MCA, Struck

from larch import use_plugin_path

use_plugin_path("epics")
from xspress3 import Xspress3

from .saveable import Saveable

DET_DEFAULT_OPTS = {
    "scaler": {"use_calc": True, "nchans": 8},
    "areadetector": {"file_plugin": "TIFF1", "auto_increment": True},
    "mca": {"nrois": 32, "use_full": False, "use_net": False},
    "xspress3": {"MultiChannelScaler": "", "nmcas": 4, "nrois": 32, "nbins": 10},
    "multimca": {"nrois": 32, "nmcas": 4, "use_full": False, "use_net": False},
}

AD_FILE_PLUGINS = ("TIFF1", "JPEG1", "NetCDF1", "HDF1", "Nexus1", "Magick1")


class Trigger(Saveable):
    """Detector Trigger for a scan. The interface is:
    trig = Trigger(pvname, value=1)
コード例 #13
0
## feff85exafs unit testing system using larch
## see HEADERS/license.h for feff's license information

import os

import nose
from os.path import isfile, isdir, join
import sys

sys.path.append(join('wrappers', 'python'))
from math import isnan

import larch
from f85ut import ut

larch.use_plugin_path('xafs')
from feffdat import feffpath

larch.use_plugin_path('io')
from columnfile import read_ascii

import re

#folders = ('Copper',)
#folders = ('ferrocene',)
#folders = ('Copper', 'NiO', 'UO2', 'Zircon', 'ferrocene', 'bromoadamantane')
folders = ('Copper', 'NiO', 'UO2', 'Zircon', 'ferrocene', 'bromoadamantane',
           'LCO-para', 'LCO-perp')
tests = dict()
doscf = os.getenv('FEFF_TEST_SCF', 'False')
コード例 #14
0
#!/usr/bin/env python

import os
import sys
import copy
import time
import gc

import numpy as np
from larch import Group, ValidateLarchPlugin, use_plugin_path
from larch.utils import OrderedDict

from larch_plugins.io import XDIFile, XDIFileException, iso8601_time

use_plugin_path('xrfmap')
from xsp3_hdf5 import XSPRESS3_TAUS, estimate_icr


@ValidateLarchPlugin
def read_gsexdi(fname, _larch=None, nmca=4, bad=None, **kws):
    """Read GSE XDI Scan Data to larch group,
    summing ROI data for MCAs and apply deadtime corrections
    """
    group = _larch.symtable.create_group()
    group.__name__ = 'GSE XDI Data file %s' % fname
    xdi = XDIFile(str(fname))

    group._xdi = xdi
    group.filename = fname
    group.npts = xdi.npts
    group.bad_channels = bad
コード例 #15
0
ファイル: gse_xdiscan.py プロジェクト: bruceravel/xraylarch
#!/usr/bin/env python

import os
import sys
import copy
import time
import gc

import numpy as np
from larch import Group, ValidateLarchPlugin, use_plugin_path
from larch.utils import OrderedDict

from larch_plugins.io import XDIFile, XDIFileException, iso8601_time

use_plugin_path('xrmmap')
from xsp3_hdf5 import XSPRESS3_TAUS, estimate_icr

@ValidateLarchPlugin
def read_gsexdi(fname, _larch=None, nmca=4, bad=None, **kws):
    """Read GSE XDI Scan Data to larch group,
    summing ROI data for MCAs and apply deadtime corrections
    """
    group = _larch.symtable.create_group()
    group.__name__ ='GSE XDI Data file %s' % fname
    xdi = XDIFile(str(fname))

    group._xdi = xdi
    group.filename = fname
    group.npts = xdi.npts
    group.bad_channels = bad
    group.dtc_taus = XSPRESS3_TAUS
コード例 #16
0
#!/usr/bin/env python

import os
import sys
import copy
import time
import gc

import numpy as np
from larch import Group, ValidateLarchPlugin, use_plugin_path
from larch.utils import OrderedDict

from larch_plugins.io import XDIFile, XDIFileException, iso8601_time

use_plugin_path('xrmmap')
from xsp3_hdf5 import XSPRESS3_TAUS, estimate_icr


@ValidateLarchPlugin
def read_gsexdi(fname, _larch=None, nmca=4, bad=None, **kws):
    """Read GSE XDI Scan Data to larch group,
    summing ROI data for MCAs and apply deadtime corrections
    """
    group = _larch.symtable.create_group()
    group.__name__ = 'GSE XDI Data file %s' % fname
    xdi = XDIFile(str(fname))

    group._xdi = xdi
    group.filename = fname
    group.npts = xdi.npts
    group.bad_channels = bad
コード例 #17
0
ファイル: spyk.py プロジェクト: Henry0422/xraylarch
yet to be implemented:
    -- th2th tth_start_rel tth_finish_rel intervals time
    -- automatic plotting
    -- save/read configuration
"""
import os
import time
import numpy as np
from ConfigParser import  ConfigParser
from cStringIO import StringIO


from larch import use_plugin_path, Group

from larch.utils.ordereddict import OrderedDict
use_plugin_path('io')
from fileutils import get_homedir, get_timestamp


try:
    from epics import PV, caget, caput, get_pv, poll
    HAS_EPICS = True
except ImportError:
    HAS_EPICS = False

try:
    use_plugin_path('epics')
    from larch_plugins.epics.larchscan   import LarchStepScan

    import epicsscan
    from epicsscan.positioner import Positioner