climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1566133 - /incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py
Date Sat, 08 Feb 2014 21:00:32 GMT
Author: joyce
Date: Sat Feb  8 21:00:32 2014
New Revision: 1566133

URL: http://svn.apache.org/r1566133
Log:
CLIMATE-332 - Add Spatial Rebin helper tests

- Add latlon bin test.
- Change backend.processing import for convenience.

Modified:
    incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py

Modified: incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py?rev=1566133&r1=1566132&r2=1566133&view=diff
==============================================================================
--- incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py (original)
+++ incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py Sat Feb  8 21:00:32 2014
@@ -5,10 +5,12 @@ from urllib import urlretrieve
 from webtest import TestApp
 
 from backend.run_webservices import app
-import backend.processing
+import backend.processing as bp
 
 import ocw.metrics as metrics
 
+import numpy
+
 test_app = TestApp(app)
 
 FILE_LEADER = "http://zipper.jpl.nasa.gov/dist/"
@@ -35,19 +37,35 @@ class TestLocalDatasetLoad(unittest.Test
             'time_name': 'time'
         }
 
-        dataset = backend.processing._load_local_dataset_object(dataset_object)
+        dataset = bp._load_local_dataset_object(dataset_object)
         self.assertEqual(dataset.variable, dataset_object['var_name'])
 
 class TestMetricLoad(unittest.TestCase):
     def test_get_valid_metric_options(self):
-        metric_map = backend.processing._get_valid_metric_options()
+        metric_map = bp._get_valid_metric_options()
         bias = metric_map['Bias']()
         self.assertTrue(isinstance(bias, metrics.Bias))
 
     def test_valid_metric_load(self):
-        metric_objs = backend.processing._load_metrics(['Bias', 'TemporalStdDev'])
+        metric_objs = bp._load_metrics(['Bias', 'TemporalStdDev'])
         self.assertTrue(isinstance(metric_objs[0], metrics.Bias))
         self.assertTrue(isinstance(metric_objs[1], metrics.TemporalStdDev))
 
     def test_invalid_metric_load(self):
-        self.assertRaises(ValueError, backend.processing._load_metrics, ['AAA'])
+        self.assertRaises(ValueError, bp._load_metrics, ['AAA'])
+
+class TestSpatialRebinHelpers(unittest.TestCase):
+    def test_latlon_bin_helper(self):
+        eval_bounds = {
+            'lat_min': -57.2,
+            'lat_max': 58.2,
+            'lon_min': -45.3,
+            'lon_max': 39.2,
+        }
+        lat_step = 1
+        lon_step = 1
+
+        lats = numpy.arange(eval_bounds['lat_min'], eval_bounds['lat_max'])
+        lons = numpy.arange(eval_bounds['lon_min'], eval_bounds['lon_max'])
+
+        new_lats, new_lons = bp._calculate_new_latlon_bins(eval_bounds, lat_step, lon_step)



Mime
View raw message