Skymap

class erwans3.Astro_tools.Skymap(map: ~typing.Union[~erwans3.Astro_tools.PixList, ~erwans3.Astro_tools.SHCoeff, ~astropy.units.quantity.Quantity], frame: ~astropy.coordinates.baseframe.BaseCoordinateFrame = <ICRS Frame>, time: ~typing.Optional[~astropy.time.core.Time] = None, freq: ~typing.Optional[~astropy.units.quantity.Quantity] = None, spectral_index: ~typing.Optional[~typing.Union[float, ~erwans3.Astro_tools.PixList, ~erwans3.Astro_tools.SHCoeff]] = None, spectral_range_validity: ~typing.Optional[tuple[astropy.units.quantity.Quantity, astropy.units.quantity.Quantity]] = None, polar: str = 'I')

Bases: object

Represents a map of the sky with contextual information such as time, frequency, polarization, and frame.

A spectral index can be associated as well (either as a scalar or as a map)

Parameters:
  • map (PixList or SHCoeff or Quantity) – The map data represented as a PixList subclass or SHCoeff. If map is a Quantity, it is assumed to be a HEALPix map.

  • frame (BaseCoordinateFrame, optional) – The coordinate frame associated with the map. Defaults to ICRS.

  • time (Time or None, optional) – The time associated with the map. Defaults to None.

  • freq (Quantity [Hz], None, optional) – The frequency associated with the map. Defaults to None.

  • spectral_index (float or PixList or SHCoeff or None, optional) – The spectral index associated with the map. Defaults to None.

  • spectral_range_validity (tuple [Quantity [Hz], Quantity [Hz]], optional) – The validity range of the spectral index. Defaults to (0, inf).

  • polar (str, optional) – The polarization information. Defaults to ‘I’.

map

The map data in PixList, SHCoeff, or HpxMap format.

Type:

PixList or SHCoeff

frame

The coordinate frame associated with the map.

Type:

BaseCoordinateFrame

time

The time associated with the map.

Type:

Time

freq

The frequency associated with the map.

Type:

Quantity [Hz]

spectral_index

The spectral index associated with the map.

Type:

float or PixList or SHCoeff or None

spectral_range_validity

The validity range of the spectral index.

Type:

tuple [Quantity [Hz], Quantity [Hz]]

polar

The polarization information.

Type:

str

Notes

  • If the input map is already a Skymap instance, the new instance will be a copy of that Skymap.

  • If frame is not provided, it defaults to the ICRS coordinate frame.

  • If time is not provided but can be inferred from frame.obstime, it is automatically set.

  • The spectral_index can be a scalar value, a PixList, SHCoeff, or HpxMap depending on the map type.

  • The spectral_range_validity tuple defines the validity range for the spectral index.

  • The default polarization mode is ‘I’ (total intensity).

Attributes Summary

map_style

Return the type of map data (SHCoeff or Pixmap).

simu_type

Return the simulation type based on the map style.

unit

Return the unit of the skymap data.

Methods Summary

b2t([copy, rj])

Convert brightness to temperature using the associated frequency of the skymap.

change_freq(new_freq[, copy])

Change the frequency of the Skymap by applying a power law with the provided spectral index.

change_map_style(new_class[, copy])

Change the class of the stored map and spectral index.

get_skymap([freq, frame, simu])

Return a new Skymap object with the desired frequency, frame, and map style.

match_other(other)

Compares this Skymap object with another Skymap and returns a tuple of boolean values indicating which criteria match between the two Skymap objects.

plot(**kwargs)

Plot the skymap using the plot method of the underlying map object.

t2b([copy, rj])

Convert temperature to brightness per steradian using the associated frequency of the skymap.

to_extensive([copy])

Convert the skymap to an extensive representation.

to_intensive([copy])

Convert the skymap to an intensive representation.

transform_to(new_frame[, copy])

Change Frame / Orientation (equivalent to rotate for maps)

ud_grade(nside_out[, copy])

Upgrade or downgrade the resolution of the skymap to the specified nside value.

Attributes Documentation

map_style

Return the type of map data (SHCoeff or Pixmap).

Returns:

The type of map data.

Return type:

type

simu_type

Return the simulation type based on the map style.

Returns:

The simulation type, either ‘SH’ for SHCoeff or ‘pixmap’ for Pixmap.

Return type:

str

unit

Return the unit of the skymap data.

Returns:

The unit of the skymap data.

Return type:

UnitBase

Methods Documentation

b2t(copy: bool = True, rj: bool = False) Skymap

Convert brightness to temperature using the associated frequency of the skymap.

If Rayleigh-Jeans is assumed, the spectral index is changed as well. otherwise, the returned skymap will not have a spectral index

Parameters:
  • copy (bool, optional) – If True, return a new Skymap object with brightness converted to temperature. If False, modify the current Skymap object in place. Default is True.

  • rj (bool, optional) – If True, assume Rayleigh-Jeans approximation (spectral index is changed accordingly). If False, the returned Skymap will not have a spectral index. Default is False.

Returns:

If copy is True, returns a new Skymap object with brightness converted to temperature. If copy is False, modifies in place.

Return type:

Skymap

change_freq(new_freq: Quantity, copy: bool = True) Skymap

Change the frequency of the Skymap by applying a power law with the provided spectral index.

Parameters:
  • new_freq (Quantity [Hz]) – The new frequency to change to, specified with appropriate units.

  • copy (bool, optional) – If True, returns a new Skymap with the frequency changed. If False, modifies the existing Skymap in place.

Returns:

If copy is True, returns a new Skymap object with the updated frequency. If copy is False, modifies and returns the existing Skymap object with the updated frequency.

Return type:

Skymap

Raises:

ValueError – If the new frequency is outside the specified spectral range validity.

Notes

  • If no spectral index is provided, nothing changes in the Skymap.

  • Upcoming: handle spectra function map

change_map_style(new_class: type, copy: bool = True, **kwargs) Skymap

Change the class of the stored map and spectral index.

Parameters:
  • new_class (type) – The new class type to convert the map and spectral index to.

  • copy (bool, optional) – If True, returns a copy of the Skymap with the updated map style. If False, modifies the current Skymap in place.

  • **kwargs – Additional keyword arguments to pass to the conversion function.

Returns:

A new Skymap object with the updated map and spectral index classes if copy=True. Otherwise, modifies and returns the current Skymap in place.

Return type:

Skymap

Notes

  • The method uses the change_map_style() function internally to convert the map and spectral index.

  • The is_map() function is used to check if the spectral index is a valid map.

get_skymap(freq: Optional[Quantity] = None, frame: Optional[Union[BaseCoordinateFrame, SkyCoord]] = None, simu: bool = True) Skymap

Return a new Skymap object with the desired frequency, frame, and map style.

Parameters:
  • freq (Quantity [Hz] or None, optional) – The desired frequency for the Skymap. If None, the frequency remains unchanged.

  • frame (BaseCoordinateFrame or SkyCoord None, optional) – The desired frame or observer for the Skymap. If None, the frame remains unchanged.

  • simu (bool, optional) – Whether to simulate the Skymap with the desired map style based on the simu_type attribute.

Returns:

A new Skymap object with the specified frequency, frame, and map style.

Return type:

Skymap

Notes

  • If freq or frame is specified, the returned Skymap will have the updated frequency or frame.

  • If simu is True, the returned Skymap will be simulated with the desired map style based on simu_type.

match_other(other: Skymap) tuple[bool]

Compares this Skymap object with another Skymap and returns a tuple of boolean values indicating which criteria match between the two Skymap objects.

return a list of boolean saying which criteria matches between 2 Skymap object

Parameters:

other (Skymap) – Another Skymap object to compare with.

Returns:

:obj:`~tuple` [ – A tuple of boolean values indicating the matching criteria: - Unit compatibility. - Time information. - Polarization information. - Frequency information. - Map style compatibility (PixList, SHCoeff).

Return type:

obj`~:bool`]

Notes

  • unit_bool: True if the physical unit types of the two Skymaps match, False otherwise.

  • time_bool: True if both Skymaps have valid time information and it matches, False otherwise.

  • freq_bool: True if both Skymaps have valid frequency information and it matches, False otherwise.

  • polar_bool: True if the polarization information of both Skymaps matches, False otherwise.

  • mapstyle_bool: True if the map style (PixList, SHCoeff) matches between the two Skymaps, False otherwise.

  • tot_bool: A tuple containing all individual boolean criteria.

plot(**kwargs)

Plot the skymap using the plot method of the underlying map object.

Parameters:

**kwargs – Additional keyword arguments to pass to the underlying map’s plot method.

Notes

  • This method forwards the plotting to the plot method of the underlying map object.

t2b(copy: bool = True, rj: bool = False) Skymap

Convert temperature to brightness per steradian using the associated frequency of the skymap.

If Rayleigh-Jeans is assumed, the spectral index is changed as well. otherwise, the returned skymap will not have a spectral index

Parameters:
  • copy (bool, optional) – If True, return a new Skymap object with temperature converted to brightness. If False, modify the current Skymap object in place. Default is True.

  • rj (bool, optional) – If True, assume Rayleigh-Jeans approximation (spectral index is changed accordingly). If False, the returned Skymap will not have a spectral index. Default is False.

Returns:

If copy is True, returns a new Skymap object with temperature converted to brightness. If copy is False, modifies in place.

Return type:

Skymap

to_extensive(copy: bool = True) Skymap

Convert the skymap to an extensive representation.

Parameters:

copy (bool, optional) – If True, return a new Skymap object with an extensive representation of the map. If False, modify the current Skymap object in place. Default is True.

Returns:

If copy is True, returns a new Skymap object with an extensive representation of the map. If copy is False, modifies in place.

Return type:

Skymap

to_intensive(copy: bool = True) Skymap

Convert the skymap to an intensive representation.

Parameters:

copy (bool, optional) – If True, return a new Skymap object with an intensive representation of the map. If False, modify the current Skymap object in place. Default is True.

Returns:

If copy is True, returns a new Skymap object with an intensive representation of the map. If copy is False, modifies in place.

Return type:

Skymap

transform_to(new_frame: BaseCoordinateFrame, copy: bool = True) Skymap

Change Frame / Orientation (equivalent to rotate for maps)

Parameters:
  • new_frame (BaseCoordinateFrame) – The new coordinate frame to transform the Skymap to.

  • copy (bool, optional) – If True, returns a new Skymap object with the transformation applied (default is True).

Returns:

If copy is True, returns a new Skymap object with the transformation applied. If copy is False, modifies the existing Skymap object in place and returns it.

Return type:

Skymap

Notes

  • If new_frame is a callable, it will be called to generate a new frame. If the new frame has a different obstime than the Skymap’s time, a new frame with the same attributes as the new frame but with the Skymap’s time will be created.

  • The rotation to transform the Skymap is determined by the composition of transformation matrices between the current frame and the new frame (comp_matrix_transfo() function is used).

  • The spectral_index attribute, if present and a map, will also be rotated along with the Skymap.

ud_grade(nside_out: int, copy: bool = True) Skymap

Upgrade or downgrade the resolution of the skymap to the specified nside value.

Can only be used with Healpix maps (HpxMap, HpxPart)

Parameters:
  • nside_out (int) – The target nside value for the skymap.

  • copy (bool, optional) – If True, return a new Skymap object with the resolution changed. If False, modify the current Skymap object in place. Default is True.

Returns:

If copy is True, returns a new Skymap object with the resolution changed. If copy is False, returns None.

Return type:

Skymap

Notes

  • For maps of class HpxMap or HpxPart, this method will change the resolution to nside_out.

  • If the spectral index is also a map (HpxMap or HpxPart), its resolution will also be changed.

  • If the map class does not support resolution changes, a TypeError will be raised.