From 487c3ddf67fa7de6fb27786f0df2ba892e3529b5 Mon Sep 17 00:00:00 2001 From: Ansgar Wehrhahn <31626864+AWehrhahn@users.noreply.github.com> Date: Thu, 19 Aug 2021 10:20:55 +0200 Subject: [PATCH] wavelength additions --- pyreduce/reduce.py | 12 +++++++++++- pyreduce/wavelength_calibration.py | 10 +++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pyreduce/reduce.py b/pyreduce/reduce.py index 870310b7..86c8b482 100755 --- a/pyreduce/reduce.py +++ b/pyreduce/reduce.py @@ -841,10 +841,11 @@ def __init__(self, *args, **config): self.iterations = config["iterations"] #:{'1D', '2D'}: Whether to use 1d or 2d polynomials self.dimensionality = config["dimensionality"] + #:int: Number of detector offset steps, due to detector design self.nstep = config["nstep"] #:float: fraction of columns, to allow individual orders to shift self.shift_window = config["shift_window"] - + #:{'number_of_files', 'exposure_time', 'mean', 'median'}: how to adjust for diferences between the bias and flat field exposure times self.bias_scaling = config["bias_scaling"] @property @@ -852,6 +853,11 @@ def savefile(self): """str: Name of the wavelength echelle file""" return join(self.output_dir, self.prefix + ".thar.npz") + @property + def savefile_thar(self): + """str: Name of the wavelength echelle file""" + return join(self.output_dir, self.prefix + ".thar_only.npz") + def run(self, files, orders, mask, curvature, bias, config): """Perform wavelength calibration @@ -913,6 +919,10 @@ def run(self, files, orders, mask, curvature, bias, config): **self.extraction_kwargs, ) + # Save the extracted wavecal spectrum only + # This can be useful for creating a calibration file in IDL + np.savez(self.savefile_thar, thar=thar) + # load reference linelist reference = self.instrument.get_wavecal_filename( thead, self.mode, **config["instrument"] diff --git a/pyreduce/wavelength_calibration.py b/pyreduce/wavelength_calibration.py index 273fb760..18426831 100644 --- a/pyreduce/wavelength_calibration.py +++ b/pyreduce/wavelength_calibration.py @@ -148,7 +148,7 @@ class LineList: (("posm", "POSM"), ">f8"), # Pixel Position (after fit) (("xfirst", "XFIRST"), ">i2"), # first pixel of the line (("xlast", "XLAST"), ">i2"), # last pixel of the line - (("approx", "APPROX"), "O"), # ??? + (("approx", "APPROX"), "O"), # Not used. Describes the shape used to approximate the line. "G" for Gaussian (("width", "WIDTH"), ">f8"), # width of the line in pixels (("height", "HEIGHT"), ">f8"), # relative strength of the line (("order", "ORDER"), ">i2"), # echelle order the line is found in @@ -183,14 +183,14 @@ def add_line(self, wave, order, pos, width, height, flag): lines = np.array(lines, dtype=self.dtype) self.data = np.append(self.data, lines) - @staticmethod - def from_list(wave, order, pos, width, height, flag): + @classmethod + def from_list(cls, wave, order, pos, width, height, flag): lines = [ (w, w, p, p, p - wi / 2, p + wi / 2, b"G", wi, h, o, f) for w, o, p, wi, h, f in zip(wave, order, pos, width, height, flag) ] - lines = np.array(lines, dtype=LineList.dtype) - return LineList(lines) + lines = np.array(lines, dtype=cls.dtype) + return cls(lines) class WavelengthCalibration: