CLIMATE-639 - Add subregion handling to evaluation creation
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/917dbdb5 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/917dbdb5 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/917dbdb5 Branch: refs/heads/master Commit: 917dbdb56e73202d470d2e48eb3625bcd3ede943 Parents: 2357078 Author: Michael Joyce <[email protected]> Authored: Thu May 28 11:13:10 2015 -0700 Committer: Michael Joyce <[email protected]> Committed: Thu May 28 11:13:10 2015 -0700 ---------------------------------------------------------------------- ocw-config-runner/evaluation_creation.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/917dbdb5/ocw-config-runner/evaluation_creation.py ---------------------------------------------------------------------- diff --git a/ocw-config-runner/evaluation_creation.py b/ocw-config-runner/evaluation_creation.py index 3502186..94967d3 100644 --- a/ocw-config-runner/evaluation_creation.py +++ b/ocw-config-runner/evaluation_creation.py @@ -58,7 +58,12 @@ def generate_evaluation_from_config(config_data): # Load metrics eval_metrics = [_load_metric(m)() for m in config_data['metrics']] - return Evaluation(reference, targets, eval_metrics) + # Load Subregions (if present) + subregions = None + if 'subregions' in config_data: + subregions = [_load_subregion(s) for s in config_data['subregions']] + + return Evaluation(reference, targets, eval_metrics, subregions=subregions) def _load_dataset(dataset_config_data): """""" @@ -147,3 +152,10 @@ def _load_metric(metric_config_data): return None return getattr(metrics, metric_config_data) + +def _load_subregion(subregion_config_data): + """""" + return Bounds(float(subregion_config_data[0]), + float(subregion_config_data[1]), + float(subregion_config_data[2]), + float(subregion_config_data[3]))
