/** * Get Z Dimension Lenght for standard CF variables * * @param var * @return */ public static int getZDimensionLength(Variable var) { final int rank = var.getRank(); if (rank > 2) { return var.getDimension(rank - Z_DIMENSION).getLength(); } // TODO: Should I avoid use this method in case of 2D Variables? return 0; }
/** * Whether this is a scalar Variable (rank == 0). * * @return true if Variable has rank 0 */ public boolean isScalar() { return getRank() == 0; }
/** * Whether this is a scalar Variable (rank == 0). * @return true if Variable has rank 0 */ public boolean isScalar() { return getRank() == 0; }
/** * Get the ith dimension. * * @param i index of the dimension. * @return requested Dimension, or null if i is out of bounds. */ public Dimension getDimension(int i) { if ((i < 0) || (i >= getRank())) return null; return dimensions.get(i); }
@Override public boolean isChunked(Variable v) { int n = v.getRank(); return n >= 2 || v.isUnlimited(); }
private int[] computeChunkingGrib(Variable v) { int n = v.getRank(); int[] result = new int[n]; if( n < 2 ) { result[0] = 1; // Unlimited variable with rank 1 } else { for (int i=0; i<n; i++) result[i] = (i<n-2) ? 1 : v.getDimension(i).getLength(); } return result; } }
private void addDimensionsAll(List<Dimension> result, Variable v) { if (v.isMemberOfStructure()) addDimensionsAll(result, v.getParentStructure()); for (int i=0; i<v.getRank(); i++) result.add( v.getDimension(i)); }
protected void addRadialVariable(NetcdfDataset nds, Variable var) { RadialVariable rsvar = null; String vName = var.getShortName() ; int rnk = var.getRank(); if(rnk == 2) { VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes()); rsvar = makeRadialVariable(nds, v, var); } if(rsvar != null) dataVariables.add(rsvar); }
private Dorade2Variable(NetcdfDataset nds, VariableSimpleIF v, Variable v0) { super(v.getShortName(), v0.getAttributes()); sweeps = new ArrayList(); name = v.getShortName(); int[] shape = v0.getShape(); int count = v0.getRank() - 1; int ngates = shape[count]; count--; int nrays = shape[count]; sweeps.add( new Dorade2Sweep(v0, 0, nrays, ngates)) ; }
private Dorade2Variable(NetcdfDataset nds, VariableSimpleIF v, Variable v0) { super(v.getShortName(), v0.getAttributes()); sweeps = new ArrayList(); name = v.getShortName(); int[] shape = v0.getShape(); int count = v0.getRank() - 1; int ngates = shape[count]; count--; int nrays = shape[count]; sweeps.add(new Dorade2Sweep(v0, 0, nrays, ngates)); }
protected void addRadialVariable(NetcdfDataset nds, Variable var) { RadialVariable rsvar = null; String vName = var.getShortName(); int rnk = var.getRank(); if (!var.getShortName().endsWith("RAW") && rnk == 2) { VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes()); rsvar = new Nids2Variable(nds, v, var); } if (rsvar != null) dataVariables.add(rsvar); }
public float[] readData() throws IOException { Array allData = null; int[] shape = sweepVar.getShape(); int[] origind = new int[sweepVar.getRank()]; try { allData = sweepVar.read(origind, shape); } catch (InvalidRangeException e) { throw new IOException(e.getMessage()); } return (float[]) allData.get1DJavaArray(float.class); }
protected Attribute getChunkAttribute(Variable v) { Attribute att = v.findAttribute(CDM.CHUNK_SIZES); if (att != null && att.getDataType().isIntegral() && att.getLength() == v.getRank()) return att; return null; }
void CheckInt32( Variable v) throws IOException { // int32 //assert(null != (v = dodsfile.findVariable("types.integers.i32"))); // assert v.getName().equals("types.integers.i32"); assert v.getRank() == 0; assert v.getSize() == 1; assert v.getDataType() == DataType.INT; CheckInt32Value(v.read()); }
void CheckUInt32( Variable v) throws IOException { // uint32 //assert(null != (v = dodsfile.findVariable("types.integers.ui32"))); //assert v.getName().equals("types.integers.ui32"); assert v.getRank() == 0; assert v.getSize() == 1; assert v.getDataType() == DataType.UINT : v.getDataType(); CheckUInt32Value(v.read()); }
void CheckUint16( Variable v) throws IOException { // uint16 //assert(null != (v = dodsfile.findVariable("types.integers.ui16"))); //assert v.getName().equals("types.integers.ui16"); assert v.getRank() == 0; assert v.getSize() == 1; assert v.getDataType() == DataType.USHORT : v.getDataType(); CheckUInt16Value(v.read()); }
void CheckLong32( Variable v) throws IOException { // uint32 //assert(null != (v = dodsfile.findVariable("types.integers.ui32"))); //assert v.getName().equals("types.integers.ui32"); assert v.getRank() == 0; assert v.getSize() == 1; assert v.getDataType() == DataType.LONG : v.getDataType(); CheckLongValue(v.read()); }
void CheckF( Variable v) throws IOException { // float //assert(null != (v = dodsfile.findVariable("types.floats.f32"))); //assert v.getName().equals("types.floats.f32"); assert v.getRank() == 0; assert v.getSize() == 1; assert v.getDataType() == DataType.FLOAT : v.getDataType(); CheckFValue(v.read()); }
void CheckUint32( Variable v) throws IOException { // uint32 //assert(null != (v = dodsfile.findVariable("types.integers.ui32"))); //assert v.getName().equals("types.integers.ui32"); assert v.getRank() == 0; assert v.getSize() == 1; assert v.getDataType() == DataType.UINT : v.getDataType(); CheckUint32Value(v.read()); }
void CheckUint16( Variable v) throws IOException { // uint16 //assert(null != (v = dodsfile.findVariable("types.integers.ui16"))); //assert v.getName().equals("types.integers.ui16"); assert v.getRank() == 0; assert v.getSize() == 1; assert v.getDataType() == DataType.USHORT : v.getDataType(); CheckUInt16Value(v.read()); }