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 <[email protected]> Authored: Fri Feb 27 11:40:08 2015 -0800 Committer: Michael Joyce <[email protected]> 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()
