diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py index 558ec084bdc7f843f6f653a7f6b44cb4a88afc90..1ac77d9b8d989e9be1a8a8659362dcc68960aaff 100644 --- a/cal_tools/cal_tools/agipdlib.py +++ b/cal_tools/cal_tools/agipdlib.py @@ -1655,8 +1655,8 @@ class AgipdCorrections: for cname, mdata in const_yaml[dname].items(): when[cname] = mdata["creation-time"] if when[cname]: - cf = h5py.File(mdata["file-path"]) - cons_data[cname] = np.copy(cf[f"{dname}/{cname}/0/data"]) + with h5py.File(mdata["file-path"], "r") as cf: + cons_data[cname] = np.copy(cf[f"{dname}/{cname}/0/data"]) else: # Create empty constant using the list elements cons_data[cname] = \