diff options
| author | Aaron LI <aaronly.me@outlook.com> | 2016-06-24 13:00:45 +0800 | 
|---|---|---|
| committer | Aaron LI <aaronly.me@outlook.com> | 2016-06-24 13:00:45 +0800 | 
| commit | 6cac8c3f1f39ebd6e1a1d1c831d7833a0f0e71bb (patch) | |
| tree | 570059f73e910b3d7dd09a9f95a215ad692b9eab | |
| parent | aa30192b0e31c132807d11eddcabe64e007a16f5 (diff) | |
| download | cexcess-6cac8c3f1f39ebd6e1a1d1c831d7833a0f0e71bb.tar.bz2 | |
Move "ChandraPixel" from "deproject_sbp.py" to "astro_params.py"
| -rw-r--r-- | astro_params.py | 38 | ||||
| -rwxr-xr-x | deproject_sbp.py | 37 | 
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  | 
