I have created a xarray dataarray using the xarray concat command. This has resulted in a dataarray with name __xarray_dataarray_variable__
. However, I cannot seem to rename it using the rename
command. Is there some other way to rename it?
I tried this:
da.rename({'__xarray_dataarray_variable__': 'new'})
but I get this error: *** ValueError: cannot rename '__xarray_dataarray_variable__' because it is not a variable or dimension in this dataset
This is what the dataarray looks like:
<xarray.DataArray (time: 2, band: 1, y: 2334, x: 4258)>
dask.array<shape=(2, 1, 2334, 4258), dtype=float32, chunksize=(1, 1, 2334, 4258)>
Coordinates:
* band (band) int32 1
* y (y) float64 4.406e+06 4.406e+06 4.406e+06 4.406e+06 4.406e+06 ...
* x (x) float64 1.125e+05 1.126e+05 1.127e+05 1.128e+05 1.129e+05 ...
* time (time) datetime64[ns] 2005-12-31 2006-12-31
Attributes:
transform: (90.0, 0.0, 112500.0, 0.0, -90.0, 4406400.0, 0.0, 0.0, 1.0)
crs: +ellps=GRS80 +no_defs +proj=utm +towgs84=0,0,0,0,0,0,0 +unit...
res: (90.0, 90.0)
is_tiled: 1
nodatavals: (-9999.0,)
From http://xarray.pydata.org/en/stable/generated/xarray.DataArray.to_netcdf.html, Only xarray.Dataset objects can be written to netCDF files, so the xarray.DataArray is converted to a xarray.Dataset object containing a single variable. If the DataArray has no name, or if the name is the same as a co-ordinate name, then it is given the name ‘xarray_dataarray_variable’.