cwitools.reduction.units.multiply_bunit

cwitools.reduction.units.multiply_bunit(bunit, multi='')

Unit conversions and multiplications.

Parameters:
  • bunit (str) – The BUNIT Header string, can be the following KCWI/PCWI defaults: ‘electrons’ or ‘variance’: non-flux calibrated units ‘FLAM’: meaning erg/s/cm2/angstrom ‘FLAM**2’: flux variance units ‘FLAMXX’: meaning 10^(-XX) erg/s/cm2/angstrom (e.g. FLAM16) ‘FLAMXX**2’: variance for the above units OR any unit string composed only of the units listed below for ‘mul_units’ and a coefficient. Format must be parseable by astropy.units.Unit()
  • multi (str) – The units to multiply the input units by, limited to the following: - a coefficient (e.g. ‘1e-16’) - ‘erg’ for energy - ‘s’ for time - ‘cm’ for area - ‘angstrom’ for wavelength - ‘arcsec’ for angular area Note: ‘A’ is not ‘Angstrom for astropy.units, so use ‘angstrom’ instead.
Returns:

The updated BUNIT string

Return type:

str

Example

To convert the default flux units of a KCWI cube (FLAM16) to erg/s/cm2/arcsec2:

>>> bunit_flam16 = hdu.header["BUNIT"] #Input unit is 1e-16 erg/s/cm2/angstrom
>>> bunit_sb = multiply_bunit(bunit_flam16, 'arcsec^-2 angstrom', coeff=1e16)