Skip to content
Merged
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
12 changes: 12 additions & 0 deletions scopesim/effects/sky_ter_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from palace import palace
import skycalc_ipy

from . import AtmosphericTERCurve
from ..utils import (get_logger, from_currsys, from_rc_config, find_file,
zendist2airmass, get_zenith_angle, get_moon_phase, get_observation_info_from_cmds, get_local_time)
from .. import rc
Expand Down Expand Up @@ -403,3 +404,14 @@ def get_skycalc_inputs(self, **kwargs):
return params


class TAPASTERCurve(AtmosphericTERCurve):
z_order: ClassVar[tuple[int, ...]] = (111, 511)

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.target, self.location, self.time, self.brightness = get_observation_info_from_cmds(self.cmds)
self.airmass = zendist2airmass(get_zenith_angle(self.target, self.location, self.time))
self.surface.table['transmission'] = self.surface.table['transmission'] ** self.airmass

def apply_to(self, obj, **kwargs):
return super().apply_to(obj, **kwargs)
22 changes: 11 additions & 11 deletions scopesim/effects/spectral_trace_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,17 @@ 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()
# # 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]
try:
Expand Down
6 changes: 3 additions & 3 deletions scopesim/effects/spectral_trace_list_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def _focal_plane_grid(self, fov):
xmin_mm, ymin_mm = fpa_wcsd.all_pix2world(xmin, ymin, 0)
xmax_mm, ymax_mm = fpa_wcsd.all_pix2world(xmax, ymax, 0)

x_mm = np.linspace(xmin_mm, xmax_mm, sub_naxis1, dtype=np.float32)
y_mm = np.linspace(ymin_mm, ymax_mm, sub_naxis2, dtype=np.float32)
x_mm = np.linspace(xmin_mm, xmax_mm, sub_naxis1, endpoint=False, dtype=np.float32)
y_mm = np.linspace(ymin_mm, ymax_mm, sub_naxis2, endpoint=False, dtype=np.float32)
return xmin, ymin, x_mm, y_mm, det_wcs

def map_spectra_to_focal_plane(self, fov):
Expand Down Expand Up @@ -870,7 +870,7 @@ def __init__(self, fov, dlam_per_pix):
# arrays of cube coordinates
cube_xi = d_xi * np.arange(n_xi) + fov.meta["xi_min"].value
cube_eta = d_eta * (np.arange(n_eta) - (n_eta - 1) / 2)
cube_lam = wcs_lam.all_pix2world(np.arange(n_lam), 1)[0]
cube_lam = wcs_lam.all_pix2world(np.arange(n_lam), 0)[0]
cube_lam *= u.Unit(wcs_lam.wcs.cunit[0]).to(u.um)

# Initialise the array to hold the xi-lambda image
Expand Down
16 changes: 14 additions & 2 deletions scopesim/effects/ter_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ class TERCurve
3.0 0.9 0.1

"""
## Made TERCurve a FOV effect as well to be able to use it for dichroic trees which act on FoV objects
z_order: ClassVar[tuple[int, ...]] = (10, 110, 510, 610)
# Even though there is a FOV block in apply_to, the default z_order for TERCurve should not have 6xx otherwise
# it will apply that transmission twice! Once to the source, then to the FOV, found out the hard way :(
z_order: ClassVar[tuple[int, ...]] = (10, 110, 510)
report_plot_include: ClassVar[bool] = True
report_table_include: ClassVar[bool] = False

Expand Down Expand Up @@ -688,6 +689,17 @@ def __init__(self, **kwargs):

def apply_to(self, obj, **kwargs):
if isinstance(obj, FieldOfView):
if obj.detector_header is not None and u.Unit(from_currsys(self.meta["position_unit"], self.cmds)) == u.pixel:
axis = str(from_currsys(self.meta["axis"], self.cmds)).lower()
if axis in {"x", "dispersion"}:
detector_axis = "NAXIS1"
elif axis in {"y", "cross_dispersion", "cross-dispersion"}:
detector_axis = "NAXIS2"
else:
raise ValueError("axis must be 'x' or 'y'.")
detector_pixels = obj.detector_header[detector_axis]
if self._position_min() != 0 or self._position_max() != detector_pixels:
warnings.warn(f"Tapered QE {axis}-axis span {self._position_min():g}..{self._position_max():g} pix differs from detector {detector_axis} span 0..{detector_pixels} pix.", stacklevel=2)
obj.meta["detector_qe"] = self
return obj

Expand Down
Loading