コード例 #1
0
 def test_coordinates(self):
     # specify dimension keys
     node = Dataset(source=self.source, time_key="day")
     nc = node.coordinates
     assert nc.dims == ("time", "lat", "lon")
     np.testing.assert_array_equal(nc["lat"].coordinates, self.lat)
     np.testing.assert_array_equal(nc["lon"].coordinates, self.lon)
     np.testing.assert_array_equal(nc["time"].coordinates, self.time)
     node.close_dataset()
コード例 #2
0
    def test_get_data(self):
        # specify data key
        node = Dataset(source=self.source, time_key="day", data_key="data")
        out = node.eval(node.coordinates)
        np.testing.assert_array_equal(out, self.data)
        node.close_dataset()

        node = Dataset(source=self.source, time_key="day", data_key="other")
        out = node.eval(node.coordinates)
        np.testing.assert_array_equal(out, self.other)
        node.close_dataset()
コード例 #3
0
ファイル: test_dataset.py プロジェクト: creare-com/podpac
    def test_extra_dimension_selection(self):
        # default
        node = Dataset(source=self.source, time_key="day", data_key="data")
        assert node.selection is None

        # treat day as an "extra" dimension, and select the second day
        node = Dataset(source=self.source,
                       data_key="data",
                       selection={"day": 1})
        assert node.coordinates.dims == ("lat", "lon")
        out = node.eval(node.coordinates)
        np.testing.assert_array_equal(out, self.data[1])
コード例 #4
0
 def test_extra_dim(self):
     # default
     node = Dataset(source=self.source)
     assert node.extra_dim is None
コード例 #5
0
    def test_get_data_multiple(self):
        node = Dataset(source=self.source,
                       time_key="day",
                       data_key=["data", "other"])
        out = node.eval(node.coordinates)
        assert out.dims == ("time", "lat", "lon", "output")
        np.testing.assert_array_equal(out["output"], ["data", "other"])
        np.testing.assert_array_equal(out.sel(output="data"), self.data)
        np.testing.assert_array_equal(out.sel(output="other"), self.other)
        node.close_dataset()

        # single
        node = Dataset(source=self.source, time_key="day", data_key=["other"])
        out = node.eval(node.coordinates)
        assert out.dims == ("time", "lat", "lon", "output")
        np.testing.assert_array_equal(out["output"], ["other"])
        np.testing.assert_array_equal(out.sel(output="other"), self.other)
        node.close_dataset()

        # alternate output names
        node = Dataset(source=self.source,
                       time_key="day",
                       data_key=["data", "other"],
                       outputs=["a", "b"])
        out = node.eval(node.coordinates)
        assert out.dims == ("time", "lat", "lon", "output")
        np.testing.assert_array_equal(out["output"], ["a", "b"])
        np.testing.assert_array_equal(out.sel(output="a"), self.data)
        np.testing.assert_array_equal(out.sel(output="b"), self.other)
        node.close_dataset()

        # default
        node = Dataset(source=self.source, time_key="day")
        out = node.eval(node.coordinates)
        assert out.dims == ("time", "lat", "lon", "output")
        np.testing.assert_array_equal(out["output"], ["data", "other"])
        np.testing.assert_array_equal(out.sel(output="data"), self.data)
        np.testing.assert_array_equal(out.sel(output="other"), self.other)
        node.close_dataset()
コード例 #6
0
 def test_available_data_keys(self):
     node = Dataset(source=self.source, time_key="day")
     assert node.available_data_keys == ["data", "other"]
コード例 #7
0
 def test_dims(self):
     node = Dataset(source=self.source, time_key="day")
     assert node.dims == ["time", "lat", "lon"]
コード例 #8
0
 def test_init_and_close(self):
     node = Dataset(source=self.source, time_key="day")
     node.close_dataset()
コード例 #9
0
ファイル: test_dataset.py プロジェクト: creare-com/podpac
 def test_get_data_array_indexing(self):
     node = Dataset(source=self.source, time_key="day", data_key="data")
     out = node.eval(node.coordinates[:, [0, 2]])
     np.testing.assert_array_equal(out, self.data[:, [0, 2]])
     node.close_dataset()