我知道有这样的软件wgrib2 http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/这会将文件转换为grib
and grib2
格式化为NetCDF
文件,但我需要走另一条路:来自NetCDF
to grib2
,因为这里的当地气象局只能使用网格数据grib2
format.
看来一种解决方案可以是Python,使用NetCDF4-Python 库 http://code.google.com/p/netcdf4-python/(或其他)阅读NetCDF
文件和使用pygrib http://code.google.com/p/pygrib/来写grib2
.
有没有更好的办法?
经过更多研究后,我最终使用了英国气象局的“Iris”包(http://scitools.org.uk/iris/docs/latest/index.html http://scitools.org.uk/iris/docs/latest/index.html)它可以读取 NetCDF 以及 OPeNDAP、GRIB 和其他几种格式,并允许保存为 NetCDF 或 GRIB。
基本上代码如下:
import iris
cubes = iris.load('input.nc') # each variable in the netcdf file is a cube
iris.save(cubes[0],'output.grib2') # save a specific variable to grib
但如果您的 netcdf 文件不包含足够的元数据,您可能需要添加它,您也可以使用 Iris 来完成此操作。这是一个完整的工作示例:
https://github.com/rsignell-usgs/ipython-notebooks/blob/master/files/Iris_CFSR_wave_wind.ipynb https://github.com/rsignell-usgs/ipython-notebooks/blob/master/files/Iris_CFSR_wave_wind.ipynb
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)