CLIMATE-391 - Normalize evaluation time values in OCW UI - Date values that are passed for an evaluation are now normalized so all the day values are 1 unless the evaluation is handling daily data.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/ee7bc13d Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/ee7bc13d Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/ee7bc13d Branch: refs/heads/master Commit: ee7bc13defcb4ce14f3760d7ce11065f2513f7ca Parents: 0e65170 Author: Michael Joyce <[email protected]> Authored: Fri Apr 4 17:00:15 2014 -0700 Committer: Michael Joyce <[email protected]> Committed: Fri Apr 4 17:00:15 2014 -0700 ---------------------------------------------------------------------- ocw-ui/backend/processing.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/ee7bc13d/ocw-ui/backend/processing.py ---------------------------------------------------------------------- diff --git a/ocw-ui/backend/processing.py b/ocw-ui/backend/processing.py index 38db1fe..deed472 100644 --- a/ocw-ui/backend/processing.py +++ b/ocw-ui/backend/processing.py @@ -173,12 +173,28 @@ def run_evaluation(): for ds in target_datasets] # Subset the datasets + start = eval_bounds['start_time'] + end = eval_bounds['end_time'] + + # Normalize all the values to the first of the month if we're not + # dealing with daily data. This will ensure that a valid subregion + # isn't considered out of bounds do to a dataset's time values + # being shifted to the first of the month. + if time_step != 'daily': + if start.day != 1: + day_offset = start.day - 1 + start -= timedelta(days=day_offset) + + if end.day != 1: + day_offset = end.day - 1 + end -= timedelta(days=day_offset) + subset = Bounds(eval_bounds['lat_min'], eval_bounds['lat_max'], eval_bounds['lon_min'], eval_bounds['lon_max'], - eval_bounds['start_time'], - eval_bounds['end_time']) + start, + end) ref_dataset = dsp.subset(subset, ref_dataset) target_datasets = [dsp.subset(subset, ds)
