Convert timestamps in metadata based on ref time
This commit is contained in:
parent
9a3efbf505
commit
1461d71b99
1 changed files with 22 additions and 4 deletions
|
|
@ -341,7 +341,10 @@ def read_metadata(data: dict, options={}) -> dict:
|
|||
default_options = {
|
||||
'get_temperature': True,
|
||||
'get_timestamp': True,
|
||||
'adjust_time': False
|
||||
'adjust_time': False,
|
||||
'convert_time': False,
|
||||
'reference_time': None,
|
||||
'time_unit': 's'
|
||||
}
|
||||
|
||||
options = aux.update_options(options=options, required_options=required_options, default_options=default_options)
|
||||
|
|
@ -371,6 +374,24 @@ def read_metadata(data: dict, options={}) -> dict:
|
|||
timestamps.append(time)
|
||||
|
||||
|
||||
if options['reference_time'] and options['convert_time']:
|
||||
from . import unit_tables
|
||||
new_times = []
|
||||
|
||||
if isinstance(options['reference_time'], str):
|
||||
options['reference_time'] = datetime.datetime.strptime(options['reference_time'], "%d.%b %y %H.%M.%S")
|
||||
|
||||
for time in timestamps:
|
||||
new_time = (time.timestamp() - options['reference_time'].timestamp()) * unit_tables.time()['s'].loc[options['time_unit']]
|
||||
|
||||
new_times.append(new_time)
|
||||
|
||||
|
||||
timestamps = new_times
|
||||
|
||||
|
||||
|
||||
|
||||
metadata = {'time': timestamps, 'temperature': temperatures}
|
||||
|
||||
return metadata
|
||||
|
|
@ -378,9 +399,6 @@ def read_metadata(data: dict, options={}) -> dict:
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def determine_active_roi(scan_data):
|
||||
|
||||
# FIXME For Co-edge, this gave a wrong scan
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue