智能摘要 AI
文章描述了使用`ecCodes`工具将ERA5再分析气象数据从GRIB格式转换为NetCDF4格式时遇到的问题。问题源于不同变量、层级或预报步长共享同一时间戳,导致合并时出现“非唯一字段”错误。具体表现为下载的数据包含额外的时间戳(如`1999-12-31T18:00:00Z`),与预期的`2000-01-01T00:00:00Z`冲突。 为解决此问题,作者建议先使用`grib_copy`工具简单地合并grib文件,避免时间戳冲突,然后通过`grib_to_netcdf`工具处理变量并转换为NetCDF4格式。最终命令为:`grib_copy 2000-2010_step_6.grib 2011-2020_step-6
0x00 事件还原
从Climate Data Store下载ERA5再分析气象数据,时间步长为6小时,Data format为GRIB,并用ecCodes中的grib_to_netcdf工具实现对grib文件合并转换为NetCDF4(官方工具方便处理变量),结果出现问题:
grib_to_netcdf: Version 2.42.0
grib_to_netcdf: Processing input file '2000-2010.grib'.
grib_to_netcdf: Processing input file '2011-2020.grib'.
ECCODES ERROR : Wrong number of fields
ECCODES ERROR : File contains 102284 GRIBs, 112504 left in internal description, 225008 in request
ECCODES ERROR : The fields are not considered distinct!
ECCODES ERROR : Hint: This may be due to several fields having the same validity time.
ECCODES ERROR : Try using the -T option (Do not use time of validity)该问题在ECMWF官网有过记录,该问题原因如下:
- 不同的变量/层级/预报步长共享同一个时间戳;
- 两个文件之间时间重叠;
- ECCODES 尝试将它们合并进 NetCDF,但识别为“非唯一字段”。
0x01 检查
从官网下载的数据为何会出现这样的问题?这里我使用Panoply查看了下grib文件的情况,结果如图:
为何会有变量time和time1以及reftime1?详细如下:
double time1(time1=30684);
:units = "Hour since 1999-12-31T18:00:00Z";
:standard_name = "time";
:long_name = "GRIB forecast or observation time";
:calendar = "proleptic_gregorian";
:bounds = "time1_bounds";
double reftime1(time1=30684);
:standard_name = "forecast_reference_time";
:long_name = "GRIB reference time";
:calendar = "proleptic_gregorian";
:units = "Hour since 1999-12-31T18:00:00Z";结果显而易见,我这里是从2000-01-01T00:00:00Z下载数据,但是如果从官网下载grib数据格式,就会多出1999-12-31T18:00:00Z,这也就很好说明了,为什么会导致冲突。
0x02 解决问题
ecCodes工具中还有个grib_copy用来合并grib文件,简单拷贝/拼接,直接合并即可,例如以下指令
grib_copy 2000-2010_step_6.grib 2011-2020_step-6.grib 2000-2020.grib然后再使用grib_to_netcdf来处理变量并转换为nc文件格式即可!





评论 (0)