jswhit / pygrib

Python interface for reading and writing GRIB data
https://jswhit.github.io/pygrib
MIT License
328 stars 97 forks source link

Can pygrib write a grib from scratch - even for a 3D variable? #240

Open Marston opened 8 months ago

Marston commented 8 months ago

Apologies for asking this as part of an issue but there is no discussion board on this repo. I've been trying to find a good grib2 writer for 2D and 3D variables but keep hitting roadblocks. Grib2io was promising but they seem to focus mainly on internal issues. I use pygrib extensively for reading all kind of gribs and so I would like to develop a grib2 writer around pygrib. Is there some code to in development that I can use? I will be writing experimental data and not the standard meteorological parameter.

jswhit commented 8 months ago

You cannot write a grib file from scratch using pygrib - a template file is needed

Marston commented 8 months ago

Thank you for responding. OK. If I have a template for 1 record, i.e., a 2D grid, how would I create a 2d and 3D grib file? By that I mean, which sections and subsections are mutable and ought to be updated? Section 0, 1, & 2 are only updated once, but 3-7 are dynamic.

jswhit commented 8 months ago

@Marston I don't know the answer - you'll just have to try it and see what works and what doesn't. It would be great if you could report back on your experience here for the benefit of others.

Marston commented 7 months ago

Apologies for the late reply. Yes, I will give this a try. Clearing some things off my plate before sketching a design. Will be an interesting project.