diff options
-rwxr-xr-x | deproject_sbp.py | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/deproject_sbp.py b/deproject_sbp.py index dc8601d..9f00e74 100755 --- a/deproject_sbp.py +++ b/deproject_sbp.py @@ -2,9 +2,11 @@ # # Aaron LI # Created: 2016-06-10 -# Updated: 2016-07-10 +# Updated: 2016-07-11 # # Change logs: +# 2016-07-11: +# * Use a default config to allow a minimal user config # 2016-07-10: # * Use class 'SmoothSpline' from module # 2016-07-04: @@ -125,12 +127,29 @@ References: [5] AtomDB / APEC model: * http://www.atomdb.org/faq.php#DensityXSPECnorm * https://heasarc.gsfc.nasa.gov/docs/xanadu/xspec/manual/XSmodelApec.html +""" + +import argparse +import json +from collections import OrderedDict + +import astropy.units as au +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas +from matplotlib.figure import Figure +from configobj import ConfigObj + +from astro_params import AstroParams, ChandraPixel +from projection import Projection +from fitting_models import PLCModel +from spline import SmoothSpline +plt.style.use("ggplot") -Sample configuration file: ------------------------------------------------------------- +config_default = """ ## Configuration for `deproject_sbp.py` -## Date: 2016-06-23 # config file for SBP fitting (e.g., sbpfit.conf) sbpfit_config = sbpfit.conf @@ -139,16 +158,16 @@ sbpfit_config = sbpfit.conf coolfunc_profile = coolfunc_profile.txt # redshift of the object (for pixel to distance conversion) -redshift = <REDSHIFT> +#redshift = <REDSHIFT> ## SBP extrapolation # ignorance radius from which the SBP is fitted for extrapolation, # specified by the ratio w.r.t sbpfit rc (default: 1.2 * rc) sbpexp_rignore_ratio = 1.2 # or directly specify the ignorance radius (override above) (unit: pixel) -sbpexp_rignore = <RIGNORE> +#sbpexp_rignore = <RIGNORE> # cut radius to which stop the extrapolation (unit: kpc) -sbpexp_rcut = <RCUT> +sbpexp_rcut = 3000 # output of the extrapolated SBP sbpexp_outfile = sbpexp.csv # extrapolation model information @@ -163,28 +182,8 @@ ne_profile = ne_profile.txt rho_gas_profile = rho_gas_profile.txt # image of the density profiles (electron density and/or gas density) density_profile_image = density_profile.png ------------------------------------------------------------- """ -import argparse -import json -from collections import OrderedDict - -import astropy.units as au -import numpy as np -import pandas as pd -import matplotlib.pyplot as plt -from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas -from matplotlib.figure import Figure -from configobj import ConfigObj - -from astro_params import AstroParams, ChandraPixel -from projection import Projection -from fitting_models import PLCModel -from spline import SmoothSpline - -plt.style.use("ggplot") - class SBP: """ @@ -434,9 +433,9 @@ class BrightnessProfile: ne = None # calculated gas mass density profile rho_gas = None - # fitted smoothing spline to the SBP + # fitted `SmoothSpline` object of the SBP s_spline = None - # fitted smoothing spline to the cooling function profile + # fitted `SmoothSpline` of the cooling function profile cf_spline = None def __init__(self, sbp_data, cf_data, z): @@ -626,8 +625,6 @@ class BrightnessProfile: fig.tight_layout() return (fig, ax, ax2) -###################################################################### - def main(): parser = argparse.ArgumentParser( @@ -637,7 +634,9 @@ def main(): "(default: sbpdeproj.conf)") args = parser.parse_args() - config = ConfigObj(args.config) + config = ConfigObj(config_default.splitlines()) + config_user = ConfigObj(args.config) + config.merge(config_user) sbpfit_conf = ConfigObj(config["sbpfit_config"]) try: sbpfit_outfile = sbpfit_conf[sbpfit_conf["model"]]["outfile"] |