summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-06-24 10:25:10 +0800
committerAaron LI <aaronly.me@outlook.com>2016-06-24 10:25:10 +0800
commit141db57c21903b2130803a1a738b55ac77aabf81 (patch)
treecd25a2ad96833eadcf006607c9b63ba68bc34de0
parent4f7eee8b1cbe552e6bebeabe5209d88f654321f5 (diff)
downloadcexcess-141db57c21903b2130803a1a738b55ac77aabf81.tar.bz2
deproject_sbp.py: split "AstroParams" to module "astro_params.py"
-rw-r--r--astro_params.py33
-rwxr-xr-xdeproject_sbp.py26
2 files changed, 41 insertions, 18 deletions
diff --git a/astro_params.py b/astro_params.py
new file mode 100644
index 0000000..a272ba4
--- /dev/null
+++ b/astro_params.py
@@ -0,0 +1,33 @@
+# -*- mode: python -*-
+#
+# Weitian LI
+# Created: 2016-06-24
+# Updated: 2016-06-24
+#
+
+"""
+This module contains the parameters/constants used in astronomy
+and astrophysics.
+"""
+
+import astropy.units as au
+
+
+class AstroParams:
+ """
+ The parameters/constants used in astronomy.
+
+ References:
+ [1] ref. [4], eq.(9) below
+ """
+ # Hubble constant at z=0
+ H0 = 71.0 # [ km/s/Mpc ]
+ # density of non-relativistic matter in units of the critical density
+ # at z=0
+ OmegaM0 = 0.27
+ # ratio of electron density (n_e) to proton density (n_p) [1]
+ ratio_ne_np = 1.211
+ # molecular weight per electron (0.3 solar abundance; grsa table) [1]
+ mu_e = 1.155
+ # atomic mass unit
+ m_atom = au.u.to(au.g) # [ g ]
diff --git a/deproject_sbp.py b/deproject_sbp.py
index 9d87ac2..2f9c3f4 100755
--- a/deproject_sbp.py
+++ b/deproject_sbp.py
@@ -2,9 +2,11 @@
#
# Weitian LI
# Created: 2016-06-10
-# Updated: 2016-06-23
+# Updated: 2016-06-24
#
# Change logs:
+# 2016-06-24:
+# * Split class 'AstroParams' to separate module 'astro_params.py'
# 2016-06-23:
# * Add configuration parameter 'sbpexp_rcut'
# * Allow extrapolate the cooling function profile
@@ -155,22 +157,9 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from configobj import ConfigObj
-plt.style.use("ggplot")
-
-
-class AstroParams:
- """
- The parameters/constants used in astronomy.
+from astro_params import AstroParams
- References:
- [1] ref. [4], eq.(9) below
- """
- # ratio of electron density (n_e) to proton density (n_p) [1]
- ratio_ne_np = 1.211
- # molecular weight per electron (0.3 solar abundance; grsa table) [1]
- mu_e = 1.155
- # atomic mass unit
- m_atom = au.u.to(au.g) # [ g ]
+plt.style.use("ggplot")
class Projection:
@@ -966,9 +955,10 @@ class ChandraPixel:
# length of one pixel at the given redshift
length = None
- def __init__(self, z=None, H0=71, OmegaM0=0.27):
+ def __init__(self, z=None):
self.z = z
- self.cosmo = FlatLambdaCDM(H0=H0, Om0=OmegaM0)
+ 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