/** * true if there may be missing data, see VariableDS.hasMissing() */ public boolean hasMissingData() { return vs.hasMissing(); }
assert( DataType.SHORT == att.getDataType()); assert( vs.hasMissing()); assert( vs.hasMissingValue()); assert( vs.isMissing( (double) ((short) -9999))); assert( vs.getDataType() == DataType.SHORT); assert( !vs.hasMissing()); assert( vs.hasMissingValue()); assert( !vs.isMissing( (double) ((short) -9999))); assert( vs.hasMissing()); assert( vs.isMissing( (double) ((short) -9999)));
/** * true if there may be missing data, see VariableDS.hasMissing() */ public boolean hasMissingData() { return vs.hasMissing(); }
public void readShort2FloatMissing() throws Exception { Variable v = null; assert(null != (v = ncfileRead.findVariable("t5"))); assert( v.getDataType() == DataType.SHORT); // standard convert with missing data assert(null != (v = dsRead.findVariable("t5"))); assert v instanceof VariableEnhanced; assert v instanceof VariableDS; VariableDS vs = (VariableDS) v; assert( vs.getDataType() == DataType.SHORT); assert( vs.hasMissing()); assert( vs.hasMissingValue()); double mv = 2 * (-9999) + 77; assert( vs.isMissing( mv)); assert( vs.isMissingValue( mv)); Array A = vs.read(); Index ima = A.getIndex(); int[] shape = A.getShape(); int i,j; assert (vs.isMissing(A.getShort(ima.set(0,0)))); for (i=0; i<shape[0]; i++) { for (j=1; j<shape[1]; j++) { float val = A.getShort(ima.set(i,j)); float want = 2* (i*10+j) + 77; if( val != want) logger.debug("{} {} {} {}", i, j, val, want); assert( val == want); } } }
@Override public boolean hasMissing() { return (vds != null) && vds.hasMissing(); }
/** * true if there may be missing data, see VariableDS.hasMissing() */ public boolean hasMissingData() { return vs.hasMissing(); }
/** * true if there may be missing data, see VariableDS.hasMissing() */ public boolean hasMissingData() { return vs.hasMissing(); }
public boolean hasMissing() { return vs.hasMissing(); }
@Override public boolean hasMissing() { return (vds != null) && vds.hasMissing(); }
public boolean hasMissing() { return vs.hasMissing(); }
public boolean hasMissing() { return vs.hasMissing(); }
public boolean hasMissing() { return vs.hasMissing(); }
/** * Convert (in place) all values in the given array that are considered * as "missing" to Float.NaN, according to isMissingData(val). * * @param values input array * @return input array, with missing values converted to NaNs. */ public float[] setMissingToNaN(float[] values) { if (!vs.hasMissing()) return values; final int length = values.length; for (int i = 0; i < length; i++) { double value = values[i]; if (vs.isMissing(value)) values[i] = Float.NaN; } return values; }
/** * Convert (in place) all values in the given array that are considered * as "missing" to Float.NaN, according to isMissingData(val). * * @param values input array * @return input array, with missing values converted to NaNs. */ public float[] setMissingToNaN(float[] values) { if (!vs.hasMissing()) return values; final int length = values.length; for (int i = 0; i < length; i++) { double value = values[i]; if (vs.isMissing(value)) values[i] = Float.NaN; } return values; }
/** * Convert (in place) all values in the given array that are considered * as "missing" to Float.NaN, according to isMissingData(val). * * @param values input array * @return input array, with missing values converted to NaNs. */ public float[] setMissingToNaN(float[] values) { if (!vs.hasMissing()) return values; final int length = values.length; for (int i = 0; i < length; i++) { double value = values[i]; if (vs.isMissing(value)) values[i] = Float.NaN; } return values; }
/** * Convert (in place) all values in the given array that are considered * as "missing" to Float.NaN, according to isMissingData(val). * * @param values input array * @return input array, with missing values converted to NaNs. */ public float[] setMissingToNaN(float[] values) { if (!vs.hasMissing()) return values; final int length = values.length; for (int i = 0; i < length; i++) { double value = values[i]; if (vs.isMissing(value)) values[i] = Float.NaN; } return values; }
public void testByteAttribute() throws IOException { String filename = TestOnLocalServer.withHttpPath("dodsC/scanCdmUnitTests/ft/stationProfile/PROFILER_wind_06min_20091030_2330.nc"); NetcdfDataset ncd = NetcdfDataset.openDataset(filename, true, null); assert ncd != null; VariableDS v = (VariableDS) ncd.findVariable("uvQualityCode"); assert v != null; assert v.hasMissing(); int count = 0; Array data = v.read(); IndexIterator ii = data.getIndexIterator(); while (ii.hasNext()) { byte val = ii.getByteNext(); if (v.isMissing(val)) count++; if (val == (byte)-1) assert v.isMissing(val); } System.out.println("size = "+v.getSize()+" missing= "+count); } }
@Test public void testByteAttribute() throws IOException { String filename = TestOnLocalServer.withHttpPath("dodsC/scanCdmUnitTests/ft/stationProfile/PROFILER_wind_06min_20091030_2330.nc"); NetcdfDataset ncd = NetcdfDataset.openDataset(filename, true, null); assert ncd != null; VariableDS v = (VariableDS) ncd.findVariable("uvQualityCode"); assert v != null; assert v.hasMissing(); int count = 0; Array data = v.read(); IndexIterator ii = data.getIndexIterator(); while (ii.hasNext()) { byte val = ii.getByteNext(); if (v.isMissing(val)) count++; if (val == (byte)-1) assert v.isMissing(val); } System.out.println("size = "+v.getSize()+" missing= "+count); } }
assert( DataType.BYTE == att.getDataType()); assert( vs.hasMissing()); assert( vs.hasFillValue()); assert( vs.isMissing( (double) ((byte) 255)));
public void readByte2Short() throws Exception { Variable t2 = null; assert(null != (t2 = ncfileRead.findVariable("t2"))); assert( t2.getDataType() == DataType.BYTE); Attribute att = t2.findAttribute(CDM.SCALE_FACTOR); assert( null != att); assert( !att.isArray()); assert( 1 == att.getLength()); assert( 2 == att.getNumericValue().doubleValue()); assert( DataType.SHORT == att.getDataType()); assert(null != (t2 = dsRead.findVariable("t2"))); assert t2 instanceof VariableEnhanced; VariableDS vs = (VariableDS) t2; assert( vs.getDataType() == DataType.SHORT) : vs.getDataType(); assert( vs.hasMissing()); Array A = vs.read(); assert( A.getElementType() == short.class) : A.getElementType(); Index ima = A.getIndex(); int[] shape = A.getShape(); int i,j; for (i=0; i<shape[0]; i++) { for (j=0; j<shape[1]; j++) { assert( A.getShort(ima.set(i,j)) == (2 * (i*10+j) + 77)); } } }