From f252691a199cb1761c3a5f81ee0931212b3c5ac9 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 21 Jul 2017 10:21:10 +0800 Subject: bin/fg21sim: Setup cosmology model at the beginning * Update copyright * Add a help on "DEBUG_FG21SIM" * Also fix a bug in cosmology setup() Signed-off-by: Aaron LI --- bin/fg21sim | 11 ++++++++--- fg21sim/utils/cosmology.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/fg21sim b/bin/fg21sim index 0e58551..c25aef3 100755 --- a/bin/fg21sim +++ b/bin/fg21sim @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- mode: python -*- # -# Copyright (c) 2016 Weitian LI +# Copyright (c) 2016-2017 Weitian LI # MIT license """ @@ -15,12 +15,13 @@ import logging import time from fg21sim.configs import configs -from fg21sim.utils import setup_logging +from fg21sim.utils import setup_logging, cosmo def main(): parser = argparse.ArgumentParser( - description="Simulate the radio foregrounds for 21cm EoR signal") + description="Simulate the radio foregrounds for 21cm EoR signal", + epilog="Set environment variable 'DEBUG_FG21SIM=1' to force debug!") parser.add_argument("config", help="user configuration file") parser.add_argument("-l", "--log", dest="loglevel", default=None, choices=["DEBUG", "INFO", "WARNING", @@ -55,6 +56,10 @@ def main(): configs.save(configfile_dump, clobber=True, backup=True) logger.info("Saved current configurations to file: %s" % configfile_dump) + # Setup cosmology model + logger.info("Setup cosmology model with parameters from configs ...") + cosmo.setup(**configs.cosmology) + logger.info("Importing modules + Numba JIT, waiting ...") from fg21sim.foregrounds import Foregrounds fg = Foregrounds(configs) diff --git a/fg21sim/utils/cosmology.py b/fg21sim/utils/cosmology.py index 3a4d5fd..fd9f1ff 100644 --- a/fg21sim/utils/cosmology.py +++ b/fg21sim/utils/cosmology.py @@ -65,7 +65,7 @@ class Cosmology: """ Setup/update the parameters of the cosmology model. """ - for key, value in kwargs: + for key, value in kwargs.items(): if key in ["H0", "Om0", "Ob0", "sigma8"]: setattr(self, key, value) else: -- cgit v1.2.2