double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
return findClosest(getCoordValues(), target);
logger.debug("mid time = {}", Arrays.toString(fooTimeAxis.getCoordValues())); logger.debug("edge time = {}", Arrays.toString(fooTimeAxis.getCoordEdges())); ok &= compare.compareData("time getCoordValues", fooTimeAxis.getCoordValues(), new double[] {15.5, 45.0, 74.5, 105.0}); ok &= compare.compareData("time getCoordEdges", fooTimeAxis.getCoordEdges(), new double[] {0.0, 31.0, 59.0, 90.0, 120.0}); logger.debug("mid lat = {}", Arrays.toString(fooLatAxis.getCoordValues())); logger.debug("edge lat = {}", Arrays.toString(fooLatAxis.getCoordEdges())); ok &= compare.compareData("lat getCoordValues", fooLatAxis.getCoordValues(), new double[] {-54.0, 9.0, 54.0, 81.0}); ok &= compare.compareData("lat getCoordEdges", fooLatAxis.getCoordEdges(), new double[] {-90.0, -18.0, 36.0, 72.0, 90.0}); logger.debug("mid lon= " + Arrays.toString(fooLonAxis.getCoordValues())); logger.debug("edge lon= " + Arrays.toString(fooLonAxis.getCoordEdges())); ok &= compare.compareData("lon getCoordValues", fooLonAxis.getCoordValues(), new double[] {18.0, 72.0, 162.0, 288.0}); ok &= compare.compareData("lon getCoordEdges", fooLonAxis.getCoordEdges(), new double[] {0.0, 36.0, 108.0, 216.0, 360.0}); logger.debug("subset mid time = {}", Arrays.toString(fooSubTimeAxis.getCoordValues())); logger.debug("subset edge time = {}", Arrays.toString(fooSubTimeAxis.getCoordEdges())); ok &= compare.compareData("subset time getCoordValues", fooSubTimeAxis.getCoordValues(), new double[] {45.0, 74.5}); ok &= compare.compareData("subset time getCoordEdges", fooSubTimeAxis.getCoordEdges(), new double[] {31.0, 59.0, 90.0}); logger.debug("subset mid lat = {}", Arrays.toString(fooSubLatAxis.getCoordValues())); logger.debug("subset edge lat = {}", Arrays.toString(fooSubLatAxis.getCoordEdges())); ok &= compare.compareData("subset lat getCoordValues", fooSubLatAxis.getCoordValues(), new double[] {9.0, 54.0} ); ok &= compare.compareData("subset lat getCoordEdges", fooSubLatAxis.getCoordEdges(), new double[] {-18.0, 36.0, 72.0} ); logger.debug("subset mid lon = {}", Arrays.toString(fooSubLonAxis.getCoordValues()));
/** * Copy constructor * @param ncd ok to reparent * @param org copy from here */ CoordinateAxis1D(NetcdfDataset ncd, CoordinateAxis1D org) { super(ncd, org); this.orgName = org.orgName; this.cache = new Variable.Cache(); // decouple cache org.setCaching(true); // copy rest of state this.increment = org.getIncrement(); this.isAscending = org.isAscending; this.isInterval = org.isInterval(); this.isRegular = org.isRegular(); this.coords = org.getCoordValues(); this.edge = org.getCoordEdges(); this.names = org.names; if (isInterval) { this.bound1 = org.getBound1(); this.bound2 = org.getBound2(); } this.wasBoundsDone = org.wasBoundsDone; this.wasCalcRegular = org.wasCalcRegular; this.wasRead = org.wasRead; }
/** * Copy constructor * * @param ncd ok to reparent * @param org copy from here */ CoordinateAxis1D(NetcdfDataset ncd, CoordinateAxis1D org) { super(ncd, org); this.orgName = org.orgName; this.cache = new Variable.Cache(); // decouple cache org.setCaching(true); // copy rest of state this.increment = org.getIncrement(); this.isAscending = org.isAscending; this.isInterval = org.isInterval(); this.isRegular = org.isRegular(); if (isNumeric()) { this.coords = org.getCoordValues(); this.edge = org.getCoordEdges(); } this.names = org.names; if (isInterval) { this.bound1 = org.getBound1(); this.bound2 = org.getBound2(); } this.wasBoundsDone = org.wasBoundsDone; this.wasCalcRegular = org.wasCalcRegular; this.wasRead = org.wasRead; }
double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
return axis1D.getCoordValues();
@Test public void checkNCSSDatesInNetcdf() throws JDOMException, IOException { String endpoint = TestOnLocalServer.withHttpPath("/ncss/grid/cdmUnitTest/ncss/climatology/PF5_SST_Climatology_Monthly_1985_2001.nc?var=sst&latitude=45&longitude=-20&temporal=all&accept=netcdf"); byte[] result = TestOnLocalServer.getContent(endpoint, 200, ContentType.netcdf); NetcdfFile nf = NetcdfFile.openInMemory("test_data.ncs", result); NetcdfDataset ds = new NetcdfDataset(nf); CoordinateAxis1D tAxis = (CoordinateAxis1D) ds.findCoordinateAxis("time"); Attribute calendarAtt = tAxis.findAttribute(CF.CALENDAR); Calendar calendar; if (calendarAtt == null) { calendar = Calendar.getDefault(); } else { calendar = Calendar.get(calendarAtt.getStringValue()); } Attribute units = tAxis.findAttribute(CDM.UNITS); double[] values = tAxis.getCoordValues(); System.out.printf("actual%n"); List<String> ccdd = new ArrayList<>(); CalendarDateUnit dateUnit = CalendarDateUnit.withCalendar(calendar, units.getStringValue()); for (double value : values) { CalendarDate cd = dateUnit.makeCalendarDate(value); System.out.printf(" \"%s\",%n", cd); ccdd.add(cd.toString()); } assertEquals(expectedDatesAsDateTime, ccdd); //FAIL!!! ??? //CoordinateAxis1DTime tAxis2 = CoordinateAxis1DTime.factory(ds, ds.findCoordinateAxis("time") , null); //assertTrue(tAxis2.getCalendarDates().equals(expectedDatesAsDateTime)); }
values = axis1D.getCoordValues(); resolution = (ncoords == 1) ? 0.0 : (endValue - startValue) / (ncoords - 1);
double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
double[] xCoords = xAxis.getCoordValues(); double[] yCoords = yAxis.getCoordValues();
@Test public void testMissingDataReplaced() throws Exception { // this one has misssing longitude data, but not getting set to NaN String filename = TestDir.cdmUnitTestDir + "/ft/point/netcdf/Surface_Synoptic_20090921_0000.nc"; NetcdfFile ncfile = null; NetcdfDataset ds = null; try { ncfile = NetcdfFile.open(filename); ds = NetcdfDataset.openDataset(filename); String varName = "Lon"; Variable wrap = ds.findVariable(varName); Array data_wrap = wrap.read(); CompareNetcdf2 compare = new CompareNetcdf2(); assert wrap instanceof CoordinateAxis1D; CoordinateAxis1D axis = (CoordinateAxis1D) wrap; assert compare.compareData(varName, data_wrap, axis.getCoordValues()); } finally { if (ncfile != null) ncfile.close(); if (ds != null) ds.close(); } }
Assert.assertNotNull("time axis", time); double[] expect = new double[]{0., 6.0, 12.0, 18.0}; double[] have = time.getCoordValues(); Assert.assertArrayEquals(expect, have, Misc.defaultMaxRelativeDiffDouble);
CoordinateAxis1D axis = (CoordinateAxis1D) wrap; ok &= compare.compareData(varName, data_org, axis.getCoordValues());