Exemplo n.º 1
0
        public void Should_be_able_to_decode_file_when_all_it_is_correct_v1(string correctFileResource)
        {
            var input = _fileIndex[correctFileResource];
            var stream = new MemoryStream(input);

            _testedv1 = new Grib1Input(stream);

            _testedv1.scan(true, false);

            var targetMapIsAtLongitude = _testedv1.GDSs.First().Value.Lo1;
            var targetMapIsAtLatitude = _testedv1.GDSs.First().Value.La1;

            Assert.IsTrue(targetMapIsAtLatitude > 0);
            Assert.IsTrue(targetMapIsAtLongitude > 0);
            Assert.IsTrue(_testedv1.ProductsCount > 0);
        }
Exemplo n.º 2
0
        static void GribOne()
        {
            #region Grib 1 Code

            //FileStream fs = new FileStream(@"c:\seawaredev\routing 3.0\gribs\pinta_38634_51527m.grb", FileMode.Open);
            Grib1Input gi = new Grib1Input(RandomAccessFile);
            gi.scan(false, false);
            byte[] b = new byte[100];

            RandomAccessFile.Seek(129400, SeekOrigin.Begin);
            RandomAccessFile.Read(b, 0, 100);

            Grib1Data data = new Grib1Data(RandomAccessFile);
            var records1 = gi.Records;

            foreach (Grib1Record record in records1)
            {
                IGrib1IndicatorSection iis = record.Is;
                IGrib1ProductDefinitionSection pdsv = record.PDS;
                IGrib1GridDefinitionSection gdsv = record.GDS;

                float[] values = data.getData(record.DataOffset, record.PDS.DecimalScale, record.PDS.bmsExists());
                if ((iis.GribEdition == 1) && (pdsv.ParameterNumber == 2))
                {
                    // U-component_of_wind
                    int c = 0;
                    for (double lat = gdsv.La1; lat >= gdsv.La2; lat = lat - gdsv.Dy)
                    {
                        for (double lon = gdsv.Lo1; lon <= gdsv.Lo2; lon = lon + gdsv.Dx)
                        {
                            Console.WriteLine("U-Wind : " + lat + "\t" + lon + "\t" + values[c]);
                            c++;
                        }
                    }
                }
                else if ((iis.GribEdition == 1) && (pdsv.ParameterNumber == 2))
                {
                    // V-component_of_wind
                    int c = 0;
                    for (double lat = gdsv.La1; lat >= gdsv.La2; lat = lat - gdsv.Dy)
                    {
                        for (double lon = gdsv.Lo1; lon <= gdsv.Lo2; lon = lon + gdsv.Dx)
                        {
                            Console.WriteLine("V-Wind : " + lat + "\t" + lon + "\t" + values[c]);
                            c++;
                        }
                    }
                }
                else if ((iis.GribEdition == 1) && (pdsv.ParameterNumber == 71))
                {
                    // Cloud
                    int c = 0;
                    for (double lat = gdsv.La1; lat >= gdsv.La2; lat = lat - gdsv.Dy)
                    {
                        for (double lon = gdsv.Lo1; lon <= gdsv.Lo2; lon = lon + gdsv.Dx)
                        {
                            Console.WriteLine("Cluod : "+lat + "\t" + lon);
                            c++;
                        }
                    }
                }
            }
            #endregion
        }