我有一个xarray数据集,它是从一堆文件连接起来的
<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)>
当我试图导出这个ds.to_netcdf('test.nc')
我收到以下错误消息:
TypeError: cannot perform __truediv__ with this index type: <class 'pandas.core.indexes.datetimes.DatetimeIndex'>
不知道是什么问题
这是生成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')
将Pandas-to-Numpy更新为最新版本
相关问题 更多 >
编程相关推荐