/** * _more_ * * @param nds _more_ * @param var _more_ */ protected void addRadialVariable(NetcdfDataset nds, Variable var) { RadialVariable rsvar = null; String vName = var.getShortName(); int tIdx = var.findDimensionIndex("time"); int rIdx = var.findDimensionIndex("range"); int ptsIdx = var.findDimensionIndex("n_points"); if (((tIdx == 0) && (rIdx == 1)) || (ptsIdx == 0)) { VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes()); rsvar = makeRadialVariable(nds, v, var); } if (rsvar != null) { dataVariables.add(rsvar); } }
/** * _more_ * * @param nds _more_ * @param var _more_ */ protected void addRadialVariable(NetcdfDataset nds, Variable var) { RadialVariable rsvar = null; String vName = var.getShortName(); int tIdx = var.findDimensionIndex("time"); int rIdx = var.findDimensionIndex("range"); int ptsIdx = var.findDimensionIndex("n_points"); if (((tIdx == 0) && (rIdx == 1)) || (ptsIdx == 0)) { VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes()); rsvar = makeRadialVariable(nds, v, var); } if (rsvar != null) { dataVariables.add(rsvar); } }
/** * _more_ * * @param nds _more_ * @param var _more_ */ protected void addRadialVariable(NetcdfDataset nds, Variable var) { RadialVariable rsvar = null; String vName = var.getShortName(); int tIdx = var.findDimensionIndex("time"); int rIdx = var.findDimensionIndex("range"); if ((tIdx == 0) && (rIdx == 1)) { VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes()); rsvar = makeRadialVariable(nds, v, var); } if (rsvar != null) { dataVariables.add(rsvar); } }
/** * _more_ * * @param nds _more_ * @param v0 _more_ */ private CFRadial2Variable(NetcdfDataset nds, Variable v0) { super(v0.getShortName(), v0.getAttributes()); sweeps = new ArrayList<>(); name = v0.getShortName(); int[] shape = v0.getShape(); int ngates = shape[v0.getRank() - 1]; flattened = v0.findDimensionIndex("n_points") == 0; for (int i = 0; i < nsweeps; i++) { // For flattened (1D stored data) find max number of gates if (flattened) { ngates = ray_n_gates[rayStartIdx[i]]; for (int ray = rayStartIdx[i]; ray <= rayEndIdx[i]; ++ray) ngates = ray_n_gates[ray] > ngates ? ray_n_gates[ray] : ngates; } sweeps.add(new CFRadial2Sweep(v0, i, ngates, rayStartIdx[i], rayEndIdx[i])); } }
/** * _more_ * * @param nds _more_ * @param v0 _more_ */ private CFRadial2Variable(NetcdfDataset nds, Variable v0) { super(v0.getShortName(), v0.getAttributes()); sweeps = new ArrayList<>(); name = v0.getShortName(); int[] shape = v0.getShape(); int ngates = shape[v0.getRank() - 1]; flattened = v0.findDimensionIndex("n_points") == 0; for (int i = 0; i < nsweeps; i++) { // For flattened (1D stored data) find max number of gates if (flattened) { ngates = ray_n_gates[rayStartIdx[i]]; for (int ray = rayStartIdx[i]; ray <= rayEndIdx[i]; ++ray) ngates = ray_n_gates[ray] > ngates ? ray_n_gates[ray] : ngates; } sweeps.add(new CFRadial2Sweep(v0, i, ngates, rayStartIdx[i], rayEndIdx[i])); } }
/** * Extract an Array (with rank reduced by one) from the Variable * for the given time index. * * @param v variable to extract from * @param timeIndex time index * @return Array of data * @throws IOException problem getting Array */ private Array getTimeSlice(Variable v, int timeIndex) throws IOException { //ADD: this would make a good utility method //ADD: use Array.slice? int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; } } try { return v.read(origin, shape).reduce(); } catch (InvalidRangeException e) { throw new IOException(e); } }
/** * Extract an Array (with rank reduced by one) from the Variable * for the given time index. * * @param v variable to extract from * @param timeIndex time index * @return Array of data * @throws IOException problem getting Array */ private Array getTimeSlice(Variable v, int timeIndex) throws IOException { //ADD: this would make a good utility method //ADD: use Array.slice? int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; } } try { return v.read(origin, shape).reduce(); } catch (InvalidRangeException e) { throw new IOException(e); } }
if (0 <= v.findDimensionIndex("nav")) {
if (0 <= v.findDimensionIndex("nav")) {
public void testHybrid1() throws IOException { String filename = TestDir.cdmUnitTestDir + "formats/grib1/HIRLAMhybrid.grib"; System.out.println("\n\nReading File " + filename); NetcdfFile ncfile = NetcdfFile.open(filename); Group best = ncfile.findGroup("Best"); Variable hybrid = ncfile.findVariable(best, "hybrid"); assert (hybrid.getNameAndDimensions().equals("hybrid(hybrid=91)")); Variable hybrida = ncfile.findVariable(best, "hybrida"); assert (hybrida.getNameAndDimensions().equals("hybrida(hybrid=91)")); Variable hybridb = ncfile.findVariable(best, "hybridb"); assert (hybridb.getNameAndDimensions().equals("hybridb(hybrid=91)")); int idx = hybrid.findDimensionIndex("hybrid"); Dimension dim = hybrid.getDimension(idx); assert dim.getShortName().equals("hybrid"); ncfile.close(); }
/** * Extract an Array (with rank reduced by one) from the Variable * for the given time index. * * @param v variable to extract from * @param timeIndex time index * @return Array of data * @throws IOException problem getting Array */ private Array getTimeSlice(Variable v, int timeIndex) throws IOException { //ADD: this would make a good utility method //ADD: use Array.slice? int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; } } try { return v.read(origin, shape).reduce(); } catch (InvalidRangeException e) { return null; } }
if (0 <= v.findDimensionIndex("nav")) {
/** * Read the data {@link ucar.ma2.Array} from the variable, at the specified * time index if applicable. If the variable does not have a time * dimension, the data array will have the same rank as the Variable. * If the variable has a time dimension, the data array will have rank-1. * * @param v variable to read * @param timeIndex time index, ignored if !isTimeDependent() * @return Array from the variable at that time index * * @throws IOException problem reading data * @throws InvalidRangeException _more_ */ protected Array readArray(Variable v, int timeIndex) throws IOException, InvalidRangeException { int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; return v.read(origin, shape).reduce(dimIndex); } } return v.read(origin, shape); }
/** * Read the data {@link ucar.ma2.Array} from the variable, at the specified * time index if applicable. If the variable does not have a time * dimension, the data array will have the same rank as the Variable. * If the variable has a time dimension, the data array will have rank-1. * * @param v variable to read * @param timeIndex time index, ignored if !isTimeDependent() * @return Array from the variable at that time index * * @throws IOException problem reading data * @throws InvalidRangeException _more_ */ protected Array readArray(Variable v, int timeIndex) throws IOException, InvalidRangeException { int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; return v.read(origin, shape).reduce(dimIndex); } } return v.read(origin, shape); }
return; int dim = v.findDimensionIndex(dimName); if (dim < 0) { errlog.format("NcML logicalSlice: cant find dimension %s in variable=%s %n", dimName, v.getFullName()); List<Dimension> dimList = new ArrayList<>(); for (String s : dims) { int idx = v.findDimensionIndex(s); if (idx < 0) { errlog.format("NcML logicalReduce: cant find dimension %s in variable=%s %n", dimName, v.getFullName());
return; int dim = v.findDimensionIndex(dimName); if (dim < 0) { errlog.format("NcML logicalSlice: cant find dimension %s in variable=%s %n", dimName, v.getFullName()); List<Dimension> dimList = new ArrayList<>(); for (String s : dims) { int idx = v.findDimensionIndex(s); if (idx < 0) { errlog.format("NcML logicalReduce: cant find dimension %s in variable=%s %n", dimName, v.getFullName());
/** * Read the data {@link ucar.ma2.Array} from the variable, at the specified * time index if applicable. If the variable does not have a time * dimension, the data array will have the same rank as the Variable. * If the variable has a time dimension, the data array will have rank-1. * * @param v variable to read * @param timeIndex time index, ignored if !isTimeDependent() * @return Array from the variable at that time index * * @throws IOException problem reading data * @throws InvalidRangeException _more_ */ protected Array readArray(Variable v, int timeIndex) throws IOException, InvalidRangeException { int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; return v.read(origin, shape).reduce(dimIndex); } } return v.read(origin, shape); }
return; int dim = v.findDimensionIndex(dimName); if (dim < 0) { errlog.format("NcML logicalSlice: cant find dimension %s in variable=%s %n", dimName, v.getFullName());
v.getDimension(v.findDimensionIndex("y")).getLength()); Assert.assertEquals(xSize, v.getDimension(v.findDimensionIndex("x")).getLength());
testReadData(var); assert (0 == var.findDimensionIndex("radial")); assert (1 == var.findDimensionIndex("gate_1"));