You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by jo...@apache.org on 2014/04/05 17:18:10 UTC

[1/6] git commit: CLIMATE-396 - Ensure RCMED parameters are cast properly

Repository: climate
Updated Branches:
  refs/heads/master a663e1562 -> bf0006034


CLIMATE-396 - Ensure RCMED parameters are cast properly

- Cast RCMED dataset id and parameter id to integers before attempting
  to load a dataset.


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

Branch: refs/heads/master
Commit: 900f264abc202f0235f7dee47155cb26d59315c9
Parents: a663e15
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Apr 4 22:33:36 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Apr 4 22:34:02 2014 -0700

----------------------------------------------------------------------
 ocw-ui/backend/processing.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/900f264a/ocw-ui/backend/processing.py
----------------------------------------------------------------------
diff --git a/ocw-ui/backend/processing.py b/ocw-ui/backend/processing.py
index deed472..eafed34 100644
--- a/ocw-ui/backend/processing.py
+++ b/ocw-ui/backend/processing.py
@@ -365,14 +365,14 @@ def _load_rcmed_dataset_object(dataset_info, eval_bounds):
     :raises KeyError: If the required keys aren't present in the dataset_info or
         eval_bounds objects.
     '''
-    dataset = rcmed.parameter_dataset(dataset_info['dataset_id'],
-								      dataset_info['parameter_id'],
-								      eval_bounds['lat_min'],
-								      eval_bounds['lat_max'],
-								      eval_bounds['lon_min'],
-								      eval_bounds['lon_max'],
-								      eval_bounds['start_time'],
-								      eval_bounds['end_time'])
+    dataset = rcmed.parameter_dataset(int(dataset_info['dataset_id']),
+                                      int(dataset_info['parameter_id']),
+                                      eval_bounds['lat_min'],
+                                      eval_bounds['lat_max'],
+                                      eval_bounds['lon_min'],
+                                      eval_bounds['lon_max'],
+                                      eval_bounds['start_time'],
+                                      eval_bounds['end_time'])
 
     # If a name is passed for the dataset, use it. Otherwise, use the file name.
     if 'name'in dataset_info.keys():


[5/6] git commit: Resolve CLIMATE-396. Merge PR #14.

Posted by jo...@apache.org.
Resolve CLIMATE-396. Merge PR #14.


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

Branch: refs/heads/master
Commit: 2edee819520d1a96c63c395a90343917a7749f40
Parents: ccfc97c 900f264
Author: Michael Joyce <jo...@apache.org>
Authored: Sat Apr 5 08:14:37 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Sat Apr 5 08:14:37 2014 -0700

----------------------------------------------------------------------
 ocw-ui/backend/processing.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------



[6/6] git commit: Resolve CLIMATE-397. Merge PR #15.

Posted by jo...@apache.org.
Resolve CLIMATE-397. Merge PR #15.


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

Branch: refs/heads/master
Commit: bf0006034989f407c1dfca6f3d83d8a392bd19e3
Parents: 2edee81 236a0d8
Author: Michael Joyce <jo...@apache.org>
Authored: Sat Apr 5 08:15:54 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Sat Apr 5 08:15:54 2014 -0700

----------------------------------------------------------------------
 ocw-ui/backend/processing.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/bf000603/ocw-ui/backend/processing.py
----------------------------------------------------------------------


[3/6] git commit: CLIMATE-397 - Switch UI backend over to safe_subset

Posted by jo...@apache.org.
CLIMATE-397 - Switch UI backend over to safe_subset

- The UI backend now uses dataset_processor.safe_subset instead of
  subset when it performs subsetting tasks on the loaded datasets. This
  helps to ensure that RCMED datasets don't wind up causing problems due
  to fractional lat/lon grids.


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

Branch: refs/heads/master
Commit: 236a0d8dcadc8500bad0846d9f2fe43c9d30a5fd
Parents: a663e15
Author: Michael Joyce <jo...@apache.org>
Authored: Sat Apr 5 07:56:35 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Sat Apr 5 07:56:35 2014 -0700

----------------------------------------------------------------------
 ocw-ui/backend/processing.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/236a0d8d/ocw-ui/backend/processing.py
----------------------------------------------------------------------
diff --git a/ocw-ui/backend/processing.py b/ocw-ui/backend/processing.py
index deed472..d7e4755 100644
--- a/ocw-ui/backend/processing.py
+++ b/ocw-ui/backend/processing.py
@@ -196,8 +196,8 @@ def run_evaluation():
                     start,
                     end)
 
-    ref_dataset = dsp.subset(subset, ref_dataset)
-    target_datasets = [dsp.subset(subset, ds)
+    ref_dataset = dsp.safe_subset(subset, ref_dataset)
+    target_datasets = [dsp.safe_subset(subset, ds)
                        for ds
                        in target_datasets]
     


[4/6] git commit: Resolve CLIMATE-395. Merge PR #13.

Posted by jo...@apache.org.
Resolve CLIMATE-395. Merge PR #13.


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

Branch: refs/heads/master
Commit: ccfc97c872bef83ced52c71380a9ea039fe1dc36
Parents: a663e15 9de222e
Author: Michael Joyce <jo...@apache.org>
Authored: Sat Apr 5 08:13:17 2014 -0700
Committer: Michael Joyce <jo...@apache.org>
Committed: Sat Apr 5 08:13:17 2014 -0700

----------------------------------------------------------------------
 ocw/tests/test_dataset.py | 12 ++++++---
 ocw/tests/test_utils.py   | 55 ++++++++++++++++++++++++++++++++++++++----
 2 files changed, 58 insertions(+), 9 deletions(-)
----------------------------------------------------------------------



[2/6] git commit: Added more unit tests for normalize_lat_lon_values() helper

Posted by jo...@apache.org.
Added more unit tests for normalize_lat_lon_values() helper


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

Branch: refs/heads/master
Commit: 9de222e18bdfc0679f4ddec9edee5ea1c2059fff
Parents: a663e15
Author: bassdx <ag...@gmail.com>
Authored: Sat Apr 5 02:32:14 2014 -0600
Committer: bassdx <ag...@gmail.com>
Committed: Sat Apr 5 02:32:14 2014 -0600

----------------------------------------------------------------------
 ocw/tests/test_dataset.py | 12 ++++++---
 ocw/tests/test_utils.py   | 55 ++++++++++++++++++++++++++++++++++++++----
 2 files changed, 58 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/9de222e1/ocw/tests/test_dataset.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset.py b/ocw/tests/test_dataset.py
index 4dd57f6..1694b20 100644
--- a/ocw/tests/test_dataset.py
+++ b/ocw/tests/test_dataset.py
@@ -90,13 +90,17 @@ class TestInvalidDatasetInit(unittest.TestCase):
 
     def test_lons_values_incorrectly_gridded(self):
         times = np.array([dt.datetime(2000, x, 1) for x in range(1, 13)])
-        lats = np.array(range(-30, 30))
-        bad_lons = np.array(range(360))
-        flat_array = np.array(range(len(times) * len(lats) * len(bad_lons)))
+        lats = np.arange(-30, 30)
+        bad_lons = np.arange(360)
+        flat_array = np.arange(len(times) * len(lats) * len(bad_lons))
         values = flat_array.reshape(len(times), len(lats), len(bad_lons))
 
         ds = Dataset(lats, bad_lons, times, values)
-        self.assertTrue(np.array_equal(ds.lons, range(-180, 180)))
+        self.assertTrue(np.array_equal(ds.lons, np.arange(-180, 180)))
+    
+    def test_reversed_lats(self):
+        ds = Dataset(self.lat[::-1], self.lon, self.time, self.value)
+        self.assertTrue(np.array_equal(ds.lats, self.lat))
 
 class TestDatasetFunctions(unittest.TestCase):
     def setUp(self):

http://git-wip-us.apache.org/repos/asf/climate/blob/9de222e1/ocw/tests/test_utils.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_utils.py b/ocw/tests/test_utils.py
index 4ca63c0..98387e6 100644
--- a/ocw/tests/test_utils.py
+++ b/ocw/tests/test_utils.py
@@ -87,16 +87,61 @@ class TestBaseTimeStringParse(unittest.TestCase):
 class TestNormalizeLatLonValues(unittest.TestCase):
     def setUp(self):
         times = np.array([datetime.datetime(2000, x, 1) for x in range(1, 13)])
-        self.lats = np.array(range(-30, 30))
-        self.lons = np.array(range(360))
-        flat_array = np.array(range(len(times) * len(self.lats) * len(self.lons)))
+        self.lats = np.arange(-30, 30)
+        self.lons = np.arange(360)
+        flat_array = np.arange(len(times) * len(self.lats) * len(self.lons))
         self.values = flat_array.reshape(len(times), len(self.lats), len(self.lons))
+        self.lats2 = np.array([-30, 0, 30])
+        self.lons2 = np.array([0, 100, 200, 300])
+        self.values2 = np.arange(12).reshape(3, 4)
+        self.lats_unsorted = np.array([-30, 20, -50])
+        self.lons_unsorted = np.array([-30, 20, -50, 40])
 
     def test_full_lons_shift(self):
         lats, lons, values = utils.normalize_lat_lon_values(self.lats,
                                                             self.lons,
                                                             self.values)
-        self.assertTrue(np.array_equal(lons, range(-180, 180)))
-
+        self.assertTrue(np.array_equal(lons, np.arange(-180, 180)))
+        
+    def test_lats_reversed(self):
+    	lons2 = np.arange(-180, 180)
+        lats, lons, values = utils.normalize_lat_lon_values(self.lats[::-1],
+                                                            lons2,
+                                                            self.values[:, ::-1, :])
+        self.assertTrue(np.array_equal(lats, self.lats))
+        self.assertTrue(np.array_equal(values, self.values))
+    
+    def test_lons_shift_values(self):
+        expected_vals = np.array([[2, 3, 0, 1],
+                                  [6, 7, 4, 5],
+                                  [10, 11, 8, 9]])
+        lats, lons, values = utils.normalize_lat_lon_values(self.lats2,
+                                                            self.lons2,
+                                                            self.values2)
+        self.assertTrue(np.array_equal(values, expected_vals))
+        
+    def test_shift_and_reversed(self):
+        expected_vals = np.array([[10, 11, 8, 9],
+                                  [6, 7, 4, 5],
+                                  [2, 3, 0, 1]])
+        lats, lons, values = utils.normalize_lat_lon_values(self.lats2[::-1],
+                                                            self.lons2,
+                                                            self.values2)
+        self.assertTrue(np.array_equal(values, expected_vals))
+        
+    def test_lats_not_sorted(self):
+        self.assertRaises(ValueError, 
+                          utils.normalize_lat_lon_values,
+                          self.lats_unsorted,
+                          self.lons2,
+                          self.values2)
+                          
+    def test_lons_not_sorted(self):
+        self.assertRaises(ValueError, 
+                          utils.normalize_lat_lon_values,
+                          self.lats2,
+                          self.lons_unsorted,
+                          self.values2)
+    
 if __name__ == '__main__':
     unittest.main()