diff options
author | Aaron LI <aaronly.me@outlook.com> | 2016-05-04 21:02:13 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2016-05-04 21:02:13 +0800 |
commit | a1c1fee7ddff5b083204cf64f64a979361ddf604 (patch) | |
tree | 2c27ad64315fd429dbed69f8f17b2f5faab68fa0 /make_r500_regions.py | |
parent | 98adaa8a40fc48f5066438b5c6866d8f69fbc571 (diff) | |
download | cexcess-a1c1fee7ddff5b083204cf64f64a979361ddf604.tar.bz2 |
make_r500_regions.py: split out function get_r500()
Diffstat (limited to 'make_r500_regions.py')
-rwxr-xr-x | make_r500_regions.py | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/make_r500_regions.py b/make_r500_regions.py index 6f7e61c..408c256 100755 --- a/make_r500_regions.py +++ b/make_r500_regions.py @@ -11,6 +11,7 @@ # # Changelog: # 2016-05-04: +# * Split `get_r500()` function to a separate module `info` # * Fix a wrong variable # * PEP8 fixes # 2016-04-28: @@ -21,40 +22,9 @@ import glob import re -import json import argparse - -def get_r500(info): - """ - Get the R500 value (in unit pixel and kpc), as well as the value of - "kpc_per_pix" - """ - if isinstance(info, str): - json_str = open(info).read().rstrip().rstrip(",") - info = json.loads(json_str) - - if "R500 (kpc)" in info.keys(): - # LWT's - r500_kpc = float(info["R500 (kpc)"]) - elif "R500" in info.keys(): - # ZZH's - r500_kpc = float(info["R500"]) - else: - raise ValueError("Cannot get R500") - - # Convert kpc to Chandra ACIS pixel - rmax_sbp_pix = float(info["Rmax_SBP (pixel)"]) - rmax_sbp_kpc = float(info["Rmax_SBP (kpc)"]) - kpc_per_pix = rmax_sbp_kpc / rmax_sbp_pix - r500_pix = r500_kpc / kpc_per_pix - - results = { - "r500_kpc": r500_kpc, - "r500_pix": r500_pix, - "kpc_per_pix": kpc_per_pix, - } - return results +from info import get_r500 def get_center(regfile): |