standardise_unit#

gammapy.utils.units.standardise_unit(unit)[source]#

Standardise unit.

Changes applied by this function:

  • Drop “photon” == “ph” from the unit

  • Drop “count” == “ct” from the unit

Parameters
unitUnit or str

Any old unit.

Returns
unitUnit

Shiny new, standardised unit.

Examples

>>> from gammapy.utils.units import standardise_unit
>>> standardise_unit('ph cm-2 s-1')
Unit("1 / (s cm2)")
>>> standardise_unit('ct cm-2 s-1')
Unit("1 / (s cm2)")
>>> standardise_unit('cm-2 s-1')
Unit("1 / (s cm2)")