GribApiDotNet / GribApi.NET

A powerful .NET library for reading and writing GRIB 1 and 2 files
Apache License 2.0
54 stars 28 forks source link

Using interop functionality #38

Closed moab360 closed 7 years ago

moab360 commented 7 years ago

I might be missing something obvious, but how would I use this library to call the following method https://software.ecmwf.int/wiki/display/GRIB/grib_get. Any help would be appreciated.

0x1mason commented 7 years ago

Simple case

$ grib_get -p name:s somefile.grib

produces the same output as

foreach (GribMessage msg in someFile)
{
   var val = msg["name"].AsString(); 
   // above works for any key, but in the case of "name" and other common keys, you can do
   //    var val = msg.Name;
   Console.WriteLine(val);
}

If you need help with a specific case, pls lmk. If you haven't already, give the README a look. If you have any suggestions for helpful examples, pass them along.

0x1mason commented 7 years ago

You may already know this, but grib_get is available via chocolately: https://chocolatey.org/packages/grib-tools

0x1mason commented 7 years ago

Are you still working with polar stereographic data?

moab360 commented 7 years ago

Thanks for the info here. Yes I'm still working with Polar stereographic data. I ended up using wgrib2 from NOAA to help parse up the data and get something functional (I'm converting astronomy data from the Canadian Meteorological Service into image tiles which then go on google maps). What I have works, but I'd like to increase the resolution of the output and the performance, so I'm back at it. I noticed you had pushed an update so I'm giving it another go.

After doing some tests this morning, I'm noticing some pretty strange data coming out of the grib files. Specifically, Latitude always seems to be 0 and Longitude jumps around between 270 and 90.

This is the simple test I'm using (file attached if you wanna take a look)

using (GribFile file = new GribFile("cloud.grib2")) { GribMessage msg = file.First(); foreach(GeoSpatialValue gs in msg.GeoSpatialValues) { Console.WriteLine(gs.Latitude + " " + gs.Longitude + " " + gs.Value) } }

cloud.zip

0x1mason commented 7 years ago

I'll try to get the fix up tomorrow. The grib_api team fixed the polar stereographic bug, but it's not part of my current release. I reopened #27

0x1mason commented 7 years ago

@moab360 Hi Daniel, sorry for the delay. Can you confirm these are the values you're expecting?

0x1mason commented 7 years ago

This is only the first 25% or so.

vals.txt

moab360 commented 7 years ago

Cool, I'll integrate this week and compare the results. Thanks again for working on this!

Sent from my mobile

On Jan 3, 2017, at 11:21 AM, Eric Millin notifications@github.com<mailto:notifications@github.com> wrote:

This is only the first 25% or so.

vals.txthttps://github.com/0x1mason/GribApi.NET/files/683041/vals.txt

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/0x1mason/GribApi.NET/issues/38#issuecomment-270199241, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AO-HuLKoj4TI1ZBks1h6-OVRQpaAJ_sOks5rOp-bgaJpZM4K8uqm.

0x1mason commented 7 years ago

Ok, the fix isn't in yet. I'll let you know as soon as it's up.

On Tue, Jan 3, 2017 at 4:51 PM, Daniel Fiordalis notifications@github.com wrote:

Cool, I'll integrate this week and compare the results. Thanks again for working on this!

Sent from my mobile

On Jan 3, 2017, at 11:21 AM, Eric Millin <notifications@github.com<mailto: notifications@github.com>> wrote:

This is only the first 25% or so.

vals.txthttps://github.com/0x1mason/GribApi.NET/files/683041/vals.txt

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ 0x1mason/GribApi.NET/issues/38#issuecomment-270199241, or mute the threadhttps://github.com/notifications/unsubscribe- auth/AO-HuLKoj4TI1ZBks1h6-OVRQpaAJ_sOks5rOp-bgaJpZM4K8uqm.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/0x1mason/GribApi.NET/issues/38#issuecomment-270235164, or mute the thread https://github.com/notifications/unsubscribe-auth/AEX_-yBsSa44HfUGa0NEPJReR-g65kUaks5rOsLcgaJpZM4K8uqm .

0x1mason commented 7 years ago

Ok, here's the pre-release. Lmk if it works for you. https://www.nuget.org/packages/Grib.Api/1.0.0-beta

0x1mason commented 7 years ago

Assuming this is resolved. Lmk if it's still an issue.