aboutsummaryrefslogtreecommitdiffstats
path: root/astro
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-09-03 17:03:37 +0800
committerAaron LI <aly@aaronly.me>2017-09-03 17:03:37 +0800
commit97a5e67495c3a92e8bb82275f9168843bb7cb1ac (patch)
treea81d1e3807767f29f6b4bfeca1adc51c1efb75c1 /astro
parent6653e976c4ab07e1e8b36bf2f7ad59bb9d723def (diff)
downloadatoolbox-97a5e67495c3a92e8bb82275f9168843bb7cb1ac.tar.bz2
fits2skymodel.py: Use astropy.units to simplify unit conversion
Diffstat (limited to 'astro')
-rwxr-xr-xastro/oskar/fits2skymodel.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/astro/oskar/fits2skymodel.py b/astro/oskar/fits2skymodel.py
index a336515..e5b2ea3 100755
--- a/astro/oskar/fits2skymodel.py
+++ b/astro/oskar/fits2skymodel.py
@@ -32,7 +32,7 @@ from datetime import datetime
import numpy as np
import astropy.io.fits as fits
-import astropy.constants as ac
+import astropy.units as au
from astropy.wcs import WCS
@@ -106,14 +106,11 @@ class SkyModel:
def factor_K2JyPixel(self):
"""
Conversion factor to convert brightness unit from 'K' to 'Jy/pixel'
-
- http://www.iram.fr/IRAMFR/IS/IS2002/html_1/node187.html
"""
- pixarea = np.deg2rad(self.pixelsize/3600.0) ** 2 # [sr]
- kB = ac.k_B.si.value # Boltzmann constant [J/K]
- c0 = ac.c.si.value # speed of light in vacuum [m/s]
- freqHz = self.freq * 1e6 # [Hz]
- factor = 2*kB * 1.0e26 * pixarea * (freqHz/c0)**2
+ pixarea = (self.pixelsize * au.arcsec) ** 2
+ freq = self.freq * au.MHz
+ equiv = au.brightness_temperature(pixarea, freq)
+ factor = au.K.to(au.Jy, equivalencies=equiv)
return factor
@property