TracePDT

class jwst.wfss_contam.trace_pdt.TracePDT(x0_grid, y0_grid, lam_grid, dx_grid, dy_grid, exact_wavelength_grid=False)[source]

Bases: object

Interpolated replacement for the “detector” to “grism_detector” WCS transform.

Holds a pixel dispersion table, which is basically a cache of the (x0, y0, wavelength) -> (dx, dy) mapping on a coarse regular grid built using the exact transform. On init a linear interpolant is built from the sparse regular grid. On call the interpolant provides a drop-in replacement for the exact detector-to-grism WCS transform to disperse the direct-image pixels.

Initialize the lookup table from precomputed grid offsets.

Parameters:
x0_grid, y0_gridnp.ndarray

1-D, strictly increasing arrays of detector x, y grid positions.

lam_gridnp.ndarray

1-D, strictly increasing array of wavelength grid positions.

dx_grid, dy_gridnp.ndarray

Arrays of shape (len(x0_grid), len(y0_grid), len(lam_grid)) giving the dispersed-pixel offset from (x0, y0) at each grid point.

exact_wavelength_gridbool, optional

If True, lam_grid is known to exactly match the wavelength array that will be passed to evaluate_grid, allowing it to skip wavelength-axis interpolation entirely. Defaults to False.

Methods Summary

__call__(x0, y0, wavelength)

Interpolate the dispersed pixel position for input pixel position(s) and wavelength(s).

evaluate_grid(x0, y0, wavelength)

Evaluate the PDT on a grid.

Methods Documentation

__call__(x0, y0, wavelength)[source]

Interpolate the dispersed pixel position for input pixel position(s) and wavelength(s).

This generic, elementwise path handles arbitrary (independently varying) input shapes. For the common case where many pixels share the same wavelength array (as in _disperse_onto_grism), use evaluate_grid instead, which is substantially faster.

Parameters:
x0, y0np.ndarray

Detector x, y position(s) of the direct image pixel(s).

wavelengthnp.ndarray

Wavelength(s) at which to evaluate the dispersion. Must have the same shape as x0 and y0.

Returns:
x, ynp.ndarray

Interpolated x, y position(s) in the dispersed image, same shape as input.

evaluate_grid(x0, y0, wavelength)[source]

Evaluate the PDT on a grid.

Every pixel is dispersed at the same set of wavelengths, so this exploits the separability of trilinear interpolation: the (x0, y0) grid-cell lookup is done once per pixel (independent of wavelength), and the wavelength grid-cell lookup is done once for the shared wavelength array.

If this TracePDT was built with exact_wavelength_grid=True, wavelength-axis interpolation is skipped entirely, reducing this to a 2-D (x0, y0) bilinear lookup. Otherwise, wavelength is interpolated linearly.

Parameters:
x0, y0np.ndarray

1-D arrays giving the detector x, y position of each pixel to disperse.

wavelengthnp.ndarray

1-D array giving the wavelengths to evaluate, shared by every pixel. If this TracePDT was built with exact_wavelength_grid=True (see build_trace_pdt’s lam_grid argument), this must be exactly the same array used to build the grid.

Returns:
x, ynp.ndarray

Arrays of shape (n_wave, n_pixels) giving the interpolated dispersed pixel positions.