public void Section_Check() { using var stream = File.OpenRead(GribFileSamples.WmoOneDataSetMessage); var reader = new Grib2Reader(stream); var messages = reader.ReadMessages(); Check.That(messages).HasOneElementOnly(); Check.That(messages.Single().DataSets).HasOneElementOnly(); var record = messages.Single().DataSets.Single(); CheckIndicatorSection(record); CheckIdentificationSection(record); CheckGridDefinitionSection(record); CheckProductDefinitionSection(record); CheckDataRepresentationSection(record); CheckBitmapSection(record); CheckDataSection(record); }
public void Read_PerturbationFile_Test() { using var stream = File.OpenRead(GribFileSamples.NcepGefsPerturbationFile); var reader = new Grib2Reader(stream); var datasets = reader.ReadAllDataSets().ToArray(); const int expectedEnsembleForecastsNumber = 20; const int expectedPerturbationNumber = 8; int perturbationNumber; int ensembleForecastsNumber; var tmpDataSet = datasets.Single(datasets => datasets.Parameter.Equals(Parameter.Temperature)); Check.That(tmpDataSet.ProductDefinitionSection.ProductDefinition.TryGet(ProductDefinitionContent.EnsembleForecastsNumber, out ensembleForecastsNumber)).IsTrue(); Check.That(ensembleForecastsNumber).IsEqualTo(expectedEnsembleForecastsNumber); Check.That(tmpDataSet.ProductDefinitionSection.TryGet(ProductDefinitionContent.PerturbationNumber, out perturbationNumber)).IsTrue(); Check.That(perturbationNumber).IsEqualTo(expectedPerturbationNumber); var apcpDataset = datasets.Single(d => d.Parameter.Equals(Parameter.TotalPrecipitation)); Check.That(apcpDataset.ProductDefinitionSection.ProductDefinition.TryGet(ProductDefinitionContent.EnsembleForecastsNumber, out ensembleForecastsNumber)).IsTrue(); Check.That(ensembleForecastsNumber).IsEqualTo(expectedEnsembleForecastsNumber); Check.That(apcpDataset.ProductDefinitionSection.TryGet(ProductDefinitionContent.PerturbationNumber, out perturbationNumber)).IsTrue(); Check.That(perturbationNumber).IsEqualTo(expectedPerturbationNumber); }
public void Read_AvgFile_Test() { using var stream = File.OpenRead(GribFileSamples.NcepGefsAvgFile); var reader = new Grib2Reader(stream); var datasets = reader.ReadAllDataSets().ToArray(); var apcpDataset = datasets.Single(d => d.Parameter.Equals(Parameter.TotalPrecipitation)); Check.That(apcpDataset.ProductDefinitionSection.ProductDefinition.TryGet(ProductDefinitionContent.EnsembleForecastsNumber, out var ensembleForecastsNumber)).IsTrue(); Check.That(ensembleForecastsNumber).IsEqualTo(20); }
public void Test() { var reader = new Grib2Reader(GribFileSamples.MfAromeTemperatureFile); var dsTemperature = reader.ReadAllDataSets().Single(); var items = new Dictionary <Coordinate, float?>(reader.ReadDataSetValues(dsTemperature)); double resolution = 0.025, north = 53, west = -8, east = 12; double lat = north; double lon = west; foreach (var item in expectedAromeValues) { var shouldChangeLatitude = lon >= east; Check.That(items[(lat, lon)]).IsEqualTo(item);
public void Test() { using var stream = File.OpenRead(GribFileSamples.NcepGfsTmpApcpFile); var reader = new Grib2Reader(stream); var datasets = reader.ReadAllDataSets().ToArray(); Check.That(datasets.Select(d => d.Parameter)).ContainsExactly( Parameter.Temperature, Parameter.TotalPrecipitation, // APCP 6 hours accumulation Parameter.TotalPrecipitation // APCP 96 hours accumulation ); var temperatureDs = datasets.Single(d => d.Parameter.Equals(Parameter.Temperature)); var data = reader.ReadDataSetValues(temperatureDs).ToList(); // Excepted values read using Panoply Check.That(data).ContainsExactly(new Dictionary <Coordinate, float?> { { (-21.25, 55), 301.405579f },
public void Test() { var reader = new Grib2Reader(GribFileSamples.DwdCosmoTotalPrecipitationFile); var dsTemperature = reader.ReadAllDataSets().Single(); var items = new Dictionary <Coordinate, float?>(reader.ReadDataSetValues(dsTemperature)); double resolution = 0.02, south = 43, west = 0, east = 17; double lat = south; double lon = west; // Expected values from Panoply // ordered from West to East then South to North var expectedCosmoValues = TestUtils.ReadCsvValues("references/DWD-COSMO-Total_precipitation_rate_surface_12_Hour_Accumulation.csv"); foreach (var item in expectedCosmoValues) { var shouldChangeLatitude = lon >= east - 1e-8; Check.That(items[(lat, lon)]).IsEqualTo(item);
public void Data_Check() { // Expected values retrieved from Panoply var expectedValues = new[] { 5407.5f, 5416.5f, 5360.6f, 5470.8f, 5512.7f, 5449.3f, 5376.0f, 5503.3f, 5515.2f, 5448.4f, 5405.9f, 5467.4f, 5440.7f, 5448.5f, 5403.4f, 5348.1f, 5378.2f, 5417.6f, 5388.2f, 5520.9f, 5367.6f, 5465.7f, 5357.2f, 5475.4f, 5407.3f }; using var stream = File.OpenRead(GribFileSamples.WmoOneDataSetMessage); var reader = new Grib2Reader(stream); var dataSets = reader.ReadAllDataSets().ToArray(); Check.That(dataSets).HasOneElementOnly(); var data = reader.ReadDataSetRawData(dataSets.Single()).ToArray(); Check.That(data).ContainsExactly(expectedValues); }