aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fg21sim
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-10-18 15:11:03 +0800
committerAaron LI <aaronly.me@outlook.com>2016-10-18 15:11:03 +0800
commit62fec594885f75408e913e4af98cd514b383ca02 (patch)
tree67952a119120b80f1a37078e3ad98ad9097180e2 /bin/fg21sim
parent1033d4abd62c58b7652d221c052466d1a48dfaac (diff)
downloadfg21sim-62fec594885f75408e913e4af98cd514b383ca02.tar.bz2
bin/fg21sim: Rewrite to use the interface from foreground.py
This greatly simplifies the "bin/fg21sim" script, and also makes the script more generic.
Diffstat (limited to 'bin/fg21sim')
-rwxr-xr-xbin/fg21sim49
1 files changed, 5 insertions, 44 deletions
diff --git a/bin/fg21sim b/bin/fg21sim
index 0effbc7..2328a28 100755
--- a/bin/fg21sim
+++ b/bin/fg21sim
@@ -13,13 +13,9 @@ import sys
import argparse
import logging
-import numpy as np
-
+from fg21sim import Foregrounds
from fg21sim.configs import configs, validate_configs
from fg21sim.utils import setup_logging
-from fg21sim.galactic import Synchrotron as GalacticSynchrotron
-from fg21sim.galactic import FreeFree as GalacticFreeFree
-from fg21sim.galactic import SuperNovaRemnants as GalacticSNR
def main():
@@ -55,45 +51,10 @@ def main():
logger = logging.getLogger(tool)
logger.info("COMMAND: {0}".format(" ".join(sys.argv)))
- frequencies = np.array(configs.frequencies, ndmin=1)
- freq_unit = configs.getn("frequency/unit")
- logger.info("Simulation frequencies: "
- "{min:.2f} - {max:.2f} {unit} (#{num:d})".format(
- min=frequencies.min(), max=frequencies.max(),
- num=len(frequencies), unit=freq_unit))
-
- # XXX/TODO: move the supported components and id's to a module/file
- fg_components = configs.getn("common/components")
- logger.info("Enabled simulation components: {0}".format(
- ", ".join(fg_components)))
- fg_maps = {}
-
- # Galactic synchrotron
- id_gsync = "galactic/synchrotron"
- if id_gsync in fg_components:
- logger.info("Simulating the Galactic synchrotron foreground ...")
- gsynchrotron = GalacticSynchrotron(configs)
- hpmap_gsync = gsynchrotron.simulate(frequencies)
- logger.info("Done simulate Galactic synchrotron foreground!")
- fg_maps[id_gsync] = hpmap_gsync
-
- # Galactic free-free
- id_gfree = "galactic/freefree"
- if id_gfree in fg_components:
- logger.info("Simulating the Galactic free-free foreground ...")
- gfreefree = GalacticFreeFree(configs)
- hpmap_gfree = gfreefree.simulate(frequencies)
- logger.info("Done simulate Galactic free-free foreground!")
- fg_maps[id_gfree] = hpmap_gfree
-
- # Galactic supernova remnants
- id_gsnr = "galactic/snr"
- if id_gsnr in fg_components:
- logger.info("Simulating the Galactic supernova remnants emission ...")
- gsnr = GalacticSNR(configs)
- hpmap_gsnr = gsnr.simulate(frequencies)
- logger.info("Done simulate Galactic supernova remnants foreground!")
- fg_maps[id_gsnr] = hpmap_gsnr
+ fg = Foregrounds(configs)
+ fg.preprocess()
+ fg.simulate()
+ fg.postprocess()
if __name__ == "__main__":