astrophot.image.func package#

Submodules#

astrophot.image.func.image module#

astrophot.image.func.image.cmos_pixel_center_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, loc: tuple[float, float], dtype, device) tuple[source]#
astrophot.image.func.image.pixel_center_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype: type, device: str) tuple[source]#
astrophot.image.func.image.pixel_corner_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype, device) tuple[source]#
astrophot.image.func.image.pixel_quad_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype, device, order=3) tuple[source]#
astrophot.image.func.image.pixel_simpsons_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype, device) tuple[source]#
astrophot.image.func.image.rotate(theta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) tuple[source]#

Applies a rotation matrix to the X,Y coordinates

astrophot.image.func.wcs module#

astrophot.image.func.wcs.pixel_to_plane_linear(i, j, i0, j0, CD, x0=0.0, y0=0.0)[source]#

Convert pixel coordinates to a tangent plane using the WCS information. This matches the FITS convention for linear transformations.

Args: - i (Tensor): The first coordinate of the pixel in pixel units. - j (Tensor): The second coordinate of the pixel in pixel units. - i0 (Tensor): The i reference pixel coordinate in pixel units. - j0 (Tensor): The j reference pixel coordinate in pixel units. - CD (Tensor): The CD matrix in arcsec per pixel. This 2x2 matrix is used to convert

from pixel to arcsec units and also handles rotation/skew.

  • x0 (float): The x reference coordinate in arcseconds.

  • y0 (float): The y reference coordinate in arcseconds.

Returns: - Tuple[Tensor, Tensor]: Tuple containing the x and y coordinates in arcseconds

astrophot.image.func.wcs.plane_to_pixel_linear(x, y, i0, j0, CD, x0=0.0, y0=0.0)[source]#

Convert tangent plane coordinates to pixel coordinates using the WCS information. This matches the FITS convention for linear transformations.

Args: - x: (Tensor) The first coordinate of the pixel in arcsec. - y: (Tensor) The second coordinate of the pixel in arcsec. - i0: (Tensor) The i reference pixel coordinate in pixel units. - j0: (Tensor) The j reference pixel coordinate in pixel units. - CD: (Tensor) The CD matrix in arcsec per pixel. - x0: (float) The x reference coordinate in arcsec. - y0: (float) The y reference coordinate in arcsec.

Returns: - Tuple[Tensor, Tensor]: Tuple containing the i and j pixel coordinates in pixel units.

astrophot.image.func.wcs.plane_to_world_gnomonic(x, y, ra0, dec0, x0=0.0, y0=0.0, s=1e-10)[source]#

Convert plane coordinates (x, y) to world coordinates (RA, Dec) using the gnomonic projection.

Args: - x: (Tensor) x coordinate in arcseconds. - y: (Tensor) y coordinate in arcseconds. - ra0: (Tensor) Reference Right Ascension in degrees. - dec0: (Tensor) Reference Declination in degrees. - s: (float) Small constant to avoid division by zero.

Returns: - ra: (Tensor) Right Ascension in degrees. - dec: (Tensor) Declination in degrees.

astrophot.image.func.wcs.sip_backward_transform(u, v, U, V, A_ORDER, B_ORDER)[source]#

Credit: Shu Liu and Lei Hi, see here: Roman-Supernova-PIT/sfft

Compute the backward transformation from (U, V) to (u, v)

astrophot.image.func.wcs.sip_coefs(order)[source]#
astrophot.image.func.wcs.sip_delta(u, v, sipA=(), sipB=())[source]#

u = j - j0 v = i - i0 sipA = dict(tuple(int,int), float)

The SIP coefficients, where the keys are tuples of powers (i, j) and the values are the coefficients. For example, {(1, 2): 0.1} means delta_u = 0.1 * (u * v^2).

astrophot.image.func.wcs.sip_matrix(u, v, order)[source]#
astrophot.image.func.wcs.world_to_plane_gnomonic(ra, dec, ra0, dec0, x0=0.0, y0=0.0)[source]#

Convert world coordinates (RA, Dec) to plane coordinates (x, y) using the gnomonic projection.

Args: - ra: (torch.Tensor) Right Ascension in degrees. - dec: (torch.Tensor) Declination in degrees. - ra0: (torch.Tensor) Reference Right Ascension in degrees. - dec0: (torch.Tensor) Reference Declination in degrees.

Returns: - x: (torch.Tensor) x coordinate in arcseconds. - y: (torch.Tensor) y coordinate in arcseconds.

Module contents#

astrophot.image.func.cmos_pixel_center_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, loc: tuple[float, float], dtype, device) tuple[source]#
astrophot.image.func.pixel_center_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype: type, device: str) tuple[source]#
astrophot.image.func.pixel_corner_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype, device) tuple[source]#
astrophot.image.func.pixel_quad_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype, device, order=3) tuple[source]#
astrophot.image.func.pixel_simpsons_meshgrid(extent: tuple[int, int, int, int], pad: int, upsample: int, dtype, device) tuple[source]#
astrophot.image.func.pixel_to_plane_linear(i, j, i0, j0, CD, x0=0.0, y0=0.0)[source]#

Convert pixel coordinates to a tangent plane using the WCS information. This matches the FITS convention for linear transformations.

Args: - i (Tensor): The first coordinate of the pixel in pixel units. - j (Tensor): The second coordinate of the pixel in pixel units. - i0 (Tensor): The i reference pixel coordinate in pixel units. - j0 (Tensor): The j reference pixel coordinate in pixel units. - CD (Tensor): The CD matrix in arcsec per pixel. This 2x2 matrix is used to convert

from pixel to arcsec units and also handles rotation/skew.

  • x0 (float): The x reference coordinate in arcseconds.

  • y0 (float): The y reference coordinate in arcseconds.

Returns: - Tuple[Tensor, Tensor]: Tuple containing the x and y coordinates in arcseconds

astrophot.image.func.plane_to_pixel_linear(x, y, i0, j0, CD, x0=0.0, y0=0.0)[source]#

Convert tangent plane coordinates to pixel coordinates using the WCS information. This matches the FITS convention for linear transformations.

Args: - x: (Tensor) The first coordinate of the pixel in arcsec. - y: (Tensor) The second coordinate of the pixel in arcsec. - i0: (Tensor) The i reference pixel coordinate in pixel units. - j0: (Tensor) The j reference pixel coordinate in pixel units. - CD: (Tensor) The CD matrix in arcsec per pixel. - x0: (float) The x reference coordinate in arcsec. - y0: (float) The y reference coordinate in arcsec.

Returns: - Tuple[Tensor, Tensor]: Tuple containing the i and j pixel coordinates in pixel units.

astrophot.image.func.plane_to_world_gnomonic(x, y, ra0, dec0, x0=0.0, y0=0.0, s=1e-10)[source]#

Convert plane coordinates (x, y) to world coordinates (RA, Dec) using the gnomonic projection.

Args: - x: (Tensor) x coordinate in arcseconds. - y: (Tensor) y coordinate in arcseconds. - ra0: (Tensor) Reference Right Ascension in degrees. - dec0: (Tensor) Reference Declination in degrees. - s: (float) Small constant to avoid division by zero.

Returns: - ra: (Tensor) Right Ascension in degrees. - dec: (Tensor) Declination in degrees.

astrophot.image.func.rotate(theta: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], x: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.'], y: Annotated[Tensor, 'One of: torch.Tensor or jax.numpy.ndarray depending on the chosen backend.']) tuple[source]#

Applies a rotation matrix to the X,Y coordinates

astrophot.image.func.sip_backward_transform(u, v, U, V, A_ORDER, B_ORDER)[source]#

Credit: Shu Liu and Lei Hi, see here: Roman-Supernova-PIT/sfft

Compute the backward transformation from (U, V) to (u, v)

astrophot.image.func.sip_coefs(order)[source]#
astrophot.image.func.sip_delta(u, v, sipA=(), sipB=())[source]#

u = j - j0 v = i - i0 sipA = dict(tuple(int,int), float)

The SIP coefficients, where the keys are tuples of powers (i, j) and the values are the coefficients. For example, {(1, 2): 0.1} means delta_u = 0.1 * (u * v^2).

astrophot.image.func.sip_matrix(u, v, order)[source]#
astrophot.image.func.world_to_plane_gnomonic(ra, dec, ra0, dec0, x0=0.0, y0=0.0)[source]#

Convert world coordinates (RA, Dec) to plane coordinates (x, y) using the gnomonic projection.

Args: - ra: (torch.Tensor) Right Ascension in degrees. - dec: (torch.Tensor) Declination in degrees. - ra0: (torch.Tensor) Reference Right Ascension in degrees. - dec0: (torch.Tensor) Reference Declination in degrees.

Returns: - x: (torch.Tensor) x coordinate in arcseconds. - y: (torch.Tensor) y coordinate in arcseconds.