cwitools.reduction.units.bunit_to_sb

cwitools.reduction.units.bunit_to_sb(header)

Get the conversion factor and new unit string to convert from FLAM to SB 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/angstrom to SB units (i.e. erg/s/cm2/arcsec), we do:

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

Then to apply the conversion:

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