Program: 11449
Project: 11449
Buggy source:
/** 
 * Output normalized image.
 * @param x0              X coordinate of the upper left corner pixel of given tile.
 * @param y0              Y coordinate of the upper left corner pixel of given tile.
 * @param w               Width of given tile.
 * @param h               Height of given tile.
 * @param gamma0ReferenceArea The simulated image for flattened gamma0 generation.
 * @param sigma0ReferenceArea The simulated image for flattened sigma0 generation.
 * @param targetTiles     The current tiles to be computed for each target band.
 * @param targetRectangle The area in pixel coordinates to be computed.
 */
private void outputNormalizedImage(final int x0,final int y0,final int w,final int h,final double[][] gamma0ReferenceArea,final double[][] sigma0ReferenceArea,final Map<Band,Tile> targetTiles,final Rectangle targetRectangle){
  try {
    for (    Band tgtBand : targetBands) {
      final Tile targetTile=targetTiles.get(tgtBand);
      final ProductData targetData=targetTile.getDataBuffer();
      final TileIndex tgtIndex=new TileIndex(targetTile);
      final String unit=tgtBand.getUnit();
      final String bandName=tgtBand.getName();
      Band srcBand=null;
      Tile sourceTile=null;
      ProductData sourceData=null;
      TileIndex srcIndex=null;
      if (bandName.contains("String_Node_Str") || bandName.contains("String_Node_Str")) {
        srcBand=targetBandToSourceBandMap.get(tgtBand);
        sourceTile=getSourceTile(srcBand,targetRectangle);
        sourceData=sourceTile.getDataBuffer();
        srcIndex=new TileIndex(sourceTile);
      }
      double[][] simulatedImage=gamma0ReferenceArea;
      if (bandName.contains("String_Node_Str")) {
        simulatedImage=sigma0ReferenceArea;
      }
      UnitType unitType=UnitType.AMPLITUDE;
      if (unit.contains(Unit.AMPLITUDE)) {
        unitType=UnitType.AMPLITUDE;
      }
 else       if (unit.contains(Unit.INTENSITY)) {
        unitType=UnitType.INTENSITY;
      }
 else       if (unit.contains(Unit.REAL) || unit.contains(Unit.IMAGINARY)) {
        unitType=UnitType.COMPLEX;
      }
 else       if (unit.contains("String_Node_Str")) {
        unitType=UnitType.RATIO;
      }
      if (unitType == UnitType.RATIO) {
        for (int y=y0; y < y0 + h; y++) {
          final int yy=y - y0;
          tgtIndex.calculateStride(y);
          for (int x=x0; x < x0 + w; x++) {
            final int xx=x - x0;
            final int tgtIdx=tgtIndex.getIndex(x);
            final double simVal=simulatedImage[yy][xx];
            if (simVal != noDataValue && simVal != 0.0) {
              targetData.setElemDoubleAt(tgtIdx,simVal / beta0);
            }
 else {
              targetData.setElemDoubleAt(tgtIdx,noDataValue);
            }
          }
        }
      }
 else {
        double v, simVal;
        int tgtIdx, srcIdx;
        for (int y=y0; y < y0 + h; y++) {
          final int yy=y - y0;
          tgtIndex.calculateStride(y);
          srcIndex.calculateStride(y);
          for (int x=x0; x < x0 + w; x++) {
            final int xx=x - x0;
            tgtIdx=tgtIndex.getIndex(x);
            srcIdx=srcIndex.getIndex(x);
            simVal=simulatedImage[yy][xx];
            if (simVal != noDataValue) {
              simVal/=beta0;
              if (isGRD) {
                simVal/=Math.sin(incidenceAngleTPG.getPixelDouble(x,y) * Constants.DTOR);
              }
              if (simVal > threshold) {
switch (unitType) {
case AMPLITUDE:
                  v=sourceData.getElemDoubleAt(srcIdx);
                targetData.setElemDoubleAt(tgtIdx,v * v / simVal);
              break;
case INTENSITY:
            v=sourceData.getElemDoubleAt(srcIdx);
          targetData.setElemDoubleAt(tgtIdx,v / simVal);
        break;
case COMPLEX:
      v=sourceData.getElemDoubleAt(srcIdx);
    targetData.setElemDoubleAt(tgtIdx,v / Math.sqrt(simVal));
  break;
}
}
}
 else {
targetData.setElemDoubleAt(tgtIdx,noDataValue);
}
}
}
}
}
}
 catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(),e);
}
}

Fixed version (ground truth):
/** 
 * Output normalized image.
 * @param x0              X coordinate of the upper left corner pixel of given tile.
 * @param y0              Y coordinate of the upper left corner pixel of given tile.
 * @param w               Width of given tile.
 * @param h               Height of given tile.
 * @param gamma0ReferenceArea The simulated image for flattened gamma0 generation.
 * @param sigma0ReferenceArea The simulated image for flattened sigma0 generation.
 * @param targetTiles     The current tiles to be computed for each target band.
 * @param targetRectangle The area in pixel coordinates to be computed.
 */
private void outputNormalizedImage(final int x0,final int y0,final int w,final int h,final double[][] gamma0ReferenceArea,final double[][] sigma0ReferenceArea,final Map<Band,Tile> targetTiles,final Rectangle targetRectangle){
  try {
    for (    Band tgtBand : targetBands) {
      final Tile targetTile=targetTiles.get(tgtBand);
      final ProductData targetData=targetTile.getDataBuffer();
      final TileIndex tgtIndex=new TileIndex(targetTile);
      final String unit=tgtBand.getUnit();
      final String bandName=tgtBand.getName();
      Band srcBand=null;
      Tile sourceTile=null;
      ProductData sourceData=null;
      TileIndex srcIndex=null;
      if (bandName.contains("String_Node_Str") || bandName.contains("String_Node_Str")) {
        srcBand=targetBandToSourceBandMap.get(tgtBand);
        sourceTile=getSourceTile(srcBand,targetRectangle);
        sourceData=sourceTile.getDataBuffer();
        srcIndex=new TileIndex(sourceTile);
      }
      double[][] simulatedImage=null;
      if (bandName.contains("String_Node_Str")) {
        simulatedImage=sigma0ReferenceArea.clone();
      }
 else {
        simulatedImage=gamma0ReferenceArea.clone();
      }
      UnitType unitType=UnitType.AMPLITUDE;
      if (unit.contains(Unit.AMPLITUDE)) {
        unitType=UnitType.AMPLITUDE;
      }
 else       if (unit.contains(Unit.INTENSITY)) {
        unitType=UnitType.INTENSITY;
      }
 else       if (unit.contains(Unit.REAL) || unit.contains(Unit.IMAGINARY)) {
        unitType=UnitType.COMPLEX;
      }
 else       if (unit.contains("String_Node_Str")) {
        unitType=UnitType.RATIO;
      }
      if (unitType == UnitType.RATIO) {
        for (int y=y0; y < y0 + h; y++) {
          final int yy=y - y0;
          tgtIndex.calculateStride(y);
          for (int x=x0; x < x0 + w; x++) {
            final int xx=x - x0;
            final int tgtIdx=tgtIndex.getIndex(x);
            double simVal=simulatedImage[yy][xx];
            if (simVal != noDataValue && simVal != 0.0) {
              simVal/=beta0;
              if (isGRD) {
                simVal/=Math.sin(incidenceAngleTPG.getPixelDouble(x,y) * Constants.DTOR);
              }
              targetData.setElemDoubleAt(tgtIdx,simVal);
            }
 else {
              targetData.setElemDoubleAt(tgtIdx,noDataValue);
            }
          }
        }
      }
 else {
        double v, simVal;
        int tgtIdx, srcIdx;
        for (int y=y0; y < y0 + h; y++) {
          final int yy=y - y0;
          tgtIndex.calculateStride(y);
          srcIndex.calculateStride(y);
          for (int x=x0; x < x0 + w; x++) {
            final int xx=x - x0;
            tgtIdx=tgtIndex.getIndex(x);
            srcIdx=srcIndex.getIndex(x);
            simVal=simulatedImage[yy][xx];
            if (simVal != noDataValue) {
              simVal/=beta0;
              if (isGRD) {
                simVal/=Math.sin(incidenceAngleTPG.getPixelDouble(x,y) * Constants.DTOR);
              }
              if (simVal > threshold) {
switch (unitType) {
case AMPLITUDE:
                  v=sourceData.getElemDoubleAt(srcIdx);
                targetData.setElemDoubleAt(tgtIdx,v * v / simVal);
              break;
case INTENSITY:
            v=sourceData.getElemDoubleAt(srcIdx);
          targetData.setElemDoubleAt(tgtIdx,v / simVal);
        break;
case COMPLEX:
      v=sourceData.getElemDoubleAt(srcIdx);
    targetData.setElemDoubleAt(tgtIdx,v / Math.sqrt(simVal));
  break;
}
}
}
 else {
targetData.setElemDoubleAt(tgtIdx,noDataValue);
}
}
}
}
}
}
 catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(),e);
}
}