Skip to content

Commit

Permalink
wavelength additions
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Aug 19, 2021
1 parent 3e1c890 commit 487c3dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 11 additions & 1 deletion pyreduce/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,17 +841,23 @@ 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
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
Expand Down Expand Up @@ -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"]
Expand Down
10 changes: 5 additions & 5 deletions pyreduce/wavelength_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 487c3dd

Please sign in to comment.