[docs]classTaurexSpectrum(ArraySpectrum):"""Observation is a taurex spectrum from a HDF5 file. An instrument function must have been used for this to work """def__init__(self,filename:t.Optional[PathLike]=None):"""Initialize and load from HDF5 file. Parameters ---------- filename: Filename of HDF5 file Raises ------ KeyError If instrument output not found in HDF5 file """super().__init__(self._load_from_hdf5(filename))def_load_from_hdf5(self,filename:PathLike)->npt.NDArray[np.float64]:"""Load from HDF5 file. Parameters ---------- filename: Filename of HDF5 file Returns ------- np.ndarray[np.float64] Array of shape (nbins, 4) with columns: 1. wavelength (um) 2. spectral data 3. error 4. bin width (um) Raises ------ KeyError If instrument output not found in HDF5 file """importh5pywithh5py.File(filename,"r")asf:try:wngrid=f["Output"]["Spectra"]["instrument_wngrid"][:]exceptKeyErrorase:self.error("Could not find instrument outputs in HDF5, ""this was caused either by the HDF5 being a ""retrieval output or not running with some ""form of instrument in the forward model"" input par file")raiseKeyError("Instrument output not found")fromespectrum=f["Output"]["Spectra"]["instrument_spectrum"][:]noise=f["Output"]["Spectra"]["instrument_noise"][:]wnwidth=f["Output"]["Spectra"]["instrument_wnwidth"][:]wlgrid=10000/wngridwlwidth=wnwidth_to_wlwidth(wngrid,wnwidth)returnnp.vstack((wlgrid,spectrum,noise,wlwidth)).T