From 62fec594885f75408e913e4af98cd514b383ca02 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 18 Oct 2016 15:11:03 +0800 Subject: bin/fg21sim: Rewrite to use the interface from foreground.py This greatly simplifies the "bin/fg21sim" script, and also makes the script more generic. --- bin/fg21sim | 49 +++++-------------------------------------------- 1 file 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__": -- cgit v1.2.2