微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

netcdf '异常:数据必须是一维的' 问题

如何解决netcdf '异常:数据必须是一维的' 问题


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 举报,一经查实,本站将立刻删除。