Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading grib2 from AROME forecast model #1

Closed
hydrique opened this issue Oct 21, 2020 · 5 comments
Closed

Reading grib2 from AROME forecast model #1

hydrique opened this issue Oct 21, 2020 · 5 comments

Comments

@hydrique
Copy link

Hi,

First of all, let me congratulate you on the amazing work you've done trying to create a working netcore grib parser! Impressive!

I'm trying myself to "get rid of" the net461 dependance on Grib.Api nugget.

I have done some testing in one of the forecast model I'm using, namely AROME 0.025 (french model). I've tried to parse the SP1 package available here [https://donneespubliques.meteofrance.fr/?fond=produit&id_produit=131&id_rubrique=51].

I've done the test on the "Temperature" parameter and I've noticed that the values that comes out of the "Grib2Reader.ReadDataSetValues" function are not consistent with what I find using Grib.Api nuget or panoply.

I don't know if maybe you have an idea why that is ?

I'll appreciate any help 👍 and congrats again on your work!
Best
Philippe

Here is the code I'm using:

`using (var stream = File.OpenRead(filePath))
{
var gribReader = new Grib2Reader(stream);
var gribMessages = gribReader.ReadMessages().ToList();

            var selectedGribMessages =
                    gribMessages
                        .Where(
                            m => m.DataSets.Single().Parameter.HasValue && m.DataSets.Single().Parameter.Value.Name == "Temperature")
                        .ToList();

            var data = gribReader.ReadDataSetValues(selectedGribMessages.First().DataSets.Single());`

image

@nmangue
Copy link
Owner

nmangue commented Oct 22, 2020

Hello Philippe,

Thank you for your kind feedback.

This particular AROME dataset uses the JPEG 2000 code stream format to encode the values. However NGrib does not support this data representation format yet (only simple or complex packing of float values). It should have raised an exception instead of reading wrong values.
The tricky part to add this support is to find (or adapt) a reliable, .NET Standard 2.0, open JPEG 2000 library. Would you be interested in implementing this functionality yourself ?

Best regards,
(Bien cordialement si vous êtes également francophone 😉)

Nicolas

@hydrique
Copy link
Author

Hello!

Thanks for your fast reply and my appologies for my late reply...

Thanks for explaining to me where the error comes from... I had a look at what exists for JPEG 2000 compression and didn't find any suitable, open source, library :( It would be interesting to integrate this functionnality to have a robust grib library in .NET.

I would be happy to help if a JPEG 2000 library comes up (even tough my coding capacity might not necessarly be enough for the task :/ ). I'll keep an eye open and if I find a possible solution I will get in touch again.

All the best and thanks again for your work 👍

Salutations :)

Philippe

@nmangue
Copy link
Owner

nmangue commented Nov 1, 2020

I found that the .NET Standard port of CS2JK seems like a good fit. It was not updated recently but it still does the job.
I have published a 0.6.0 version with this update and some fixes. Could you try it ?

@hydrique
Copy link
Author

Hi! I'm really sorry I'm only seeing your message now :( I'm not using my private account, so I don't receive any notifications...

It's very nice you found a solution! I'll try first thing in the morning and let you know how it went!

Thanks again and sorry for the delay...

@hydrique
Copy link
Author

Hi again !

Your fix worked great 👍 I've tested on AROME and now the temperature are decoded correctly!

Thanks a lot for the effort !
Best

@nmangue nmangue closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant