units#

Methods related to using units and quantities from astropy.units.

class hsr4hci.units.InstrumentUnitsContext[source]#

Context manager that allows to provide local, instrument-specific values for the pixscale and lambda_over_d to the registry of astropy.units.

In order to convert between pixels and arcseconds, one has to define a pixel scale; this value, however, is instrument-specific. Similarly, the value of \(\lambda / D\) obviously depends both on the wavelength \(\lambda\) of the observation and the diameter \(D\) of the primary mirror.

If we want to use \(\lambda / D\) as a unit (as it is a characteristic scale, e.g., for the PSF size), we need to define its value in terms of other units somewhere. This class provides a context manager that is initialized with values for the pixel scale and \(\lambda / D\), and it then provides a (re-usable!) context inside of which an astropy.units.Quantity can be converted freely between units of pixels, arc seconds and \(\lambda / D\).

Parameters:
  • pixscale โ€“

    An astropy.units.Quantity with units arcsec / pixel that defines the pixel scale.

    Example

    For VLT/NACO, the pixscale is typically: PIXSCALE = 0.0271 arcsec / pixel.

  • lambda_over_d โ€“

    An astropy.units.Quantity with units arc seconds that defines the ratio between the wavelength \(\lambda\) of the observation and \(D\), the diameter of the primary mirror.

    Example

    For Lโ€™-band data (\(\lambda\) = 3800 nm) at the VLT (\(D\) = 8.2 m), this value is: lambda_over_d = 0.0956 arcsec.

__init__(pixscale, lambda_over_d)[source]#
Parameters:
Return type:

None

hsr4hci.units.flux_ratio_to_magnitudes(flux_ratio)[source]#

Convert a given flux ratio to magnitudes.

Example

>>> flux_ratio_to_magnitudes(1e-5)
12.5
Parameters:

flux_ratio (Union[float, ndarray]) โ€“ The brightness (or contrast) as a flux ratio; either as a single float or as a numpy array of floats.

Returns:

The brightness (or contrast) in magnitudes.

Return type:

Union[float, ndarray]

hsr4hci.units.magnitude_to_flux_ratio(magnitudes)[source]#

Convert magnitudes to a flux ratio.

Example

>>> magnitude_to_flux_ratio(5)
0.01
Parameters:

magnitudes (Union[float, ndarray]) โ€“ The brightness (or contrast) in magnitudes; either as a single float or as a numpy array of floats.

Returns:

The brightness (or contrast) as a flux ratio.

Return type:

Union[float, ndarray]