ucar.nc2.dataset.CoordinateAxis2D Java Examples
The following examples show how to use
ucar.nc2.dataset.CoordinateAxis2D.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoGridCoordinate2D.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
GeoGridCoordinate2D(CoordinateAxis2D latCoord, CoordinateAxis2D lonCoord) { this.latCoord = latCoord; this.lonCoord = lonCoord; assert latCoord.getRank() == 2; assert lonCoord.getRank() == 2; int[] shape = latCoord.getShape(); nrows = shape[0]; ncols = shape[1]; }
Example #2
Source File: GridCoordinate2D.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
GridCoordinate2D(CoordinateAxis2D latCoord, CoordinateAxis2D lonCoord) { this.latCoord = latCoord; this.lonCoord = lonCoord; assert latCoord.getRank() == 2; assert lonCoord.getRank() == 2; int[] shape = latCoord.getShape(); nrows = shape[0]; ncols = shape[1]; }
Example #3
Source File: LatLonAxis2D.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Array getCoordBoundsAsArray() { // LOOK do we want to cache this ? return CoordinateAxis2D.makeEdges((ArrayDouble.D2) getCoordsAsArray()); // makeXEdges same as makeYEdges }
Example #4
Source File: CurvilinearCS.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
public CoordinateAxis2D getLatAxis() { return (CoordinateAxis2D) super.getXHorizAxis(); }
Example #5
Source File: CurvilinearCS.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
public CoordinateAxis2D getLonAxis() { return (CoordinateAxis2D) super.getYHorizAxis(); }
Example #6
Source File: TestDtWithCoverageReadingSingleP.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testReadGridCoverageSlice() throws IOException, InvalidRangeException { // read single slice System.out.printf("Test Dataset %s coverage %s%n", endpoint, covName); try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(endpoint)) { Assert.assertNotNull(endpoint, cc); CoverageCollection gcs = (type == null) ? cc.getCoverageCollections().get(0) : cc.findCoverageDataset(type); Assert.assertNotNull("gcs", gcs); Coverage cover = gcs.findCoverage(covName); Assert.assertNotNull(covName, cover); // check DtCoverageCS try (GridDataset ds = GridDataset.open(endpoint)) { GridDatatype dt = ds.findGridByName(gridName); if (dt == null) dt = ds.findGridByName(covName); Assert.assertNotNull(gridName, dt); GridCoordSystem csys = dt.getCoordinateSystem(); CoordinateAxis1DTime rtAxis = csys.getRunTimeAxis(); CoordinateAxis1D ensAxis = csys.getEnsembleAxis(); CoordinateAxis1DTime timeAxis = csys.getTimeAxis1D(); CoordinateAxis1D vertAxis = csys.getVerticalAxis(); int calcTimeIdx = -1; int rt_idx = (rtAxis == null || rt_val == null) ? -1 : rtAxis.findTimeIndexFromCalendarDate(rt_val); if (time_idx == null) { if (time_val != null) { if (timeAxis != null) calcTimeIdx = timeAxis.findTimeIndexFromCalendarDate(time_val); else if (rt_idx >= 0) { CoordinateAxis2D timeAxis2D = (CoordinateAxis2D) csys.getTimeAxis(); calcTimeIdx = timeAxis2D.findTimeIndexFromCalendarDate(rt_idx, time_val); // timeAxis = csys.getTimeAxisForRun(rt_idx); // LOOK doesnt work for interval coords // if (timeAxis != null) // calcTimeIdx = timeAxis.findTimeIndexFromCalendarDate(time_val); // LOOK theres a bug here, set time_idx // as workaround } } } else { calcTimeIdx = time_idx; } int ens_idx = (ensAxis == null || ens_val == null) ? -1 : ensAxis.findCoordElement(ens_val); int vert_idx = (vertAxis == null || vert_val == null) ? -1 : vertAxis.findCoordElement(vert_val); /* * static void readAllVertLevels(Coverage cover, GridDatatype dt, CalendarDate rt_val, int rt_idx, CalendarDate * time_val, int time_idx, * // double ens_val, int ens_idx, CoordinateAxis1D vertAxis) * TestDtWithCoverageReadingP.readAllVertLevels(cover, dt, rt_val, rt_idx, time_val, calcTimeIdx, * ens_val == null ? 0 : ens_val, ens_idx, * vertAxis); // */ TestDtWithCoverageReadingP.readOneSlice(cover, dt, rt_val, rt_idx, time_val, calcTimeIdx, ens_val == null ? 0 : ens_val, ens_idx, vert_val == null ? 0 : vert_val, vert_idx); // */ } } }
Example #7
Source File: GridRenderer.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void drawGridHoriz(java.awt.Graphics2D g, Array data) { int count = 0; GridCoordSystem geocs = stridedGrid.getCoordinateSystem(); CoordinateAxis xaxis = geocs.getXHorizAxis(); CoordinateAxis yaxis = geocs.getYHorizAxis(); if ((xaxis instanceof CoordinateAxis1D) && (yaxis instanceof CoordinateAxis1D)) { drawGridHoriz1D(g, data, (CoordinateAxis1D) xaxis, (CoordinateAxis1D) yaxis); return; } data = data.reduce(); if (data.getRank() != 2) throw new IllegalArgumentException("must be 2D"); if (!(xaxis instanceof CoordinateAxis2D) || !(yaxis instanceof CoordinateAxis2D)) throw new IllegalArgumentException("must be CoordinateAxis2D"); // 2D case CoordinateAxis2D xaxis2D = (CoordinateAxis2D) xaxis; CoordinateAxis2D yaxis2D = (CoordinateAxis2D) yaxis; String stag = geocs.getHorizStaggerType(); if (CDM.ARAKAWA_E.equals(stag)) { drawGridHorizRotated(g, data, xaxis2D, yaxis2D); return; } ArrayDouble.D2 edgex = xaxis2D.getEdges(); ArrayDouble.D2 edgey = yaxis2D.getEdges(); Index ima = data.getIndex(); GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 5); int[] shape = xaxis2D.getShape(); // should both be the same int ny = shape[0]; int nx = shape[1]; for (int y = 0; y < ny; y++) { for (int x = 0; x < nx; x++) { gp.reset(); gp.moveTo((float) edgex.get(y, x), (float) edgey.get(y, x)); gp.lineTo((float) edgex.get(y, x + 1), (float) edgey.get(y, x + 1)); gp.lineTo((float) edgex.get(y + 1, x + 1), (float) edgey.get(y + 1, x + 1)); gp.lineTo((float) edgex.get(y + 1, x), (float) edgey.get(y + 1, x)); // debug F:\data2\formats\hdf4\AMSR_E_L2A_BrightnessTemperatures_V08_200801012345_A.hdf if (false) { double d1 = Math.abs(edgex.get(y, x) - edgex.get(y, x + 1)); double d2 = Math.abs(edgex.get(y, x + 1) - edgex.get(y + 1, x + 1)); double d3 = Math.abs(edgex.get(y + 1, x + 1) - edgex.get(y + 1, x)); double d4 = Math.abs(edgex.get(y + 1, x) - edgex.get(y, x)); if (Math.abs(d1) > 10 || Math.abs(d2) > 10 || Math.abs(d3) > 10 || Math.abs(d4) > 10) { System.out.printf("x=%d y=%d %n", x, y); System.out.printf("%f %f %f %f %n", edgex.get(y, x), edgex.get(y, x + 1), edgex.get(y + 1, x), edgex.get(y + 1, x + 1)); System.out.printf("%n%s", Ncdump.printArray(edgex.slice(0, y + 1), "row " + y, null)); System.out.printf("%n%s", Ncdump.printArray(edgex.slice(0, y + 1), "row " + (y + 1), null)); } } double val = data.getDouble(ima.set(y, x)); // ordering LOOK int colorIndex = cs.getIndexFromValue(val); g.setColor(cs.getColor(colorIndex)); g.fill(gp); } } }
Example #8
Source File: GridRenderer.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void drawGridLines(java.awt.Graphics2D g) { int count = 0; GridCoordSystem geocs = stridedGrid.getCoordinateSystem(); CoordinateAxis xaxis = geocs.getXHorizAxis(); CoordinateAxis yaxis = geocs.getYHorizAxis(); if (!(xaxis instanceof CoordinateAxis2D) || !(yaxis instanceof CoordinateAxis2D)) return; // 2D case CoordinateAxis2D xaxis2D = (CoordinateAxis2D) xaxis; CoordinateAxis2D yaxis2D = (CoordinateAxis2D) yaxis; ArrayDouble.D2 edgex = xaxis2D.getEdges(); ArrayDouble.D2 edgey = yaxis2D.getEdges(); GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 5); g.setColor(Color.BLACK); int[] shape = xaxis2D.getShape(); // should both be the same int ny = shape[0]; int nx = shape[1]; for (int y = 0; y < ny + 1; y += 10) { gp.reset(); for (int x = 0; x < nx + 1; x++) { if (x == 0) gp.moveTo((float) edgex.get(y, x), (float) edgey.get(y, x)); else gp.lineTo((float) edgex.get(y, x), (float) edgey.get(y, x)); } g.draw(gp); } for (int x = 0; x < nx + 1; x += 10) { gp.reset(); for (int y = 0; y < ny + 1; y++) { if (y == 0) gp.moveTo((float) edgex.get(y, x), (float) edgey.get(y, x)); else gp.lineTo((float) edgex.get(y, x), (float) edgey.get(y, x)); } g.draw(gp); } }
Example #9
Source File: VariableWrapper.java From sis with Apache License 2.0 | 4 votes |
/** * Returns a coordinate for this two-dimensional grid coordinate axis. * This is (indirectly) a callback method for {@link Grid#getAxes(Decoder)}. */ @Override protected double coordinateForAxis(final int j, final int i) { return (variable instanceof CoordinateAxis2D) ? ((CoordinateAxis2D) variable).getCoordValue(j, i) : Double.NaN; }