You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by wh...@apache.org on 2015/04/22 00:33:04 UTC

[1/2] climate git commit: CLIMATE-622 - allow Bounds object to take optional start and end times - Update the start and end parameter in the Bounds class in DS to optional parameters - Update the subset and safe_subset functions in DSP to set the time ra

Repository: climate
Updated Branches:
  refs/heads/master c9be83458 -> b258cce24


CLIMATE-622 - allow Bounds object to take optional start and end times
- Update the start and end parameter in the Bounds class in DS to optional parameters
- Update the subset and safe_subset functions in DSP to set the time ranges to that
  of the target DS when subsetting if no Bounds time-ranges are entered.


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

Branch: refs/heads/master
Commit: c4efd0af387a70f4e970e5d7d30f75d981b43660
Parents: c9be834
Author: Kim Whitehall <ki...@jpl.nasa.gov>
Authored: Tue Apr 21 09:56:24 2015 -0700
Committer: Kim Whitehall <ki...@jpl.nasa.gov>
Committed: Tue Apr 21 15:31:32 2015 -0700

----------------------------------------------------------------------
 ocw/dataset.py           | 36 +++++++++++++++++++++++-------------
 ocw/dataset_processor.py | 14 ++++++++++----
 2 files changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/c4efd0af/ocw/dataset.py
----------------------------------------------------------------------
diff --git a/ocw/dataset.py b/ocw/dataset.py
index ee86532..d219d52 100644
--- a/ocw/dataset.py
+++ b/ocw/dataset.py
@@ -236,7 +236,7 @@ class Bounds(object):
     * Temporal bounds must a valid datetime object
     '''
 
-    def __init__(self, lat_min, lat_max, lon_min, lon_max, start, end):
+    def __init__(self, lat_min, lat_max, lon_min, lon_max, start=None, end=None):
         '''Default Bounds constructor
 
         :param lat_min: The minimum latitude bound.
@@ -251,10 +251,10 @@ class Bounds(object):
         :param lon_max: The maximum longitude bound.
         :type lon_max: :class:`float`
 
-        :param start: The starting datetime bound.
+        :param start: An optional datetime object for the starting datetime bound.
         :type start: :class:`datetime.datetime`
 
-        :param end: The ending datetime bound.
+        :param end: An optional datetime object for the ending datetime bound.
         :type end: :class:`datetime.datetime`
 
         :raises: ValueError
@@ -263,8 +263,16 @@ class Bounds(object):
         self._lat_max = float(lat_max)
         self._lon_min = float(lon_min)
         self._lon_max = float(lon_max)
-        self._start = start
-        self._end = end
+
+        if not start:
+            self._start = None 
+        else:
+            self._start = start
+
+        if not end:
+            self._end = None 
+        else:
+            self._end = end
 
     @property
     def lat_min(self):
@@ -324,10 +332,11 @@ class Bounds(object):
 
     @start.setter
     def start(self, value):
-        if not (type(value) is dt.datetime and value < self._end):
-            error = "Attempted to set start to invalid value: %s" % (value)
-            logger.error(error)
-            raise ValueError(error)
+        if self._end:
+            if not (type(value) is dt.datetime and value < self._end):
+                error = "Attempted to set start to invalid value: %s" % (value)
+                logger.error(error)
+                raise ValueError(error)
 
         self._start = value
 
@@ -337,10 +346,11 @@ class Bounds(object):
 
     @end.setter
     def end(self, value):
-        if not (type(value) is dt.datetime and value > self._start):
-            error = "Attempted to set end to invalid value: %s" % (value)
-            logger.error(error)
-            raise ValueError(error)
+        if self._start:
+            if not (type(value) is dt.datetime and value > self._start):
+                error = "Attempted to set end to invalid value: %s" % (value)
+                logger.error(error)
+                raise ValueError(error)
 
         self._end = value
 

http://git-wip-us.apache.org/repos/asf/climate/blob/c4efd0af/ocw/dataset_processor.py
----------------------------------------------------------------------
diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py
index eb93104..ec00262 100644
--- a/ocw/dataset_processor.py
+++ b/ocw/dataset_processor.py
@@ -170,6 +170,10 @@ def subset(subregion, target_dataset, subregion_name=None):
     :raises: ValueError
     '''
 
+    if not subregion.start:
+        subregion.start = target_dataset.times[0] 
+        subregion.end = target_dataset.times[-1]
+        
     # Ensure that the subregion information is well formed
     _are_bounds_contained_by_dataset(subregion, target_dataset)
 
@@ -236,11 +240,13 @@ def safe_subset(subregion, target_dataset, subregion_name=None):
     if subregion.lon_max > lon_max:
         subregion.lon_max = lon_max
 
-    if subregion.start < start:
-        subregion.start = start
+    if subregion.start: 
+        if subregion.start < start:
+            subregion.start = start
 
-    if subregion.end > end:
-        subregion.end = end
+    if subregion.end:
+        if subregion.end > end:
+            subregion.end = end
 
     return subset(subregion, target_dataset, subregion_name)
 


[2/2] climate git commit: Resolve CLIMATE-622. Merge PR #191.

Posted by wh...@apache.org.
Resolve CLIMATE-622. Merge PR #191.


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

Branch: refs/heads/master
Commit: b258cce241eab37e46d1fc19758ae122af0ed186
Parents: c9be834 c4efd0a
Author: Kim Whitehall <ki...@jpl.nasa.gov>
Authored: Tue Apr 21 15:32:49 2015 -0700
Committer: Kim Whitehall <ki...@jpl.nasa.gov>
Committed: Tue Apr 21 15:32:49 2015 -0700

----------------------------------------------------------------------
 ocw/dataset.py           | 36 +++++++++++++++++++++++-------------
 ocw/dataset_processor.py | 14 ++++++++++----
 2 files changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------