Я пытаюсь объединить несколько файлов grib с помощью xarray. После открытия содержимое файла выглядит следующим образом
Dimensions: (isobaricInhPa: 6, time: 8, x: 421, y: 461)
Coordinates:
number int64 1
* time (time) datetime64[ns] 2015-12-01 ... 2015-12-01T21:00:00
step timedelta64[ns] 22:00:00
surface int64 0
latitude (y, x) float64 44.77 44.77 44.77 ... 56.14 56.14 56.14
longitude (y, x) float64 2.976 3.011 3.046 ... 19.75 19.8 19.84
valid_time (time) datetime64[ns] 2015-12-01T22:00:00 ... 2015-12-02T19:00:00
level int64 0
isobaricLayer int64 0
* isobaricInhPa (isobaricInhPa) int64 1000 975 950 850 700 500
meanSea int64 0
heightAboveGround int64 2
depthBelowLandLayer int64 0
Dimensions without coordinates: x, y
Data variables:
eva (time, y, x) float32 9.8228455e-05 ... -4.386902e-05
al (time, y, x) float32 13.415038 13.410155 ... 6.999999
lhtfl (time, y, x) float32 -0.0006713867 ... -0.0016174316
photar (time, y, x) float32 28.988626 28.990091 ... 9.832597
shtfl (time, y, x) float32 0.0019760132 ... 0.0005378723
nswrf (time, y, x) float32 67.433395 67.4373 ... 21.75779
nominalTop int64 0
ASWDIFD_S (time, y, x) float32 32.785587 32.785587 ... 15.658528
uswrf (time, y, x) float32 14.960247 14.960247 ... 2.8130045
ASWDIR_S (time, y, x) float32 49.61133 49.61133 ... 8.912109
nlwrf (time, y, x) float32 -105.77579 ... -96.966675
CAPE_ML (time, y, x) float32 0.0 0.0 ... 3.3457031 2.7578125
ceil (time, y, x) float32 21999.963 21999.963 ... 832.33594
CIN_ML (time, y, x) float32 -999.9 -999.9 ... 6.2249756
ccl (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
CLCT (time, y, x) float32 0.0 0.0 0.0 ... 100.0 100.0 100.0
z (time, isobaricInhPa, y, x) float32 2426.991 ... 54894.156
FRESHSNW (time, y, x) float32 1.0 1.0 1.0 1.0 ... 0.0 0.0 0.0
PRG_GSP (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
GRAU_GSP (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
HBAS_SC (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
sde (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
HTOP_DC (time, y, x) float32 0.0 0.0 0.0 ... 217.875 217.875
HTOP_SC (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
w (time, isobaricInhPa, y, x) float32 0.109972954 ... 0.19146729
prmsl (time, y, x) float32 103109.95 103109.95 ... 101911.98
PRR_GSP (time, y, x) float32 0.0 0.0 ... 4.0844083e-05
RAIN_GSP (time, y, x) float32 0.0 0.0 ... 2.1391602 2.1396484
lssrwe (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
sp (time, y, x) float32 89760.3 89861.3 ... 101911.67
q (time, y, x) float32 0.0029035625 ... 0.007563515
r2 (time, y, x) float32 38.06086 39.715157 ... 85.22328
r (time, isobaricInhPa, y, x) float32 30.83601 ... 15.898354
rsn (time, y, x) float32 50.0 50.0 50.0 ... 250.0 250.0
SDI_1 (time, y, x) float32 4.278263e-09 ... 7.2759576e-09
SDI_2 (time, y, x) float32 -4.5401976e-09 ... 9.604264e-10
t2m (time, y, x) float32 277.9533 277.72968 ... 283.14392
TCH (time, y, x) float32 0.0018555125 ... 0.0007821385
cd (time, y, x) float32 0.0025276025 ... 0.0012515625
d2m (time, y, x) float32 264.8841 265.22882 ... 280.60837
TDIV_HUM (time, y, x) float32 -0.00061035156 ... 0.0034179688
t (time, isobaricInhPa, y, x) float32 285.52493 ... 253.54015
tp (time, y, x) float32 0.0 0.0 ... 2.1391602 2.1396484
TQC (time, y, x) float32 0.0 0.0 ... 0.097717285 0.08065796
TQG (time, y, x) float32 0.0 0.0 ... 0.010297775
TQI (time, y, x) float32 0.0 0.0 ... 0.018722534
tcolr (time, y, x) float32 0.0 0.0 ... 0.01467514 0.01461792
tcols (time, y, x) float32 0.0 0.0 ... 0.011795044
tciwv (time, y, x) float32 1.937272 1.9587563 ... 15.321946
sot (time, y, x) float32 272.13693 271.70236 ... 283.2293
T_SNOW (time, y, x) float32 272.13705 271.70248 ... 283.22812
depthBelowLand int64 0
TWATER (time, y, x) float32 1.937272 1.9587563 ... 15.458177
u (time, isobaricInhPa, y, x) float32 -0.9138613 ... 15.933444
v (time, isobaricInhPa, y, x) float32 0.24166584 ... -12.343933
cnwat (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
sd (time, y, x) float32 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0
W_SO (time, y, x) float32 2.572754 2.6184082 ... 0.0 0.0
W_SO_ICE (time, y, x) float32 2.1436768 3.274292 ... 0.0 0.0
sr (time, y, x) float32 0.17956643 ... 0.00012307029
Теперь у меня есть файл на каждый день, и я хочу объединить данные вдоль оси time
, используя xarray.open_mfdataset
. Поскольку меня интересует только подмножество переменных данных, я выбираю это подмножество на этапе предварительной обработки. Мой текущий подход выглядит следующим образом:
relevant_feature_names = ['CAPE_ML', 'eva', 'TWATER', 'TQC', 'TQI', 'TDIV_HUM', 'u', 'v', 'w']
xr.open_mfdataset(paths=model_data_paths, parallel=True, engine="cfgrib", combine="by_coords",
preprocess=lambda x: x[relevant_feature_names], data_vars="minimal",
compat="override", coords=["time"])
Если я не выберу соответствующие переменные, т. Е.
ds = xr.open_mfdataset(paths=model_data_paths, parallel=True, engine="cfgrib",
data_vars="minimal", compat="override", coords=["time"])
, вместо этого я получу MergeError: unable to determine if these variables should be coordinates or not in the merged result: {'depthBelowLand'}
Однако яполучить ошибку ValueError: variables {'depthBelowLand'} are present in some datasets but not others.
Даже если я хочу исключить эту переменную. Как я могу сказать xarray игнорировать эту отсутствующую переменную и использовать только те переменные / координаты, которые меня интересуют?
Я использую версию xarray 0.13.0
.