-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Code Sample, a copy-pastable example if possible
import numpy as np
import xarray as xr
import glob, os
NCDIR = './output/out/'
finalfile = 'summaout.nc'
outfilelist = glob.glob((NCDIR+'/*{}*.nc').format('basin_*timestep'))
ds=xr.open_mfdataset(outfilelist, concat_dim='hru')
replace = ds['pptrate']
runoff = ds['averageInstantRunoff'].values
runoff = np.squeeze(runoffdata, axis=2)
runoff = runoff.transpose()
replace.values = runoff
ncconvert = ds.drop('averageInstantRunoff')
runoffarray = xr.DataArray(runoff, dims=['time','hru'])
ds['averageInstantRunoff'] = runoffarray
ds.to_netcdf('test.nc')
Problem description
This is ds
just before export.
<xarray.Dataset>
Dimensions: (hru: 17, time: 233)
Coordinates:
* hru (hru) int64 9 17 11 8 3 2 6 4 7 12 1 13 10 16 15 5 14
* time (time) datetime64[ns] 2010-01-01 ... 2010-01-30
Data variables:
pptrate (time, hru) float64 9.241e-05 9.241e-05 ... 2.717e-09
hruId (hru) int64 dask.array<shape=(17,), chunksize=(1,)>
averageInstantRunoff (time, hru) float64 9.241e-05 9.241e-05 ... 2.717e-09
nSnow (time, hru) int32 dask.array<shape=(233, 17), chunksize=(233, 1)>
nSoil (time, hru) int32 dask.array<shape=(233, 17), chunksize=(233, 1)>
nLayers (time, hru) int32 dask.array<shape=(233, 17), chunksize=(233, 1)>
I get this error message:
TypeError: cannot perform __truediv__ with this index type: <class 'pandas.core.indexes.datetimes.DatetimeIndex'>
Expected Output
netCDF
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 3.12.62-60.64.8-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
xarray: 0.11.0
pandas: 0.21.0
numpy: 1.13.3
scipy: 1.0.0
netCDF4: 1.4.0
h5netcdf: 0.5.0
h5py: 2.7.1
Nio: None
zarr: None
cftime: 1.0.0
PseudonetCDF: None
rasterio: None
iris: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.19.3
distributed: 1.23.3
matplotlib: 2.1.2
cartopy: 0.15.1
seaborn: 0.9.0
setuptools: 36.7.2
pip: 18.1
conda: 4.5.11
pytest: 3.2.5
IPython: 6.2.1
sphinx: 1.6.5