Search in sources :

Example 1 with Enhance

use of ucar.nc2.dataset.NetcdfDataset.Enhance in project ncWMS by Unidata.

the class DataChunk method readDataChunk.

/**
 * Creates a DataChunk by reading from the given variable
 */
public static DataChunk readDataChunk(VariableDS var, RangesList ranges) throws IOException {
    final Array arr;
    Variable origVar = var.getOriginalVariable();
    if (origVar == null) {
        // We read from the enhanced variable
        arr = readVariable(var, ranges);
    } else {
        // We read from the original variable to avoid enhancing data
        // values that we won't use
        arr = readVariable(origVar, ranges);
    }
    // Decide whether or not we need to enhance any data values we
    // read from this array
    final boolean needsEnhance;
    Set<Enhance> enhanceMode = var.getEnhanceMode();
    if (enhanceMode.contains(Enhance.ScaleMissingDefer)) {
        // Values read from the array are not enhanced, but need to be
        needsEnhance = true;
    } else if (enhanceMode.contains(Enhance.ScaleMissing)) {
        // We only need to enhance if we read data from the plain Variable
        needsEnhance = origVar != null;
    } else {
        // Values read from the array will not be enhanced
        needsEnhance = false;
    }
    return new DataChunk(var, arr, needsEnhance);
}
Also used : Array(ucar.ma2.Array) Variable(ucar.nc2.Variable) Enhance(ucar.nc2.dataset.NetcdfDataset.Enhance)

Aggregations

Array (ucar.ma2.Array)1 Variable (ucar.nc2.Variable)1 Enhance (ucar.nc2.dataset.NetcdfDataset.Enhance)1