summaryrefslogtreecommitdiffstats
path: root/astro_params.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-06-24 13:00:45 +0800
committerAaron LI <aaronly.me@outlook.com>2016-06-24 13:00:45 +0800
commit6cac8c3f1f39ebd6e1a1d1c831d7833a0f0e71bb (patch)
tree570059f73e910b3d7dd09a9f95a215ad692b9eab /astro_params.py
parentaa30192b0e31c132807d11eddcabe64e007a16f5 (diff)
downloadcexcess-6cac8c3f1f39ebd6e1a1d1c831d7833a0f0e71bb.tar.bz2
Move "ChandraPixel" from "deproject_sbp.py" to "astro_params.py"
Diffstat (limited to 'astro_params.py')
-rw-r--r--astro_params.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/astro_params.py b/astro_params.py
index a272ba4..b3b733b 100644
--- a/astro_params.py
+++ b/astro_params.py
@@ -4,6 +4,10 @@
# Created: 2016-06-24
# Updated: 2016-06-24
#
+# Change logs:
+# 2016-06-24:
+# * Add class 'ChandraPixel', moved from 'deproject_sbp.py'
+#
"""
This module contains the parameters/constants used in astronomy
@@ -11,6 +15,7 @@ and astrophysics.
"""
import astropy.units as au
+from astropy.cosmology import FlatLambdaCDM
class AstroParams:
@@ -31,3 +36,36 @@ class AstroParams:
mu_e = 1.155
# atomic mass unit
m_atom = au.u.to(au.g) # [ g ]
+
+
+class ChandraPixel:
+ """
+ Chandra pixel unit conversions.
+ """
+ angle = 0.492 * au.arcsec
+ z = None
+ # cosmology calculator
+ cosmo = None
+ # angular diameter distance
+ D_A = None
+ # length of one pixel at the given redshift
+ length = None
+
+ def __init__(self, z=None):
+ self.z = z
+ self.cosmo = FlatLambdaCDM(H0=AstroParams.H0,
+ Om0=AstroParams.OmegaM0)
+ if z is not None:
+ self.D_A = self.cosmo.angular_diameter_distance(z)
+ self.length = self.D_A * self.angle.to(au.radian).value
+
+ def get_angle(self):
+ return self.angle
+
+ def get_length(self, z=None):
+ if z is None:
+ length = self.length
+ else:
+ D_A = self.cosmo.angular_diameter_distance(z)
+ length = D_A * self.angle.to(au.radian).value
+ return length