Program: 11494
Project: 11494
Buggy source:
/** 
 * 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".</p>
 * @param targetTileMap   The target tiles associated with all target bands to be computed.
 * @param targetRectangle The rectangle of target tile.
 * @param pm              A progress monitor which should be used to determine computation cancelation requests.
 * @throws org.esa.beam.framework.gpf.OperatorException If an error occurs during computation of the target raster.
 */
@Override public void computeTileStack(Map<Band,Tile> targetTileMap,Rectangle targetRectangle,ProgressMonitor pm) throws OperatorException {
  try {
    int y0=targetRectangle.y;
    int yN=y0 + targetRectangle.height - 1;
    int x0=targetRectangle.x;
    int xN=targetRectangle.x + targetRectangle.width - 1;
    final Window tileWindow=new Window(y0,yN,x0,xN);
    Band topoPhaseBand;
    Band targetBand_I;
    Band targetBand_Q;
    for (    String ifgKey : targetMap.keySet()) {
      ProductContainer product=targetMap.get(ifgKey);
      GeoPoint[] geoCorners=GeoUtils.computeCorners(product.sourceMaster.metaData,product.sourceMaster.orbit,tileWindow);
      PixelPos[] pixelCorners=new PixelPos[2];
      pixelCorners[0]=dem.getIndex(new GeoPos(geoCorners[0].lat,geoCorners[0].lon));
      pixelCorners[1]=dem.getIndex(new GeoPos(geoCorners[1].lat,geoCorners[1].lon));
      double[] tileHeights=computeMaxHeight(pixelCorners,targetRectangle);
      GeoPoint geoExtent=GeoUtils.defineExtraPhiLam(tileHeights[0],tileHeights[1],tileWindow,product.sourceMaster.metaData,product.sourceMaster.orbit);
      geoCorners=GeoUtils.extendCorners(geoExtent,geoCorners);
      pixelCorners[0]=dem.getIndex(new GeoPos(geoCorners[0].lat,geoCorners[0].lon));
      pixelCorners[1]=dem.getIndex(new GeoPos(geoCorners[1].lat,geoCorners[1].lon));
      pixelCorners[0]=new PixelPos(Math.ceil(pixelCorners[0].x),Math.floor(pixelCorners[0].y));
      pixelCorners[1]=new PixelPos(Math.floor(pixelCorners[1].x),Math.ceil(pixelCorners[1].y));
      GeoPos upperLeftGeo=dem.getGeoPos(pixelCorners[0]);
      int nLatPixels=(int)Math.abs(pixelCorners[1].y - pixelCorners[0].y);
      int nLonPixels=(int)Math.abs(pixelCorners[1].x - pixelCorners[0].x);
      int startX=(int)pixelCorners[0].x;
      int endX=startX + nLonPixels;
      int startY=(int)pixelCorners[0].y;
      int endY=startY + nLatPixels;
      double[][] elevation=new double[nLatPixels][nLonPixels];
      for (int y=startY, i=0; y < endY; y++, i++) {
        for (int x=startX, j=0; x < endX; x++, j++) {
          try {
            double elev=dem.getSample(x,y);
            if (Double.isNaN(elev))             elev=demNoDataValue;
            elevation[i][j]=elev;
          }
 catch (          Exception e) {
            elevation[i][j]=demNoDataValue;
          }
        }
      }
      DemTile demTile=new DemTile(upperLeftGeo.lat * Constants.DTOR,upperLeftGeo.lon * Constants.DTOR,nLatPixels,nLonPixels,Math.abs(demSamplingLat),Math.abs(demSamplingLon),(long)demNoDataValue);
      demTile.setData(elevation);
      final TopoPhase topoPhase=new TopoPhase(product.sourceMaster.metaData,product.sourceMaster.orbit,product.sourceSlave.metaData,product.sourceSlave.orbit,tileWindow,demTile);
      topoPhase.radarCode();
      topoPhase.gridData();
      Tile tileReal=getSourceTile(product.sourceMaster.realBand,targetRectangle);
      Tile tileImag=getSourceTile(product.sourceMaster.imagBand,targetRectangle);
      ComplexDoubleMatrix complexIfg=TileUtilsDoris.pullComplexDoubleMatrix(tileReal,tileImag);
      final ComplexDoubleMatrix cplxTopoPhase=new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)),MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
      complexIfg.muli(cplxTopoPhase.conji());
      targetBand_I=targetProduct.getBand(product.targetBandName_I);
      Tile tileOutReal=targetTileMap.get(targetBand_I);
      TileUtilsDoris.pushDoubleMatrix(complexIfg.real(),tileOutReal,targetRectangle);
      targetBand_Q=targetProduct.getBand(product.targetBandName_Q);
      Tile tileOutImag=targetTileMap.get(targetBand_Q);
      TileUtilsDoris.pushDoubleMatrix(complexIfg.imag(),tileOutImag,targetRectangle);
      topoPhaseBand=targetProduct.getBand(product.masterSubProduct.targetBandName_I);
      Tile tileOutTopoPhase=targetTileMap.get(topoPhaseBand);
      TileUtilsDoris.pushDoubleArray2D(topoPhase.demPhase,tileOutTopoPhase,targetRectangle);
    }
  }
 catch (  Exception e) {
    throw new OperatorException(e);
  }
}

Fixed version (ground truth):
/** 
 * 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".</p>
 * @param targetTileMap   The target tiles associated with all target bands to be computed.
 * @param targetRectangle The rectangle of target tile.
 * @param pm              A progress monitor which should be used to determine computation cancelation requests.
 * @throws org.esa.beam.framework.gpf.OperatorException If an error occurs during computation of the target raster.
 */
@Override public void computeTileStack(Map<Band,Tile> targetTileMap,Rectangle targetRectangle,ProgressMonitor pm) throws OperatorException {
  try {
    int y0=targetRectangle.y;
    int yN=y0 + targetRectangle.height - 1;
    int x0=targetRectangle.x;
    int xN=targetRectangle.x + targetRectangle.width - 1;
    final Window tileWindow=new Window(y0,yN,x0,xN);
    Band topoPhaseBand;
    Band targetBand_I;
    Band targetBand_Q;
    for (    String ifgKey : targetMap.keySet()) {
      ProductContainer product=targetMap.get(ifgKey);
      GeoPoint[] geoCorners=GeoUtils.computeCorners(product.sourceMaster.metaData,product.sourceMaster.orbit,tileWindow);
      PixelPos[] pixelCorners=new PixelPos[2];
      pixelCorners[0]=dem.getIndex(new GeoPos(geoCorners[0].lat,geoCorners[0].lon));
      pixelCorners[1]=dem.getIndex(new GeoPos(geoCorners[1].lat,geoCorners[1].lon));
      final int x0DEM=(int)Math.round(pixelCorners[0].x);
      final int y0DEM=(int)Math.round(pixelCorners[0].y);
      final int x1DEM=(int)Math.round(pixelCorners[1].x);
      final int y1DEM=(int)Math.round(pixelCorners[1].y);
      final Rectangle demTileRect=new Rectangle(x0DEM,y0DEM,x1DEM - x0DEM + 1,y1DEM - y0DEM + 1);
      double[] tileHeights=computeMaxHeight(pixelCorners,demTileRect);
      GeoPoint geoExtent=GeoUtils.defineExtraPhiLam(tileHeights[0],tileHeights[1],tileWindow,product.sourceMaster.metaData,product.sourceMaster.orbit);
      geoCorners=GeoUtils.extendCorners(geoExtent,geoCorners);
      pixelCorners[0]=dem.getIndex(new GeoPos(geoCorners[0].lat,geoCorners[0].lon));
      pixelCorners[1]=dem.getIndex(new GeoPos(geoCorners[1].lat,geoCorners[1].lon));
      pixelCorners[0]=new PixelPos(Math.floor(pixelCorners[0].x),Math.floor(pixelCorners[0].y));
      pixelCorners[1]=new PixelPos(Math.ceil(pixelCorners[1].x),Math.ceil(pixelCorners[1].y));
      GeoPos upperLeftGeo=dem.getGeoPos(pixelCorners[0]);
      int nLatPixels=(int)Math.abs(pixelCorners[1].y - pixelCorners[0].y);
      int nLonPixels=(int)Math.abs(pixelCorners[1].x - pixelCorners[0].x);
      int startX=(int)pixelCorners[0].x;
      int endX=startX + nLonPixels;
      int startY=(int)pixelCorners[0].y;
      int endY=startY + nLatPixels;
      double[][] elevation=new double[nLatPixels][nLonPixels];
      for (int y=startY, i=0; y < endY; y++, i++) {
        for (int x=startX, j=0; x < endX; x++, j++) {
          try {
            double elev=dem.getSample(x,y);
            if (Double.isNaN(elev)) {
              elev=demNoDataValue;
            }
            elevation[i][j]=elev;
          }
 catch (          Exception e) {
            elevation[i][j]=demNoDataValue;
          }
        }
      }
      DemTile demTile=new DemTile(upperLeftGeo.lat * Constants.DTOR,upperLeftGeo.lon * Constants.DTOR,nLatPixels,nLonPixels,Math.abs(demSamplingLat),Math.abs(demSamplingLon),(long)demNoDataValue);
      demTile.setData(elevation);
      final TopoPhase topoPhase=new TopoPhase(product.sourceMaster.metaData,product.sourceMaster.orbit,product.sourceSlave.metaData,product.sourceSlave.orbit,tileWindow,demTile);
      topoPhase.radarCode();
      topoPhase.gridData();
      Tile tileReal=getSourceTile(product.sourceMaster.realBand,targetRectangle);
      Tile tileImag=getSourceTile(product.sourceMaster.imagBand,targetRectangle);
      ComplexDoubleMatrix complexIfg=TileUtilsDoris.pullComplexDoubleMatrix(tileReal,tileImag);
      final ComplexDoubleMatrix cplxTopoPhase=new ComplexDoubleMatrix(MatrixFunctions.cos(new DoubleMatrix(topoPhase.demPhase)),MatrixFunctions.sin(new DoubleMatrix(topoPhase.demPhase)));
      complexIfg.muli(cplxTopoPhase.conji());
      targetBand_I=targetProduct.getBand(product.targetBandName_I);
      Tile tileOutReal=targetTileMap.get(targetBand_I);
      TileUtilsDoris.pushDoubleMatrix(complexIfg.real(),tileOutReal,targetRectangle);
      targetBand_Q=targetProduct.getBand(product.targetBandName_Q);
      Tile tileOutImag=targetTileMap.get(targetBand_Q);
      TileUtilsDoris.pushDoubleMatrix(complexIfg.imag(),tileOutImag,targetRectangle);
      topoPhaseBand=targetProduct.getBand(product.masterSubProduct.targetBandName_I);
      Tile tileOutTopoPhase=targetTileMap.get(topoPhaseBand);
      TileUtilsDoris.pushDoubleArray2D(topoPhase.demPhase,tileOutTopoPhase,targetRectangle);
    }
  }
 catch (  Exception e) {
    throw new OperatorException(e);
  }
}