astrophot.utils package#

Subpackages#

Submodules#

astrophot.utils.decorators module#

class astrophot.utils.decorators.classproperty(fget)[source]#

Bases: object

astrophot.utils.decorators.combine_docstrings(cls)[source]#
astrophot.utils.decorators.ignore_numpy_warnings(func)[source]#

This decorator is used to turn off numpy warnings. This should only be used in initialize scripts which often run heuristic code to determine initial parameter values. These heuristics may encounter log(0) or sqrt(-1) or other numerical artifacts and should handle them before returning. This decorator simply cleans up that processes to minimize clutter in the output.

astrophot.utils.fitsopen module#

astrophot.utils.fitsopen.flip_hdu(hdu)[source]#

Flips the image data in the FITS HDU on the RA axis to match the expected orientation.

Args:

hdu (astropy.io.fits.HDUList): The FITS HDU to be flipped.

Returns:

astropy.io.fits.HDUList: The flipped FITS HDU.

astrophot.utils.fitsopen.ls_open(ra, dec, size_arcsec, band='r', release='ls_dr9')[source]#

Retrieves and opens a FITS cutout from the deepest stacked image in the specified Legacy Survey data release using the Astro Data Lab SIA service.

Args:

ra (float): Right Ascension in decimal degrees. dec (float): Declination in decimal degrees. size_arcsec (float): Size of the square cutout (side length) in arcseconds. band (str): The filter band (e.g., ‘g’, ‘r’, ‘z’). Case-insensitive. release (str): The Legacy Survey Data Release (e.g., ‘DR9’).

Returns:

astropy.io.fits.HDUList: The opened FITS file object.

astrophot.utils.integration module#

astrophot.utils.integration.quad_table(order, dtype, device)[source]#

Generate a meshgrid for quadrature points using Legendre-Gauss quadrature.

Parameters#

nint

The number of quadrature points in each dimension.

dtypetorch.dtype

The desired data type of the tensor.

devicetorch.device

The device on which to create the tensor.

Returns#

Tuple[torch.Tensor, torch.Tensor, torch.Tensor]

The generated meshgrid as a tuple of Tensors.

astrophot.utils.interpolate module#

astrophot.utils.interpolate.default_prof(shape: tuple[int, int], pixelscale: float, min_pixels: int = 2, scale: float = 0.2) ndarray[source]#
astrophot.utils.interpolate.interp2d(im: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], i: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], j: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], padding_mode: str = 'zeros') Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'][source]#

Interpolates a 2D image at specified coordinates. Similar to torch.nn.functional.grid_sample with align_corners=False.

Args:

im (Tensor): A 2D tensor representing the image. i (Tensor): A tensor of i coordinates (in pixel space) at which to interpolate. j (Tensor): A tensor of j coordinates (in pixel space) at which to interpolate.

Returns:

Tensor: Tensor with the same shape as i and j containing the interpolated values.

astrophot.utils.parametric_profiles module#

astrophot.utils.parametric_profiles.exponential_np(R: ndarray, Ie: ndarray, Re: ndarray) ndarray[source]#

Exponential 1d profile function, works more generally with numpy operations.

Args: - R: Radii array at which to evaluate the exponential function - Ie: Effective surface density - Re: Effective radius in the same units as R

astrophot.utils.parametric_profiles.ferrer_np(R: ndarray, rout: ndarray, alpha: ndarray, beta: ndarray, I0: ndarray) ndarray[source]#

Modified Ferrer profile.

Args: - R: Radial distance from the center. - rout: Outer radius of the profile. - alpha: Power-law index. - beta: Exponent for the modified Ferrer function. - I0: Central intensity.

astrophot.utils.parametric_profiles.gaussian_np(R: ndarray, sigma: ndarray, I0: ndarray) ndarray[source]#

Gaussian 1d profile function, works more generally with numpy operations.

Args: - R: Radii array at which to evaluate the gaussian function - sigma: standard deviation of the gaussian in the same units as R - I0: central surface density

astrophot.utils.parametric_profiles.king_np(R: ndarray, Rc: ndarray, Rt: ndarray, alpha: ndarray, I0: ndarray) ndarray[source]#

Empirical King profile.

Args: - R: The radial distance from the center. - Rc: The core radius of the profile. - Rt: The truncation radius of the profile. - alpha: The power-law index of the profile. - I0: The central intensity of the profile.

astrophot.utils.parametric_profiles.moffat_np(R: ndarray, n: ndarray, Rd: ndarray, I0: ndarray) ndarray[source]#

Moffat 1d profile function, works with numpy operations.

Args: - R: Radii array at which to evaluate the moffat function - n: concentration index - Rd: scale length in the same units as R - I0: central surface density

astrophot.utils.parametric_profiles.nuker_np(R: ndarray, Rb: ndarray, Ib: ndarray, alpha: ndarray, beta: ndarray, gamma: ndarray) ndarray[source]#

Nuker 1d profile function, works with numpy functions

Args: - R: Radii tensor at which to evaluate the nuker function - Ib: brightness at the scale length, represented as the log of the brightness divided by pixel scale squared. - Rb: scale length radius - alpha: sharpness of transition between power law slopes - beta: outer power law slope - gamma: inner power law slope

astrophot.utils.parametric_profiles.sersic_np(R: ndarray, n: ndarray, Re: ndarray, Ie: ndarray) ndarray[source]#

Sersic 1d profile function, works more generally with numpy operations. In the event that impossible values are passed to the function it returns large values to guide optimizers away from such values.

Args: - R: Radii array at which to evaluate the sersic function - n: sersic index restricted to n > 0.36 - Re: Effective radius in the same units as R - Ie: Effective surface density

Module contents#

astrophot.utils.ls_open(ra, dec, size_arcsec, band='r', release='ls_dr9')[source]#

Retrieves and opens a FITS cutout from the deepest stacked image in the specified Legacy Survey data release using the Astro Data Lab SIA service.

Args:

ra (float): Right Ascension in decimal degrees. dec (float): Declination in decimal degrees. size_arcsec (float): Size of the square cutout (side length) in arcseconds. band (str): The filter band (e.g., ‘g’, ‘r’, ‘z’). Case-insensitive. release (str): The Legacy Survey Data Release (e.g., ‘DR9’).

Returns:

astropy.io.fits.HDUList: The opened FITS file object.