Capture more metadata
This commit is contained in:
parent
2232a91f2e
commit
910737202f
@ -25,7 +25,8 @@ def measure(
|
||||
stop_on_script_end: bool=False,
|
||||
verbose: bool=False,
|
||||
command_queue: None|Queue=None,
|
||||
data_queue: None|Queue=None
|
||||
data_queue: None|Queue=None,
|
||||
add_measurement_info_to_metadata=True
|
||||
):
|
||||
"""
|
||||
Perform a measurement
|
||||
@ -62,22 +63,24 @@ def measure(
|
||||
The default is None.
|
||||
data_queue : None|Queue, optional
|
||||
A queue to put data in. The default is None.
|
||||
|
||||
add_measurement_info_to_metadata : bool, optional
|
||||
If True, add measurement info to the metadata:
|
||||
time, measurement_interval, measurement_use_buffer, measurement_voltage_device, measurement_led_device
|
||||
The default is True.
|
||||
Returns
|
||||
-------
|
||||
None.
|
||||
|
||||
"""
|
||||
# old hack when using multiprocessing instead of mulithreading:
|
||||
# devices are not pickleable and thus cant be moved to / shared with the measurement process
|
||||
# if led_dev is None:
|
||||
# led_dev = LEDD1B()
|
||||
# if vm_dev is None:
|
||||
# vm_dev = init("GPIB0::22::INSTR")
|
||||
# if no "time" in metadata, set the current local time in ISO 8601 format
|
||||
# and without microseconds
|
||||
if not "time" in data.metadata:
|
||||
data.metadata["time"] = datetime.datetime.now().replace(microsecond=0).astimezone().isoformat()
|
||||
get_time = lambda: datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
|
||||
if add_measurement_info_to_metadata:
|
||||
data.metadata["measurement_interval"] = str(delta_t)
|
||||
data.metadata["measurement_use_buffer"] = str(use_buffer)
|
||||
data.metadata["measurement_voltage_device"] = str(vm_dev)
|
||||
data.metadata["measurement_led_device"] = str(led_dev)
|
||||
data.metadata["measurement_time_start"] = get_time()
|
||||
# write metadata to disk
|
||||
data.write_metadata()
|
||||
vm_dev.reset(True)
|
||||
if use_buffer:
|
||||
vm_dev.buffer_measure(delta_t, verbose=True)
|
||||
@ -148,6 +151,10 @@ def measure(
|
||||
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
if add_measurement_info_to_metadata:
|
||||
data.metadata["measurement_time_stop"] = get_time()
|
||||
# Write again after having updated the stop time
|
||||
data.write_metadata()
|
||||
data.flush(verbose=verbose)
|
||||
led_dev.off()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user