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 2015/03/05 18:15:56 UTC

[1/9] climate git commit: CLIMATE-593 - Add ASF headers to config parser

Repository: climate
Updated Branches:
  refs/heads/master 6e73c8a51 -> 511a7e175


CLIMATE-593 - Add ASF headers to config parser


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

Branch: refs/heads/master
Commit: 4871e6d74f0ae57c302121141127bdeb33f67c45
Parents: 6e73c8a
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Feb 27 10:01:00 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Feb 27 10:01:00 2015 -0800

----------------------------------------------------------------------
 ocw-config-runner/configuration_parsing.py        | 17 +++++++++++++++++
 ocw-config-runner/evaluation_creation.py          | 17 +++++++++++++++++
 ocw-config-runner/plot_generation.py              | 17 +++++++++++++++++
 ocw-config-runner/tests/test_config_parsing.py    | 17 +++++++++++++++++
 .../tests/test_evaluation_creation.py             | 18 +++++++++++++++++-
 5 files changed, 85 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/4871e6d7/ocw-config-runner/configuration_parsing.py
----------------------------------------------------------------------
diff --git a/ocw-config-runner/configuration_parsing.py b/ocw-config-runner/configuration_parsing.py
index 600d7ac..43285f7 100644
--- a/ocw-config-runner/configuration_parsing.py
+++ b/ocw-config-runner/configuration_parsing.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import logging
 import re
 import sys

http://git-wip-us.apache.org/repos/asf/climate/blob/4871e6d7/ocw-config-runner/evaluation_creation.py
----------------------------------------------------------------------
diff --git a/ocw-config-runner/evaluation_creation.py b/ocw-config-runner/evaluation_creation.py
index 66794d9..3502186 100644
--- a/ocw-config-runner/evaluation_creation.py
+++ b/ocw-config-runner/evaluation_creation.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import dateutil.parser
 from datetime import timedelta
 import logging

http://git-wip-us.apache.org/repos/asf/climate/blob/4871e6d7/ocw-config-runner/plot_generation.py
----------------------------------------------------------------------
diff --git a/ocw-config-runner/plot_generation.py b/ocw-config-runner/plot_generation.py
index c802af2..40c5718 100644
--- a/ocw-config-runner/plot_generation.py
+++ b/ocw-config-runner/plot_generation.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 import logging
 
 import ocw.plotter as plots

http://git-wip-us.apache.org/repos/asf/climate/blob/4871e6d7/ocw-config-runner/tests/test_config_parsing.py
----------------------------------------------------------------------
diff --git a/ocw-config-runner/tests/test_config_parsing.py b/ocw-config-runner/tests/test_config_parsing.py
index d51bf43..36ef9be 100644
--- a/ocw-config-runner/tests/test_config_parsing.py
+++ b/ocw-config-runner/tests/test_config_parsing.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 from mock import patch
 import unittest
 

http://git-wip-us.apache.org/repos/asf/climate/blob/4871e6d7/ocw-config-runner/tests/test_evaluation_creation.py
----------------------------------------------------------------------
diff --git a/ocw-config-runner/tests/test_evaluation_creation.py b/ocw-config-runner/tests/test_evaluation_creation.py
index 6fc79f8..41f998e 100644
--- a/ocw-config-runner/tests/test_evaluation_creation.py
+++ b/ocw-config-runner/tests/test_evaluation_creation.py
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 from mock import patch
 import unittest
 
@@ -6,7 +23,6 @@ import ocw.metrics
 
 import yaml
 
-
 class TestMetricLoad(unittest.TestCase):
     def test_valid_metric_load(self):
         config = yaml.load("""


[3/9] climate git commit: CLIMATE-594 - Add tests for Dataset attribute changes

Posted by jo...@apache.org.
CLIMATE-594 - Add tests for Dataset attribute changes

- Add attribute test for Dataset 'name' since this was missing.
- Add test for new Dataset 'origin' attribute.


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

Branch: refs/heads/master
Commit: b02d74c6a07e6225502ee1acc80d5dd1dad9d431
Parents: d4f2b50
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Feb 27 10:46:27 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Feb 27 10:46:27 2015 -0800

----------------------------------------------------------------------
 ocw/tests/test_dataset.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/b02d74c6/ocw/tests/test_dataset.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dataset.py b/ocw/tests/test_dataset.py
index 94d7740..3edbe83 100644
--- a/ocw/tests/test_dataset.py
+++ b/ocw/tests/test_dataset.py
@@ -30,8 +30,11 @@ class TestDatasetAttributes(unittest.TestCase):
         flat_array = np.array(range(300))
         self.value = flat_array.reshape(12, 5, 5)
         self.variable = 'prec'
+        self.name = 'foo'
+        self.origin = {'path': '/a/fake/file/path'}
         self.test_dataset = Dataset(self.lat, self.lon, self.time, 
-                                    self.value, self.variable)
+                                    self.value, self.variable,
+                                    self.name, self.origin)
 
     def test_lats(self):
         self.assertItemsEqual(self.test_dataset.lats, self.lat)
@@ -48,6 +51,12 @@ class TestDatasetAttributes(unittest.TestCase):
     def test_variable(self):
         self.assertEqual(self.test_dataset.variable, self.variable)
 
+    def test_name(self):
+        self.assertEqual(self.test_dataset.name, self.name)
+
+    def test_origin(self):
+        self.assertEqual(self.test_dataset.origin, self.origin)
+
 class TestInvalidDatasetInit(unittest.TestCase):
     def setUp(self):
         self.lat = np.array([10, 12, 14, 16, 18])


[2/9] climate git commit: CLIMATE-594 - Add 'origin' attribute to Dataset class

Posted by jo...@apache.org.
CLIMATE-594 - Add 'origin' attribute to Dataset class

- Add 'origin' attribute to the Dataset class for tracking where a
  dataset was loaded from. Future commits will update the data sources
  so that this attribute is set.


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

Branch: refs/heads/master
Commit: d4f2b50ff1c6531e6c4589aa72c6c04916f7911a
Parents: 6e73c8a
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Feb 27 10:39:53 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Feb 27 10:39:53 2015 -0800

----------------------------------------------------------------------
 ocw/dataset.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/d4f2b50f/ocw/dataset.py
----------------------------------------------------------------------
diff --git a/ocw/dataset.py b/ocw/dataset.py
index 1d4b2d8..3d2cc48 100644
--- a/ocw/dataset.py
+++ b/ocw/dataset.py
@@ -35,7 +35,8 @@ logger = logging.getLogger(__name__)
 class Dataset:
     '''Container for a dataset's attributes and data.'''
 
-    def __init__(self, lats, lons, times, values, variable=None, name=""):
+    def __init__(self, lats, lons, times, values, variable=None, name="",
+                 origin=None):
         '''Default Dataset constructor
 
         :param lats: One dimensional numpy array of unique latitude values.
@@ -58,6 +59,10 @@ class Dataset:
         :param name: An optional string name for the Dataset.
         :type name: :mod:`string`
 
+        :param origin: An optional object used to specify information on where
+            this dataset was loaded from.
+        :type origin: :class:`dict`
+
         :raises: ValueError
         '''
         self._validate_inputs(lats, lons, times, values)
@@ -69,6 +74,7 @@ class Dataset:
         self.values = values
         self.variable = variable
         self.name = name
+        self.origin = origin
 
     def spatial_boundaries(self):
         '''Calculate the spatial boundaries.


[4/9] climate git commit: CLIMATE-594 - Update DAP data source with origin info

Posted by jo...@apache.org.
CLIMATE-594 - Update DAP data source with origin info

- Add origin information when loading a dataset with the DAP data
  source.
- Minor updates to previous DAP test.


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

Branch: refs/heads/master
Commit: e716ad95d100a29b929453deae3fd3a86495ae30
Parents: b02d74c
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Feb 27 11:40:08 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Feb 27 11:40:08 2015 -0800

----------------------------------------------------------------------
 ocw/data_source/dap.py | 5 ++++-
 ocw/tests/test_dap.py  | 9 +++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/e716ad95/ocw/data_source/dap.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/dap.py b/ocw/data_source/dap.py
index 3694410..3012c27 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[:])
 
-    return Dataset(lats, lons, times, values, variable, name=name)
+    origin = {'url': url}
+
+    return Dataset(lats, lons, times, values, variable,
+                   name=name, origin=origin)
 
 def _convert_times_to_datetime(time):
     '''Convert the OpenDAP time object's values to datetime objects

http://git-wip-us.apache.org/repos/asf/climate/blob/e716ad95/ocw/tests/test_dap.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_dap.py b/ocw/tests/test_dap.py
index be01f6c..c608953 100644
--- a/ocw/tests/test_dap.py
+++ b/ocw/tests/test_dap.py
@@ -23,7 +23,9 @@ import datetime as dt
 class TestDap(unittest.TestCase):
     @classmethod
     def setup_class(self):
-        self.dataset = dap.load('http://test.opendap.org/dap/data/nc/sst.mnmean.nc.gz', 'sst', name='foo')
+        self.url = 'http://test.opendap.org/dap/data/nc/sst.mnmean.nc.gz'
+        self.name = 'foo'
+        self.dataset = dap.load(self.url, 'sst', name=self.name)
 
     def test_dataset_is_returned(self):
         self.assertTrue(isinstance(self.dataset, Dataset))
@@ -42,7 +44,10 @@ class TestDap(unittest.TestCase):
         self.assertTrue(start == self.dataset.times[0])
 
     def test_custom_dataset_name(self):
-        self.assertEquals(self.dataset.name, 'foo')
+        self.assertEquals(self.dataset.name, self.name)
+
+    def test_dataset_origin(self):
+        self.assertEquals(self.dataset.origin['url'], self.url)
 
 if __name__ == '__main__':
     unittest.main()


[9/9] climate git commit: Resolve CLIMATE-594. Resolve PR #161.

Posted by jo...@apache.org.
Resolve CLIMATE-594. Resolve PR #161.


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

Branch: refs/heads/master
Commit: 511a7e175d7978cff283888a7f21b7e5c86c2042
Parents: 65cb1e2 a708478
Author: Michael Joyce <jo...@apache.org>
Authored: Thu Mar 5 09:15:17 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Thu Mar 5 09:15:17 2015 -0800

----------------------------------------------------------------------
 ocw/data_source/dap.py    |  5 ++++-
 ocw/data_source/esgf.py   |  4 ++++
 ocw/data_source/local.py  | 11 ++++++++++-
 ocw/data_source/rcmed.py  | 13 ++++++++++++-
 ocw/dataset.py            |  8 +++++++-
 ocw/tests/test_dap.py     |  9 +++++++--
 ocw/tests/test_dataset.py | 11 ++++++++++-
 ocw/tests/test_local.py   |  7 +++++++
 ocw/tests/test_rcmed.py   | 14 ++++++++++++++
 9 files changed, 75 insertions(+), 7 deletions(-)
----------------------------------------------------------------------



[5/9] climate git commit: CLIMATE-594 - Update local data load with origin info

Posted by jo...@apache.org.
CLIMATE-594 - Update local data load with origin info


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

Branch: refs/heads/master
Commit: 25b7267faaa6dfd49afefa34b79ffdd0f6c68085
Parents: e716ad9
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Feb 27 12:18:37 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Feb 27 12:18:37 2015 -0800

----------------------------------------------------------------------
 ocw/data_source/local.py | 11 ++++++++++-
 ocw/tests/test_local.py  |  7 +++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/25b7267f/ocw/data_source/local.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py
index c6405a9..2b56d69 100644
--- a/ocw/data_source/local.py
+++ b/ocw/data_source/local.py
@@ -206,4 +206,13 @@ def load_file(file_path,
         else:
             values = values [:,:,:,elevation_index]
 
-    return Dataset(lats, lons, times, values, variable_name, name=name)
+    origin = {
+        'path': file_path,
+        'lat_name': lat_name,
+        'lon_name': lon_name,
+        'time_name': time_name
+    }
+    if elevation_index != 0: origin['elevation_index'] = elevation_index
+
+    return Dataset(lats, lons, times, values, variable_name,
+                   name=name, origin=origin)

http://git-wip-us.apache.org/repos/asf/climate/blob/25b7267f/ocw/tests/test_local.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_local.py b/ocw/tests/test_local.py
index 27f4245..6d67896 100644
--- a/ocw/tests/test_local.py
+++ b/ocw/tests/test_local.py
@@ -69,6 +69,13 @@ class test_load_file(unittest.TestCase):
         ds = local.load_file(self.file_path, 'value', name='foo')
         self.assertEqual(ds.name, 'foo')
 
+    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' ])
+        self.assertEqual(set(ds.origin.keys()), expected_keys)
+
+
 class test_get_netcdf_variable_names(unittest.TestCase):
     file_path = "http://zipper.jpl.nasa.gov/dist/"
     test_model = "AFRICA_KNMI-RACMO2.2b_CTL_ERAINT_MM_50km_1989-2008_tasmax.nc"


[7/9] climate git commit: CLIMATE-594 - Add origin info to ESGF data source

Posted by jo...@apache.org.
CLIMATE-594 - Add origin info to ESGF data source


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

Branch: refs/heads/master
Commit: a708478beb9126175ca5ce297b9ab781e33ad175
Parents: 7f1f033
Author: Michael Joyce <jo...@apache.org>
Authored: Fri Feb 27 12:41:21 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Fri Feb 27 12:41:21 2015 -0800

----------------------------------------------------------------------
 ocw/data_source/esgf.py | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/a708478b/ocw/data_source/esgf.py
----------------------------------------------------------------------
diff --git a/ocw/data_source/esgf.py b/ocw/data_source/esgf.py
index c5ed03a..b7a9f25 100644
--- a/ocw/data_source/esgf.py
+++ b/ocw/data_source/esgf.py
@@ -84,6 +84,10 @@ def load_dataset(dataset_id,
                                         name=name,
                                         elevation_index=elevation_index))
 
+    origin = {'dataset_id': dataset_id, 'variable': variable}
+    for ds in datasets:
+        ds.origin = origin
+
     return datasets
 
 def _get_file_download_data(dataset_id, variable, url=DEFAULT_ESGF_SEARCH):


[8/9] climate git commit: Resolve CLIMATE-593. Merge PR #160.

Posted by jo...@apache.org.
Resolve CLIMATE-593. Merge PR #160.


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

Branch: refs/heads/master
Commit: 65cb1e23cefb9158756bfb3684a1f032550bf0da
Parents: 6e73c8a 4871e6d
Author: Michael Joyce <jo...@apache.org>
Authored: Thu Mar 5 09:14:34 2015 -0800
Committer: Michael Joyce <jo...@apache.org>
Committed: Thu Mar 5 09:14:34 2015 -0800

----------------------------------------------------------------------
 ocw-config-runner/configuration_parsing.py        | 17 +++++++++++++++++
 ocw-config-runner/evaluation_creation.py          | 17 +++++++++++++++++
 ocw-config-runner/plot_generation.py              | 17 +++++++++++++++++
 ocw-config-runner/tests/test_config_parsing.py    | 17 +++++++++++++++++
 .../tests/test_evaluation_creation.py             | 18 +++++++++++++++++-
 5 files changed, 85 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[6/9] climate git commit: CLIMATE-594 - Add origin information to rcmed data source

Posted by jo...@apache.org.
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 <jo...@apache.org>
Authored: Fri Feb 27 12:32:49 2015 -0800
Committer: Michael Joyce <jo...@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()