Exemplo n.º 1
0
  // do not call directly
  @Override
  public Array reallyRead(Variable client, Section section, CancelTask cancelTask)
      throws IOException, InvalidRangeException {
    // see if its really a full read
    if ((null == section) || section.computeSize() == getSize())
      return reallyRead(client, cancelTask);

    if (orgVar == null) return getMissingDataArray(section.getShape());

    return orgVar.read(section);
  }
Exemplo n.º 2
0
 long computeArraySize(SDArray da) throws Exception {
   assert (da.getContainerVar() instanceof DPrimitive);
   BaseType base = da.getPrimitiveVector().getTemplate();
   DataType dtype = DODSNetcdfFile.convertToNCType(base);
   int elemSize = dtype.getSize();
   int n = da.numDimensions();
   List<Range> ranges = new ArrayList<Range>(n);
   long size = 0;
   for (int i = 0; i < n; i++) {
     ranges.add(new Range(da.getStart(i), da.getStop(i), da.getStride(i)));
     Section s = new Section(ranges);
     size += s.computeSize() * elemSize;
   }
   return size;
 }
Exemplo n.º 3
0
  /**
   * Read the data for each variable passed in
   *
   * @param v2
   * @param section
   * @return output data
   * @throws IOException
   * @throws ucar.ma2.InvalidRangeException
   */
  public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException {

    // subset
    Object data;
    Array outputData;
    byte[] vdata = null;
    NOWRadheader.Vinfo vinfo;
    ByteBuffer bos;
    List<Range> ranges = section.getRanges();

    vinfo = (NOWRadheader.Vinfo) v2.getSPobject();

    try {
      vdata = headerParser.getData((int) vinfo.hoff);
    } catch (Exception e) {
    }

    bos = ByteBuffer.wrap(vdata);
    data = readOneScanData(bos, vinfo, v2.getShortName());
    outputData = Array.factory(v2.getDataType().getPrimitiveClassType(), v2.getShape(), data);
    outputData = outputData.flip(1);

    // outputData = outputData.flip(2);
    return (outputData.sectionNoReduce(ranges).copy());

    // return outputData;
  }
Exemplo n.º 4
0
  public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException {
    Vgroup vgroup = (Vgroup) v2.getSPobject();

    Range scanRange = section.getRange(0);
    Range radialRange = section.getRange(1);
    Range gateRange = section.getRange(2);

    Array data = Array.factory(v2.getDataType().getPrimitiveClassType(), section.getShape());
    IndexIterator ii = data.getIndexIterator();

    for (int i = scanRange.first(); i <= scanRange.last(); i += scanRange.stride()) {
      Cinrad2Record[] mapScan = vgroup.map[i];
      readOneScan(mapScan, radialRange, gateRange, vgroup.datatype, ii);
    }

    return data;
  }
  public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException {
    // Vgroup vgroup = (Vgroup) v2.getSPobject();
    // Range scanRange = section.getRange(0);
    // Range radialRange = section.getRange(1);
    // Range gateRange = section.getRange(2);

    Array data = Array.factory(v2.getDataType().getPrimitiveClassType(), section.getShape());
    IndexIterator ii = data.getIndexIterator();

    List<List<Ray>> groups;
    String shortName = v2.getShortName();
    if (shortName.startsWith("Reflectivity")) groups = volScan.getReflectivityGroups();
    else if (shortName.startsWith("Velocity")) groups = volScan.getVelocityGroups();
    else if (shortName.startsWith("TotalPower")) groups = volScan.getTotalPowerGroups();
    else if (shortName.startsWith("Width")) groups = volScan.getWidthGroups();
    else if (shortName.startsWith("DiffReflectivity"))
      groups = volScan.getDifferentialReflectivityGroups();
    else throw new IllegalStateException("Illegal variable name = " + shortName);

    if (section.getRank() == 2) {
      Range radialRange = section.getRange(0);
      Range gateRange = section.getRange(1);
      List<Ray> lli = groups.get(0);
      readOneScan(lli, radialRange, gateRange, ii);
    } else {
      Range scanRange = section.getRange(0);
      Range radialRange = section.getRange(1);
      Range gateRange = section.getRange(2);
      for (int i = scanRange.first(); i <= scanRange.last(); i += scanRange.stride()) {
        readOneScan(groups.get(i), radialRange, gateRange, ii);
      }
    }
    return data;
  }
Exemplo n.º 6
0
  // section of regular Variable
  @Override
  protected Array _read(Section section) throws IOException, InvalidRangeException {
    // really a full read
    if ((null == section) || section.computeSize() == getSize()) return _read();

    Array result;
    if (hasCachedData()) result = super._read(section);
    else result = proxyReader.reallyRead(this, section, null);

    if (needScaleOffsetMissing) return convertScaleOffsetMissing(result);
    else if (needEnumConversion) return convertEnums(result);
    else return result;
  }
 /**
  * Read data from a top level Variable and return a memory resident Array.
  *
  * @param v2 Variable. It may have FLOAT/INTEGER data type.
  * @param section wanted section of data of Variable. The section list is a list of ucar.ma2.Range
  *     which define the requested data subset.
  * @return Array of data which will be read from Variable through this call.
  */
 public Array readData1(ucar.nc2.Variable v2, Section section)
     throws IOException, InvalidRangeException {
   // doData(raf, ncfile, varList);
   int[] sh = section.getShape();
   Array temp = Array.factory(v2.getDataType(), sh);
   long pos0 = 0;
   // Suppose that the data has LayoutRegular
   LayoutRegular index = new LayoutRegular(pos0, v2.getElementSize(), v2.getShape(), section);
   if (v2.getShortName().startsWith("time") | v2.getShortName().startsWith("numGates")) {
     temp = readIntData(index, v2);
   } else {
     temp = readFloatData(index, v2);
   }
   return temp;
 }