Convert NetCDF to GRIB2

I know that there is software, such as wgrib2 , which converts the file format griband grib2in NetCDF, but I need to go in the opposite direction from NetCDFbefore grib2, because the local meteorological service here can consume only the data from grid format grib2.

It looks like one solution could be in Python, using the NetCDF4-Python library (or another) to read files NetCDFand using pygrib to write grib2.

Is there a better way?

+5
source share
4 answers

"Iris" Met Office (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

+5
0
source

I know that CDO is mentioned above, but I thought it would be useful to give a complete command

cdo -f grb2 copy in.nc out.grb
0
source

All Articles