From 716e4acb822a78f690fe1492b5ef9bdd2642a5df Mon Sep 17 00:00:00 2001 From: halvorhv Date: Thu, 1 Sep 2022 14:09:03 +0200 Subject: [PATCH] Also hh:mm:ss is usable when selecting spectra --- nafuma/xanes/plot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nafuma/xanes/plot.py b/nafuma/xanes/plot.py index 440308c..78230c6 100644 --- a/nafuma/xanes/plot.py +++ b/nafuma/xanes/plot.py @@ -64,14 +64,22 @@ def plot_xanes(data, options={}): 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 + split_operator=timestamp[0][-3] #Adding this to enable reading of both "." and ":" as operators to split hour:minute:second + if not timestamp[0]: timestamp[0] = datetime.datetime.strptime('1970 01 01 00:00:00', '%Y %m %d %H:%M:%S') 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]: timestamp[1] = datetime.datetime.strptime('3000 01 01 00:00:00', '%Y %m %d %H:%M:%S') 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 = [] for i, time in enumerate(metadata['time']):