Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion scopesim/effects/spectral_trace_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,14 @@ def __init__(self, **kwargs):
"x_colname": "x",
"y_colname": "y",
"s_colname": "s",
"offset_x": 0, # [mm] in detector plane
"offset_y": 0, # [mm] in detector plane
"wave_colname": "wavelength",
"center_on_wave_mid": False,
"dwave": 0.002, # [um] for finding the best fit dispersion
"invalid_value": None, # for dodgy trace file values
}
self.meta.update(params)

# Parameters that are specific to the subclass
self.meta.update(self._class_params)
self.meta.update(kwargs)
Expand Down Expand Up @@ -239,6 +240,18 @@ def apply_to(self, obj, **kwargs):
logger.info("Making cube")
obj.cube = obj.make_hdu()

# Check whether an offset slit is used. If so, recompute spectral traces.
offset_x = obj.cube.header["CRVAL1D"]
offset_y = obj.cube.header["CRVAL2D"]
if (offset_x != self.meta["offset_x"] or
offset_y != self.meta["offset_y"]):
logger.debug("Recomputing spectral traces for offset (%.1g, %.1g)",
offset_x, offset_y)
self.meta["offset_x"] = offset_x
self.meta["offset_y"] = offset_y
self.make_spectral_traces()
self.update_meta()

spt = self.spectral_traces[obj.trace_id]
obj.hdu = spt.map_spectra_to_focal_plane(obj)

Expand Down
9 changes: 7 additions & 2 deletions scopesim/effects/spectral_trace_list_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class SpectralTrace:
"x_colname": "x",
"y_colname": "y",
"s_colname": "s",
"offset_x": 0,
"offset_y": 0,
"wave_colname": "wavelength",
"dwave": 0.002,
"aperture_id": 0,
Expand Down Expand Up @@ -119,9 +121,12 @@ def compute_interpolation_functions(self):
Focal plane coordinates are `x` and `y`, in mm. Slit coordinates are
`xi` (spatial coordinate along the slit, in arcsec) and `lam`
(wavelength, in um).

The interpolation functions include a shift in the focal-plane
coordinates, determined from the CRVAL of the source FOV.
"""
x_arr = self.table[self.meta["x_colname"]]
y_arr = self.table[self.meta["y_colname"]]
x_arr = self.table[self.meta["x_colname"]] + self.meta["offset_x"]
y_arr = self.table[self.meta["y_colname"]] + self.meta["offset_y"]
xi_arr = self.table[self.meta["s_colname"]]
lam_arr = self.table[self.meta["wave_colname"]]

Expand Down
Loading