coords

coords.find_min_rectangle_xy(vertices_rotated)

Find the minimum axis-aligned rectangle in the X-Y plane that contains all projected vertices.

Parameters:

vertices_rotated – A (8, 3) array of the rotated vertices.

Returns:

  • min_x,max_x,min_y,max_y

Return type:

tuple

coords.get_extragalactic_positions(npix: int, theta, phi, x_length: float = 20, y_length: float = 20, z_length: float = 5, num_int_points: int = 512)[source]

Calculate the integration points along each line of sight for a HEALPix map with given nside, from the location of the observer to the box boundary. A HEALPix map with a given nside should contains npix = 12*nside**2 pixels.

Parameters:
  • npix (int) – number of pixels along a axis of the desired rectagular observed map.

  • theta – In unit of radian. degrees around Z-axis

  • phi – In unit of radian. degrees around Y-axis

  • x_length (float) – In unit of kpc. half of the box length along x-axis.

  • y_length (float) – In unit of kpc. half of the box length along y-axis.

  • z_length (float) – In unit of kpc. half of the box length along z-axis.

  • num_int_points (int) – the number of integration points along one LoS.

Returns:

  • poss (jnp.Array): In unit of kpc. 3D array of shape (npix, num_int_points, 3), coordinates of integration points along all sightlines of a HEALPix map.

  • dls (jnp.Array): In unit of kpc. 1D array of shape (npix), length of integration segment for all sightlines.

  • nhats (jnp.Array): In unit of rad. 2D array of shape (npix,3), unit vector of LoS for all pixels.

  • mask (bool): whether this sightline in the rectagular observed map intersects with the box. If not, leave as 0.

  • resolution (float): the resolution of the rectagular observed map

Return type:

tuple

coords.get_healpix_positions(nside=64, obs_coord: tuple[float] = (-8.3, 0.0, 0.006), x_length: float = 20, y_length: float = 20, z_length: float = 5, num_int_points: int = 512, epsilon: float = 1e-07)[source]

Calculate the integration points along each line of sight for a HEALPix map with given nside, from the location of the observer to the box boundary. A HEALPix map with a given nside should contains npix = 12*nside**2 pixels.

Parameters:
  • nside (int) – NSIDE of the HEALPix map.

  • obs_coord (tuple[float]) – In unit of kpc. the location of observer.

  • x_length (float) – In unit of kpc. half of the box length along x-axis.

  • y_length (float) – In unit of kpc. half of the box length along y-axis.

  • z_length (float) – In unit of kpc. half of the box length along z-axis.

  • num_int_points (int) – the number of integration points along one LoS.

Returns:

  • poss (jnp.Array): In unit of kpc. 3D array of shape (npix, num_int_points, 3), coordinates of integration points along all sightlines of a HEALPix map.

  • dls (jnp.Array): In unit of kpc. 1D array of shape (npix), length of integration segment for all sightlines.

  • nhats (jnp.Array): In unit of rad. 2D array of shape (npix,3), unit vector of LoS for all pixels.

Return type:

tuple

coords.get_rotated_box_vertices(x, y, z, theta, phi)[source]

Calculate the coordinates of the vertices of a rectangular box after rotation.

Parameters:
  • x – Half dimensions of the box along the X, Y, and Z axes. e.g. (-x,x) is the boundary of the box in x-axis

  • y – Half dimensions of the box along the X, Y, and Z axes. e.g. (-x,x) is the boundary of the box in x-axis

  • z – Half dimensions of the box along the X, Y, and Z axes. e.g. (-x,x) is the boundary of the box in x-axis

  • theta – Rotation angle around the Z-axis (in radians).

  • phi – Rotation angle around the Y-axis (in radians).

Returns:

A (8, 3) array of the rotated vertices.

Return type:

  • vertices_rotated

coords.obtain_positions(theta, phi, obs_coord: tuple[float] = (-8.3, 0.0, 0.006), x_length: float = 20, y_length: float = 20, z_length: float = 5, num_int_points: int = 512, epsilon: float = 1e-07)

Calculate the integration points along one line of sight, from the location of the observer to the box boundary

Parameters:
  • theta (float) – In unit of rad. The galactic longitude.

  • phi (float) – In unit of rad. The galactic co-lattitude. These values can be automatically generate by healpy.pix2ang with lonlat = False.

  • obs_coord (tuple[float]) – In unit of kpc. the location of observer.

  • x_length (float) – In unit of kpc. half of the box length along x-axis.

  • y_length (float) – In unit of kpc. half of the box length along y-axis.

  • z_length (float) – In unit of kpc. half of the box length along z-axis.

  • num_int_points (int) – the number of integration points along one LoS.

Returns:

  • pos (jnp.Array): In unit of kpc. 2D array of shape (num_int_points,3), coordinates of integration points along one sightline specified by (theta,phi).

  • dl (jnp.float): In unit of kpc. length of each integration segment.

  • nhat (jnp.Array): In unit of rad. 1D array of shape (3), unit vector of this LoS.

Return type:

tuple

coords.obtain_positions_hammurabi(theta, phi, obs_coord: tuple[float] = (-8.3, 0.0, 0.006), x_length: float = 4, y_length: float = 4, z_length: float = 4, num_int_points: int = 256, epsilon: float = 1e-07)

Calculate the integration points along one line of sight in hammurabi way. Unlike integrate to the box boundary, now we integrate to a certain distance (x_length,y_length,z_length) way from observer.

Parameters:
  • theta (float) – In unit of rad. The galactic longitude.

  • phi (float) – In unit of rad. The galactic co-lattitude. These values can be automatically generate by healpy.pix2ang with lonlat = False.

  • obs_coord (tuple[float]) – In unit of kpc. the location of observer.

  • x_length (float) – In unit of kpc. integration length along x-axis.

  • y_length (float) – In unit of kpc. integration length along y-axis.

  • z_length (float) – In unit of kpc. integration length along z-axis.

  • num_int_points (int) – the number of integration points along one LoS.

Returns:

  • pos (jnp.Array): In unit of kpc. 2D array of shape (num_int_points,3), coordinates of integration points along one sightline specified by (theta,phi).

  • dl (jnp.float): In unit of kpc. length of each integration segment.

  • nhat (jnp.Array): In unit of rad. 1D array of shape (3), unit vector of this LoS.

Return type:

tuple

coords.transform_points_back(points, theta, phi)[source]

Transform the array of points back to the original coordinate system.

Parameters:
  • points – array of shape (…, 3), where … can be any number of dimensions

  • theta – rotation angle around the Z-axis (in radians)

  • phi – rotation angle around the Y-axis (in radians)

Returns:

  • points_original: array of same shape as ‘points’, points in the original coordinate system

Return type:

Array

coords.vertical_line_intersects_box(vertices_rotated, x0, y0)[source]

Determines whether the vertical line at (x0, y0) intersects the rotated box.

Parameters:
  • vertices_rotated – A (8, 3) array of the rotated vertices.

  • x0 – Coordinates of the point(s) in the XY plane. Can be scalars or arrays.

  • y0 – Coordinates of the point(s) in the XY plane. Can be scalars or arrays.

Returns:

  • intersects: Boolean array indicating whether each line intersects the box.

  • min_z: Array of minimum Z-values where the line intersects the box.

  • max_z: Array of maximum Z-values where the line intersects the box.

Return type:

tuple

coords.vertical_line_intersects_box_vamp(vertices_rotated, x0, y0)

Determines whether the vertical line at (x0, y0) intersects the rotated box.

Parameters:
  • vertices_rotated – A (8, 3) array of the rotated vertices.

  • x0 – Coordinates of the point(s) in the XY plane. Can be scalars or arrays.

  • y0 – Coordinates of the point(s) in the XY plane. Can be scalars or arrays.

Returns:

  • intersects: Boolean array indicating whether each line intersects the box.

  • min_z: Array of minimum Z-values where the line intersects the box.

  • max_z: Array of maximum Z-values where the line intersects the box.

Return type:

tuple