/** * Create a new Variable that is a logical subsection of this Variable. * No data is read until a read method is called on it. * * @param ranges List of type ucar.ma2.Range, with size equal to getRank(). * Each Range corresponds to a Dimension, and specifies the section of data to read in that Dimension. * A Range object may be null, which means use the entire dimension. * @return a new Variable which is a logical section of this Variable. * @throws InvalidRangeException */ public Variable section(List<Range> ranges) throws InvalidRangeException { return section(new Section(ranges, shape).makeImmutable()); }
/** * Create a new Variable that is a logical subsection of this Variable. * No data is read until a read method is called on it. * * @param ranges List of type ucar.ma2.Range, with size equal to getRank(). * Each Range corresponds to a Dimension, and specifies the section of data to read in that Dimension. * A Range object may be null, which means use the entire dimension. * @return a new Variable which is a logical section of this Variable. * @throws InvalidRangeException */ public Variable section(List<Range> ranges) throws InvalidRangeException { return section(new Section(ranges, shape).makeImmutable()); }
/** * Create a new Variable that is a logical subsection of this Variable. * No data is read until a read method is called on it. * * @param ranges List of type ucar.ma2.Range, with size equal to getRank(). * Each Range corresponds to a Dimension, and specifies the section of data to read in that Dimension. * A Range object may be null, which means use the entire dimension. * @return a new Variable which is a logical section of this Variable. * @throws InvalidRangeException */ public Variable section(List<Range> ranges) throws InvalidRangeException { return section(new Section(ranges, shape).makeImmutable()); }
List<Range> ranges = new ArrayList<>(); ranges.add(zRangeUse); paramVar = paramVar.section(ranges);
List<Range> ranges = new ArrayList<>(); ranges.add(zRangeUse); paramVar = paramVar.section(ranges);
List<Range> ranges = new ArrayList<Range>(); ranges.add(zRangeUse); paramVar = paramVar.section(ranges);
List<Range> ranges = new ArrayList<Range>(); ranges.add(zRangeUse); paramVar = paramVar.section(ranges);
List<Range> ranges = new ArrayList<Range>(); ranges.add(zRangeUse); paramVar = paramVar.section(ranges);
private void createNewVariables(NetcdfDataset ds, Variable ncVar, List<Dimension> newDims, Dimension levelDim) throws InvalidRangeException { List<Dimension> dims = ncVar.getDimensions(); int newDimIndex = dims.indexOf(levelDim); //String shapeS = ncVar.getShapeS(); int[] origin = new int[ncVar.getRank()]; int[] shape = ncVar.getShape(); int count = 0; for (Dimension dim : newDims) { String name = ncVar.getShortName() + "-" + dim.getShortName(); origin[newDimIndex] = count; shape[newDimIndex] = dim.getLength(); Variable varNew = ncVar.section(new Section(origin, shape)); varNew.setName(name); varNew.setDimension(newDimIndex, dim); // synthesize long name String long_name = ds.findAttValueIgnoreCase(ncVar, CDM.LONG_NAME, ncVar.getShortName()); long_name = long_name + "-" + dim.getShortName(); ds.addVariableAttribute(varNew, new Attribute(CDM.LONG_NAME, long_name)); ds.addVariable(null, varNew); parseInfo.format("Created New Variable as section = "); varNew.getNameAndDimensions(parseInfo, true, false); parseInfo.format("%n"); count += dim.getLength(); } }
private void createNewVariables(NetcdfDataset ds, Variable ncVar, List<Dimension> newDims, Dimension levelDim) throws InvalidRangeException { List<Dimension> dims = ncVar.getDimensions(); int newDimIndex = dims.indexOf(levelDim); //String shapeS = ncVar.getShapeS(); int[] origin = new int[ncVar.getRank()]; int[] shape = ncVar.getShape(); int count = 0; for (Dimension dim : newDims) { String name = ncVar.getShortName() + "-" + dim.getShortName(); origin[newDimIndex] = count; shape[newDimIndex] = dim.getLength(); Variable varNew = ncVar.section(new Section(origin, shape)); varNew.setName(name); varNew.setDimension(newDimIndex, dim); // synthesize long name String long_name = ds.findAttValueIgnoreCase(ncVar, CDM.LONG_NAME, ncVar.getShortName()); long_name = long_name + "-" + dim.getShortName(); ds.addVariableAttribute(varNew, new Attribute(CDM.LONG_NAME, long_name)); ds.addVariable(null, varNew); parseInfo.format("Created New Variable as section = "); varNew.getNameAndDimensions(parseInfo, true, false); parseInfo.format("\n"); count += dim.getLength(); } }
private void createNewVariables(NetcdfDataset ds, Variable ncVar, List<Dimension> newDims, Dimension levelDim) throws InvalidRangeException { List<Dimension> dims = ncVar.getDimensions(); int newDimIndex = dims.indexOf(levelDim); //String shapeS = ncVar.getShapeS(); int[] origin = new int[ncVar.getRank()]; int[] shape = ncVar.getShape(); int count = 0; for (Dimension dim : newDims) { String name = ncVar.getShortName() + "-" + dim.getShortName(); origin[newDimIndex] = count; shape[newDimIndex] = dim.getLength(); Variable varNew = ncVar.section(new Section(origin, shape)); varNew.setName(name); varNew.setDimension(newDimIndex, dim); // synthesize long name String long_name = ds.findAttValueIgnoreCase(ncVar, CDM.LONG_NAME, ncVar.getShortName()); long_name = long_name + "-" + dim.getShortName(); ds.addVariableAttribute(varNew, new Attribute(CDM.LONG_NAME, long_name)); ds.addVariable(null, varNew); parseInfo.format("Created New Variable as section = "); varNew.getNameAndDimensions(parseInfo, true, false); parseInfo.format("%n"); count += dim.getLength(); } }
private void doSubset(String filename) throws IOException, InvalidRangeException { // read the packed form, enhance using scale/offset, compare to original try (NetcdfDataset ncd = NetcdfDataset.openDataset(filename)) { Variable vs = ncd.findVariable("packed"); assert vs != null; Section s = new Section().appendRange(1, 1).appendRange(1, 1); Array readEnhanced = vs.read(s); logger.debug(NCdumpW.toString(readEnhanced)); Variable sec = vs.section(s); Array readSection = sec.read(); logger.debug(NCdumpW.toString(readSection)); ucar.unidata.util.test.CompareNetcdf.compareData(readEnhanced, readSection); } }
return; Variable view = v.section(viewSection); g.removeVariable(v.getShortName()); g.addVariable(view);
return; Variable view = v.section(viewSection); g.removeVariable(v.getShortName()); g.addVariable(view);
return; Variable view = v.section(viewSection); g.removeVariable(v.getShortName()); g.addVariable(view);
ranges.add( r1); Variable tempSection = temp.section(ranges); assert tempSection.getRank() == 2; int[] vshape = tempSection.getShape();
int[] shape = {12,17}; Variable tempSection = temp.section(new Section(origin, shape));