summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--astro_params.py38
-rwxr-xr-xdeproject_sbp.py37
2 files changed, 40 insertions, 35 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
diff --git a/deproject_sbp.py b/deproject_sbp.py
index 5dfbc2d..ce6ad8d 100755
--- a/deproject_sbp.py
+++ b/deproject_sbp.py
@@ -6,6 +6,7 @@
#
# Change logs:
# 2016-06-24:
+# * Move class 'ChandraPixel' to module 'astro_params.py'
# * Split class 'Projection' to a separate module 'projection.py'
# * Move class 'DensityProfile' to tool 'calc_mass_potential.py'
# * Split class 'AstroParams' to separate module 'astro_params.py'
@@ -148,7 +149,6 @@ import json
from collections import OrderedDict
import astropy.units as au
-from astropy.cosmology import FlatLambdaCDM
import numpy as np
import pandas as pd
import scipy.optimize
@@ -159,7 +159,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from configobj import ConfigObj
-from astro_params import AstroParams
+from astro_params import AstroParams, ChandraPixel
from projection import Projection
plt.style.use("ggplot")
@@ -809,39 +809,6 @@ class SBP:
######################################################################
-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
-
-
class BrightnessProfile:
"""
Calculate the electron number density and/or gas mass density profile