diff options
Diffstat (limited to 'fg21sim')
-rw-r--r-- | fg21sim/configs/00-general.conf.spec | 31 | ||||
-rw-r--r-- | fg21sim/configs/checkers.py | 41 | ||||
-rw-r--r-- | fg21sim/configs/manager.py | 18 | ||||
-rw-r--r-- | fg21sim/foregrounds.py | 4 |
4 files changed, 63 insertions, 31 deletions
diff --git a/fg21sim/configs/00-general.conf.spec b/fg21sim/configs/00-general.conf.spec index 4779f6c..aa2a29a 100644 --- a/fg21sim/configs/00-general.conf.spec +++ b/fg21sim/configs/00-general.conf.spec @@ -19,19 +19,24 @@ nside = integer(min=1, default=1024) lmin = integer(min=0, default=10) lmax = integer(min=1, default=3071) -# List of foreground components to be simulated: -# + galactic/synchrotron: -# Diffuse Galactic synchrotron emission (unpolarized) -# + galactic/freefree: -# Diffuse Galactic free-free emission -# + galactic/snr: -# Galactic supernova remnants emission -# + extragalactic/clusters: -# Extragalactic clusters of galaxies emission -# + extragalactic/pointsources: -# Emission from multiple types of extragalactic point sources -# NOTE: This component is not well integrated and tested at the moment -components = force_list(default=list("galactic/synchrotron", "galactic/freefree", "galactic/snr", "extragalactic/clusters")) + +# Foreground components to be simulated +[foregrounds] +# Diffuse Galactic synchrotron emission (unpolarized) +galactic/synchrotron = boolean(default=True) + +# Diffuse Galactic free-free emission +galactic/freefree = boolean(default=True) + +# Galactic supernova remnants emission +galactic/snr = boolean(default=True) + +# Extragalactic clusters of galaxies emission +extragalactic/clusters = boolean(default=True) + +# Emission from multiple types of extragalactic point sources +# NOTE: This component is not well integrated and tested at the moment +extragalactic/pointsources = boolean(default=False) # Frequencies specification of the simulation products diff --git a/fg21sim/configs/checkers.py b/fg21sim/configs/checkers.py index 7bbcdd7..74d61e3 100644 --- a/fg21sim/configs/checkers.py +++ b/fg21sim/configs/checkers.py @@ -101,26 +101,37 @@ def check_output(configs): def check_galactic_synchrotron(configs): """Check the "[galactic][synchrotron]" section of the configurations.""" comp = "galactic/synchrotron" - comp_enabled = configs.getn("common/components") + comp_enabled = configs.foregrounds[0] + if comp not in comp_enabled: + return {} + results = {} - if comp in comp_enabled: - # Only validate the configs if this component is enabled - results.update( - _check_missing(configs, [comp+"/template_freq", - comp+"/template_unit"]) - ) - results.update( - _check_existence(configs, [comp+"/template", comp+"/indexmap"]) - ) - if configs.getn(comp+"/save"): - results.update(_check_missing(configs, comp+"/output_dir")) + # Only validate the configs if this component is enabled + results.update( + _check_missing(configs, [comp+"/template_freq", + comp+"/template_unit"]) + ) + results.update( + _check_existence(configs, [comp+"/template", comp+"/indexmap"]) + ) + if configs.getn(comp+"/add_smallscales"): + # "lmax" must be greater than "lmin" + key = comp + "/lmax" + res = _check_missing(configs, [key, comp+"/lmin"]) + if res == {}: + if configs.getn(key) <= configs.getn(comp+"/lmin"): + results[key] = "not greater than 'lmin'" + else: + results.update(res) + if configs.getn(comp+"/save"): + results.update(_check_missing(configs, comp+"/output_dir")) return results def check_galactic_freefree(configs): """Check the "[galactic][freefree]" section of the configurations.""" comp = "galactic/freefree" - comp_enabled = configs.getn("common/components") + comp_enabled = configs.foregrounds[0] results = {} if comp in comp_enabled: # Only validate the configs if this component is enabled @@ -139,7 +150,7 @@ def check_galactic_freefree(configs): def check_galactic_snr(configs): """Check the "[galactic][snr]" section of the configurations.""" comp = "galactic/snr" - comp_enabled = configs.getn("common/components") + comp_enabled = configs.foregrounds[0] results = {} if comp in comp_enabled: # Only validate the configs if this component is enabled @@ -156,7 +167,7 @@ def check_extragalactic_clusters(configs): Check the "[extragalactic][clusters]" section of the configurations. """ comp = "extragalactic/clusters" - comp_enabled = configs.getn("common/components") + comp_enabled = configs.foregrounds[0] results = {} if comp in comp_enabled: # Only validate the configs if this component is enabled diff --git a/fg21sim/configs/manager.py b/fg21sim/configs/manager.py index 7818d1c..1cddb75 100644 --- a/fg21sim/configs/manager.py +++ b/fg21sim/configs/manager.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Weitian LI <liweitianux@live.com> +# Copyright (c) 2016-2017 Weitian LI <weitian@aaronly.me> # MIT license # # References: @@ -455,6 +455,22 @@ class ConfigManager: return os.path.normpath(path) @property + def foregrounds(self): + """Get all available and enabled foreground components. + + Returns + ------- + enabled : list[str] + Enabled foreground components to be simulated + available : list[str] + All available foreground components + """ + fg = self.get("foregrounds") + avaliable = list(fg.keys()) + enabled = [key for key, value in fg.items() if value] + return (enabled, avaliable) + + @property def frequencies(self): """Get or calculate if ``frequency/type = custom`` the frequencies where to perform the simulations. diff --git a/fg21sim/foregrounds.py b/fg21sim/foregrounds.py index d74dfaf..c398394 100644 --- a/fg21sim/foregrounds.py +++ b/fg21sim/foregrounds.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Weitian LI <liweitianux@live.com> +# Copyright (c) 2016-2017 Weitian LI <weitian@aaronly.me> # MIT license """ @@ -91,7 +91,7 @@ class Foregrounds: def _set_configs(self): """Load the configs and set the corresponding class attributes.""" - self.components_id = self.configs.getn("common/components") + self.components_id = self.configs.foregrounds[0] logger.info("All supported simulation components: {0}".format( ", ".join(list(self.COMPONENTS_ALL.keys())))) logger.info("Enabled components: {0}".format( |