/** * create new Array with given indexImpl and same backing store */ protected Array createView(Index index) { Array result = ArrayInt.factory(index, storage); result.setUnsigned( isUnsigned()); return result; }
/** * create new Array with given indexImpl and same backing store */ protected Array createView(Index index) { Array result = ArrayInt.factory(index, storage); result.setUnsigned( isUnsigned()); return result; }
/** * create new Array with given indexImpl and same backing store */ protected Array createView(Index index) { Array result = ArrayShort.factory(index, storage); result.setUnsigned( isUnsigned()); return result; } /* Get underlying primitive array storage. CAUTION! You may invalidate your warrentee! */
protected Array createView(Index index) { Array result = ArrayByte.factory(index, storage); result.setUnsigned( isUnsigned()); return result; }
protected Array createView(Index index) { Array result = ArrayByte.factory(index, storage); result.setUnsigned( isUnsigned()); return result; }
/** * create new Array with given indexImpl and same backing store */ protected Array createView(Index index) { Array result = ArrayShort.factory(index, storage); result.setUnsigned( isUnsigned()); return result; } /* Get underlying primitive array storage. CAUTION! You may invalidate your warrentee! */
protected Array readData(ucar.nc2.Variable v, Section ranges) throws IOException, InvalidRangeException { long start = 0; if (showRequest) { System.out.printf("Data request for variable: %s section %s", v.getFullName(), ranges); start = System.currentTimeMillis(); } /* if (unlocked) { String info = cache.getInfo(this); throw new IllegalStateException("File is unlocked - cannot use\n" + info); } */ if (spi == null) { throw new IOException("spi is null, perhaps file has been closed. Trying to read variable " + v.getFullName()); } Array result = spi.readData(v, ranges); result.setUnsigned(v.isUnsigned()); if (showRequest) { long took = System.currentTimeMillis() - start; System.out.printf(" took= %d msecs%n", took); } return result; }
protected Array readData(ucar.nc2.Variable v, Section ranges) throws IOException, InvalidRangeException { long start = 0; if (showRequest) { System.out.printf("Data request for variable: %s section %s", v.getFullName(), ranges); start = System.currentTimeMillis(); } /* if (unlocked) { String info = cache.getInfo(this); throw new IllegalStateException("File is unlocked - cannot use\n" + info); } */ if (spi == null) { throw new IOException("spi is null, perhaps file has been closed. Trying to read variable " + v.getFullName()); } Array result = spi.readData(v, ranges); result.setUnsigned(v.isUnsigned()); if (showRequest) { long took = System.currentTimeMillis() - start; System.out.printf(" took= %d msecs%n", took); } return result; }
private void decodeVlenField(Field fld, UserType userType, int pos, int idx, ByteBuffer bbuff) throws IOException { ConvertedType cvt = convertDataType(userType.baseTypeid); Array array = decodeVlen(cvt.dt, pos, bbuff); fld.data.setObject(idx, array); if (cvt.isUnsigned) fld.data.setUnsigned(true); }
public Attribute(String name, Number val, boolean isUnsigned) { super(name); if (name == null) throw new IllegalArgumentException("Trying to set name to null on "+this); int[] shape = new int[1]; shape[0] = 1; DataType dt = DataType.getType(val.getClass()); Array vala = Array.factory(dt.getPrimitiveClassType(), shape); Index ima = vala.getIndex(); vala.setDouble(ima.set0(0), val.doubleValue()); setValues(vala); this.isUnsigned = isUnsigned; if (isUnsigned) vala.setUnsigned(true); setImmutable(true); }
/** * Create a copy of this Array, copying the data so that physical order is the same as * logical order * * @return the new Array */ public Array copy() { Array newA = factory(getElementType(), getShape()); MAMath.copy(newA, this); newA.setUnsigned( isUnsigned()); return newA; }
/** * Create a copy of this Array, copying the data so that physical order is the same as * logical order * * @return the new Array */ public Array copy() { Array newA = factory(getElementType(), getShape()); MAMath.copy(newA, this); newA.setUnsigned(isUnsigned()); return newA; }
/** * Create a new Array by copying this Array to a new one with given shape * * @param shape the new shape * @return the new Array * @throws IllegalArgumentException new shape is not conformable */ public Array reshape(int[] shape) { Array result = factory(this.getElementType(), shape); if (result.getSize() != getSize()) throw new IllegalArgumentException("reshape arrays must have same total size"); result.setUnsigned(isUnsigned()); Array.arraycopy(this, 0, result, 0, (int) getSize()); return result; }
/** * Create a new Array by copying this Array to a new one with given shape * * @param shape the new shape * @return the new Array * @throws IllegalArgumentException new shape is not conformable */ public Array reshape(int[] shape) { Array result = factory(this.getElementType(), shape); if (result.getSize() != getSize()) throw new IllegalArgumentException("reshape arrays must have same total size"); result.setUnsigned( isUnsigned()); Array.arraycopy(this, 0, result, 0, (int) getSize()); return result; }
/** * Read a variable using the given section specification. * The result is always an array of the type of the innermost variable. * Its shape is the accumulation of all the shapes of its parent structures. * * @param variableSection the constraint expression. * @return data requested * @throws IOException if error * @throws InvalidRangeException if variableSection is invalid * @see <a href="http://www.unidata.ucar.edu/software/netcdf-java/reference/SectionSpecification.html">SectionSpecification</a> */ public Array readSection(String variableSection) throws IOException, InvalidRangeException { /* if (unlocked) throw new IllegalStateException("File is unlocked - cannot use"); */ ParsedSectionSpec cer = ParsedSectionSpec.parseVariableSection(this, variableSection); if (cer.child == null) { Array result = cer.v.read(cer.section); result.setUnsigned(cer.v.isUnsigned()); return result; } if (spi == null) return IospHelper.readSection(cer); else // allow iosp to optimize return spi.readSection(cer); }
/** * Read a variable using the given section specification. * The result is always an array of the type of the innermost variable. * Its shape is the accumulation of all the shapes of its parent structures. * * @param variableSection the constraint expression. * @return data requested * @throws IOException if error * @throws InvalidRangeException if variableSection is invalid * @see <a href="http://www.unidata.ucar.edu/software/netcdf-java/reference/SectionSpecification.html">SectionSpecification</a> */ public Array readSection(String variableSection) throws IOException, InvalidRangeException { /* if (unlocked) throw new IllegalStateException("File is unlocked - cannot use"); */ ParsedSectionSpec cer = ParsedSectionSpec.parseVariableSection(this, variableSection); if (cer.child == null) { Array result = cer.v.read(cer.section); result.setUnsigned(cer.v.isUnsigned()); return result; } if (spi == null) return IospHelper.readSection(cer); else // allow iosp to optimize return spi.readSection(cer); }
static public ucar.ma2.Array readSection(ParsedSectionSpec cer) throws IOException, InvalidRangeException { Variable inner = null; List<Range> totalRanges = new ArrayList<>(); ParsedSectionSpec current = cer; while (current != null) { totalRanges.addAll(current.section.getRanges()); inner = current.v; current = current.child; } assert inner != null; Section total = new Section(totalRanges); Array result = Array.factory(inner.getDataType(), total.getShape()); // must be a Structure Structure outer = (Structure) cer.v; Structure outerSubset = outer.select(cer.child.v.getShortName()); // allows IOSPs to optimize for this case ArrayStructure outerData = (ArrayStructure) outerSubset.read(cer.section); extractSection(cer.child, outerData, result.getIndexIterator()); result.setUnsigned(cer.v.isUnsigned()); return result; }
static public ucar.ma2.Array readSection(ParsedSectionSpec cer) throws IOException, InvalidRangeException { Variable inner = null; List<Range> totalRanges = new ArrayList<Range>(); ParsedSectionSpec current = cer; while (current != null) { totalRanges.addAll(current.section.getRanges()); inner = current.v; current = current.child; } Section total = new Section(totalRanges); Array result = Array.factory(inner.getDataType(), total.getShape()); // must be a Structure Structure outer = (Structure) cer.v; Structure outerSubset = outer.select(cer.child.v.getShortName()); // allows IOSPs to optimize for this case ArrayStructure outerData = (ArrayStructure) outerSubset.read(cer.section); extractSection(cer.child, outerData, result.getIndexIterator()); result.setUnsigned(cer.v.isUnsigned()); return result; }
private static FlagCoding readFlagCoding(Variable variable, String codingName) { final Attribute flagMasks = variable.findAttribute(FLAG_MASKS); final int[] maskValues; if (flagMasks != null) { final Array flagMasksArray = flagMasks.getValues(); // must set the unsigned property explicitly, // even though it is set when writing the flag_masks attribute flagMasksArray.setUnsigned(variable.isUnsigned()); maskValues = new int[flagMasks.getLength()]; for (int i = 0; i < maskValues.length; i++) { maskValues[i] = flagMasksArray.getInt(i); } } else { maskValues = null; } final Attribute flagMeanings = variable.findAttribute(FLAG_MEANINGS); final String[] flagNames; if (flagMeanings != null) { flagNames = flagMeanings.getStringValue().split(" "); } else { flagNames = null; } return createFlagCoding(codingName, maskValues, flagNames); }
private static FlagCoding readFlagCoding(Variable variable, String codingName) { final Attribute flagMasks = variable.findAttribute(FLAG_MASKS); final int[] maskValues; if (flagMasks != null) { final Array flagMasksArray = flagMasks.getValues(); // must set the unsigned property explicitly, // even though it is set when writing the flag_masks attribute flagMasksArray.setUnsigned(variable.isUnsigned()); maskValues = new int[flagMasks.getLength()]; for (int i = 0; i < maskValues.length; i++) { maskValues[i] = flagMasksArray.getInt(i); } } else { maskValues = null; } final Attribute flagMeanings = variable.findAttribute(FLAG_MEANINGS); final String[] flagNames; if (flagMeanings != null) { flagNames = flagMeanings.getStringValue().split(" "); } else { flagNames = null; } return createFlagCoding(codingName, maskValues, flagNames); }