Skip to content

Commit

Permalink
Merge pull request #284 from vuillaut/close_file
Browse files Browse the repository at this point in the history
fix bug with file close
  • Loading branch information
rlopezcoto authored Feb 17, 2020
2 parents 692331a + eb98438 commit 8442541
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lstchain/calib/camera/time_correction_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ def save_to_hdf5_file(self):
fbn_array[low_gain, pix_id, :] = self.fbn

try:
hf = h5py.File(self.calib_file_path, 'w')
hf.create_dataset('fan', data=fan_array)
hf.create_dataset('fbn', data=fbn_array)
hf.attrs['n_events'] = self.sum_events
hf.attrs['n_harm'] = self.n_harmonics
with h5py.File(self.calib_file_path, 'w') as hf:
hf.create_dataset('fan', data=fan_array)
hf.create_dataset('fbn', data=fbn_array)
hf.attrs['n_events'] = self.sum_events
hf.attrs['n_harm'] = self.n_harmonics

except Exception as err:
print("FAILED!", err)
hf.close()
print(f"FAILED to create the file {self.calib_file_path}", err)

0 comments on commit 8442541

Please sign in to comment.