/usr/bin/cnvgrib1to2 is in python-grib 1.9.3-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #!/usr/bin/python
import pygrib, sys
if len(sys.argv) < 3:
sys.stdout.write("""
cnvgrib1to2 <grib1 filename> <grib2 filename> <packing scheme>
<packing_scheme> is optional - can be 'grid_simple', 'grid_complex',
'grid_complex_spatial_differencing', 'grid_jpeg', or 'grid_png'.
Default is 'grid_jpeg'\n\n""")
raise SystemExit
grbs = pygrib.open(sys.argv[1])
f = open(sys.argv[2],'wb')
if len(sys.argv) > 3:
grb2packing = sys.argv[3]
else:
grb2packing = 'grid_jpeg' # default is jpeg2000
sys.stdout.write('converting %s from grib1 to grib2 (%s) with %s packing ...\n' % (sys.argv[1],sys.argv[2],grb2packing))
nmsg = 0
for grb in grbs:
try:
grb.editionNumber=2
grb.packingType = grb2packing
nmsg = nmsg + 1
except:
sys.stdout.write('cannot convert message %s\n' % grb.messagenumber)
continue
f.write(grb.tostring())
sys.stdout.write('%s messges out of %s converted\n' % (nmsg,grbs.messages))
grbs.close()
f.close()
|