diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-05-16 14:21:58 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-05-16 15:26:46 +0800 |
commit | 02d9b9bc2263d4eabee8a07bbf8c7606255fa761 (patch) | |
tree | c3f05984a124d16f8251b3b68131663b2aaf054a /fg21sim/configs | |
parent | d19f16e0d5a2f753fbc323fa13c438327ff3e058 (diff) | |
download | fg21sim-02d9b9bc2263d4eabee8a07bbf8c7606255fa761.tar.bz2 |
configs: Use separate section "foregrounds" to config components
Also update copyright information.
Diffstat (limited to 'fg21sim/configs')
-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 |
3 files changed, 61 insertions, 29 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. |