Program: 11470
Project: 11470
Buggy source:
/** 
 * Apply calibrations to the given point. The following calibrations are included: calibration constant, antenna pattern compensation, range spreading loss correction and incidence angle correction.
 * @param v                   The pixel value.
 * @param slantRange          The slant range (in m).
 * @param satelliteHeight     The distance from satellite to earth centre (in m).
 * @param sceneToEarthCentre  The distance from the backscattering element position to earth centre (in m).
 * @param localIncidenceAngle The local incidence angle (in degrees).
 * @param bandPolar           The source band polarization index.
 * @param bandUnit            The source band unit.
 * @param subSwathIndex       The sub swath index for current pixel for wide swath product case.
 * @return The calibrated pixel value.
 */
public double applyCalibration(final double v,final double rangeIndex,final double azimuthIndex,final double slantRange,final double satelliteHeight,final double sceneToEarthCentre,final double localIncidenceAngle,final String bandPolar,final Unit.UnitType bandUnit,int[] subSwathIndex){
  int bandPolarIdx=0;
  if (bandPolar != null && mdsPolar[1] != null && mdsPolar[1].contains(bandPolar)) {
    bandPolarIdx=1;
  }
  double sigma=0.0;
  if (bandUnit == Unit.UnitType.AMPLITUDE) {
    sigma=v * v;
  }
 else   if (bandUnit == Unit.UnitType.AMPLITUDE_DB) {
    sigma=FastMath.pow(10,v / 5.0);
  }
 else   if (bandUnit == Unit.UnitType.INTENSITY || bandUnit == Unit.UnitType.REAL || bandUnit == Unit.UnitType.IMAGINARY) {
    sigma=v;
  }
 else   if (bandUnit == Unit.UnitType.INTENSITY_DB) {
    sigma=FastMath.pow(10,v / 10.0);
  }
 else {
    throw new OperatorException("String_Node_Str");
  }
  sigma*=FastMath.sin(Math.abs(localIncidenceAngle) * Constants.DTOR) / newCalibrationConstant[bandPolarIdx];
  if (multilookFlag && antElevCorrFlag) {
    return sigma;
  }
  if (auxFile == null || !auxFile.contains(CalibrationOp.PRODUCT_AUX)) {
    sigma*=FastMath.pow(slantRange / refSlantRange800km,rangeSpreadingCompPower);
  }
  if (applyAntennaPatternCorr) {
    final double elevationAngle=computeElevationAngle(slantRange,satelliteHeight,sceneToEarthCentre);
    double gain;
    if (wideSwathProductFlag) {
      if (subSwathIndex[0] == INVALID_SUB_SWATH_INDEX) {
        final TiePointInterpolator slantRangeTPGInterp=new TiePointInterpolator(slantRangeTime);
        computeSubSwathIndex(rangeIndex,azimuthIndex,newRefElevationAngle,subSwathIndex,slantRangeTPGInterp);
      }
      gain=getAntennaPatternGain(elevationAngle,bandPolarIdx,newRefElevationAngle,newAntennaPatternWideSwath,false,subSwathIndex);
    }
 else {
      gain=computeAntPatGain(elevationAngle,newRefElevationAngle[0],newAntennaPatternSingleSwath[bandPolarIdx]);
    }
    sigma/=gain;
  }
  return sigma;
}

Fixed version (ground truth):
/** 
 * Apply calibrations to the given point. The following calibrations are included: calibration constant, antenna pattern compensation, range spreading loss correction and incidence angle correction.
 * @param v                   The pixel value.
 * @param slantRange          The slant range (in m).
 * @param satelliteHeight     The distance from satellite to earth centre (in m).
 * @param sceneToEarthCentre  The distance from the backscattering element position to earth centre (in m).
 * @param localIncidenceAngle The local incidence angle (in degrees).
 * @param bandPolar           The source band polarization index.
 * @param bandUnit            The source band unit.
 * @param subSwathIndex       The sub swath index for current pixel for wide swath product case.
 * @return The calibrated pixel value.
 */
public double applyCalibration(final double v,final double rangeIndex,final double azimuthIndex,final double slantRange,final double satelliteHeight,final double sceneToEarthCentre,final double localIncidenceAngle,final String bandName,final String bandPolar,final Unit.UnitType bandUnit,int[] subSwathIndex){
  int bandPolarIdx=0;
  if (bandPolar != null && mdsPolar[1] != null && mdsPolar[1].contains(bandPolar)) {
    bandPolarIdx=1;
  }
  double sigma=0.0;
  if (bandUnit == Unit.UnitType.AMPLITUDE) {
    sigma=v * v;
  }
 else   if (bandUnit == Unit.UnitType.AMPLITUDE_DB) {
    sigma=FastMath.pow(10,v / 5.0);
  }
 else   if (bandUnit == Unit.UnitType.INTENSITY || bandUnit == Unit.UnitType.REAL || bandUnit == Unit.UnitType.IMAGINARY) {
    sigma=v;
  }
 else   if (bandUnit == Unit.UnitType.INTENSITY_DB) {
    sigma=FastMath.pow(10,v / 10.0);
  }
 else {
    throw new OperatorException("String_Node_Str");
  }
  sigma*=FastMath.sin(Math.abs(localIncidenceAngle) * Constants.DTOR) / newCalibrationConstant[bandPolarIdx];
  if (multilookFlag && antElevCorrFlag) {
    return sigma;
  }
  if (auxFile == null || !auxFile.contains(CalibrationOp.PRODUCT_AUX)) {
    sigma*=FastMath.pow(slantRange / refSlantRange800km,rangeSpreadingCompPower);
  }
  if (applyAntennaPatternCorr) {
    final double elevationAngle=computeElevationAngle(slantRange,satelliteHeight,sceneToEarthCentre);
    double gain;
    if (wideSwathProductFlag) {
      if (subSwathIndex[0] == INVALID_SUB_SWATH_INDEX) {
        final TiePointInterpolator slantRangeTPGInterp=new TiePointInterpolator(slantRangeTime);
        computeSubSwathIndex(rangeIndex,azimuthIndex,newRefElevationAngle,subSwathIndex,slantRangeTPGInterp);
      }
      gain=getAntennaPatternGain(elevationAngle,bandPolarIdx,newRefElevationAngle,newAntennaPatternWideSwath,false,subSwathIndex);
    }
 else {
      gain=computeAntPatGain(elevationAngle,newRefElevationAngle[0],newAntennaPatternSingleSwath[bandPolarIdx]);
    }
    sigma/=gain;
  }
  return sigma;
}