@Test public void testEcmwf() throws IOException { // scanMode 192 String filename = TestDir.cdmUnitTestDir + "formats/grib2/MSG1-SEVI-MSGCLMK-0100-0100-20060102111500.000000000Z-12774.grb.grb"; logger.debug("Reading File {}", filename); GridDataset gds = GridDataset.open(filename); GeoGrid grid = gds.findGridByName("Cloud_mask"); assert grid != null; assert (grid.getDimensions().size() == 3); GridCoordSystem gcs = grid.getCoordinateSystem(); int[] result = gcs.findXYindexFromCoord(0, 0, null); logger.debug("x,y={},{}", result[0], result[1]); // should be non NAN Array data = grid.readDataSlice(0, 0, result[1], result[0]); logger.debug("{}", NCdumpW.toString(data)); Index ima = data.getIndex(); float val = data.getFloat(ima); Assert2.assertNearlyEquals(val, 0.0); gds.close(); } }
@Test // scanMode = 0 public void testScanMode0() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib2/S-HSAF-h03_20131214_1312_rom.grb"; logger.debug("Reading File {}", filename); GridDataset gds = GridDataset.open(filename); GeoGrid grid = gds.findGridByName("Instantaneous_rain_rate"); assert grid != null; assert (grid.getDimensions().size() == 3); GridCoordSystem gcs = grid.getCoordinateSystem(); int[] result = gcs.findXYindexFromCoord(-7, 60.0, null); logger.debug("x,y={},{}", result[0], result[1]); // should be non NAN Array data = grid.readDataSlice(0, 0, 714, 1779); logger.debug("{}", NCdumpW.toString(data)); Index ima = data.getIndex(); float val = data.getFloat(ima); Assert2.assertNearlyEquals(val, 5.0192626E-5); gds.close(); }
@Test public void testGridDomain() throws Exception { System.err.printf("%nOpen %s grid='%s'%n", filename, gridName); Grib.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly")); try (GridDataset dataset = GridDataset.open(filename)) { GeoGrid grid = dataset.findGridByName(gridName); GridCoordSystem gcs = grid.getCoordinateSystem(); System.err.printf("%s%n", gcs); testDomain("original grid", grid.getDimensions(), gcs.getCoordinateAxes()); GridDatatype gridSubset = grid.makeSubset(null, null, new Range(0, 0), null, null, null); GridCoordSystem gcsSubset = gridSubset.getCoordinateSystem(); System.err.printf("%s%n", gcsSubset); testDomain("subset grid", gridSubset.getDimensions(), gcsSubset.getCoordinateAxes()); } finally { Grib.setDebugFlags(new DebugFlagsImpl("")); } }