Geographic Information Systems Asked on September 3, 2021
The challenge is to extract multidimensional data (weather and ocean data in this case) from .grib files, without having to
so that
Ie. needing a downloadable command-line tool(set) that (after virus testing) extracts the data from .grib files, for further processing!
The GRIB format
GRIB (GRIdded Binary or General Regularly-distributed Information in
Binary form1) is a concise data format commonly used in meteorology
to store historical and forecast weather data.
There are numerous packages available on the net (see the wikipedia page in the question) but after two days of investigating practically everything I could find, there was only one good tool (fit for me) available:
NOAA / The Climate Prediction Center's (CPC) and it's wgrib or wgrib2 tool.
(I have only tried wgrib, and the grib data is Copernicus ERA5 ECMWF reanalysis).
The wgrib tool is a handful of downloadable files including one executable. Seems one can place them in any directory and the .exe (compiled in 2017) runs autonomously. The documentation is good.
The command line
wgrib source.grib | -i source.grib -text -nh -o target.txt
will write a concatenation of the multidimensional grib-file's data values as readable text (one value per row) into target.txt.
The command line
wgrib source.grib | -i source.grib -bin -nh -o target.bin
will write a concatenation of the same as binary into target.bin.
There are multiple options.
Edit 26.7 2020: In response to user "xunilks" comment below, I'm adding some detail about the output formats of the conversion.
Example: If the grib file contains the following dimensions:
with the following cell data
and the dimensional spans are
then there will be an output of 5x11x49 = 2695 cells and each cell will contain 3 numbers (windu, windv, waveh). Hence, the total number of numbers in the data file will be 2695x3 = 8085. wgrib writes them either as a readable text file (with 8085 rows) or a binary file of 32-bit (=4 byte) floats (note: not 64-bit, unfortunately, so we get 7 significants instead of 14 - not a huge problem), hence the file size will be 8085x4 = 32340 bytes.
(For example in C#, one can use BitConverter to convert bytes into float-32's)
The order seems to be (time(data(lat(lon)))) repetitions, where data consists of windu,windv,waveh. This means that
wgrib writes a nice housekeeping file that shows detail about the order of the written numbers. In Windows, one gets that into a text file by adding >[filename] to the command line, eg.
wgrib source.grib | -i source.grib -text -nh -o target.txt >myindexhelpfile.txt
See wgrib documentation!
Answered by Stormwind on September 3, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP