public double readValue(Variable targetVar, Variable fromVar, int[] index) throws InvalidRangeException, IOException { Section axisElement = mapIndex( targetVar, fromVar, index); Array result = targetVar.read(axisElement); return result.nextDouble(); }
public double readValue(Variable targetVar, Variable fromVar, int[] index) throws InvalidRangeException, IOException { Section axisElement = mapIndex( targetVar, fromVar, index); Array result = targetVar.read(axisElement); return result.nextDouble(); }
private void writeVariable(VariableDS v, Array mdata) throws IOException { int count = 0; String name = v.getShortName(); String units = v.getUnitsString(); out.format("%svar='%s' units='%s' : ", indent, name, units); mdata.resetLocalIterator(); while (mdata.hasNext()) { if (count++ > 0) out.format(","); if (v.getDataType().isNumeric()) { double val = mdata.nextDouble(); if (v.isMissing(val)) { // check if missing out.format("missing"); } else { out.format("%s", Double.toString(val)); } } else { // not numeric out.format("%s", mdata.next()); } } out.format("%n"); }
double val = mdata.nextDouble();
public static Array convert2Unpacked(Array packed, ScaleOffset scaleOffset) { //boolean isUnsigned = packed.isUnsigned(); Array result = Array.factory(DataType.DOUBLE, packed.getShape()); IndexIterator riter = result.getIndexIterator(); while (packed.hasNext()) { riter.setDoubleNext( packed.nextDouble() * scaleOffset.scale + scaleOffset.offset); } return result; }
public static Array convert2Unpacked(Array packed, ScaleOffset scaleOffset) { Array result = Array.factory(DataType.DOUBLE, packed.getShape()); IndexIterator riter = result.getIndexIterator(); while (packed.hasNext()) { riter.setDoubleNext( packed.nextDouble() * scaleOffset.scale + scaleOffset.offset); } return result; }
public static Array convert2Unpacked(Array packed, ScaleOffset scaleOffset) { //boolean isUnsigned = packed.isUnsigned(); Array result = Array.factory(DataType.DOUBLE, packed.getShape()); IndexIterator riter = result.getIndexIterator(); while (packed.hasNext()) { riter.setDoubleNext( packed.nextDouble() * scaleOffset.scale + scaleOffset.offset); } return result; }
public static Array convert2packed(Array unpacked, double missingValue, int nbits, boolean isUnsigned, DataType packedType) { MAMath.ScaleOffset scaleOffset = calcScaleOffsetSkipMissingData(unpacked, missingValue, nbits, isUnsigned); Array result = Array.factory(packedType, unpacked.getShape()); IndexIterator riter = result.getIndexIterator(); while (unpacked.hasNext()) { double uv = unpacked.nextDouble(); double pv = (uv - scaleOffset.offset) / scaleOffset.scale; riter.setDoubleNext( pv); } return result; }
public static Array convert2packed(Array unpacked, double missingValue, int nbits, boolean isUnsigned, DataType packedType) { MAMath.ScaleOffset scaleOffset = calcScaleOffsetSkipMissingData(unpacked, missingValue, nbits, isUnsigned); Array result = Array.factory(packedType, unpacked.getShape()); IndexIterator riter = result.getIndexIterator(); while (unpacked.hasNext()) { double uv = unpacked.nextDouble(); double pv = (uv - scaleOffset.offset) / scaleOffset.scale; riter.setDoubleNext( pv); } return result; }
public static Array convert2packed(Array unpacked, double missingValue, int nbits, DataType packedType) { MAMath.ScaleOffset scaleOffset = calcScaleOffsetSkipMissingData(unpacked, missingValue, nbits); Array result = Array.factory(packedType, unpacked.getShape()); IndexIterator riter = result.getIndexIterator(); while (unpacked.hasNext()) { double uv = unpacked.nextDouble(); double pv = (uv - scaleOffset.offset) / scaleOffset.scale; riter.setDoubleNext( pv); } return result; }
double val = mdata.nextDouble();
IndexIterator ii = pressure.getIndexIterator(); while (lev.hasNext()) { double result = p0 * Math.exp(-lev.nextDouble()); ii.setDoubleNext( result );
IndexIterator ii = pressure.getIndexIterator(); while (lev.hasNext()) { double result = p0 * Math.exp(-lev.nextDouble()); ii.setDoubleNext( result );
IndexIterator ii = pressure.getIndexIterator(); while (lev.hasNext()) { double result = p0 * Math.exp(-lev.nextDouble()); ii.setDoubleNext( result );
public void testSequence() { String url = "http://tsds.net/tsds/test/Scalar"; try { NetcdfDataset ds = NetcdfDataset.openDataset(url); System.out.println(ds); Structure struct = (Structure) ds.findVariable("TimeSeries"); Variable var = struct.findVariable("time"); Array arr = var.read(); int n = (int) arr.getSize(); int i; for (i=0; arr.hasNext() && i<n; i++) System.out.println(arr.nextDouble()); if(i != n) { System.err.println("short sequence"); System.exit(1); } } catch (Exception e) { e.printStackTrace(); } } }
@Test public void testNBits0() throws IOException { // Tests of GRIB2 nbits=0; should be reference value (0.0), not missing value String filename = TestDir.cdmUnitTestDir + "formats/grib2/SingleRecordNbits0.grib2"; logger.debug("testNBits0: {}", filename); try (NetcdfFile ncfile = NetcdfFile.open(filename, null)) { Variable v = ncfile.findVariableByAttribute(null, Grib.VARIABLE_ID_ATTNAME, "VAR_0-1-194_L1"); assert v != null : ncfile.getLocation(); Array vals = v.read(); while (vals.hasNext()) { assert 0.0 == vals.nextDouble(); } } }
int count = 0; while (data.hasNext()) result[count++] = data.nextDouble();
double[] values = new double[n]; while (subset.hasNext()) values[count++] = subset.nextDouble(); double[] values = new double[n]; while (subset.hasNext()) values[count++] = subset.nextDouble();
double val = data.nextDouble(); logger.debug("date = {}", Double.isNaN(val) ? val : formatter.toDateTimeStringISO(du.makeDate(val)));
static void readAllTimes2D(Coverage cover, GridDatatype dt, CalendarDate rt_val, int rt_idx, TimeHelper helper, Array timeVals, CoordinateAxis1D ensAxis, CoordinateAxis1D vertAxis) { int[] shape = timeVals.getShape(); if (timeVals.getRank() == 1) { timeVals.resetLocalIterator(); int time_idx = 0; while (timeVals.hasNext()) { double timeVal = timeVals.nextDouble(); readAllEnsembles(cover, dt, rt_val, rt_idx, helper.makeDate(timeVal), time_idx++, ensAxis, vertAxis); } } else { Index index = timeVals.getIndex(); for (int i=0; i<shape[0]; i++) { double timeVal = (timeVals.getDouble(index.set(i,0)) + timeVals.getDouble(index.set(i,1))) / 2; readAllEnsembles(cover, dt, rt_val, rt_idx, helper.makeDate(timeVal), i, ensAxis, vertAxis); } } }