public void removeFactorsForCurrentTile(Band targetBand, Tile targetTile, String srcBandName) throws OperatorException { Band sourceBand = sourceProduct.getBand(targetBand.getName()); Tile sourceTile = calibrationOp.getSourceTile(sourceBand, targetTile.getRectangle()); targetTile.setRawSamples(sourceTile.getRawSamples()); }
/** * Overridden to call the {@link #computeSample(int, int, Sample[], WritableSample) computeSample} * method for every pixel in the given tile's rectangle. * * @param targetBand The target band. * @param targetTile The current tile associated with the target band to be computed. * @param pm A progress monitor which should be used to determine computation cancelation * requests. * @throws OperatorException */ @Override public final void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) throws OperatorException { final Rectangle targetRectangle = targetTile.getRectangle(); final Point location = new Point(); final Sample[] sourceSamples = createSourceSamples(targetRectangle, location); final Sample sourceMaskSamples = createSourceMaskSamples(targetRectangle, location); final WritableSample targetSample = createTargetSample(targetTile, location); final int x1 = targetTile.getMinX(); final int y1 = targetTile.getMinY(); final int x2 = targetTile.getMaxX(); final int y2 = targetTile.getMaxY(); try { pm.beginTask(getId(), targetTile.getHeight()); if (sourceMaskSamples != null) { for (location.y = y1; location.y <= y2; location.y++) { for (location.x = x1; location.x <= x2; location.x++) { if (sourceMaskSamples.getBoolean()) { computeSample(location.x, location.y, sourceSamples, targetSample); } else { setInvalid(targetSample); } } pm.worked(1); } } else { for (location.y = y1; location.y <= y2; location.y++) { for (location.x = x1; location.x <= x2; location.x++) { computeSample(location.x, location.y, sourceSamples, targetSample); } pm.worked(1); } } } finally { pm.done(); } }
/** * Called by the framework in order to compute a tile for the given target band. * * <p>The default implementation throws a runtime exception with the message "not implemented". * * @param targetBand The target band. * @param targetTile The current tile associated with the target band to be computed. * @param pm A progress monitor which should be used to determine computation cancelation * requests. * @throws org.esa.snap.framework.gpf.OperatorException If an error occurs during computation of * the target raster. */ public void computeTile(Band targetBand, Tile targetTile, ProgressMonitor pm) throws OperatorException { final Rectangle targetTileRectangle = targetTile.getRectangle(); final int x0 = targetTileRectangle.x; final int y0 = targetTileRectangle.y; final int w = targetTileRectangle.width; final int h = targetTileRectangle.height; Tile sourceRaster1 = null; ProductData srcData1 = null; ProductData srcData2 = null; Band sourceBand1 = null; final String[] srcBandNames = targetBandNameToSourceBandName.get(targetBand.getName()); if (srcBandNames.length == 1) { sourceBand1 = sourceProduct.getBand(srcBandNames[0]); sourceRaster1 = calibrationOp.getSourceTile(sourceBand1, targetTileRectangle); srcData1 = sourceRaster1.getDataBuffer(); } else { sourceBand1 = sourceProduct.getBand(srcBandNames[0]); final Band sourceBand2 = sourceProduct.getBand(srcBandNames[1]); sourceRaster1 = calibrationOp.getSourceTile(sourceBand1, targetTileRectangle); final Tile sourceRaster2 = calibrationOp.getSourceTile(sourceBand2, targetTileRectangle); srcData1 = sourceRaster1.getDataBuffer(); srcData2 = sourceRaster2.getDataBuffer(); } final Unit.UnitType bandUnit = Unit.getUnitType(sourceBand1); // copy band if unit is phase if (bandUnit == Unit.UnitType.PHASE) { targetTile.setRawSamples(sourceRaster1.getRawSamples()); return; } final ProductData trgData = targetTile.getDataBuffer(); final TileIndex srcIndex = new TileIndex(sourceRaster1); final TileIndex tgtIndex = new TileIndex(targetTile); final int maxY = y0 + h; final int maxX = x0 + w; double dn = 0, dn2 = 0, sigma, i, q; int srcIdx, tgtIdx; for (int y = y0; y < maxY; ++y) { srcIndex.calculateStride(y); tgtIndex.calculateStride(y); for (int x = x0; x < maxX; ++x) { srcIdx = srcIndex.getIndex(x); tgtIdx = tgtIndex.getIndex(x); if (bandUnit == Unit.UnitType.AMPLITUDE) { dn = srcData1.getElemDoubleAt(srcIdx); dn2 = dn * dn; } else if (bandUnit == Unit.UnitType.INTENSITY) { dn2 = srcData1.getElemDoubleAt(srcIdx); } else if (bandUnit == Unit.UnitType.REAL || bandUnit == Unit.UnitType.IMAGINARY) { if (outputImageInComplex) { dn = srcData1.getElemDoubleAt(srcIdx); } else { i = srcData1.getElemDoubleAt(srcIdx); q = srcData2.getElemDoubleAt(srcIdx); dn2 = i * i + q * q; } } else { throw new OperatorException("ALOS Calibration: unhandled unit"); } if (isComplex && outputImageInComplex) { sigma = dn * Math.sqrt(calibrationFactor); } else { sigma = dn2 * calibrationFactor; } if (outputImageScaleInDb) { // convert calibration result to dB if (sigma < underFlowFloat) { sigma = -underFlowFloat; } else { sigma = 10.0 * Math.log10(sigma); } } trgData.setElemDoubleAt(tgtIdx, sigma); } } }
public TileIndex(final Tile tile) { tileOffset = tile.getScanlineOffset(); tileStride = tile.getScanlineStride(); tileMinX = tile.getMinX(); tileMinY = tile.getMinY(); }