我有一个从一堆文件连接起来的xarray数据集。
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
averageInstantRunoff (time, hru) float64 9.241e-05 9.241e-05 ... 2.717e-09
nSnow (time, hru) int32 dask.array
nSoil (time, hru) int32 dask.array
nLayers (time, hru) int32 dask.array
当我试图导出这个
ds.to_netcdf('test.nc')
我收到此错误消息:
TypeError: cannot perform __truediv__ with this index type:
不知道是什么问题。
这是生成
ds
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')