/** * 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"); } }
/** * 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"); } }
private void makeRanges() { for (ucar.nc2.dt.GridDataset.Gridset gset : getGridsets()) { GridCoordSystem gcs = gset.getGeoCoordSystem(); 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.extend(dateRange); } } }
private void makeRanges() { for (ucar.nc2.dt.GridDataset.Gridset gset : getGridsets()) { GridCoordSystem gcs = gset.getGeoCoordSystem(); 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.extend(dateRange); } } }
public ThreddsMetadata.GeospatialCoverage extractGeospatial(GridDataset gridDataset) { LatLonRect llbb = null; CoordinateAxis1D vaxis = null; for (GridDataset.Gridset gridset : gridDataset.getGridsets()) { GridCoordSystem gsys = gridset.getGeoCoordSystem(); if (llbb == null) llbb = gsys.getLatLonBoundingBox(); CoordinateAxis1D vaxis2 = gsys.getVerticalAxis(); if (vaxis == null) vaxis = vaxis2; else if ((vaxis2 != null) && (vaxis2.getSize() > vaxis.getSize())) vaxis = vaxis2; } return new ThreddsMetadata.GeospatialCoverage(llbb, vaxis, 0.0, 0.0); // LOOK can we extract dx, dy ? }
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); } } }
private void testLatLonSubset(GeoGrid grid, LatLonRect bbox, int[] shape) throws Exception { logger.debug("grid bbox = {}", grid.getCoordinateSystem().getLatLonBoundingBox().toString2()); 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() == 2; logger.debug("resulting bbox = {}", gcs2.getLatLonBoundingBox().toString2()); Array data = grid_section.readDataSlice(0, 0, -1, -1); assert data != null; assert data.getRank() == 2; assert data.getShape()[0] == shape[0] : data.getShape()[0]; assert data.getShape()[1] == shape[1] : data.getShape()[1]; }
@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())); } }
static public ThreddsMetadata.GeospatialCoverage extractGeospatial(GridDataset gridDataset) { ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage(); LatLonRect llbb = null; CoordinateAxis1D vaxis = null; for(GridDataset.Gridset gridset : gridDataset.getGridsets()) { GridCoordSystem gsys = gridset.getGeoCoordSystem(); if (llbb == null) llbb = gsys.getLatLonBoundingBox(); CoordinateAxis1D vaxis2 = gsys.getVerticalAxis(); if (vaxis == null) vaxis = vaxis2; else if ((vaxis2 != null) && (vaxis2.getSize() > vaxis.getSize())) vaxis = vaxis2; } if (llbb != null) gc.setBoundingBox(llbb); if (vaxis != null) gc.setVertical(vaxis); return gc; }
static public ThreddsMetadata.GeospatialCoverage extractGeospatial(GridDataset gridDataset) { ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage(); LatLonRect llbb = null; CoordinateAxis1D vaxis = null; for(GridDataset.Gridset gridset : gridDataset.getGridsets()) { GridCoordSystem gsys = gridset.getGeoCoordSystem(); if (llbb == null) llbb = gsys.getLatLonBoundingBox(); CoordinateAxis1D vaxis2 = gsys.getVerticalAxis(); if (vaxis == null) vaxis = vaxis2; else if ((vaxis2 != null) && (vaxis2.getSize() > vaxis.getSize())) vaxis = vaxis2; } if (llbb != null) gc.setBoundingBox(llbb); if (vaxis != null) gc.setVertical(vaxis); return gc; }
static public ThreddsMetadata.GeospatialCoverage extractGeospatial(GridDataset gridDataset) { ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage(); LatLonRect llbb = null; CoordinateAxis1D vaxis = null; for(GridDataset.Gridset gridset : gridDataset.getGridsets()) { GridCoordSystem gsys = gridset.getGeoCoordSystem(); if (llbb == null) llbb = gsys.getLatLonBoundingBox(); CoordinateAxis1D vaxis2 = gsys.getVerticalAxis(); if (vaxis == null) vaxis = vaxis2; else if ((vaxis2 != null) && (vaxis2.getSize() > vaxis.getSize())) vaxis = vaxis2; } if (llbb != null) gc.setBoundingBox(llbb); if (vaxis != null) gc.setVertical(vaxis); return gc; }
@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); } }
@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())); } }
@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())); } }
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); assert null != gcs2; logger.debug("subset bbox = {} ({})", gcs2.getBoundingBox(), gcs2.getLatLonBoundingBox());
@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 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(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]; } }
lonLatEnvelopeElem.setAttribute( "srsName", "urn:ogc:def:crs:OGC:1.3:CRS84" ); LatLonRect llbb = gcs.getLatLonBoundingBox(); LatLonPoint llpt = llbb.getLowerLeftPoint(); LatLonPoint urpt = llbb.getUpperRightPoint();