Merge branch 'master' of github.com:rasmusthog/nafuma
This commit is contained in:
commit
39f59e472c
2 changed files with 26 additions and 8 deletions
|
|
@ -10,7 +10,7 @@ def split_scan_data(data: dict, options={}) -> list:
|
||||||
''' Splits a XANES-file from BM31 into different files depending on the edge. Has the option to add intensities of all scans of same edge into the same file.
|
''' Splits a XANES-file from BM31 into different files depending on the edge. Has the option to add intensities of all scans of same edge into the same file.
|
||||||
As of now only picks out xmap_rois (fluoresence mode) and for Mn, Fe, Co and Ni K-edges.'''
|
As of now only picks out xmap_rois (fluoresence mode) and for Mn, Fe, Co and Ni K-edges.'''
|
||||||
|
|
||||||
required_options = ['log', 'logfile', 'save', 'save_folder', 'replace', 'active_roi', 'add_rois', 'return']
|
required_options = ['log', 'logfile', 'save', 'save_folder', 'replace', 'active_roi', 'add_rois', 'return', 'skip_if_no_roi']
|
||||||
|
|
||||||
default_options = {
|
default_options = {
|
||||||
'log': False,
|
'log': False,
|
||||||
|
|
@ -20,7 +20,8 @@ def split_scan_data(data: dict, options={}) -> list:
|
||||||
'replace': False, # whether to replace the files if they already exist
|
'replace': False, # whether to replace the files if they already exist
|
||||||
'active_roi': None,
|
'active_roi': None,
|
||||||
'add_rois': False, # Whether to add the rois of individual scans of the same edge together
|
'add_rois': False, # Whether to add the rois of individual scans of the same edge together
|
||||||
'return': True
|
'return': True,
|
||||||
|
'skip_if_no_roi': True
|
||||||
}
|
}
|
||||||
|
|
||||||
options = aux.update_options(options=options, required_options=required_options, default_options=default_options)
|
options = aux.update_options(options=options, required_options=required_options, default_options=default_options)
|
||||||
|
|
@ -100,10 +101,14 @@ def split_scan_data(data: dict, options={}) -> list:
|
||||||
|
|
||||||
|
|
||||||
if not ('xmap_roi00' in headers[i]) and (not 'xmap_roi01' in headers[i]):
|
if not ('xmap_roi00' in headers[i]) and (not 'xmap_roi01' in headers[i]):
|
||||||
|
if options['skip_if_no_roi']:
|
||||||
if options['log']:
|
if options['log']:
|
||||||
aux.write_log(message='... ... Did not find fluoresence data. Skipping...', options=options)
|
aux.write_log(message='... ... Did not find fluoresence data. Skipping...', options=options)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
if options['log']:
|
||||||
|
aux.write_log(message='... ... Did not find fluoresence data, but still proceeding ...', options=options)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -362,7 +367,12 @@ def read_metadata(data: dict, options={}) -> dict:
|
||||||
if options['get_timestamp']:
|
if options['get_timestamp']:
|
||||||
|
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
time = f.readline().strip('# Time: ')
|
#time = f.readline().strip('# Time: ') #<-- Previous code
|
||||||
|
time = f.readline().split('# Time: ')[-1] #Hope this does not fuck you up, Rasmus - but I needed another space here
|
||||||
|
split_operator=time[-9] #This should be the operator that splits hours, minutes and seconds
|
||||||
|
if split_operator == ".":
|
||||||
|
time = datetime.datetime.strptime(time, "%a %b %d %H.%M.%S %Y ")
|
||||||
|
if split_operator == ":":
|
||||||
time = datetime.datetime.strptime(time, "%a %b %d %H:%M:%S %Y ")
|
time = datetime.datetime.strptime(time, "%a %b %d %H:%M:%S %Y ")
|
||||||
|
|
||||||
if options['adjust_time']:
|
if options['adjust_time']:
|
||||||
|
|
|
||||||
|
|
@ -64,14 +64,22 @@ def plot_xanes(data, options={}):
|
||||||
def pick_out_scans(metadata: dict, timestamp: list):
|
def pick_out_scans(metadata: dict, timestamp: list):
|
||||||
|
|
||||||
# If either start or end are None, set to way back when or way into the future
|
# If either start or end are None, set to way back when or way into the future
|
||||||
|
split_operator=timestamp[0][-3] #Adding this to enable reading of both "." and ":" as operators to split hour:minute:second
|
||||||
|
|
||||||
if not timestamp[0]:
|
if not timestamp[0]:
|
||||||
timestamp[0] = datetime.datetime.strptime('1970 01 01 00:00:00', '%Y %m %d %H:%M:%S')
|
timestamp[0] = datetime.datetime.strptime('1970 01 01 00:00:00', '%Y %m %d %H:%M:%S')
|
||||||
else:
|
else:
|
||||||
|
if split_operator == ".":
|
||||||
timestamp[0] = datetime.datetime.strptime(timestamp[0], "%d.%b %y %H.%M.%S")
|
timestamp[0] = datetime.datetime.strptime(timestamp[0], "%d.%b %y %H.%M.%S")
|
||||||
|
if split_operator == ":":
|
||||||
|
timestamp[0] = datetime.datetime.strptime(timestamp[0], "%d.%b %y %H:%M:%S")
|
||||||
if not timestamp[1]:
|
if not timestamp[1]:
|
||||||
timestamp[1] = datetime.datetime.strptime('3000 01 01 00:00:00', '%Y %m %d %H:%M:%S')
|
timestamp[1] = datetime.datetime.strptime('3000 01 01 00:00:00', '%Y %m %d %H:%M:%S')
|
||||||
else:
|
else:
|
||||||
|
if split_operator == ".":
|
||||||
timestamp[1] = datetime.datetime.strptime(timestamp[1], "%d.%b %y %H.%M.%S")
|
timestamp[1] = datetime.datetime.strptime(timestamp[1], "%d.%b %y %H.%M.%S")
|
||||||
|
if split_operator == ":":
|
||||||
|
timestamp[1] = datetime.datetime.strptime(timestamp[1], "%d.%b %y %H:%M:%S")
|
||||||
|
|
||||||
scans = []
|
scans = []
|
||||||
for i, time in enumerate(metadata['time']):
|
for i, time in enumerate(metadata['time']):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue