aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/configs/checkers.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-05-16 15:26:58 +0800
committerAaron LI <aaronly.me@outlook.com>2017-05-16 19:09:27 +0800
commit3c07a41448ddce396ffb98e105fca4ae5d6a74ee (patch)
tree5ccc6580492575b27826e8b79752819ae194a2ee /fg21sim/configs/checkers.py
parent02d9b9bc2263d4eabee8a07bbf8c7606255fa761 (diff)
downloadfg21sim-3c07a41448ddce396ffb98e105fca4ae5d6a74ee.tar.bz2
configs: New "sky" section, and remove "common" section
* Update checkers accordingly
Diffstat (limited to 'fg21sim/configs/checkers.py')
-rw-r--r--fg21sim/configs/checkers.py50
1 files changed, 27 insertions, 23 deletions
diff --git a/fg21sim/configs/checkers.py b/fg21sim/configs/checkers.py
index 74d61e3..ffb1e63 100644
--- a/fg21sim/configs/checkers.py
+++ b/fg21sim/configs/checkers.py
@@ -50,29 +50,32 @@ def _is_power2(n):
return (n and not (n & (n-1)))
-def check_common(configs):
- """Check the "[common]" section of the configurations."""
+def check_foregrounds(configs):
+ """Check the "[foregrounds]" section of the configurations."""
results = {}
- # "common/nside" must be a power of 2
- key = "common/nside"
- res = _check_missing(configs, key)
- if res == {}:
- if not _is_power2(configs.getn(key)):
- results[key] = "not a power of 2"
- else:
- results.update(res)
- # "common/lmax" must be greater than "common/lmin"
- key = "common/lmax"
- res = _check_missing(configs, [key, "common/lmin"])
- if res == {}:
- if configs.getn(key) <= configs.getn("common/lmin"):
- results[key] = "not greater than 'common/lmin'"
- else:
- results.update(res)
- # Check enabled components
- key = "common/components"
- if len(configs.getn(key)) == 0:
- results[key] = "no components enabled/selected"
+ # Check enabled foreground components
+ fg = configs.foregrounds
+ if len(fg[0]) == 0:
+ results["foregrounds"] = "no foreground components enabled"
+ return results
+
+
+def check_sky(configs):
+ """Check the "[sky]" section of the configurations."""
+ results = {}
+ skytype = configs.getn("sky/type")
+ if skytype == "patch":
+ sec = "sky/patch"
+ elif skytype == "healpix":
+ sec = "sky/healpix"
+ # "nside" must be a power of 2
+ key = sec + "/nside"
+ res = _check_missing(configs, key)
+ if res == {}:
+ if not _is_power2(configs.getn(key)):
+ results[key] = "not a power of 2"
+ else:
+ results.update(res)
return results
@@ -181,7 +184,8 @@ def check_extragalactic_clusters(configs):
# Available checkers to validate the configurations
_CHECKERS = [
- check_common,
+ check_foregrounds,
+ check_sky,
check_frequency,
check_output,
check_galactic_synchrotron,