private void setBandProperties(Band band, String validMaskExpression) { band.setDescription(bandDescription); band.setUnit(bandUnit); band.setSpectralWavelength(bandWavelength); band.setGeophysicalNoDataValue(noDataValue); band.setNoDataValueUsed(noDataValueUsed); band.setValidPixelExpression(validMaskExpression); }
@Override protected void configureTargetProduct(ProductConfigurer productConfigurer) { super.configureTargetProduct(productConfigurer); if (nadir) { final Band nadirSstBand = productConfigurer.addBand(NADIR_SST_BAND_NAME, ProductData.TYPE_FLOAT32); nadirSstBand.setUnit(SstConstants.OUT_BAND_UNIT); nadirSstBand.setDescription(SstConstants.OUT_BAND_NADIR_DESCRIPTION); nadirSstBand.setGeophysicalNoDataValue(invalidSstValue); nadirSstBand.setNoDataValueUsed(true); } if (dual) { final Band dualSstBand = productConfigurer.addBand(DUAL_SST_BAND_NAME, ProductData.TYPE_FLOAT32); dualSstBand.setUnit(SstConstants.OUT_BAND_UNIT); dualSstBand.setDescription(SstConstants.OUT_BAND_DUAL_DESCRIPTION); dualSstBand.setGeophysicalNoDataValue(invalidSstValue); dualSstBand.setNoDataValueUsed(true); } }
public void testSetGeophysicalNoDataValue() { final Band b = createBand(p, ProductData.TYPE_UINT16, 0.005, 4, false); ChangeDetector detector = new ChangeDetector(); p.addProductNodeListener(detector); final double geoValue = 32.237; final int rawValue = (int) ((geoValue - 4) / 0.005); b.setGeophysicalNoDataValue(geoValue); assertEquals(rawValue, b.getNoDataValue(), 1e-10); assertEquals(4 + 0.005 * rawValue, b.getGeophysicalNoDataValue(), 1e-10); assertEquals(1, detector.sourceNodes.size()); assertSame(b, detector.sourceNodes.get(0)); assertEquals(1, detector.propertyNames.size()); assertEquals(RasterDataNode.PROPERTY_NAME_NO_DATA_VALUE, detector.propertyNames.get(0)); }
public void testSetGeophysicalNoDataValueWithLogScaling() { final Band b = createBand(p, ProductData.TYPE_UINT16, 2.3, -1.8, true); final int rawValue = 0; final double geoValue = Math.pow(10.0, -1.8 + 2.3 * rawValue); b.setNoDataValue(rawValue); assertEquals(rawValue, b.getNoDataValue(), 1e-10); assertEquals(geoValue, b.getGeophysicalNoDataValue(), 1e-10); b.setGeophysicalNoDataValue(geoValue); assertEquals(rawValue, b.getNoDataValue(), 1e-10); assertEquals(geoValue, b.getGeophysicalNoDataValue(), 1e-10); }
private static Band _createFloatingPointBand(int type, double scalingFactor, boolean dataValueUsed, double noDataValue) { Product product = new Product("n", "t", W, H); Band band = product.addBand("x", type); band.setScalingFactor(scalingFactor); band.setGeophysicalNoDataValue(noDataValue); band.setNoDataValueUsed(dataValueUsed); ProductData rasterData = band.createCompatibleRasterData(); for (int i = 0; i < N; i++) { rasterData.setElemDoubleAt(i, (i + 1) + 0.1); } band.setRasterData(rasterData); return band; }
private void initProduct(final String productName) { final int width = _fileInfo.getWidth(); final int height = _fileInfo.getHeight(); _product = new Product(productName, GETASSE30ReaderPlugIn.FORMAT_NAME, width, height, this); final MapInfo mapInfo = new MapInfo(MapProjectionRegistry.getProjection(IdentityTransformDescriptor.NAME), 0.5F, 0.5F, _fileInfo.getEasting(), _fileInfo.getNorthing() + height * _fileInfo.getPixelSizeY(), _fileInfo.getPixelSizeX(), _fileInfo.getPixelSizeY(), Datum.WGS_84); mapInfo.setSceneWidth(width); mapInfo.setSceneHeight(height); _product.setGeoCoding(new MapGeoCoding(mapInfo)); _product.setDescription("GETASSE30 DEM"); Band elevationBand = new Band("elevation", ProductData.TYPE_INT16, width, height); elevationBand.setUnit("m"); elevationBand.setDescription("GETASSE30 Elevation"); // setting geo-physical no-data value to prevent for scaling elevationBand.setGeophysicalNoDataValue(_fileInfo.getNoDataValue()); _product.addBand(elevationBand); }
floatBand.setGeophysicalNoDataValue(-999.0); assertEquals("fneq(b,-999.0)", floatBand.getValidMaskExpression()); floatBand.setGeophysicalNoDataValue(1.0 / z); assertEquals("!inf(b)", floatBand.getValidMaskExpression()); floatBand.setGeophysicalNoDataValue(-1.0 / z); assertEquals("!inf(b)", floatBand.getValidMaskExpression()); floatBand.setGeophysicalNoDataValue(Double.NaN); assertEquals("!nan(b)", floatBand.getValidMaskExpression()); intBand.setGeophysicalNoDataValue(40); assertEquals("i.raw != 4.0", intBand.getValidMaskExpression());
targetBand.setGeophysicalNoDataValue(sourceBand.getGeophysicalNoDataValue()); } else { targetBand.setNoDataValue(sourceBand.getNoDataValue()); targetBand.setGeophysicalNoDataValue(defaultNoDataValue);
realBand.setGeophysicalNoDataValue(computedBand.getGeophysicalNoDataValue()); realBand.setNoDataValueUsed(computedBand.isNoDataValueUsed()); if (computedBand.isStxSet()) {
@Test public void testGetSamplesFloatWithNoDataAndBorderExtender() { Product product = new Product("n", "t", 1000, 1000); product.setPreferredTileSize(100, 100); Band band = product.addBand("x", ProductData.TYPE_FLOAT32); band.setScalingFactor(10.0); band.setGeophysicalNoDataValue(5025); band.setNoDataValueUsed(true); band.setSourceImage(VirtualBandOpImage.create("Y * 1000 + X", band.getDataType(), Float.NaN, product, ResolutionLevel.MAXRES)); MultiLevelImage sourceImage = band.getSourceImage(); Rectangle tileBounds = sourceImage.getTile(0,0).getBounds(); tileBounds.grow(10,0); BorderExtenderConstant nanExtender = new BorderExtenderConstant(new double[]{Float.NaN}); TileImpl tile = new TileImpl(band, sourceImage.getExtendedData(tileBounds, nanExtender)); try { float[] samplesFloat = tile.getSamplesFloat(); assertEquals(120*100, samplesFloat.length); assertEquals(Float.NaN, samplesFloat[2], 1.0e-6f); // NaN because of BorderExtender assertEquals(5005, samplesFloat[10], 1.0e-6f); assertEquals(Float.NaN, samplesFloat[12], 1.0e-6f); // NaN because of GeophysicalNoDataValue } catch (OperatorException e) { Assert.fail("OperatorException should not been thrown."); } }