climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [6/9] climate git commit: CLIMATE-594 - Add origin information to rcmed data source
Date Thu, 05 Mar 2015 17:16:01 GMT
CLIMATE-594 - Add origin information to rcmed data source


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

Branch: refs/heads/master
Commit: 7f1f033f32f9c60ba8731cee27dae2b9a94246d7
Parents: 25b7267
Author: Michael Joyce <joyce@apache.org>
Authored: Fri Feb 27 12:32:49 2015 -0800
Committer: Michael Joyce <joyce@apache.org>
Committed: Fri Feb 27 12:32:49 2015 -0800

----------------------------------------------------------------------
 ocw/data_source/rcmed.py | 13 ++++++++++++-
 ocw/tests/test_rcmed.py  | 14 ++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/7f1f033f/ocw/data_source/rcmed.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/rcmed.py b/ocw/data_source/rcmed.py
index d184078..4733a45 100644
--- a/ocw/data_source/rcmed.py
+++ b/ocw/data_source/rcmed.py
@@ -355,5 +355,16 @@ def parameter_dataset(dataset_id, parameter_id, min_lat, max_lat, min_lon,
max_l
     unique_times = _calculate_time(unique_lats_lons_times[2], time_step)
     values = _reshape_values(values, unique_lats_lons_times)
     values = _make_mask_array(values, parameter_id, parameters_metadata)
+
+    origin = {
+        'dataset_id': dataset_id,
+        'parameter_id': parameter_id
+    }
     
-    return Dataset(unique_lats_lons_times[0], unique_lats_lons_times[1], unique_times, values,
parameter_name, name=name)
+    return Dataset(unique_lats_lons_times[0],
+                   unique_lats_lons_times[1],
+                   unique_times,
+                   values,
+                   parameter_name,
+                   name=name,
+                   origin=origin)

http://git-wip-us.apache.org/repos/asf/climate/blob/7f1f033f/ocw/tests/test_rcmed.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_rcmed.py b/ocw/tests/test_rcmed.py
index 6c882f4..e59dbae 100644
--- a/ocw/tests/test_rcmed.py
+++ b/ocw/tests/test_rcmed.py
@@ -108,5 +108,19 @@ class test_rcmed(unittest.TestCase, CustomAssertions):
         ds = rcmed.parameter_dataset(self.dataset_id, self.parameter_id, self.min_lat, self.max_lat,
self.min_lon, self.max_lon, self.start_time, self.end_time, name='foo')
         self.assertEquals(ds.name, 'foo')
 
+    def test_dataset_origin(self):
+        rcmed.urllib2.urlopen = self.return_text
+        ds = rcmed.parameter_dataset(self.dataset_id,
+                                     self.parameter_id,
+                                     self.min_lat,
+                                     self.max_lat,
+                                     self.min_lon,
+                                     self.max_lon,
+                                     self.start_time,
+                                     self.end_time,
+                                     name='foo')
+        self.assertEquals(ds.origin['dataset_id'], self.dataset_id)
+        self.assertEquals(ds.origin['parameter_id'], self.parameter_id)
+
 if __name__ == '__main__':
     unittest.main()


Mime
View raw message