From fd85a3ecaa2fc0b684d6dbd00c803c9b1ca75349 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 12 Oct 2016 12:42:09 +0800 Subject: configs/validate.py: Check component configs only if enabled --- fg21sim/configs/validate.py | 48 ++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'fg21sim/configs/validate.py') diff --git a/fg21sim/configs/validate.py b/fg21sim/configs/validate.py index f12bac1..aaf7fd1 100644 --- a/fg21sim/configs/validate.py +++ b/fg21sim/configs/validate.py @@ -67,35 +67,39 @@ 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") results = {} - results.update( - _check_missing(configs, ["galactic/synchrotron/template_freq", - "galactic/synchrotron/template_unit"]) - ) - results.update( - _check_existence(configs, ["galactic/synchrotron/template", - "galactic/synchrotron/indexmap"]) - ) - if configs.getn("galactic/synchrotron/save"): - results.update(_check_missing(configs, - "galactic/synchrotron/output_dir")) + 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")) return results def check_galactic_freefree(configs): """Check the "[galactic][freefree]" section of the configurations.""" + comp = "galactic/freefree" + comp_enabled = configs.getn("common/components") results = {} - results.update( - _check_missing(configs, ["galactic/freefree/halphamap_unit", - "galactic/freefree/dustmap_unit"]) - ) - results.update( - _check_existence(configs, ["galactic/freefree/halphamap", - "galactic/freefree/dustmap"]) - ) - if configs.getn("galactic/freefree/save"): - results.update(_check_missing(configs, - "galactic/freefree/output_dir")) + if comp in comp_enabled: + # Only validate the configs if this component is enabled + results.update( + _check_missing(configs, [comp+"/halphamap_unit", + comp+"/dustmap_unit"]) + ) + results.update( + _check_existence(configs, [comp+"/halphamap", comp+"/dustmap"]) + ) + if configs.getn(comp+"/save"): + results.update(_check_missing(configs, comp+"/output_dir")) return results -- cgit v1.2.2