climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [1/2] climate git commit: CLIMATE-609 - Add data source flag to dataset origin information
Date Thu, 19 Mar 2015 18:04:03 GMT
Repository: climate
Updated Branches:
  refs/heads/master 44d8d29f9 -> 9a2be2e84


CLIMATE-609 - Add data source flag to dataset origin information

- Add a 'source' flag to dataset origin information when loaded from a
  data_source. This is set to 'local', 'dap', 'esgf', or 'rcmed'
  depending on the data_source used.
- Update data_source tests to take new source flag into account.


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

Branch: refs/heads/master
Commit: 119834915abafae23ed77d152d8dd7be97fac2f1
Parents: 44d8d29
Author: Michael Joyce <joyce@apache.org>
Authored: Thu Mar 19 08:29:00 2015 -0700
Committer: Michael Joyce <joyce@apache.org>
Committed: Thu Mar 19 08:29:00 2015 -0700

----------------------------------------------------------------------
 ocw/data_source/dap.py   | 5 ++++-
 ocw/data_source/esgf.py  | 6 +++++-
 ocw/data_source/local.py | 1 +
 ocw/data_source/rcmed.py | 1 +
 ocw/tests/test_dap.py    | 1 +
 ocw/tests/test_local.py  | 5 +++--
 ocw/tests/test_rcmed.py  | 2 ++
 7 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/11983491/ocw/data_source/dap.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/dap.py b/ocw/data_source/dap.py
index 3012c27..f5f9b40 100644
--- a/ocw/data_source/dap.py
+++ b/ocw/data_source/dap.py
@@ -59,7 +59,10 @@ def load(url, variable, name=''):
     lons = np.array(dataset[lon][:])
     values = np.array(dataset[:])
 
-    origin = {'url': url}
+    origin = {
+        'source': 'dap',
+        'url': url
+    }
 
     return Dataset(lats, lons, times, values, variable,
                    name=name, origin=origin)

http://git-wip-us.apache.org/repos/asf/climate/blob/11983491/ocw/data_source/esgf.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/esgf.py b/ocw/data_source/esgf.py
index b7a9f25..fd773d7 100644
--- a/ocw/data_source/esgf.py
+++ b/ocw/data_source/esgf.py
@@ -84,7 +84,11 @@ def load_dataset(dataset_id,
                                         name=name,
                                         elevation_index=elevation_index))
 
-    origin = {'dataset_id': dataset_id, 'variable': variable}
+    origin = {
+        'source': 'esgf',
+        'dataset_id': dataset_id,
+        'variable': variable
+    }
     for ds in datasets:
         ds.origin = origin
 

http://git-wip-us.apache.org/repos/asf/climate/blob/11983491/ocw/data_source/local.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py
index f2f0388..2de03f5 100644
--- a/ocw/data_source/local.py
+++ b/ocw/data_source/local.py
@@ -212,6 +212,7 @@ def load_file(file_path,
             values = values [:,:,:,elevation_index]
 
     origin = {
+        'source': 'local',
         'path': file_path,
         'lat_name': lat_name,
         'lon_name': lon_name,

http://git-wip-us.apache.org/repos/asf/climate/blob/11983491/ocw/data_source/rcmed.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/rcmed.py b/ocw/data_source/rcmed.py
index ef0dc78..baeb326 100644
--- a/ocw/data_source/rcmed.py
+++ b/ocw/data_source/rcmed.py
@@ -357,6 +357,7 @@ def parameter_dataset(dataset_id, parameter_id, min_lat, max_lat, min_lon,
max_l
     values = _make_mask_array(values, parameter_id, parameters_metadata)
 
     origin = {
+        'source': 'rcmed',
         'dataset_id': dataset_id,
         'parameter_id': parameter_id
     }

http://git-wip-us.apache.org/repos/asf/climate/blob/11983491/ocw/tests/test_dap.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dap.py b/ocw/tests/test_dap.py
index c608953..db0d4c0 100644
--- a/ocw/tests/test_dap.py
+++ b/ocw/tests/test_dap.py
@@ -47,6 +47,7 @@ class TestDap(unittest.TestCase):
         self.assertEquals(self.dataset.name, self.name)
 
     def test_dataset_origin(self):
+        self.assertEquals(self.dataset.origin['source'], 'dap')
         self.assertEquals(self.dataset.origin['url'], self.url)
 
 if __name__ == '__main__':

http://git-wip-us.apache.org/repos/asf/climate/blob/11983491/ocw/tests/test_local.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_local.py b/ocw/tests/test_local.py
index 254c7f7..a9e1a71 100644
--- a/ocw/tests/test_local.py
+++ b/ocw/tests/test_local.py
@@ -71,9 +71,10 @@ class test_load_file(unittest.TestCase):
 
     def test_dataset_origin(self):
         ds = local.load_file(self.file_path, 'value', elevation_index=1)
-        expected_keys = set(['path', 'lat_name', 'lon_name',
-                         'time_name', 'elevation_index' ])
+        expected_keys = set(['source', 'path', 'lat_name', 'lon_name',
+                             'time_name', 'elevation_index' ])
         self.assertEqual(set(ds.origin.keys()), expected_keys)
+        self.assertEqual(ds.origin['source'], 'local')
 
 
 class test_get_netcdf_variable_names(unittest.TestCase):

http://git-wip-us.apache.org/repos/asf/climate/blob/11983491/ocw/tests/test_rcmed.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_rcmed.py b/ocw/tests/test_rcmed.py
index e59dbae..58c38bc 100644
--- a/ocw/tests/test_rcmed.py
+++ b/ocw/tests/test_rcmed.py
@@ -119,6 +119,8 @@ class test_rcmed(unittest.TestCase, CustomAssertions):
                                      self.start_time,
                                      self.end_time,
                                      name='foo')
+
+        self.assertEquals(ds.origin['source'], 'rcmed')
         self.assertEquals(ds.origin['dataset_id'], self.dataset_id)
         self.assertEquals(ds.origin['parameter_id'], self.parameter_id)
 


Mime
View raw message