added id9 log file parser
This commit is contained in:
parent
18430895ad
commit
d17b9caa7f
|
@ -4,6 +4,7 @@ from . import mask
|
|||
from . import peaks
|
||||
from . import cell
|
||||
from . import filters
|
||||
from . import id9
|
||||
try:
|
||||
from . import azav
|
||||
except ImportError:
|
||||
|
|
43
xray/id9.py
43
xray/id9.py
|
@ -48,6 +48,49 @@ def readDelayFromDiagnostic(fname):
|
|||
delays = np.round(delays.astype(float),12)
|
||||
return collections.OrderedDict( zip(files,delays) )
|
||||
|
||||
def _findDark(line):
|
||||
_,value = line.split(":")
|
||||
return float(value)
|
||||
|
||||
def _delayToNum(delay):
|
||||
if delay.decode('ascii') == 'off':
|
||||
delay = -10
|
||||
else:
|
||||
delay=utils.strToTime(delay)
|
||||
return delay
|
||||
|
||||
def findLogFile(folder):
|
||||
files = utils.getFiles(folder,basename='*.log')
|
||||
files.remove(os.path.join(folder,"diagnostics.log"))
|
||||
logfile = files[0]
|
||||
if len(files)>1: log.warn("Found more than one *.log file that is not diagnostics.log: %s"%files)
|
||||
return logfile
|
||||
|
||||
def readLogFile(fnameOrFolder,subtractDark=False):
|
||||
""" read id9 style logfile """
|
||||
if os.path.isdir(fnameOrFolder):
|
||||
fname = findLogFile(fnameOrFolder)
|
||||
else:
|
||||
fname = fnameOrFolder
|
||||
f = open(fname,"r")
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
lines = [line.strip() for line in lines]
|
||||
darks = {}
|
||||
for line in lines:
|
||||
if line.find("pd1 dark/sec")>=0: darks['pd1ic'] = _findDark(line)
|
||||
if line.find("pd2 dark/sec")>=0: darks['pd2ic'] = _findDark(line)
|
||||
if line.find("pd3 dark/sec")>=0: darks['pd3ic'] = _findDark(line)
|
||||
if line.find("pd4 dark/sec")>=0: darks['pd4ic'] = _findDark(line)
|
||||
for iline,line in enumerate(lines):
|
||||
if line.lstrip()[0] != "#": break
|
||||
data=np.genfromtxt(fname,skip_header=iline-1,names=True,comments="%",dtype=None,converters = {'delay': lambda s: _delayToNum(s)})
|
||||
if subtractDark:
|
||||
for diode in ['pd1ic','pd2ic','pd3ic','pd4ic']:
|
||||
if diode in darks: data[diode]=data[diode]-darks[diode]*data['timeic']
|
||||
return data
|
||||
|
||||
|
||||
|
||||
def doFolder_azav(folder,nQ=1500,files='*.edf*',force=False,mask=None,
|
||||
saveChi=True,poni='pyfai.poni',storageFile='auto',dark=9.9,zingerFilter=30,qlims=(0,10),
|
||||
|
|
Loading…
Reference in New Issue