关于多grib文件合并以及netcdf和grib的方法

前言

  • 之前在使用WRF做敏感性试验时,曾修改初始场的grib文件,并涉及到多个grib文件合并的情况,下面介绍一些好用的工具处理netcdf和grib

1、 grib_copy

官网:https://confluence.ecmwf.int/display/ECC/grib_copy

在Linux系统上,有一个比较好用的工具,来自于ECMWF的eccodes工具包,为grib_copy
使用命令为:

grib_copy grib_file_1 grib_file_2 ... output_grib_file

这里给出官网的一些使用例子:

  • 从文件中只复制一个气压层的数据:
 grib_copy -w levtype=pl ../data/tigge_pf_ecmwf.grib2 out.grib
 

https://www.researchgate.net/post/How_to_Concatenate_grib2_data_as_a_single_grib2file

  • Convert GRIB file(s) to netCDF format.
 grib_to_netcdf -o output.nc input.grib1

2、CDO

CDO作为气象数据处理中强劲的工具,仅仅需要一行代码就可以实现多种任务需求,其中就包括各种格式之间的转换
https://code.mpimet.mpg.de/boards/1/topics/2907

  • 转换girb文件 为netcdf 文件
cdo -f nc copy file.grb file.nc
  • 转换netcdf为grib文件
cdo -b 16 -f grb copy file.nc file.grb

3、grib_to_netcdf

https://www.mankier.com/1/grib_to_netcdf

将 GRIB file(s)转换为 netCDF format.

注意: The GRIB geometry should be a regular lat/lon grid or a regular Gaussian grid (the key “typeOfGrid” should be “regular_ll” or “regular_gg”)

4、 NCL: GRIB to netCDF

https://www.ncl.ucar.edu/Applications/grib2netCDF.shtml

ncl中封装了很大方面的函数,可以直接实现数据格式之间的转换

ncl_convert2nc was created to convert all or part of a GRIB file to netCDF.

关于多grib文件合并以及netcdf和grib的方法_第1张图片

5、 wgrib2

实现netcdf 向grib2的转换

主要包含两个步骤:

  • 要将 netcdf 转换为 grib,我们将在 wgrib2中使用**-import _ netcdf** 选项。使用 wgrib2进行转换的第一步是创建一个模板文件,该文件的网格定义与 netcdf 字段相同,意思就是复制一份原本netcdf中的各种框架信息
  • wgrib2 script,使用脚本:要将 netcdf 转换为 grib2,我们将使用“ wgrib2 ostia.template”并使用 -import _ netcdf 替换网格点值。然后更改一些元数据,比如变量名,并使用-grib _ out 以 grib 格式写出数据。
    说实话,看着还比较麻烦
    关于多grib文件合并以及netcdf和grib的方法_第2张图片

6、 python

  • https://stackoverflow.com/questions/15432587/converting-netcdf-to-grib2
  • https://gist.github.com/copernicusmarinegist/3b69345ef0352817e1ce1b8232e0df61

7、 其他

问题: Is it possible to convert WRF output data (netcdf) to grib?
答案:

  • https://www.researchgate.net/post/Is_it_possible_to_convert_WRF_output_data_netcdf_to_grib

问题:NCO netCDF Operators Discussion

  • https://sourceforge.net/p/nco/discussion/9829/thread/2d39b07e/

你可能感兴趣的:(python-海洋数据处理,python,CDO,netcdf,grib2,文件格式转换)