climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From huiky...@apache.org
Subject [2/3] climate git commit: debugging dataset_processor for subregion objects without start and end attributes
Date Mon, 17 Apr 2017 18:44:30 GMT
debugging dataset_processor for subregion objects without start and end attributes


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/c4291784
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/c4291784
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/c4291784

Branch: refs/heads/master
Commit: c42917847e4c8a7fb5badf35961431aab2394514
Parents: 6f6cde8
Author: huikyole <huikyole@argo.jpl.nasa.gov>
Authored: Mon Apr 17 11:41:30 2017 -0700
Committer: huikyole <huikyole@argo.jpl.nasa.gov>
Committed: Mon Apr 17 11:41:30 2017 -0700

----------------------------------------------------------------------
 ocw/dataset_processor.py | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/c4291784/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index 18058ca..a99cba9 100755
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -1466,6 +1466,7 @@ def _are_bounds_contained_by_dataset(dataset, bounds):
     '''
     lat_min, lat_max, lon_min, lon_max = dataset.spatial_boundaries()
     start, end = dataset.temporal_boundaries()
+    
     errors = []
 
     # TODO:  THIS IS TERRIBLY inefficent and we need to use a geometry
@@ -1479,16 +1480,17 @@ def _are_bounds_contained_by_dataset(dataset, bounds):
         error = ("bounds.lon_max: %s is not between lon_min: %s and"
                  " lon_max: %s" % (bounds.lon_max, lon_min, lon_max))
         errors.append(error)
-
-    if not start <= bounds.start <= end:
-        error = ("bounds.start: %s is not between start: %s and end: %s" %
-                 (bounds.start, start, end))
-        errors.append(error)
-
-    if not start <= bounds.end <= end:
-        error = ("bounds.end: %s is not between start: %s and end: %s" %
-                 (bounds.end, start, end))
-        errors.append(error)
+    if not (bounds.start is None):
+        if not start <= bounds.start <= end:
+            error = ("bounds.start: %s is not between start: %s and end: %s" %
+                     (bounds.start, start, end))
+            errors.append(error)
+
+    if not (bounds.end is None):
+        if not start <= bounds.end <= end:
+            error = ("bounds.end: %s is not between start: %s and end: %s" %
+                     (bounds.end, start, end))
+            errors.append(error)
 
     if len(errors) == 0:
         return True
@@ -1514,8 +1516,12 @@ def _get_subregion_slice_indices(target_dataset, subregion):
     lonStart = min(np.nonzero(target_dataset.lons >= subregion.lon_min)[0])
     lonEnd = max(np.nonzero(target_dataset.lons <= subregion.lon_max)[0])
 
-    timeStart = min(np.nonzero(target_dataset.times >= subregion.start)[0])
-    timeEnd = max(np.nonzero(target_dataset.times <= subregion.end)[0])
+    if not (subregion.start is None):
+        timeStart = min(np.nonzero(target_dataset.times >= subregion.start)[0])
+        timeEnd = max(np.nonzero(target_dataset.times <= subregion.end)[0])
+    else:
+        timeStart = 0
+        timeEnd = len(target_dataset.times) -1
 
     return {
         "lat_start": latStart,


Mime
View raw message