*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit c8f3daef authored by Schabbauer, Johannes's avatar Schabbauer, Johannes
Browse files

Adwin Analog inputs: added getting traces without writing to hdf5 file (much...

Adwin Analog inputs: added getting traces without writing to hdf5 file (much faster, esp. if we need them just once for plotting)
parent 030569ea
No related branches found
No related tags found
No related merge requests found
...@@ -103,7 +103,7 @@ def get_channel_from_BLACS_name(BLACS_name): ...@@ -103,7 +103,7 @@ def get_channel_from_BLACS_name(BLACS_name):
return int(channel) return int(channel)
def get_ain_traces(h5file, raw_data_name="ADwinAnalogIn_DATA", convert_data=True, device_name="ADwin"): def get_ain_traces(h5file, raw_data_name="ADwinAnalogIn_DATA", convert_data=True, device_name="ADwin", write_hdf5 = True):
""" """
Split raw (sorted!) data from ADwin analog inputs into aquisitions Split raw (sorted!) data from ADwin analog inputs into aquisitions
of channels and store the traces for each channel in the h5 file. of channels and store the traces for each channel in the h5 file.
...@@ -118,8 +118,11 @@ def get_ain_traces(h5file, raw_data_name="ADwinAnalogIn_DATA", convert_data=True ...@@ -118,8 +118,11 @@ def get_ain_traces(h5file, raw_data_name="ADwinAnalogIn_DATA", convert_data=True
Set is the input voltage is stored as row value, or converted to volts. Set is the input voltage is stored as row value, or converted to volts.
device_name : str, optional device_name : str, optional
Name of the ADwin device. Name of the ADwin device.
write_hdf5 : bool, optional
Decides if the single traces are written to the hdf5 file or returned.
""" """
with h5py.File(h5file, 'r+') as f: return_dict = {}
with h5py.File(h5file, 'r'+write_hdf5*'+') as f: # open with(out) write permission depending on argument
group = f["data/traces"] group = f["data/traces"]
if raw_data_name not in group: if raw_data_name not in group:
print(f"No raw acquisition data with name '{raw_data_name}' found!") print(f"No raw acquisition data with name '{raw_data_name}' found!")
...@@ -154,8 +157,13 @@ def get_ain_traces(h5file, raw_data_name="ADwinAnalogIn_DATA", convert_data=True ...@@ -154,8 +157,13 @@ def get_ain_traces(h5file, raw_data_name="ADwinAnalogIn_DATA", convert_data=True
else: else:
times = np.arange(acquisition_times["start_time"][i],acquisition_times["stop_time"][i]) / clock_rate times = np.arange(acquisition_times["start_time"][i],acquisition_times["stop_time"][i]) / clock_rate
# print(times.size,acquisition.size) # print(times.size,acquisition.size)
data = np.rec.fromarrays([times, acquisition], dtype=dtype) if write_hdf5:
group.create_dataset(label, compression = config.compression, data = data) data = np.rec.fromarrays([times, acquisition], dtype=dtype)
group.create_dataset(label, compression = config.compression, data = data)
else:
return_dict[label] = times, acquisition
if not write_hdf5:
return return_dict
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment