Skip to content

Commit

Permalink
units: switch to simple module constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtsmith authored and Dries Van De Putte committed May 9, 2024
1 parent a274097 commit 548ded1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions pahfit/features/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from importlib import resources
from pahfit.errors import PAHFITFeatureError
from pahfit.features.features_format import BoundedMaskedColumn, BoundedParTableFormatter
from pahfit.units import UNITS
import pahfit.units

# Feature kinds and associated parameters
KIND_PARAMS = {'starlight': {'temperature', 'tau'},
Expand All @@ -36,9 +36,9 @@
'absorption': {'wavelength', 'fwhm', 'tau', 'geometry'}}

# Parameter default units: flux density/intensity/power (other units determined on fit)
PARAM_UNITS = {'temperature': UNITS.temperature.value,
'wavelength': UNITS.wavelength.value,
'fwhm': UNITS.wavelength.value}
PARAM_UNITS = {'temperature': pahfit.units.temperature,
'wavelength': pahfit.units.wavelength,
'fwhm': pahfit.units.wavelength}


class UniqueKeyLoader(yaml.SafeLoader):
Expand Down
16 changes: 7 additions & 9 deletions pahfit/units.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
from enum import Enum
import astropy.units as u
from astropy.units import CompositeUnit


# Working/default unitParameter default units: flux density/intensity/power
# These are PAHFITs default science packs parameter and output units
class UNITS(Enum):
temperature = u.K
wavelength = u.um
flux_density = u.mJy
flux_power = CompositeUnit(1e-22, (u.W, u.m), (1, -2))
solid_angle = u.sr
intensity = u.MJy / u.sr
intensity_power = CompositeUnit(1e-10, (u.W, u.m, u.sr), (1, -2, -1))
temperature = u.K
wavelength = u.um
flux_density = u.mJy
flux_power = CompositeUnit(1e-22, (u.W, u.m), (1, -2))
solid_angle = u.sr
intensity = u.MJy / u.sr
intensity_power = CompositeUnit(1e-10, (u.W, u.m, u.sr), (1, -2, -1))

# Note: integrated power units of 1e-22 W/m^2 (from flux) corresponds
# to the unit 1e-10 W/m^2/sr (from intensity) if it occurs uniformly
Expand Down

0 comments on commit 548ded1

Please sign in to comment.