pyimcom.utils.piffutils

Utilities for interacting with Piff files.

Attributes

HAS_PIFF

Functions

piff_to_legendre(psf_file, sca[, stamp_size, ...])

Convert a PSF file from piff to a Legendre polynomial expansion.

piff_to_legendre_multi(psf_file, out_file, format[, ...])

Convert a PSF file from piff to a Legendre polynomial expansion and save as a PyIMCOM

Module Contents

HAS_PIFF = True[source]
piff_to_legendre(psf_file, sca, stamp_size=128, oversamp=6, legendre_order=5, normbox=None, write_coeffs=False, coeffs_file=None)[source]

Convert a PSF file from piff to a Legendre polynomial expansion.

Parameters:
  • psf_file (str) – The path to the PSF file.

  • sca (int) – The sca number at which to draw the PSF (range: 1 to 18, inclusive).

  • stamp_size (int, optional) – The size of the PSF stamp. Default is 128.

  • oversamp (int, optional) – The oversampling factor for the PSF stamp. Default is 6.

  • legendre_order (int, optional) – Polynomial order for Legendre polynomial expansion. Default is 5.

  • normbox (int, optional) – If given, normalizes the PSF to integrate to 1 in the specified box size (which may be different from the region size used in Piff; we envision it will be larger if the PSF has far wings that are not re-fit by Piff, e.g., from a physical model or fit to scattered light in stacked bright stars, etc.).

  • write_coeffs (bool, optional) – Whether to write the coefficients to a file. Default is False.

  • coeffs_file (str, optional) – The path to the FITS file where the coefficients will be saved. Required if write_coeffs is True. Will overwrite the file if it already exists.

Returns:

coeffs – The coefficients of the Legendre polynomial expansion.

Return type:

np.ndarray of shape ((legendre order + 1)**2, stamp_size*oversamp, stamp_size*oversamp)

piff_to_legendre_multi(psf_file, out_file, format, chips=None, stamp_size=128, oversamp=6, legendre_order=5, normbox=None)[source]

Convert a PSF file from piff to a Legendre polynomial expansion and save as a PyIMCOM PSF input file.

Parameters:
  • psf_file (str) – The path to the PSF file.

  • out_file (str) – The path to the FITS file where the coefficients will be saved. Will overwrite the file if it already exists.

  • format (str) – The PSF file format; currently only "L2_2506" is an option.

  • chips (list of int, optional) – The sca/chip numbers at which to draw the PSF; default is all.

  • stamp_size (int, optional) – The size of the PSF stamp. Default is 128.

  • oversamp (int, optional) – The oversampling factor for the PSF stamp. Default is 6.

  • legendre_order (int, optional) – Polynomial order for Legendre polynomial expansion. Default is 5.

  • normbox (int, optional) – If given, normalizes the PSF to integrate to 1 in the specified box size (which may be different from the region size used in Piff; we envision it will be larger if the PSF has far wings that are not re-fit by Piff, e.g., from a physical model or fit to scattered light in stacked bright stars, etc.).

Return type:

None