/** * Show Grids and coordinate systems. * @param buf put info here */ private void getInfo(Formatter buf) { int countGridset = 0; for (Gridset gs : gridsetHash.values()) { GridCoordSystem gcs = gs.getGeoCoordSystem(); buf.format("%nGridset %d coordSys=%s", countGridset, gcs); buf.format(" LLbb=%s ", gcs.getLatLonBoundingBox()); if ((gcs.getProjection() != null) && !gcs.getProjection().isLatLon()) buf.format(" bb= %s", gcs.getBoundingBox()); buf.format("%n"); buf.format("Name__________________________Unit__________________________hasMissing_Description%n"); for (GridDatatype grid : gs.getGrids()) { buf.format("%s%n", grid.getInfo()); } countGridset++; buf.format("%n"); } buf.format("%nGeoReferencing Coordinate Axes%n"); buf.format("Name__________________________Units_______________Type______Description%n"); for (CoordinateAxis axis : ncd.getCoordinateAxes()) { if (axis.getAxisType() == null) continue; axis.getInfo(buf); buf.format("%n"); } }
/** * Show Grids and coordinate systems. * @param buf put info here */ private void getInfo(Formatter buf) { int countGridset = 0; for (Gridset gs : gridsetHash.values()) { GridCoordSystem gcs = gs.getGeoCoordSystem(); buf.format("%nGridset %d coordSys=%s", countGridset, gcs); buf.format(" LLbb=%s ", gcs.getLatLonBoundingBox()); if ((gcs.getProjection() != null) && !gcs.getProjection().isLatLon()) buf.format(" bb= %s", gcs.getBoundingBox()); buf.format("%n"); buf.format("Name__________________________Unit__________________________hasMissing_Description%n"); for (GridDatatype grid : gs.getGrids()) { buf.format("%s%n", grid.getInfo()); } countGridset++; buf.format("%n"); } buf.format("\nGeoReferencing Coordinate Axes\n"); buf.format("Name__________________________Units_______________Type______Description\n"); for (CoordinateAxis axis : ds.getCoordinateAxes()) { if (axis.getAxisType() == null) continue; axis.getInfo(buf); buf.format("\n"); } }
/** * Show Grids and coordinate systems. * @param buf put info here */ private void getInfo(Formatter buf) { int countGridset = 0; for (Gridset gs : gridsetHash.values()) { GridCoordSystem gcs = gs.getGeoCoordSystem(); buf.format("%nGridset %d coordSys=%s", countGridset, gcs); buf.format(" LLbb=%s ", gcs.getLatLonBoundingBox()); if ((gcs.getProjection() != null) && !gcs.getProjection().isLatLon()) buf.format(" bb= %s", gcs.getBoundingBox()); buf.format("%n"); buf.format("Name__________________________Unit__________________________hasMissing_Description%n"); for (GridDatatype grid : gs.getGrids()) { buf.format("%s%n", grid.getInfo()); } countGridset++; buf.format("%n"); } buf.format("%nGeoReferencing Coordinate Axes%n"); buf.format("Name__________________________Units_______________Type______Description%n"); for (CoordinateAxis axis : ds.getCoordinateAxes()) { if (axis.getAxisType() == null) continue; axis.getInfo(buf); buf.format("%n"); } }
@Test @Ignore("Does this file exist in a shared location?") public void testBBSubsetVP2() throws Exception { String filename = "C:/Documents and Settings/caron/My Documents/downloads/MSG2-SEVI-MSGCLAI-0000-0000-20070522114500.000000000Z-582760.grb"; try (GridDataset dataset = GridDataset.open(filename)) { GeoGrid grid = dataset.findGridByName("Pixel_scene_type"); assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; logger.debug("original bbox = {}", gcs.getBoundingBox()); logger.debug("lat/lon bbox = {}", gcs.getLatLonBoundingBox()); ucar.unidata.geoloc.LatLonRect llbb_subset = new LatLonRect(new LatLonPointImpl(), 20.0, 40.0); logger.debug("subset lat/lon bbox = {}", llbb_subset); GeoGrid grid_section = grid.subset(null, null, llbb_subset, 1, 1, 1); GridCoordSystem gcs2 = grid_section.getCoordinateSystem(); assert null != gcs2; logger.debug("result lat/lon bbox = {}", gcs2.getLatLonBoundingBox()); logger.debug("result bbox = {}", gcs2.getBoundingBox()); ProjectionRect pr = gcs2.getProjection().getDefaultMapArea(); logger.debug("projection mapArea = {}", pr); assert (pr.nearlyEquals(gcs2.getBoundingBox())); } }
private void makeRanges() { for (ucar.nc2.dt.GridDataset.Gridset gset : getGridsets()) { GridCoordSystem gcs = gset.getGeoCoordSystem(); ProjectionRect bb = gcs.getBoundingBox(); if (projBB == null) projBB = bb; else projBB.add(bb); LatLonRect llbb = gcs.getLatLonBoundingBox(); if (llbbMax == null) llbbMax = llbb; else llbbMax.extend(llbb); CalendarDateRange dateRange = gcs.getCalendarDateRange(); if (dateRange != null) { if (dateRangeMax == null) dateRangeMax = dateRange; else dateRangeMax = dateRangeMax.extend(dateRange); } } }
@Test @Category(NeedsCdmUnitTest.class) public void testBBSubsetVP() throws Exception { String filename = TestDir.cdmUnitTestDir + "transforms/Eumetsat.VerticalPerspective.grb"; try (GridDataset dataset = GridDataset.open(filename)) { GeoGrid grid = dataset.findGridDatatypeByAttribute(Grib.VARIABLE_ID_ATTNAME, "VAR_3-0-8"); // "Pixel_scene_type"); assert null != grid : dataset.getLocation(); GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; logger.debug("original bbox = {}", gcs.getBoundingBox()); logger.debug("lat/lon bbox = {}", gcs.getLatLonBoundingBox()); ucar.unidata.geoloc.LatLonRect llbb_subset = new LatLonRect(new LatLonPointImpl(), 20.0, 40.0); logger.debug("subset lat/lon bbox = {}", llbb_subset); GeoGrid grid_section = grid.subset(null, null, llbb_subset, 1, 1, 1); GridCoordSystem gcs2 = grid_section.getCoordinateSystem(); assert null != gcs2; logger.debug("result lat/lon bbox = {}", gcs2.getLatLonBoundingBox()); logger.debug("result bbox = {}", gcs2.getBoundingBox()); ProjectionRect pr = gcs2.getProjection().getDefaultMapArea(); logger.debug("projection mapArea = {}", pr); assert (pr.nearlyEquals(gcs2.getBoundingBox())); } }
@Test @Category(NeedsCdmUnitTest.class) public void testBBSubset() throws Exception { try (GridDataset dataset = GridDataset.open( "dods://localhost:8081/thredds/dodsC/cdmUnitTest/ncss/CONUS_80km_nc/GFS_CONUS_80km_20120419_0000.nc")) { GeoGrid grid = dataset.findGridByName("Pressure"); assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; logger.debug("original bbox = {}", gcs.getBoundingBox()); logger.debug("lat/lon bbox = {}", gcs.getLatLonBoundingBox()); LatLonRect llbb = gcs.getLatLonBoundingBox(); LatLonRect llbb_subset = new LatLonRect(llbb.getLowerLeftPoint(), 20.0, llbb.getWidth() / 2); logger.debug("subset lat/lon bbox = {}", llbb_subset); GeoGrid grid_section = grid.subset(null, null, llbb_subset, 1, 1, 1); GridCoordSystem gcs2 = grid_section.getCoordinateSystem(); assert null != gcs2; logger.debug("result lat/lon bbox = {}", gcs2.getLatLonBoundingBox()); logger.debug("result bbox = " + gcs2.getBoundingBox()); ProjectionRect pr = gcs2.getProjection().getDefaultMapArea(); logger.debug("projection mapArea = {}", pr); assert (pr.nearlyEquals(gcs2.getBoundingBox())); } }
@Test @Category(NeedsCdmUnitTest.class) public void testBBSubset2() throws Exception { try (GridDataset dataset = GridDataset.open(TestOnLocalServer.withDodsPath( "dodsC/cdmUnitTest/ncss/CONUS_80km_nc/GFS_CONUS_80km_20120419_0000.nc"))) { GeoGrid grid = dataset.findGridByName("Pressure"); assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; logger.debug("original bbox = {}", gcs.getBoundingBox()); logger.debug("lat/lon bbox = {}", gcs.getLatLonBoundingBox()); LatLonRect llbb = gcs.getLatLonBoundingBox(); LatLonRect llbb_subset = new LatLonRect(new LatLonPointImpl(-15, -140), new LatLonPointImpl(55, 30)); logger.debug("subset lat/lon bbox = {}", llbb_subset); GeoGrid grid_section = grid.subset(null, null, llbb_subset, 1, 1, 1); GridCoordSystem gcs2 = grid_section.getCoordinateSystem(); assert null != gcs2; logger.debug("result lat/lon bbox = {}", gcs2.getLatLonBoundingBox()); logger.debug("result bbox = {}", gcs2.getBoundingBox()); ProjectionRect pr = gcs2.getProjection().getDefaultMapArea(); logger.debug("projection mapArea = {}", pr); assert (pr.nearlyEquals(gcs2.getBoundingBox())); } }
csElem.setAttribute("name", cs.getName()); ProjectionRect rect = cs.getBoundingBox(); Element projBBOX =new Element("projectionBox"); Element minx = new Element("minx");
csElem.setAttribute("name", cs.getName()); ProjectionRect rect = cs.getBoundingBox(); Element projBBOX =new Element("projectionBox"); Element minx = new Element("minx");
csElem.setAttribute("name", cs.getName()); ProjectionRect rect = cs.getBoundingBox(); Element projBBOX =new Element("projectionBox"); Element minx = new Element("minx");
@Test @Category(NeedsCdmUnitTest.class) public void testBBSubsetUnits() throws Exception { try (GridDataset dataset = GridDataset.open(TestDir.cdmUnitTestDir + "ncml/testBBSubsetUnits.ncml")) { logger.debug("file = {}", dataset.getLocation()); GeoGrid grid = dataset.findGridByName("pr"); assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; logger.debug("original bbox = {}", gcs.getBoundingBox()); logger.debug("lat/lon bbox = {}", gcs.getLatLonBoundingBox()); ucar.unidata.geoloc.LatLonRect llbb_subset = new LatLonRect(new LatLonPointImpl(38, -110), new LatLonPointImpl(42, -90)); logger.debug("subset lat/lon bbox = {}", llbb_subset); GeoGrid grid_section = grid.subset(null, null, llbb_subset, 1, 1, 1); GridCoordSystem gcs2 = grid_section.getCoordinateSystem(); assert null != gcs2; logger.debug("result lat/lon bbox = {}", gcs2.getLatLonBoundingBox()); logger.debug("result bbox = {}", gcs2.getBoundingBox()); ProjectionRect pr = gcs2.getProjection().getDefaultMapArea(); logger.debug("projection mapArea = {}", pr); assert (pr.nearlyEquals(gcs2.getBoundingBox())); CoordinateAxis xaxis = gcs.getXHorizAxis(); CoordinateAxis yaxis = gcs.getYHorizAxis(); logger.debug("(nx,ny)= {}, {}", xaxis.getSize(), yaxis.getSize()); } }
@Test @Category(NeedsExternalResource.class) public void testScaleOffset() throws Exception { try (GridDataset dataset = GridDataset.open("http://esrl.noaa.gov/psd/thredds/dodsC/Datasets/noaa.oisst.v2/sst.wkmean.1990-present.nc")) { GeoGrid grid = dataset.findGridByName("sst"); assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; logger.debug("original bbox = {} ({})", gcs.getBoundingBox(), gcs.getLatLonBoundingBox()); LatLonRect llbb = gcs.getLatLonBoundingBox(); LatLonRect llbb_subset = new LatLonRect(llbb.getLowerLeftPoint(), 20.0, llbb.getWidth() / 2); GeoGrid grid2 = grid.subset(null, null, llbb_subset, 1, 1, 1); GridCoordSystem gcs2 = grid2.getCoordinateSystem(); assert null != gcs2; logger.debug("subset bbox = {} ({})", gcs2.getBoundingBox(), gcs2.getLatLonBoundingBox()); logger.debug("original grid var = {}", grid.getVariable()); logger.debug("subset grid var = {}", grid2.getVariable()); Array data = grid.readDataSlice(0, 0, 159, 0); Array data2 = grid2.readDataSlice(0, 0, 0, 0); logger.debug(NCdumpW.toString(data, "org", null)); logger.debug(NCdumpW.toString(data2, "subset", null)); ucar.unidata.util.test.CompareNetcdf.compareData(data, data2); } }
assert null != gcs; logger.debug("original bbox = {} ({})", gcs.getBoundingBox(), gcs.getLatLonBoundingBox()); assert null != gcs2; logger.debug("subset bbox = {} ({})", gcs2.getBoundingBox(), gcs2.getLatLonBoundingBox());
ProjectionRect rect = grids.get(0).getCoordinateSystem().getBoundingBox();
assert org_shape[2] == data_shape[1]; logger.debug("original bbox = {}" + gcs.getBoundingBox()); assert grid_section.getRank() == 3; ucar.unidata.geoloc.ProjectionRect subset_prect = gcs2.getBoundingBox(); logger.debug("resulting bbox = {}", subset_prect);
assert data_org.getElementType() == int.class : data_org.getElementType(); logger.debug("original bbox = {}", gcs.getBoundingBox()); assert grid_section.getDataType() == DataType.UINT; ucar.unidata.geoloc.ProjectionRect subset_prect = gcs2.getBoundingBox(); logger.debug("resulting bbox = {}", subset_prect);
@Test @Category(NeedsCdmUnitTest.class) public void testLatLonSubset() throws Exception { try (GridDataset dataset = GridDataset.open(TestDir.cdmUnitTestDir + "conventions/cf/SUPER-NATIONAL_latlon_IR_20070222_1600.nc")) { GeoGrid grid = dataset.findGridByName("micron11"); assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; assert grid.getRank() == 2; logger.debug("original bbox = {}", gcs.getBoundingBox()); LatLonRect bbox = new LatLonRect(new LatLonPointImpl(40.0, -100.0), 10.0, 20.0); testLatLonSubset(grid, bbox, new int[]{141, 281}); bbox = new LatLonRect(new LatLonPointImpl(-40.0, -180.0), 120.0, 300.0); testLatLonSubset(grid, bbox, new int[]{800, 1300}); } }
@Test @Category(NeedsCdmUnitTest.class) public void testLatLonSubset2() throws Exception { try (GridDataset dataset = GridDataset.open(TestDir.cdmUnitTestDir + "tds/ncep/GFS_Global_onedeg_20100913_0000.grib2")) { GeoGrid grid = dataset.findGridDatatypeByAttribute(Grib.VARIABLE_ID_ATTNAME, "VAR_0-3-0_L1"); // "Pressure_Surface"); assert null != grid : dataset.getLocation(); GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; assert grid.getRank() == 3 : grid.getRank(); logger.debug("original bbox = {}", gcs.getBoundingBox()); logger.debug("lat/lon bbox = {}", gcs.getLatLonBoundingBox().toString2()); LatLonRect bbox = new LatLonRect(new LatLonPointImpl(40.0, -100.0), 10.0, 20.0); logger.debug("constrain bbox = {}", bbox.toString2()); GeoGrid grid_section = grid.subset(null, null, bbox, 1, 1, 1); GridCoordSystem gcs2 = grid_section.getCoordinateSystem(); assert null != gcs2; assert grid_section.getRank() == grid.getRank(); logger.debug("resulting bbox = {}", gcs2.getLatLonBoundingBox().toString2()); Array data = grid_section.readDataSlice(0, 0, -1, -1); assert data != null; assert data.getRank() == 2; int[] dataShape = data.getShape(); assert dataShape.length == 2; assert dataShape[0] == 11 : data.getShape()[0]; assert dataShape[1] == 21 : data.getShape()[1]; } }
ProjectionRect rect = gcs.getBoundingBox(); logger.debug(" rect = {}", rect); logger.debug(" rect = {}", gcs.getBoundingBox());