From 8d716592843a46a273575812ff8dde2516573a42 Mon Sep 17 00:00:00 2001 From: Tomas Stolker Date: Sat, 30 Mar 2024 17:08:36 +0100 Subject: [PATCH] Fixed appending issue with Vega spectrum --- species/phot/syn_phot.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/species/phot/syn_phot.py b/species/phot/syn_phot.py index 784424c..e29b877 100644 --- a/species/phot/syn_phot.py +++ b/species/phot/syn_phot.py @@ -114,11 +114,18 @@ def calc_zero_point(self) -> Union[float, np.float64]: read_filt = ReadFilter(self.filter_name) self.wavel_range = read_filt.wavelength_range() - with h5py.File(self.database, "a") as h5_file: - if "spectra/calibration/vega" not in h5_file: - add_vega(self.data_folder, h5_file) + with h5py.File(self.database, "r") as hdf5_file: + if "spectra/calibration/vega" in hdf5_file: + vega_found = True + else: + vega_found = False + + if not vega_found: + with h5py.File(self.database, "a") as hdf5_file: + add_vega(self.data_folder, hdf5_file) - vega_spec = np.array(h5_file["spectra/calibration/vega"]) + with h5py.File(self.database, "r") as hdf5_file: + vega_spec = np.array(hdf5_file["spectra/calibration/vega"]) wavelength = vega_spec[0,] flux = vega_spec[1,]