Skip to content

Commit

Permalink
Force the helper to use the PyMca files.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasole committed Mar 2, 2015
1 parent d581b76 commit 8c435d7
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions PyMca5/PyMcaPhysics/xrf/FisxHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# The PyMca X-Ray Fluorescence Toolkit
#
# Copyright (c) 2004-2014 European Synchrotron Radiation Facility
# Copyright (c) 2004-2015 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
Expand Down Expand Up @@ -44,24 +44,40 @@
def getElementsInstance(dataDir=None, bindingEnergies=None, xcomFile=None):
if dataDir is None:
dataDir = DataDir.FISX_DATA_DIR
try:
from PyMca5.PyMcaDataDir import PYMCA_DATA_DIR as pymcaDataDir
except:
print("Using fisx shell constants and ratios")
pymcaDataDir = None
if bindingEnergies is None:
bindingEnergies = os.path.join(dataDir, "BindingEnergies.dat")
if pymcaDataDir is None:
bindingEnergies = os.path.join(dataDir, "BindingEnergies.dat")
else:
bindingEnergies = os.path.join(pymcaDataDir, "BindingEnergies.dat")
if xcomFile is None:
xcomFile = os.path.join(dataDir, "XCOM_CrossSections.dat")
if pymcaDataDir is None:
xcomFile = os.path.join(dataDir, "XCOM_CrossSections.dat")
else:
xcomFile = os.path.join(pymcaDataDir, "XCOM_CrossSections.dat")
if DEBUG:
t0 = time.time()
instance = FisxElements(dataDir, bindingEnergies, xcomFile)
if DEBUG:
print("Shell constants")
# the files should be taken from PyMca to make sure the same data are used
for key in ["K", "L", "M"]:
fname = instance.getShellConstantsFile(key)
if sys.version > '3.0':
# we have to make sure we have got a string
if hasattr(fname, "decode"):
fname = fname.decode("latin-1")
if DEBUG:
print("Before %s" % fname)
fname = os.path.join(os.path.dirname(fname), key + "ShellConstants.dat")
print("Before %s" % fname)
if pymcaDataDir is not None:
fname = os.path.join(pymcaDataDir, key + "ShellConstants.dat")
else:
fname = os.path.join(os.path.dirname(fname),
key + "ShellConstants.dat")
instance.setShellConstantsFile(key, fname)
if DEBUG:
print("After %s" % instance.getShellConstantsFile(key))
Expand All @@ -76,11 +92,14 @@ def getElementsInstance(dataDir=None, bindingEnergies=None, xcomFile=None):
fname = fname.decode("latin-1")
if DEBUG:
print("Before %s" % fname)
fname = os.path.join(os.path.dirname(fname), key + "ShellRates.dat")
if pymcaDataDir is not None:
fname = os.path.join(pymcaDataDir, key + "ShellRates.dat")
else:
fname = os.path.join(os.path.dirname(fname), key + "ShellRates.dat")
instance.setShellRadiativeTransitionsFile(key, fname)
if DEBUG:
print("After %s " % instance.getShellRadiativeTransitionsFile(key))

if DEBUG:
print("Reading Elapsed = ", time.time() - t0)
return instance
Expand Down

0 comments on commit 8c435d7

Please sign in to comment.