yippy.offax#
Base class for all offax_psfs.fits files.
This has been deprecated. Please use OffJAX instead.
Classes#
Base class for off-axis PSF handling. |
Module Contents#
- class yippy.offax.OffAx(yip_dir, offax_data_file, offax_offsets_file, pixel_scale_arcsec, x_symmetric, y_symmetric, downsample_shape=None)[source]#
Base class for off-axis PSF handling.
Handles YIP data loading, offset parsing, and symmetry detection.
OffJAXinherits from this class and overridescreate_psf/create_psfswith JAX-accelerated implementations.The pure-Python
create_psfandcreate_psfsmethods on this class are retained as a reference implementation but are not used in production. AllCoronagraphinstances now useOffJAXexclusively.This class loads and processes PSF data from the yield input package (YIP). It currently supports oneD and quarter symmetric PSF YIPs. The primary use is to interpolate the PSF data to a given x/y position. This is done by calling the OffAx object with the x/y position as arguments, which itself calls the psf object after converting units.
- Attributes:
- pixel_scale_arcsec (Quantity):
Pixel scale of the PSF data in lambda/D.
- center_x (Quantity):
Central x position in the PSF data.
- center_y (Quantity):
Central y position in the PSF data.
- psf:
Instance of the appropriate PSF class (e.g., OneD, TwoD) based on input YIP.
- Args:
- yip_dir (Path):
Path to the directory containing PSF and offset data.
- logger (Logger):
Logger for logging events and information.
- offax_data_file (str):
Name of the file containing the PSF data.
- offax_offsets_file (str):
Name of the file containing the offsets data.
- pixel_scale_arcsec (Quantity):
Pixel scale of the PSF data in lambda/D.
- Parameters:
- pixel_scale_arcsec#
- x_symmetric#
- y_symmetric#
- center_x#
- center_y#
- max_offset_in_image#
- flat_psfs = None#
- flat_offsets = None#
- n_psfs#
- x_inds#
- y_inds#
- offset_to_flat_idx#
- x_offsets#
- y_offsets#
- x_range#
- y_range#
- psf_shape#
- get_psf_by_offset_idx(x_idx, y_idx)[source]#
Get PSF at the given offset indices.
- Args:
- x_idx (int):
Index into x_offsets array.
- y_idx (int):
Index into y_offsets array.
- Returns:
- np.ndarray:
The PSF at the given offset indices, or None if no PSF exists at that combination.
- create_psf(x, y)[source]#
Create and return the PSF at the specified off-axis position.
Deprecated since version The: pure-Python implementation is deprecated. Use
Coronagraph(which usesOffJAX) instead.Interpolates and returns the Point Spread Function (PSF) at the specified off-axis position (x, y). If the exact (x, y) position matches one of the PSFs in the YIP, that PSF is returned directly. Otherwise, the PSFs from the surrounding positions are combined using Gaussian weighting and Fourier interpolation to produce an interpolated PSF.
- Args:
- x (float):
The x-coordinate of the off-axis position.
- y (float):
The y-coordinate of the off-axis position.
- Returns:
- np.ndarray:
The interpolated PSF corresponding to the input (x, y) position.
- Notes:
If self.type is “1d”, the (x, y) position is converted to a
radial separation and angle for interpolation. - If self.type is “2dq”, the (x, y) position is mirrored to the first quadrant, and the PSF is flipped accordingly after interpolation. - Gaussian weighting is used to combine the nearest PSFs when the exact (x, y) position does not match any precomputed PSF. The weighting is based on the distance from the input position. - The PSFs are shifted to align with the input position before combining, and the final PSF is normalized by the cumulative weight for each pixel.
- create_psfs(x, y)[source]#
Create and return the PSFs at the specified off-axis positions.
Deprecated since version The: pure-Python implementation is deprecated. Use
Coronagraph(which usesOffJAX) instead.- Parameters:
x (numpy.typing.NDArray)
y (numpy.typing.NDArray)
- Return type:
numpy.typing.NDArray
- create_psfs_parallel(x, y, lam=None, D=None, dist=None, workers=4)[source]#
Compute PSFs for batches of (x, y) arrays using multiprocessing.
Deprecated since version The: pure-Python implementation is deprecated. Use
Coronagraph(which usesOffJAX) instead.- Args:
- x (np.ndarray):
Array of x positions.
- y (np.ndarray):
Array of y positions.
- lam (astropy.units.Quantity):
Wavelength of the observation
- D (astropy.units.Quantity):
Diameter of the telescope
- dist (astropy.units.Quantity):
Distance to the system
- workers (int):
Number of parallel processes to use.
- Returns:
- np.ndarray:
A stacked numpy array of the computed PSFs with shape (N, height, width), where N = len(x).
- Parameters:
x (numpy.ndarray)
y (numpy.ndarray)
workers (int)
- Return type:
- __call__(x, y, lam=None, D=None, dist=None)[source]#
Return the PSF at the given x/y position.
This function (via util.convert_to_lod) has the following assumptions on the x/y values provided:
If units are pixels, they follow the 00LL convention. As in the (0,0) point is the lower left corner of the image.
If the x/y values are in lambda/D, angular, or length units the (0,0) point is the center of the image, where the star is (hopefully) located.
- Args:
- x (astropy.units.Quantity):
x position. Can be either units of pixel, lod, an angular unit (e.g. arcsec), or a length unit (e.g. AU)
- y (astropy.units.Quantity):
y position. Can be either units of pixel, lod, an angular unit (e.g. arcsec), or a length unit (e.g. AU)
- lam (astropy.units.Quantity):
Wavelength of the observation
- D (astropy.units.Quantity):
Diameter of the telescope
- dist (astropy.units.Quantity):
Distance to the system
- Returns:
- NDArray:
The PSF at the given x/y position
- Parameters:
x (astropy.units.Quantity)
y (astropy.units.Quantity)
- Return type:
numpy.typing.NDArray