我正在使用找到的数据here(注意,这些是预测数据的旋转文件,因此实际日期会随着时间的推移而变化,您可能需要在几天内更新我的示例中的日期)
!wget ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/cfs/prod/cfs/cfs.20180524/00/6hrly_grib_01/pgbf2018052400.01.2018052400.grb2
tmp2 = xr.open_dataset('pgbf2018052400.01.2018052400.grb2',
engine='pynio')
,读作
<xarray.Dataset>
Dimensions: (lat_0: 181, lon_0: 360, lv_AMSL1: 4, lv_HTGL6: 2, lv_ISBL0: 37, lv_ISBL4: 32, lv_ISBL5: 2, lv_PVL2: 2, lv_SIGL3: 4)
Coordinates:
* lon_0 (lon_0) float32 0.0 1.0 2.0 3.0 4.0 5.0 6.0 ...
* lv_ISBL0 (lv_ISBL0) float32 100.0 200.0 300.0 500.0 ...
* lv_ISBL5 (lv_ISBL5) float32 50000.0 100000.0
* lv_ISBL4 (lv_ISBL4) float32 1000.0 2000.0 3000.0 5000.0 ...
* lat_0 (lat_0) float32 90.0 89.0 88.0 87.0 86.0 85.0 ...
* lv_PVL2 (lv_PVL2) float32 -2e-06 2e-06
* lv_AMSL1 (lv_AMSL1) float32 1829.0 2743.0 3658.0 4572.0
Dimensions without coordinates: lv_HTGL6, lv_SIGL3
Data variables:
TOZNE_P0_L200_GLL0 (lat_0, lon_0) float32 ...
HGT_P0_L100_GLL0 (lv_ISBL0, lat_0, lon_0) float32 ...
VVEL_P0_L100_GLL0 (lv_ISBL0, lat_0, lon_0) float32 ...
UGRD_P0_L6_GLL0 (lat_0, lon_0) float32 ...
HGT_P0_L7_GLL0 (lat_0, lon_0) float32 ...
CIN_P0_2L108_GLL0 (lat_0, lon_0) float32 ...
PRES_P0_L109_GLL0 (lv_PVL2, lat_0, lon_0) float32 ...
UGRD_P0_L7_GLL0 (lat_0, lon_0) float32 ...
UGRD_P0_L109_GLL0 (lv_PVL2, lat_0, lon_0) float32 ...
PRES_P0_L7_GLL0 (lat_0, lon_0) float32 ...
PLI_P0_2L108_GLL0 (lat_0, lon_0) float32 ...
和许多其他变量
我现在的斗争是了解如何生成这些变量名称(即PLI_P0_2L108_GLL0)。
如果我直接跑Nio:
f = Nio.open_file('pgbf2018052400.01.2018052400.grb2')
print(f)
我明白了:
Nio file: pgbf2018052400.01.2018052400.grb2
global attributes:
dimensions:
lat_0 = 181
lon_0 = 360
lv_ISBL0 = 37
lv_AMSL1 = 4
lv_PVL2 = 2
lv_SIGL3 = 4
lv_ISBL4 = 32
lv_ISBL5 = 2
lv_HTGL6 = 2
variables:
float TMP_P0_L6_GLL0 [ lat_0, lon_0 ]
center : US National Weather Service - NCEP (WMC)
production_status : Operational products
long_name : Temperature
units : K
_FillValue : 1e+20
grid_type : Latitude/longitude
parameter_discipline_and_category : Meteorological products, Temperature
parameter_template_discipline_category_number : [0, 0, 0, 0]
level_type : Maximum wind level
level : 0
forecast_time : 0
forecast_time_units : hours
initial_time : 05/24/2018 (00:00)
float TMP_P0_L7_GLL0 [ lat_0, lon_0 ]
等等,但变量的名称在那里。所以它是在Nio级定义的东西(我认为)
但是,当我用wgrib2检查数据时,我有:
wgrib2 pgbf2018052400.01.2018052400.grb2
1:0:d=2018052400:PRES:mean sea level:anl:
2:66570:d=2018052400:HGT:1 mb:anl:
3:102113:d=2018052400:TMP:1 mb:anl:
4:118939:d=2018052400:RH:1 mb:anl:
5:122609:d=2018052400:SPFH:1 mb:anl:
6:141106:d=2018052400:VVEL:1 mb:anl:
7.1:219137:d=2018052400:UGRD:1 mb:anl:
7.2:219137:d=2018052400:VGRD:1 mb:anl:
8:283014:d=2018052400:ABSV:1 mb:anl:
9:319471:d=2018052400:O3MR:1 mb:anl:
10:372630:d=2018052400:HGT:2 mb:anl:
11:408159:d=2018052400:TMP:2 mb:anl:
12:425397:d=2018052400:RH:2 mb:anl:
13:427490:d=2018052400:SPFH:2 mb:anl:
14:459259:d=2018052400:VVEL:2 mb:anl:
15.1:517010:d=2018052400:UGRD:2 mb:anl:
15.2:517010:d=2018052400:VGRD:2 mb:anl:
16:580043:d=2018052400:ABSV:2 mb:anl:
17:617506:d=2018052400:O3MR:2 mb:anl:
18:672805:d=2018052400:HGT:3 mb:anl:
19:707799:d=2018052400:TMP:3 mb:anl:
20:725593:d=2018052400:RH:3 mb:anl:
21:729682:d=2018052400:SPFH:3 mb:anl:
22:765030:d=2018052400:VVEL:3 mb:anl:
23.1:828383:d=2018052400:UGRD:3 mb:anl:
23.2:828383:d=2018052400:VGRD:3 mb:anl:
24:892759:d=2018052400:ABSV:3 mb:anl:
25:931422:d=2018052400:O3MR:3 mb:anl:
26:979930:d=2018052400:HGT:5 mb:anl:
我遇到的问题是我试图在xarray中运行open_mfdataset以连接预测开始时间和预测前导时间数以千计这些小文件,不幸的是变量名称(相同数量,比如对流降水,其中)在整个提前期(从6小时到大约6480小时)xarray读取的grib文件是ACPC)...从ACPCP_P8_L1_GLL0_acc到ACPCP_P8_L1_GLL0_acc6h再到ACPCP_P0_L1_GLL0,使事情变得复杂。
我试图用预处理功能覆盖变量名称,但有时似乎不是一致的变化,使事情变得复杂。
任何人都知道字符串在哪里&#34; _P0_L6_GLL0&#34;附加到grib变量名来自哪里?无论如何要修改它?