lightcurvelynx.astro_utils.detector_footprint

A wrapper class for representing detector footprints (which are stored as astropy PixelRegion). This class provides methods for checking if points are within the footprint and for plotting the footprint.

Classes

DetectorFootprint

A wrapper class for representing detector footprints.

Module Contents

class DetectorFootprint(region, *, wcs=None, pixel_scale=None, center_pixels=(0.5, 0.5), **kwargs)[source]

A wrapper class for representing detector footprints.

region[source]

The astropy PixelRegion representing the footprint.

Type:

astropy.regions.PixelRegion

wcs[source]

The WCS associated with the region, if any.

Type:

astropy.wcs.WCS or None

Parameters:
  • region (astropy.regions.SkyRegion or astropy.regions.PixelRegion) – The astropy SkyRegion or PixelRegion representing the footprint. SkyRegions will be converted to PixelRegions using the provided WCS or a default WCS.

  • wcs (astropy.wcs.WCS or None) – The WCS associated with the region, if any.

  • pixel_scale (float or None) – The pixel scale in arcseconds/pixel, this is required if no WCS is provided.

  • center_pixels (tuple of float, optional) – The pixel coordinates of the center of the detector. Default is (0.5, 0.5) for the center of the (0, 0) pixel. This is only used if no WCS is provided and a default WCS is created.

wcs = None[source]
region[source]
classmethod from_sky_rect(width, height, wcs=None, pixel_scale=None, **kwargs)[source]

Create a rectangular footprint in degrees.

Parameters:
  • width (float) – Width of the rectangle in degrees.

  • height (float) – Height of the rectangle in degrees.

  • wcs (astropy.wcs.WCS, optional) – The WCS associated with the region. If None, a default WCS will be created.

  • pixel_scale (float, optional) – The pixel scale in arcseconds/pixel, this is required if no WCS is provided.

  • **kwargs (dict) – Additional keyword arguments to pass to the RectangleSkyRegion constructor.

Returns:

The rectangular detector footprint.

Return type:

DetectorFootprint

classmethod from_pixel_rect(width, height, wcs=None, pixel_scale=None, **kwargs)[source]

Create a rectangular footprint in pixels.

Parameters:
  • width (float) – Width of the rectangle in pixels.

  • height (float) – Height of the rectangle in pixels.

  • wcs (astropy.wcs.WCS, optional) – The WCS associated with the region. If None, a default WCS will be created.

  • pixel_scale (float, optional) – The pixel scale in arcseconds/pixel, this is required if no WCS is provided.

  • **kwargs (dict) – Additional keyword arguments to pass to the RectangleSkyRegion constructor.

Returns:

The rectangular detector footprint.

Return type:

DetectorFootprint

static rotate_to_center(ra, dec, center_ra, center_dec, *, rotation=None)[source]

Transform the given points, represented by (ra, dec) in degrees, to a local coordinate system centered on (center_ra, center_dec), accounting for rotation if specified.

Note

This method is vectorized so it can handle an array of points and an (equally sized) array of center points. The transformation is done on each point for the corresponding center point.

Parameters:
  • ra (np.ndarray) – Right ascension in degrees.

  • dec (np.ndarray) – Declination in degrees.

  • center_ra (np.ndarray) – Center right ascension of the detector in degrees.

  • center_dec (np.ndarray) – Center declination of the detector in degrees.

  • rotation (np.ndarray, optional) – The rotation angle of the detector for each pointing in degrees clockwise. Used to represent non-axis-aligned footprints.

Returns:

Transformed (lon, lat) offsets from the center in degrees.

Return type:

tuple of np.ndarray

sky_to_pixel(ra, dec, center_ra, center_dec, *, rotation=None)[source]

Transform sky coordinates (ra, dec) to pixel coordinates.

Parameters:
  • ra (float or array-like) – Right ascension in degrees.

  • dec (float or array-like) – Declination in degrees.

  • center_ra (float) – Center right ascension of the detector in degrees.

  • center_dec (float) – Center declination of the detector in degrees.

  • rotation (float or array-like, optional) – The rotation angle of the detector for each pointing in degrees clockwise. Used to represent non-axis-aligned footprints.

Returns:

Pixel coordinates (x, y) corresponding to the input sky coordinates.

Return type:

tuple of np.ndarray

contains(ra, dec, center_ra, center_dec, *, rotation=None)[source]

Check that given points, represented by (ra, dec) in degrees, are within the footprint.

Parameters:
  • ra (float or array-like) – Right ascension in degrees.

  • dec (float or array-like) – Declination in degrees.

  • center_ra (float or array-like) – Center right ascension of the detector in degrees.

  • center_dec (float or array-like) – Center declination of the detector in degrees.

  • rotation (np.ndarray, optional) – The rotation angle of the detector for each pointing in degrees clockwise. Used to represent non-axis-aligned footprints.

Returns:

True if the point is within the footprint, False otherwise.

Return type:

bool or array-like of bool

compute_radius()[source]

Compute an approximate bounding radius of the footprint in degrees.

Note

This radius is based on the bounding box of the footprint (with a small pixel padding), so it will be larger than the actual radius of the footprint.

Returns:

The radius of the footprint in degrees.

Return type:

float

compute_sky_region(center_ra, center_dec, *, rotation=0.0)[source]

Compute the sky region of the footprint at the given center position.

Parameters:
  • center_ra (float) – Center right ascension of the detector in degrees.

  • center_dec (float) – Center declination of the detector in degrees.

  • rotation (float, optional) – The rotation angle of the detector for each pointing in degrees clockwise. Used to represent non-axis-aligned footprints. Default is 0.0.

Returns:

  • astropy.regions.SkyRegion – The sky region representing the footprint at the given center position.

  • astropy.wcs.WCS – The WCS representing the footprint at the given center position.

plot(*, ax=None, figure=None, center_ra=0, center_dec=0, rotation=0, point_ra=None, point_dec=None, **kwargs)[source]

Plot the footprint using matplotlib and an optional set of points to overlay.

Parameters:
  • ax (matplotlib.pyplot.Axes or None, optional) – Axes, If None, a new axes will be created. None by default.

  • figure (matplotlib.pyplot.Figure or None) – Figure, If None, a new figure will be created. None by default.

  • center_ra (float, optional) – Center right ascension of the detector in degrees. Default is 0.

  • center_dec (float, optional) – Center declination of the detector in degrees. Default is 0.

  • rotation (np.ndarray, optional) – The rotation angle of the detector for each pointing in degrees clockwise. Used to represent non-axis-aligned footprints. Default is 0.

  • point_ra (array-like or None, optional) – Right ascension of points to overlay in degrees. None by default.

  • point_dec (array-like or None, optional) – Declination of points to overlay in degrees. None by default.

  • **kwargs (dict) – Optional parameters to pass to the plotting function