def test_eof_16(self): data = np.asarray(self._sample_data_eof[0]) data = np.transpose(data, axes=(2, 1, 0)) dims = [f"dim_{i}" for i in range(data.ndim)] dims[0] = 'time' data = xr.DataArray(data, dims=dims, attrs={ "prop1": "prop1", "prop2": 2, }) results = eofunc_eofs(data, 1, meta=True) eof = results.data attrs = results.attrs nt.assert_equal(self.expected_output.shape, results.shape) nt.assert_array_almost_equal(self.expected_output, eof, 5) nt.assert_equal(self._num_attrs + 2, len(attrs)) nt.assert_almost_equal(self.expected_eigen_val_time_dim_2, attrs['eigenvalues'].values[0], 5) nt.assert_equal(True, ("prop1" in attrs)) nt.assert_equal(True, ("prop2" in attrs)) nt.assert_equal("prop1", attrs["prop1"]) nt.assert_equal(2, attrs["prop2"])
def test_eof_00(self): data = self._sample_data_eof[0] results = eofunc_eofs(data, neofs=1, time_dim=2) eof = results.data attrs = results.attrs nt.assert_equal(self.expected_output.shape, results.shape) nt.assert_array_almost_equal(self.expected_output, eof, 5) nt.assert_equal(self._num_attrs, len(attrs)) nt.assert_almost_equal(self.expected_eigen_val_time_dim_2, attrs['eigenvalues'].values[0], 5)