diff --git a/scopesim/effects/spectral_trace_list.py b/scopesim/effects/spectral_trace_list.py index 45120f9f..480d546d 100644 --- a/scopesim/effects/spectral_trace_list.py +++ b/scopesim/effects/spectral_trace_list.py @@ -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) @@ -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) diff --git a/scopesim/effects/spectral_trace_list_utils.py b/scopesim/effects/spectral_trace_list_utils.py index 44b4f5a5..28111b49 100644 --- a/scopesim/effects/spectral_trace_list_utils.py +++ b/scopesim/effects/spectral_trace_list_utils.py @@ -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, @@ -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"]]