/** * Make an 1D array from a list of strings. * * @param dtype data type of the array. Assumed unsigned * @param stringValues list of strings. * @return resulting 1D array. * @throws NumberFormatException if string values not parseable to specified data type */ static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException { return makeArray(dtype, false, stringValues); }
/** * Make a 1D array from a list of strings. * * @param dtype data type of the array. * @param stringValues list of strings. * @return resulting 1D array. * @throws NumberFormatException if string values not parssable to specified data type * @deprecated use Array#makeArray directly */ static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException { return Array.makeArray(dtype, stringValues); }
/** * Make a 1D array from a list of strings. * * @param dtype data type of the array. * @param stringValues list of strings. * @return resulting 1D array. * @throws NumberFormatException if string values not parssable to specified data type * @deprecated use Array#makeArray directly */ static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException { return Array.makeArray(dtype, stringValues); }
/** * Make a 1D array from a list of strings. * * @param dtype data type of the array. * @param stringValues list of strings. * @return resulting 1D array. * @throws NumberFormatException if string values not parssable to specified data type * @deprecated use Array#makeArray directly */ static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException { return Array.makeArray(dtype, stringValues); }
/** * Make an 1D array from an array of strings. * * @param dtype data type of the array. Assumed unsigned * @param stringValues list of strings. * @return resulting 1D array. * @throws NumberFormatException if string values not parseable to specified data type */ static public Array makeArray(DataType dtype, String[] stringValues) throws NumberFormatException { return makeArray(dtype, Arrays.asList(stringValues)); }
/** * Make an 1D array from an array of strings. * * @param dtype data type of the array. Assumed unsigned * @param stringValues list of strings. * @return resulting 1D array. * @throws NumberFormatException if string values not parseable to specified data type */ static public Array makeArray(DataType dtype, String[] stringValues) throws NumberFormatException { return makeArray(dtype, Arrays.asList(stringValues)); }
public void testIsGlobalShifted180() { Array longitudeData = Array.makeArray(DataType.DOUBLE, 480, 0.0, 0.75); assertTrue(CfGeocodingPart.isGlobalShifted180(longitudeData)); longitudeData = Array.makeArray(DataType.DOUBLE, 480, 0.75, 0.75); assertTrue(CfGeocodingPart.isGlobalShifted180(longitudeData)); longitudeData = Array.makeArray(DataType.DOUBLE, 480, 0.375, 0.75); assertTrue(CfGeocodingPart.isGlobalShifted180(longitudeData)); longitudeData = Array.makeArray(DataType.DOUBLE, 480, 1.0, 0.75); assertFalse(CfGeocodingPart.isGlobalShifted180(longitudeData)); longitudeData = Array.makeArray(DataType.DOUBLE, 480, -0.375, 0.75); assertFalse(CfGeocodingPart.isGlobalShifted180(longitudeData)); } }
/** * Generate the list of values from a starting value and an increment. * Will reshape to variable if needed. * * @param npts number of values, must = v.getSize() * @param start starting value * @param incr increment */ public void setValues(int npts, double start, double incr) { if (npts != getSize()) throw new IllegalArgumentException("bad npts = " + npts + " should be " + getSize()); Array data = Array.makeArray(getDataType(), npts, start, incr); if (getRank() != 1) data = data.reshape(getShape()); setCachedData(data, true); }
/** * Generate the list of values from a starting value and an increment. * Will reshape to variable if needed. * * @param npts number of values, must = v.getSize() * @param start starting value * @param incr increment */ public void setValues(int npts, double start, double incr) { if (npts != getSize()) throw new IllegalArgumentException("bad npts = " + npts + " should be " + getSize()); Array data = Array.makeArray(getDataType(), npts, start, incr); if (getRank() != 1) data = data.reshape(getShape()); setCachedData(data, true); }
/** * Generate the list of values from a starting value and an increment. * Will reshape to variable if needed. * * @param npts number of values, must = v.getSize() * @param start starting value * @param incr increment */ public void setValues(int npts, double start, double incr) { if (npts != getSize()) throw new IllegalArgumentException("bad npts = " + npts + " should be " + getSize()); Array data = Array.makeArray(getDataType(), npts, start, incr); if (getRank() != 1) data = data.reshape(getShape()); setCachedData(data, true); }
/** * Generate the list of values from a starting value and an increment. * Will reshape to variable if needed. * * @param v for this variable * @param npts number of values, must = v.getSize() * @param start starting value * @param incr increment * @deprecated use Variable.setValues() */ public void setValues(Variable v, int npts, double start, double incr) { if (npts != v.getSize()) throw new IllegalArgumentException("bad npts = " + npts + " should be " + v.getSize()); Array data = Array.makeArray(v.getDataType(), npts, start, incr); if (v.getRank() != 1) data = data.reshape(v.getShape()); v.setCachedData(data, true); }
/** * Generate the list of values from a starting value and an increment. * Will reshape to variable if needed. * * @param v for this variable * @param npts number of values, must = v.getSize() * @param start starting value * @param incr increment * @deprecated use Variable.setValues() */ public void setValues(Variable v, int npts, double start, double incr) { if (npts != v.getSize()) throw new IllegalArgumentException("bad npts = " + npts + " should be " + v.getSize()); Array data = Array.makeArray(v.getDataType(), npts, start, incr); if (v.getRank() != 1) data = data.reshape(v.getShape()); v.setCachedData(data, true); }
/** * Generate the list of values from a starting value and an increment. * Will reshape to variable if needed. * * @param v for this variable * @param npts number of values, must = v.getSize() * @param start starting value * @param incr increment * @deprecated use Variable.setValues() */ public void setValues(Variable v, int npts, double start, double incr) { if (npts != v.getSize()) throw new IllegalArgumentException("bad npts = " + npts + " should be " + v.getSize()); Array data = Array.makeArray(v.getDataType(), npts, start, incr); if (v.getRank() != 1) data = data.reshape(v.getShape()); v.setCachedData(data, true); }
/** * Set the data values from a list of Strings. * * @param values list of Strings * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type */ public void setValues(List<String> values) throws IllegalArgumentException { Array data = Array.makeArray(getDataType(), values); if (data.getSize() != getSize()) throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + getFullName() + " needed= " + getSize() + " given=" + data.getSize()); if (getRank() != 1) // dont have to reshape for rank 1 data = data.reshape(getShape()); setCachedData(data, true); }
/** * Set the data values from a list of Strings. * * @param values list of Strings * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type */ public void setValues(List<String> values) throws IllegalArgumentException { Array data = Array.makeArray(getDataType(), values); if (data.getSize() != getSize()) throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + getFullName() + " needed= " + getSize() + " given=" + data.getSize()); if (getRank() != 1) // dont have to reshape for rank 1 data = data.reshape(getShape()); setCachedData(data, true); }
public void testSlice3D() throws InvalidRangeException, IOException { Array a = Array.makeArray(DataType.DOUBLE, 1000, 0.0, 1.0); Array a3 = a.reshape(new int[] {10,10,10}); logger.debug("{}", NCdumpW.toString(a3, "test a3", null)); Array a2 = a3.slice(0,1); logger.debug("{}", NCdumpW.toString(a2, "a3.slice(0,1)", null)); Array a1 = a2.slice(0,1); logger.debug("{}", NCdumpW.toString(a1, "a2.slice(0,1)", null)); ArrayDouble.D2 twoD = (ArrayDouble.D2) a2; System.out.printf("wrong= %f%n", a2.getDouble(0)); System.out.printf("right= %f%n", twoD.get(0, 0)); ArrayDouble.D1 oneD = (ArrayDouble.D1) a1; System.out.printf("wrong= %f%n", a1.getDouble(0)); System.out.printf("right= %f%n", oneD.get(0)); } }
/** * Set the data values from a list of Strings. * * @param v for this variable * @param values list of Strings * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type * @deprecated use Variable.setValues() */ public void setValues(Variable v, List<String> values) throws IllegalArgumentException { Array data = Array.makeArray(v.getDataType(), values); if (data.getSize() != v.getSize()) throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + v.getFullName() + " needed= " + v.getSize() + " given=" + data.getSize()); if (v.getRank() != 1) // dont have to reshape for rank 1 data = data.reshape(v.getShape()); v.setCachedData(data, true); }
/** * Set the data values from a list of Strings. * * @param values list of Strings * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type */ public void setValues(List<String> values) throws IllegalArgumentException { Array data = Array.makeArray(getDataType(), isUnsigned(), values); if (data.getSize() != getSize()) throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + getFullName() + " needed= " + getSize() + " given=" + data.getSize()); if (getRank() != 1) // dont have to reshape for rank 1 data = data.reshape(getShape()); setCachedData(data, true); }
/** * Set the data values from a list of Strings. * * @param v for this variable * @param values list of Strings * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type * @deprecated use Variable.setValues() */ public void setValues(Variable v, List<String> values) throws IllegalArgumentException { Array data = Array.makeArray(v.getDataType(), v.isUnsigned(), values); if (data.getSize() != v.getSize()) throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + v.getFullName() + " needed= " + v.getSize() + " given=" + data.getSize()); if (v.getRank() != 1) // dont have to reshape for rank 1 data = data.reshape(v.getShape()); v.setCachedData(data, true); }
private boolean addTimeCoordinate(NetcdfDataset ds) { // add time coordinate CalendarDate cd = parseFilenameForDate(ds.getLocation()); if (cd == null) return false; ds.addAttribute(ds.getRootGroup(), new Attribute("_MODIS_Date", cd.toString())); // add the time dimension int nTimesDim = 1; Dimension newDim = new Dimension(TIME_NAME, nTimesDim); ds.addDimension( null, newDim); // add the coordinate variable String units = "seconds since "+cd.toString(); String desc = "time coordinate"; Array data = Array.makeArray(DataType.DOUBLE, 1, 0.0, 0.0) ; CoordinateAxis1D timeCoord = new CoordinateAxis1D( ds, null, TIME_NAME, DataType.DOUBLE, "", units, desc); timeCoord.setCachedData(data, true); timeCoord.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); ds.addCoordinateAxis(timeCoord); return true; }