LookupTablePSF

class msaexp.utils.LookupTablePSF(psf_file='nirspec_merged_s200a1_exp_psf_lookup_001.fits', **kwargs)[source]

Bases: object

Fast lookup table PSF derived from point sources in the fixed slit.

The table is evaluated for a grid of slit-frame (y) pixels, wavelength and a profile width convolved with the PSF profile.

Parameters
psf_filestr, ‘nirspec_prism_clear_exp_psf_lookup.fits’

Which PSF table to use. nirspec_exp_psf_lookup.fits assumes an exponential profile where the width parameter is the half-light radius. nirspec_gau_psf_lookup.fits is a Gaussian profile with the width parameter sigma.

Examples

import numpy as np
import matplotlib.pyplot as plt
import msaexp.utils as msautils

waves = np.linspace(0.8, 5.6, 128)
yslit = np.arange(-9, 10, dtype=float)
w2d, y2d = np.meshgrid(waves, yslit)

fig, axes = plt.subplots(2,1,figsize=(8,5), sharex=True, sharey=True)

# Initialize the lookup table
prf_model = msautils.LookupTablePSF()

# Straight trace
prf = prf_model.evaluate(sigma=0, dy=0.0, slit_coords=(w2d, y2d))

axes[0].imshow(
    prf,
    extent=(waves[0], waves[-1], yslit[0], yslit[-1]),
    aspect='auto'
)

# Curved trace
dy = -((w2d-4)/2)**2
prf2 = prf_model.evaluate(sigma=0.2, dy=dy, slit_coords=(w2d, y2d))

axes[1].imshow(
    prf2,
    extent=(waves[0], waves[-1], yslit[0], yslit[-1]),
    aspect='auto'
)

axes[1].set_xlabel('wavelength')
axes[1].set_ylabel('y pixel')
fig.tight_layout(pad=1)

# Verify that integral of each along the trace is 1.0
assert(np.allclose(prf.sum(axis=0), 1., rtol=0.01))
assert(np.allclose(prf2.sum(axis=0), 1., rtol=0.01))

(Source code, png, hires.png, pdf)

../_images/msaexp-utils-LookupTablePSF-1.png

Methods Summary

__call__(**kwargs)

Run execute

evaluate([sigma, dy, slit_coords, order])

Run the lookup

path_loss(wave[, sigma, x_offset, order])

Interpolate path loss

read_data()

Read the lookup table data in psf_file

set_slit_coords(wave, slit_y)

Set wavelength and pixel interpolants, perhaps to speed up execution if these don't change.

set_slit_offset([dy])

Set an offset to the cross-dispersion y pixel, added to slit_y

Methods Documentation

__call__(**kwargs)[source]

Run execute

evaluate(sigma=0, dy=0.0, slit_coords=None, order=1, **kwargs)[source]

Run the lookup

Parameters
sigmafloat > 0

Gaussian width convolved with the PSF profile

dyNone, scalar, array-like

Offset added to slit coordinates with set_slit_offset.

slit_coordsNone, (array-like, array-like)

Interpolation location coordinates wave and slit_y passed to set_slit_coords.

orderint

Order of the interpolation with scipy.ndimage.map_coordinates.

Returns
map_interparray-like

Interpolated PSF model (same shape as inputs to slit_coords).

path_loss(wave, sigma=0.0, x_offset=0.0, order=1)[source]

Interpolate path loss

Parameters
wavearray-like

Wavelengths, microns

sigmafloat

Exponential profile width

x_offsetfloat, (-0.5, 0.5)

Source x position within the shutter

orderint

Interpolation order

Returns
path_lossarray-like

Estimated path loss

read_data()[source]

Read the lookup table data in psf_file

set_slit_coords(wave, slit_y)[source]

Set wavelength and pixel interpolants, perhaps to speed up execution if these don’t change.

Parameters
wavearray-like

Wavelengths, microns

slit_yarray-like

Cross-dispersion pixel centers

Returns
Sets slit_shape, slit_y attributes and computes interpolator indices
slit_wavei, slit_yi.
set_slit_offset(dy=None)[source]

Set an offset to the cross-dispersion y pixel, added to slit_y

Parameters
dyNone, scalar, array-like

Offset added to slit_y and then compute interpolant slit_yi_offset