问题描述
import pandas as pd
from random import sample
stations = pd.read_csv('.../KONYA_LONG_LAT_4digit.csv',encoding='iso-8859-1',index_col=None)
#station = stations.sample(n=1) # We can randomly choose a station
station=stations[stations['stname'] == 308] # We have chosen a station for consistency
station
import xarray as xr
ds = xr.open_dataset('.../isimizeyarar.nc')
ds.time
clim = xr.open_dataset('.../clim_151118.nc')
clim
ds.vsw.shape
# extract data for selected point in netcdf file by LISFLOOD coordinates
dsloc = ds.sel(x=station.lat.values,y=station.long.values,method='nearest')
climloc = clim.sel(x=station.lat.values,method='nearest')
import numpy as np
base=dsloc.time.values
time=np.array([base+np.timedelta64(step) for step in dsloc.step.values])
df = pd.DataFrame({
# 'Historical_times': np.array(climloc.time.values + np.timedelta64(climloc.step.values)),'Historical_times': np.array(climloc.time.values),# Historical Times from the climatology File
'Historical': climloc.dis24.values}) # [:,-1,-1]#,# Historical Data from the climatology file
# 'timestep': time}) # Time data from the Ensemble Data file as Times (Base + Delta("STEP"))
df.rename(columns={'Historical': stnam},inplace=True)
if stnam == stations.stname[1]:
dfyear = pd.concat([dfyear,df],axis=1,sort=False)
print(stnam)
else:
df = df.drop(columns=['Historical_times'])
dfyear = pd.concat([dfyear,sort=False)
dfall = dfall.append(dfyear,ignore_index=True)
给出异常:数据必须是一维错误。我怎么解决这个问题?您可以从这里下载 .nc 和 .csv 文件; https://wetransfer.com/downloads/37b3525e4573920ac5b0477fd7e9691120210331124543/080530e8f9c1fd402ca58572d018017d20210331124628/948323
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)