cwitools.reduction.units.bunit_to_flam

cwitools.reduction.units.bunit_to_flam(header)

Get the conversion factor and new unit string to convert from SB to FLAM units.

Parameters:header (astropy FITS Header) – The Header of the input HDU. Input units must be: ‘FLAM’/’FLAM16’ or similar (e.g. ‘FLAM18’) OR a string parseable by astropy.units.Unit(), made up of ‘erg’, ‘s’, ‘cm’, ‘arcsec’, ‘angstrom’ and a coefficient (e.g. “erg s-1 cm-2 arcsec-2”)
Returns:The coefficient to multiply the data by for this conversion str: The new BUNIT header value
Return type:float

Example

To get the conversion from an input HDU with units of erg/s/cm2/arcsec2 to FLAM units (i.e. erg/s/cm2/angstrom), we do:

>>> coeff, new_bunit = bunit_to_flam(hdu.header)

Then to apply the conversion:

>>> hdu.data *= coeff
>>> hdu.header["BUNIT"] = new_bunit