ValueError: 无法转换形式的元组 (dims, data[, attrs, encoding]):
我在构建这个数据集时遇到问题,我不知道如何解决它,我尝试了很多解决方案,它给了我同样的错误
import cfgrib
import glob
import xarray as xr
import pandas as pd
folder = input('Folder Path:')
val = input('Variable Name:')
files = glob.glob(rf'{folder}/*.grib2')
data_conc=[]
for file in files:
data = xr.open_dataset(file,engine='cfgrib',
backend_kwargs={'filter_by_keys':{'typeOfLevel': 'hybrid'}})
lon = data.variables['longitude'].values
lat = data.variables['latitude'].values
hyb = data.variables['hybrid'].values
time = pd.Timestamp(data.time.values) + pd.to_timedelta(data.step.values,'H')
X = xr.Dataset(
data_vars = {
'data':(['Alt','lat','lon'], data[val].values)
},
coords = {
'Alt':(['lat','lon'],hyb),
'lat':(['lat','lon'],lat),
'lon':(['lat','lon'],on),
'time':time
},
)
data_conc.append(X)