weacast / weacast-grib2json

CLI to converts GRIB2 files to JSON
MIT License
40 stars 9 forks source link

[Question] Understanding the way to use the data parsed #17

Closed jeremybarbet closed 3 years ago

jeremybarbet commented 3 years ago

Hey!

Thank you for the great library, it helped me a lot! This is not an issue per se, but more questions on how to handle the outputted data generated.

I'm converting GRIB2 files obtained from the DWD for the ICON-EU forecast model for the cloud coverage (total cover, high, middle and low clouds).

In general, do you have good read about grib2 and libraries to interpolate its values? There is a lot of python/java libraries, but I would prefer a javascript solution.

Thanks in advance, hope it won't be too much bother with my questions,

claustres commented 3 years ago

Hi, about your first question yes the values are produced by the underlying grib processing tool. You can visualize the content of your grib file using eg https://www.giss.nasa.gov/tools/panoply/ and check the values. We are on the way to integrate a new tool that is not based on Java, see weacast/weacast#17, you might give it a try and see if the output is similar.

About your second question, although the interpolation algorithm is well defined per se, the different conventions about the values ordering and the latitude/longitude range could make it a bit tricky to implement. As a consequence, we have built a pretty generic class to handle different cases in weacast (grid of different sizes, longitude crossing, etc.). This is for instance used to resample the weather data on-demand. Feel free to use it or start something from it.

jeremybarbet commented 3 years ago

Thank you, this is very helpful!

Thank you for your help and answer,

claustres commented 3 years ago

Yes ICON uses an icosahedral grid for modeling but you can convert ICON files to the more standard rectangular grid using https://github.com/DeutscherWetterdienst/regrid first, then perform the standard bilinear interpolation. By the way this tool also relies on ecCodes so the interpolation algorithm probably comes from it.

Triangular interpolation follows the same mathematical principles as standard bilinear interpolation over quads but it is less used except in video games where meshes are triangles ;-) You might find relevant resources about it if you'd like to interpolate raw icon data.

jeremybarbet commented 3 years ago

Thank you for your help. I ended up using ecCodes and its grib_get_data which returns a file of latitude/longitude/value. Just add to create a buildpack for heroku to install ecCodes