diff options
author | Aaron LI <aly@aaronly.me> | 2017-06-23 10:37:15 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-06-23 10:37:15 +0800 |
commit | eb660ae70db40d36418f1e4eb886fd9bb02af1a7 (patch) | |
tree | 2f4bf926bd817df748a904bd649310a5618d8ed2 /fg21sim | |
parent | 77e77c36b80be17b0abec00cd696b71922a01860 (diff) | |
download | fg21sim-eb660ae70db40d36418f1e4eb886fd9bb02af1a7.tar.bz2 |
utils/convert.py: Use 'utils.units' module
Diffstat (limited to 'fg21sim')
-rw-r--r-- | fg21sim/utils/convert.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/fg21sim/utils/convert.py b/fg21sim/utils/convert.py index fc9a228..1ada6ae 100644 --- a/fg21sim/utils/convert.py +++ b/fg21sim/utils/convert.py @@ -1,14 +1,15 @@ -# Copyright (c) 2016 Weitian LI <liweitianux@live.com> +# Copyright (c) 2016-2017 Weitian LI <weitian@aaronly.me> # MIT license """ Utilities for conversion among common astronomical quantities. """ -import numpy as np import astropy.units as au import numba +from .units import (Constants as AC, UnitConversions as AUC) + def Fnu_to_Tb(Fnu, omega, freq): """Convert flux density to brightness temperature, using the @@ -92,11 +93,11 @@ def Sb_to_Tb_fast(Sb, freq): Calculated brightness temperature, unit [ K ] """ # NOTE: `radian` is dimensionless - rad2_to_deg2 = np.rad2deg(1.0) * np.rad2deg(1.0) + rad2_to_deg2 = AUC.rad2deg ** 2 Sb_rad2 = Sb * rad2_to_deg2 # unit: [ Jy/rad^2 ] -> [ Jy ] - c = 29979245800.0 # speed of light, [ cm/s ] - k_B = 1.3806488e-16 # Boltzmann constant, [ erg/K ] - coef = 1e-35 # take care the unit conversions + c = AC.c # speed of light, [ cm/s ] + k_B = AC.k_B # Boltzmann constant, [ erg/K ] + coef = 1e-35 # unit conversion factor Tb = coef * (Sb_rad2 * c*c) / (2 * k_B * freq*freq) # unit: [ K ] return Tb |