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.

Parameters:
  • i (Array) – The first coordinate of the pixel in pixel units.

  • j (Array) – The second coordinate of the pixel in pixel units.

  • i0 (Array) – The i reference pixel coordinate in pixel units.

  • j0 (Array) – The j reference pixel coordinate in pixel units.

  • CD (Array) – The CD matrix in arcsec per pixel. This 2x2 matrix converts 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 containing the x and y coordinates in arcseconds

Return type:

tuple[Array, Array]

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.

Parameters:
  • x (Array) – The first coordinate of the pixel in arcsec.

  • y (Array) – The second coordinate of the pixel in arcsec.

  • i0 (Array) – The i reference pixel coordinate in pixel units.

  • j0 (Array) – The j reference pixel coordinate in pixel units.

  • CD (Array) – 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 containing the i and j pixel coordinates in pixel units.

Return type:

tuple[Array, Array]

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.

Parameters:
  • x (Array) – x coordinate in arcseconds.

  • y (Array) – y coordinate in arcseconds.

  • ra0 (Array) – Reference Right Ascension in degrees.

  • dec0 (Array) – Reference Declination in degrees.

  • s (float) – Small constant to avoid division by zero.

Returns:

Tuple containing ra and dec in degrees.

Return type:

tuple[Array, Array]

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.

Parameters:
  • ra (Array) – Right Ascension in degrees.

  • dec (Array) – Declination in degrees.

  • ra0 (Array) – Reference Right Ascension in degrees.

  • dec0 (Array) – Reference Declination in degrees.

Returns:

Tuple containing x and y coordinates in arcseconds.

Return type:

tuple[Array, Array]

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.

Parameters:
  • i (Array) – The first coordinate of the pixel in pixel units.

  • j (Array) – The second coordinate of the pixel in pixel units.

  • i0 (Array) – The i reference pixel coordinate in pixel units.

  • j0 (Array) – The j reference pixel coordinate in pixel units.

  • CD (Array) – The CD matrix in arcsec per pixel. This 2x2 matrix converts 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 containing the x and y coordinates in arcseconds

Return type:

tuple[Array, Array]

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.

Parameters:
  • x (Array) – The first coordinate of the pixel in arcsec.

  • y (Array) – The second coordinate of the pixel in arcsec.

  • i0 (Array) – The i reference pixel coordinate in pixel units.

  • j0 (Array) – The j reference pixel coordinate in pixel units.

  • CD (Array) – 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 containing the i and j pixel coordinates in pixel units.

Return type:

tuple[Array, Array]

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.

Parameters:
  • x (Array) – x coordinate in arcseconds.

  • y (Array) – y coordinate in arcseconds.

  • ra0 (Array) – Reference Right Ascension in degrees.

  • dec0 (Array) – Reference Declination in degrees.

  • s (float) – Small constant to avoid division by zero.

Returns:

Tuple containing ra and dec in degrees.

Return type:

tuple[Array, Array]

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.

Parameters:
  • ra (Array) – Right Ascension in degrees.

  • dec (Array) – Declination in degrees.

  • ra0 (Array) – Reference Right Ascension in degrees.

  • dec0 (Array) – Reference Declination in degrees.

Returns:

Tuple containing x and y coordinates in arcseconds.

Return type:

tuple[Array, Array]