res2nside

erwans3.utils.res2nside(res: Any, degree: bool = False, method: str = 'up_bound') int

Returns the HEALPix Nside corresponding to a given resolution

method: The method to determine the nside value:
  • ‘up_bound’ (default): Calculate nside such that pixels are smaller than the given resolution.

  • ‘round’: Calculate nside and round to the nearest power of 2.

  • ‘down_bound’: Calculate nside such that pixels are larger than the given resolution.

Parameters:
  • res (Quantity or float or int) – The resolution parameter. If given as a Quantity, it should be in angular units. Otherwise, it is assumed to be in radians if degree is False, otherwise in degrees.

  • degree (bool, optional) – If True, res is interpreted as being in degrees. Default is False.

  • method ({'up_bound', 'round', 'down_bound'}, optional) – The method to use for rounding the calculated nside. Default is ‘up_bound’.

Returns:

The corresponding HEALPix nside value.

Return type:

int

Raises:

TypeError – If an invalid method is specified. Valid methods are ‘up_bound’, ‘round’, or ‘down_bound’.

Note

  • Healpix is a pixelization scheme used in astronomy to create maps of the sky with equal-area pixels.

  • The nside parameter determines the resolution of the map, with higher values providing finer resolution.

Example

>>> res = 1.0*u.rad
>>> nside = res2nside(res)
>>> print(nside)
512