Reputation: 874
I'm opening netcdf output produced by MITgcm using open_dataset. However, one of the coordinate variables in the DataSet is coming back as the whole DataSet rather than a DataArray.
The process seems to work normally:
import xarray as xr
ds = xr.open_dataset('state.0000000000.nc')
<xarray.Dataset>
Dimensions: (T: 8, X: 16, Xp1: 17, Y: 16, Yp1: 17, Zld000100: 100, Zmd000100: 100)
Coordinates:
* T (T) float64 1.296e+05 3.888e+05 6.48e+05
* X (X) float64 500.0 1.5e+03 2.5e+03
* Y (Y) float64 4.85e+04 4.95e+04
* Xp1 (Xp1) float64 0.0 1e+03 2e+03
* Yp1 (Yp1) float64 4.8e+04 4.9e+04
* Zmd000100 (Zmd000100) int64 0 1 2
* Zld000100 (Zld000100) int64 0 1 2
Data variables:
iter (T) int32 1296 3888
diag_levels (Zmd000100) float64 1.0
(where I've omitted some of the details of the output). However, when I check the type of the T coordinate, it comes back as a DataSet
type(ds.T)
# xarray.core.dataset.Dataset
When I check the type of any of the other coordinates/variables, they come back as
xarray.core.dataarray.DataArray
The ds.T coordinate appears to be the same object as ds. For example, if I add a variable to ds, it also is added to ds.T. It also seems to be infinitely recursive, such that ds.T.T.T is the same object for example.
In the underlying netcdf files, the only difference between the T dimension and the others is that T has unlimited dimension.
T = UNLIMITED ; // (4 currently)
However, I've created a dummy netcdf file that has an unlimited dimension and the problem didn't recur.
I've tried it with decode_times, decode_cf and decide_coords=False with no difference.
I'm using xarray version 0.8.2, running python 2.7.12.
Upvotes: 0
Views: 885
Reputation: 9593
You need to access the variable T
like ds['T']
. ds.T
does a transpose. See also:
How to read a variable called "T" with xarray?
Upvotes: 3