@Override public String toString() { return "{"+Misc.showInts(vals)+"}"; }
public void show(Formatter f) { if (isConstant) f.format("isConstant=%d",start); else if (isSequential) f.format("isSequential start=%d",start); else { f.format("isSorted=%s ", isSorted); Misc.showInts(raw, f); } }
public void show(Formatter f) { if (isConstant) f.format("isConstant="+start); else if (isOrdered) f.format("isOrdered start="+start); else Misc.showInts(raw, f); }
@Override public void showInfo(Formatter info, Indent indent) { info.format("%s%s:", indent, getType()); for (Integer cd : offsetSorted) info.format(" %3d,", cd); info.format(" (%d) %n", offsetSorted.size()); if (time2runtime != null) info.format("%stime2runtime: %s", indent, Misc.showInts(time2runtime)); }
@Override public void showInfo(Formatter info, Indent indent) { info.format("%s%s:", indent, getType()); for (TimeCoord.Tinv cd : timeIntervals) info.format(" %s,", cd); info.format(" (%d) %n", timeIntervals.size()); if (time2runtime != null) info.format("%stime2runtime: %s", indent, Misc.showInts(time2runtime)); }
@Override public void toString(Formatter f, Indent indent) { super.toString(f, indent); f.format("%s shape=[%s]%n", indent, Misc.showInts(shape)); }
public void add(T thing, Formatter info, int... index) { content.add(thing); // add the thing at end of list, idx = size-1 int where = calcIndex(index); if (where < 0 || where >= track.length) { logger.error("BAD index add=" + Misc.showInts(index), new Throwable()); } if (track[where] > 0) { ndups++; if (info != null) info.format(" duplicate %s%n with %s%n%n", thing, content.get(track[where] - 1)); } track[where] = content.size(); // 1-based so that 0 = missing, so content at where = content.get(track[where]-1) }
public void toString(Formatter f, Indent indent) { indent.incr(); f.format("%s CoordSys '%s' type %s", indent, name, type); f.format(" has coordVars:"); for (String v : axisNames) f.format("%s, ", v); f.format(" (shape=[%s])", Misc.showInts(getShape())); if (transformNames != null && !transformNames.isEmpty()) { f.format("; has transforms:"); for (String t : transformNames) f.format("%s, ", t); } indent.decr(); }
@Override public void toString(Formatter f, Indent indent) { super.toString(f, indent); f.format("%s %s%n", indent, Misc.showInts(shape)); Array data = getCoordsAsArray(); f.format("%s%n", NCdumpW.toString(data, getName() + " values", null)); }
@Override public void toString(Formatter f, Indent indent) { super.toString(f, indent); f.format("%s %s%n", indent, Misc.showInts(shape)); Array data = getCoordsAsArray(); f.format("%s%n", NCdumpW.toString(data, getName() + " values", null)); }
public DataReceiver(int[] shape, RangeIterator yRange, RangeIterator xRange) { this.yRange = yRange; this.xRange = xRange; this.horizSize = yRange.length() * xRange.length(); long len = Section.computeSize(shape); if (len > 100 * 1000 * 1000*4) { // LOOK make configurable logger.debug("Len greater that 100MB shape={}\n{}", Misc.showInts(shape), Throwables.getStackTraceAsString(new Throwable())); throw new IllegalArgumentException("RequestTooLarge: Len greater that 100M "); } float[] data = new float[ (int) len]; Arrays.fill(data, Float.NaN); // prefill primitive array dataArray = Array.factory(DataType.FLOAT, shape, data); }
public void showInfo(Formatter info, GribRecordStats all) { info.format("SparseArray shape=[%s] ", Misc.showInts(shape)); info.format("ndups=%d, missing/total=%d/%d, density=%f%n", ndups, countMissing(), totalSize, getDensity()); if (all != null) { all.dups += ndups; all.recordsUnique += countNotMissing(); all.recordsTotal += totalSize; all.vars++; } List<Integer> sizes = new ArrayList<>(); for (int s : shape) { if (s == 1) continue; // skip dimension len 1 sizes.add(s); } info.format("%n"); showMissingRecurse(0, sizes, info); }
public static ByteString copyArrayToByteString(Array data) { int nbytes = (int) data.getSizeBytes(); if (nbytes < 0) { System.out.printf("copyArrayToByteString neg byte size %d dataType = %d data size %d shape = %s%n", nbytes, data.getDataType().getSize(), data.getSize(), Misc.showInts(data.getShape())); } ByteBuffer bb = ByteBuffer.allocate(nbytes); bb.order(ByteOrder.nativeOrder()); copyArrayToBB(data, false, bb); bb.flip(); return ByteString.copyFrom(bb); }
private static boolean readRandom(NetcdfDataset ncd, PrintWriter pw ) throws IOException, InvalidRangeException { int ncov = ncd.getVariables().size(); Random r = new Random(System.currentTimeMillis()); int randomIdx = r.nextInt(ncov); Variable randomVariable = ncd.getVariables().get(randomIdx); int[] shape = randomVariable.getShape(); int[] origin = new int[shape.length]; int[] size = new int[shape.length]; for (int i=0; i< shape.length; i++) { origin[i] = r.nextInt(shape[i]); size[i] = 1; } Array data = randomVariable.read(origin, size); pw.format(" read data from %s origin = %s return = %s%n", randomVariable.getNameAndDimensions(), Misc.showInts(origin), NCdumpW.toString(data)); return true; }
private void checkLatLonSubset(CoverageCollection gcs, Coverage coverage, LatLonRect bbox, int[] expectedShape) throws Exception { System.out.printf(" coverage llbb = %s width=%f%n", gcs.getLatlonBoundingBox().toString2(), gcs.getLatlonBoundingBox().getWidth()); System.out.printf(" constrain bbox= %s width=%f%n", bbox.toString2(), bbox.getWidth()); SubsetParams params = new SubsetParams().setLatLonBoundingBox(bbox).setTimePresent(); GeoReferencedArray geo = coverage.readData(params); CoverageCoordSys gcs2 = geo.getCoordSysForData(); Assert.assertNotNull("CoordSysForData", gcs2); System.out.printf(" data cs shape=%s%n", Misc.showInts(gcs2.getShape())); System.out.printf(" data shape=%s%n", Misc.showInts(geo.getData().getShape())); Assert.assertArrayEquals("CoordSys=Data shape", gcs2.getShape(), geo.getData().getShape()); Assert.assertArrayEquals("expected data shape", expectedShape, geo.getData().getShape()); }
private void readCoverageData(Coverage cover, SubsetParams coords) throws IOException, InvalidRangeException { countReadsForVariable++; if (MAX_READS > 0 && countReadsForVariable > MAX_READS) return; GribDataReader.currentDataRecord = null; GeoReferencedArray geoArray = cover.readData(coords); int[] shape = geoArray.getData().getShape(); if (shape[1] != 1) { cover.readData(coords); } for (int i = 0; i < shape.length - 2; i++) { Assert.assertEquals(Misc.showInts(shape), 1, shape[i]); } if (isGrib1) readAndTestGrib1(cover.getName(), coords); else readAndTestGrib2(cover.getName(), coords); this.cover = null; }
@Test public void testBadSize() throws IOException, InvalidRangeException { // Grib.setDebugFlags(new DebugFlagsImpl("Grib/debugGbxIndexOnly")); String endpoint = "D:/work/rdavm/ds084.3/ds084.3.ncx4"; String covName = "Geopotential_height_isobaric"; try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(endpoint)) { Assert.assertNotNull(endpoint, fdc); CoverageCollection cc = fdc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull(FeatureType.FMRC.toString(), cc); Coverage cov = cc.findCoverage(covName); Assert.assertNotNull(covName, cov); SubsetParams subset = new SubsetParams().setTimePresent(); GeoReferencedArray geo = cov.readData(subset); Array data = geo.getData(); System.out.printf(" read data from %s shape = %s%n", cov.getName(), Misc.showInts(data.getShape())); } Grib.setDebugFlags(new DebugFlagsImpl("")); }
public void testWrongRuntime() throws IOException, InvalidRangeException { Grib.setDebugFlags(new DebugFlagsImpl("Grib/debugGbxIndexOnly")); String endpoint = "D:/work/rdavm/index/ds083.2_Grib2.ncx4"; String covName = "Soil_temperature_depth_below_surface_layer"; try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(endpoint)) { Assert.assertNotNull(endpoint, fdc); CoverageCollection cc = fdc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull(FeatureType.GRID.toString(), cc); Coverage cov = cc.findCoverage(covName); Assert.assertNotNull(covName, cov); SubsetParams subset = new SubsetParams().setTimePresent(); GeoReferencedArray geo = cov.readData(subset); Array data = geo.getData(); System.out.printf(" read data from %s shape = %s%n", cov.getName(), Misc.showInts(data.getShape())); } Grib.setDebugFlags(new DebugFlagsImpl("")); }
@Test public void testNonOrthMRUTC() throws IOException, InvalidRangeException { Grib.setDebugFlags(new DebugFlagsImpl("Grib/debugGbxIndexOnly")); String endpoint = "D:/work/rdavm/ds277.6/monthly/ds277.6.ncx4"; String ccName = "ds277.6#MRUTC-LatLon_418X360-4p83S-179p50W"; String covName = "Salinity_depth_below_sea_Average"; try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(endpoint)) { Assert.assertNotNull(endpoint, fdc); CoverageCollection cc = fdc.findCoverageDataset(ccName); Assert.assertNotNull(ccName, cc); Coverage cov = cc.findCoverage(covName); Assert.assertNotNull(covName, cov); SubsetParams subset = new SubsetParams().setTimePresent(); GeoReferencedArray geo = cov.readData(subset); Array data = geo.getData(); System.out.printf(" read data from %s shape = %s%n", cov.getName(), Misc.showInts(data.getShape())); } Grib.setDebugFlags(new DebugFlagsImpl("")); }
@Test public void testNegDataSize() throws IOException, InvalidRangeException { Grib.setDebugFlags(new DebugFlagsImpl("Grib/debugGbxIndexOnly")); String endpoint = "D:/work/rdavm/ds084.3/ds084.3.ncx4"; String covName = "v-component_of_wind_potential_vorticity_surface"; try (FeatureDatasetCoverage fdc = CoverageDatasetFactory.open(endpoint)) { Assert.assertNotNull(endpoint, fdc); CoverageCollection cc = fdc.findCoverageDataset(FeatureType.GRID); Assert.assertNotNull(FeatureType.FMRC.toString(), cc); Coverage cov = cc.findCoverage(covName); Assert.assertNotNull(covName, cov); SubsetParams subset = new SubsetParams().setTimePresent(); GeoReferencedArray geo = cov.readData(subset); Array data = geo.getData(); System.out.printf(" read data from %s shape = %s%n", cov.getName(), Misc.showInts(data.getShape())); } Grib.setDebugFlags(new DebugFlagsImpl("")); }