@Test public void testScaledFillValue() throws URISyntaxException, IOException { File testResource = new File(getClass().getResource("testScaledFillValue.ncml").toURI()); try (NetcdfDataset ncd = NetcdfDataset.openDataset(testResource.getAbsolutePath(), true, null)) { VariableDS fooVar = (VariableDS) ncd.findVariable("foo"); double expectedFillValue = .99999; double actualFillValue = fooVar.getFillValue(); // Scale factor of "1.e-05" has been applied to original "99999". Assert2.assertNearlyEquals(expectedFillValue, actualFillValue); fooVar.removeEnhancement(Enhance.ConvertMissing); double fooValWithoutNaNs = fooVar.read().getDouble(0); // "foo" value is equals to fill value. Scale factor has been applied to both. Assert2.assertNearlyEquals(actualFillValue, fooValWithoutNaNs); // "foo" value is considered a fill. Assert.assertTrue(fooVar.isFillValue(fooValWithoutNaNs)); fooVar.addEnhancement(Enhance.ConvertMissing); double fooValWithNaNs = fooVar.read().getDouble(0); // "foo" value was converted to NaN because it was equal to _FillValue. Assert.assertTrue(Double.isNaN(fooValWithNaNs)); // Note that we can't use isFillValue() because we've applied the ConvertMissing enhancement. // See the EnhanceScaleMissingUnsigned Javadoc. Assert.assertTrue(fooVar.isMissing(fooValWithNaNs)); } }
double vald = ((Number) val).doubleValue(); double valde = ((Number) vale).doubleValue(); if (ve.isFillValue(vald)) { if (v.getDataType().isFloatingPoint()) Assert.assertTrue(Double.toString(valde), Double.isNaN(valde)); double valde = ((Number) vale).doubleValue(); if (val.equals(fillValue)) Assert.assertTrue(ve.isFillValue(vald)); if (ve.isFillValue(vald)) { if (v.getDataType().isFloatingPoint()) Assert.assertTrue(Double.toString(valde), Double.isNaN(valde));
assert( vs.hasFillValue()); assert( vs.isMissing( (double) ((byte) 255))); assert( vs.isFillValue( (double) ((byte) 255)));
Assert.assertTrue(fooVar.isFillValue(-0.01)); Assert.assertTrue(fooVar.isFillValue(-0.01)); Assert.assertTrue(fooVar.isMissingValue(-0.01)); Assert.assertTrue(fooVar.isInvalidData(-0.01));