How to specify the desired product (band) in the GFS NOAA GRIB file? Something like
wa.grb2=gd:HGT:1000 or something else
I wanted to do it without preliminary conversion (grdconvert). if there is such an opportunity.
File to test: wa.grb2.zip (437,9 КБ)
It shouldn’t be. The =gd form was introduced to force reading through GDAL when an alternative way exists in GMT itself. Otherwise depending on the format the decision is taken by a guess algorithm. And in the GRIB case the only possibility is to read via GDAL.
Yes, its working
grdmath w2.grb2=gd+b0 w2.grb2=gd+b1 SUB = sub.nc=nf
So I was confused by the incorrect grdinfo output and i found very simple and compact syntax
grdinfo wa.grb2=gd:1
Joaquim,
i started with grdcontour and does not find the answer. All this forms falls with the same error
grdcontour [ERROR]: Computed -srcwin falls outside raster size of 720x181.
grdcontour [ERROR]: ERROR reading file with gdalread.
grdcontour (gmtapi_import_grid): Could not open file [wa.grb2=gd:1]
Error returned from GMT API: GMT_GRID_READ_ERROR (18)
grdcontour “wa.grb2=gd:1” -JS75/90/61c -R-30/180/30/85 -S6 -Gd20 -W1p -A5+s26 -P >foo.ps
or gd=1 or =gd+b1 or +b1 and with the other projections and for gmt 6.6.0 version too
It is probably more surprising some things are working rather than the opposite.
In a situation like this I would rather stick to something that is known working. E.g.
gmt math w2.grb2=gd+b0 = w2_b0.nc
gmt grdcontour w2_b0.nc ...
PS I tried extracting band 2 using gdal_translate. gmt grdinfo provides wrong min/max values on the resulting wa_band2.grb2:
then I run gdalinfo -stats that generates wa_band2.grb2.aux.xml and suddenly gmt grdinfo wa_band2.grb2 is providing correct min/max values - only until the .aux.xml file is removed:
So -R is failing here (grdcut fails with same error message). Regarding the failure of grdinfo that is the GDAL side I think. Sometimes has to be told to recompute the file stats when saving files. grdinfo also has an option to force computing the stats instead of relying on what is in the grid’s header.
I’ll try to see what is going on with the -R thing when I have some opportunity.