diff --git a/spectractor/extractor/spectrum.py b/spectractor/extractor/spectrum.py index 88c3b87e..07262fed 100644 --- a/spectractor/extractor/spectrum.py +++ b/spectractor/extractor/spectrum.py @@ -691,7 +691,13 @@ def save_spectrum(self, output_file_name, overwrite=False): if extname == "SPEC_COV": hdus[extname].data = self.cov_matrix elif extname == "ORDER2": - hdus[extname].data = [self.lambdas, self.data_next_order, self.err_next_order] + if self.data_next_order is None: + data_next_order = np.zeros_like(self.data) + err_next_order = np.zeros_like(self.err) + else: + data_next_order = self.data_next_order + err_next_order = self.err_next_order + hdus[extname].data = [self.lambdas, data_next_order, err_next_order] elif extname == "ORDER0": hdus[extname].data = self.target.image hdus[extname].header["IM_X0"] = self.target.image_x0