Skip to content
Snippets Groups Projects
Commit 58e90a84 authored by David Hammer's avatar David Hammer
Browse files

Explicitly set read mode on h5py.File

parent 4628ab14
No related branches found
No related tags found
2 merge requests!451Feat/agipd fixed gain correction,!438Feat/agipd add fixed gain mode to dark notebook
...@@ -75,7 +75,7 @@ def get_acq_rate(fast_paths: Tuple[str, str, int], ...@@ -75,7 +75,7 @@ def get_acq_rate(fast_paths: Tuple[str, str, int],
fast_data_file = Path(fast_data_file) fast_data_file = Path(fast_data_file)
if fast_data_file.is_file(): if fast_data_file.is_file():
fast_data_path = f'INSTRUMENT/{karabo_id}/DET/{module}CH0:xtdf/image/pulseId' # noqa fast_data_path = f'INSTRUMENT/{karabo_id}/DET/{module}CH0:xtdf/image/pulseId' # noqa
with h5py.File(fast_data_file) as fin: with h5py.File(fast_data_file, "r") as fin:
if fast_data_path in fin: if fast_data_path in fin:
# pulses is of shape (NNNN, 1), of type uint8. # pulses is of shape (NNNN, 1), of type uint8.
# Squeeze out the data, and subtract the 3rd entry from the 2nd # Squeeze out the data, and subtract the 3rd entry from the 2nd
...@@ -132,7 +132,7 @@ def get_gain_mode(fname: str, h5path_ctrl: str) -> AgipdGainMode: ...@@ -132,7 +132,7 @@ def get_gain_mode(fname: str, h5path_ctrl: str) -> AgipdGainMode:
h5path_run = h5path_ctrl.replace("CONTROL/", "RUN/", 1) h5path_run = h5path_ctrl.replace("CONTROL/", "RUN/", 1)
h5path_gainmode = f'{h5path_run}/gainModeIndex/value' h5path_gainmode = f'{h5path_run}/gainModeIndex/value'
with h5py.File(fname, 'r') as fd: with h5py.File(fname, "r") as fd:
if h5path_gainmode in fd: if h5path_gainmode in fd:
return AgipdGainMode(fd[h5path_gainmode][0]) return AgipdGainMode(fd[h5path_gainmode][0])
return AgipdGainMode.ADAPTIVE_GAIN return AgipdGainMode.ADAPTIVE_GAIN
...@@ -299,7 +299,7 @@ class AgipdCorrections: ...@@ -299,7 +299,7 @@ class AgipdCorrections:
data_dict = self.shared_dict[i_proc] data_dict = self.shared_dict[i_proc]
data_dict['moduleIdx'][0] = module_idx data_dict['moduleIdx'][0] = module_idx
try: try:
f = h5py.File(file_name, 'r') f = h5py.File(file_name, "r")
group = f[agipd_base]["image"] group = f[agipd_base]["image"]
(_, first_index, last_index, (_, first_index, last_index,
...@@ -362,7 +362,7 @@ class AgipdCorrections: ...@@ -362,7 +362,7 @@ class AgipdCorrections:
return return
trains = data_dict['trainId'][:n_img] trains = data_dict['trainId'][:n_img]
with h5py.File(ofile_name, 'w') as outfile: with h5py.File(ofile_name, "w") as outfile:
# Copy any other data from the input file. # Copy any other data from the input file.
# This includes indexes, so it's important that the corrected data # This includes indexes, so it's important that the corrected data
# we write is aligned with the raw data. # we write is aligned with the raw data.
......
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