Also hh:mm:ss is usable when selecting spectra

This commit is contained in:
halvorhv 2022-09-01 14:09:03 +02:00
parent 8714e86753
commit 716e4acb82

View file

@ -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:
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 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:
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")
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']):