Menu

Get Data using Coordinates

Help
2016-01-18
2016-01-18
  • Elsabe Matthee

    Elsabe Matthee - 2016-01-18

    Hi Everyone

    I am new to the whole GRIB file thing, so please excuse me if i ask silly questions.

    Is there no documentation available for GribCS?

    I have followed a post by Erik (https://sourceforge.net/p/gribcs/discussion/1311584/thread/3a6efd3b/) to get the data from the file. Then I got the same error as DSB (https://sourceforge.net/p/gribcs/discussion/1311584/thread/6f17aaf5/?limit=25#fd39) and I got that sorted it with the help of the posts mentioned above.

    But I only need the data for certain coordinates? How can I set the coordinates?

    FileStream fs = new FileStream(@"C:\Grib\gfs_4_20160113_0000_129.grb2",  FileMode.Open);
            Grib2Input gi = new Grib2Input(fs);
    
            gi.scan(false, false);
    
            for (int i = 0; i < gi.Records.Count; i++)
            {
                Grib2Record rec = (Grib2Record)gi.Records[i];
                Grib2Data gd = new Grib2Data(fs);
    
                float[] data = gd.getData(rec.getGdsOffset(), rec.getPdsOffset());
                float dataMin = float.MaxValue;
                float dataMax = -float.MaxValue;
    
                for (int j = 0; j < data.Length; j++)
                {
                    System.Console.WriteLine(data[j]);
    
                    if (data[j] > -9998.0)
                    {
                        dataMin = Math.Min(dataMin, data[j]);
                        dataMax = Math.Max(dataMax, data[j]);
                    }
                }
    
                string gridName = Grib2GridDefinitionSection.getGridName(rec.GDS.Gdtn);
            }
    

    Thank you in advance.

     
  • Erik

    Erik - 2016-01-18

    I'm afraid GribCS only reads the raw data as an array. The information in the Grib2Record can be used to determine how the data is stored row-major or coulm-major order and in which corner it starts.

    The library is an automatic conversion of a "Java GRIB reader" and I'm afraid no documentation exists for the .NET version.

     

    Last edit: Erik 2016-01-18

Log in to post a comment.