Link Search Menu Expand Document

grib2json

download and compile

  • need maven, brew install maven on macOS
git clone https://github.com/cambecc/grib2json.git
cd grib2json
mvn package
gz=/Users/Data/javascripts/D3js/earth/grib2json/target/grib2json-0.8.0-SNAPSHOT.tar.gz
cd  ~/MyPrograms/
tar tvfz $gz
ln -s ~/MyPrograms/grib2json-0.8.0-SNAPSHOT/bin/grib2json ~/bin

help

all options

> grib2json --help
Usage: grib2json [options] FILE
	[--compact -c] : enable compact Json formatting
	[--data -d] : print GRIB record data
	[--filter.category --fc value] : select records with this numeric category
	[--filter.parameter --fp value] : select records with this numeric parameter
	[--filter.surface --fs value] : select records with this numeric surface type
	[--filter.value --fv value] : select records with this numeric surface value
	[--help -h] : display this help
	[--names -n] : print names of numeric codes
	[--output -o value] : write output to the specified file (default is stdout)
	[--verbose -v] : enable logging to stdout

pickup certain variables

–fpparameterNumberName#
0Temperature13
1Relative_humidity12
1Pressure_reduced_to_MSL1
2U-component_of_wind12
3V-component_of_wind12
5Geopotential_height11
6Dew_point_temperature1
8Total_precipitation1
9Vertical_velocity11
17Skin_temperature1
# --fp wind: convert both U and V-component of wind
grib2json -n -d --fp wind --fs 103 --fv 10.0 -o current-wind-surface-level-cwb-3K.json $grb

$ for i in {1..10};do echo $i $(grib2json --names --fp $i  $gb |grep "parameterNumberName");done
1 "parameterNumberName":"Relative_humidity", 
...
"parameterNumberName":"Vertical_velocity", "parameterNumberName":"Vertical_velocity",
10

dump grib2 file to json

  • with data: grib2json -d -n -o $gb.json $gb

nc2json

resource

  • cambecc(2017), A command line utility that decodes GRIB2 files as JSON, grib2json
  • pwcazenave(2017), Convert netCDF output to JSON for use in earth, netcdf2json