Program: 11530
Project: 11530
Buggy source:
/** 
 * Compute zero Doppler time for given point with the product orbit state vectors using bisection method.
 * @param firstLineUTC     The zero Doppler time for the first range line.
 * @param lineTimeInterval The line time interval.
 * @param wavelength       The radar wavelength.
 * @param earthPoint       The earth point in xyz coordinate.
 * @param orbit            The object holding orbit state vectors.
 * @return The zero Doppler time in days if it is found, NonValidZeroDopplerTime otherwise.
 * @throws OperatorException The operator exception.
 */
public static double getZeroDopplerTime(final double firstLineUTC,final double lineTimeInterval,final double wavelength,final double[] earthPoint,final SARGeocoding.Orbit orbit) throws OperatorException {
  final int numOrbitVec=orbit.orbitStateVectors.length;
  double[] sensorPosition=new double[3];
  double[] sensorVelocity=new double[3];
  double firstVecTime=0.0;
  double secondVecTime=0.0;
  double firstVecFreq=0.0;
  double secondVecFreq=0.0;
  for (int i=0; i < numOrbitVec; i++) {
    sensorPosition[0]=orbit.orbitStateVectors[i].x_pos;
    sensorPosition[1]=orbit.orbitStateVectors[i].y_pos;
    sensorPosition[2]=orbit.orbitStateVectors[i].z_pos;
    sensorVelocity[0]=orbit.orbitStateVectors[i].x_vel;
    sensorVelocity[1]=orbit.orbitStateVectors[i].y_vel;
    sensorVelocity[2]=orbit.orbitStateVectors[i].z_vel;
    final double currentFreq=getDopplerFrequency(earthPoint,sensorPosition,sensorVelocity,wavelength);
    if (i == 0 || firstVecFreq * currentFreq > 0) {
      firstVecTime=orbit.orbitStateVectors[i].time_mjd;
      firstVecFreq=currentFreq;
    }
 else {
      secondVecTime=orbit.orbitStateVectors[i].time_mjd;
      secondVecFreq=currentFreq;
      break;
    }
  }
  if (firstVecFreq * secondVecFreq >= 0.0) {
    return NonValidZeroDopplerTime;
  }
  double lowerBoundTime=firstVecTime;
  double upperBoundTime=secondVecTime;
  double lowerBoundFreq=firstVecTime;
  double upperBoundFreq=secondVecFreq;
  double diffTime=Math.abs(upperBoundTime - lowerBoundTime);
  while (diffTime > Math.abs(lineTimeInterval)) {
    final double midTime=(upperBoundTime + lowerBoundTime) / 2.0;
    orbit.getPositionVelocity(midTime,sensorPosition,sensorVelocity);
    final double midFreq=getDopplerFrequency(earthPoint,sensorPosition,sensorVelocity,wavelength);
    if (midFreq * lowerBoundFreq > 0.0) {
      lowerBoundTime=midTime;
      lowerBoundFreq=midFreq;
    }
 else     if (midFreq * upperBoundFreq > 0.0) {
      upperBoundTime=midTime;
      upperBoundFreq=midFreq;
    }
 else     if (Double.compare(midFreq,0.0) == 0) {
      return midTime;
    }
    diffTime=Math.abs(upperBoundTime - lowerBoundTime);
  }
  return lowerBoundTime - lowerBoundFreq * (upperBoundTime - lowerBoundTime) / (upperBoundFreq - lowerBoundFreq);
}

Fixed version (ground truth):
/** 
 * Compute zero Doppler time for given point with the product orbit state vectors using bisection method.
 * @param firstLineUTC     The zero Doppler time for the first range line.
 * @param lineTimeInterval The line time interval.
 * @param wavelength       The radar wavelength.
 * @param earthPoint       The earth point in xyz coordinate.
 * @param orbit            The object holding orbit state vectors.
 * @return The zero Doppler time in days if it is found, NonValidZeroDopplerTime otherwise.
 * @throws OperatorException The operator exception.
 */
public static double getZeroDopplerTime(final double firstLineUTC,final double lineTimeInterval,final double wavelength,final double[] earthPoint,final SARGeocoding.Orbit orbit) throws OperatorException {
  final int numOrbitVec=orbit.orbitStateVectors.length;
  double[] sensorPosition=new double[3];
  double[] sensorVelocity=new double[3];
  double firstVecTime=0.0;
  double secondVecTime=0.0;
  double firstVecFreq=0.0;
  double secondVecFreq=0.0;
  for (int i=0; i < numOrbitVec; i++) {
    sensorPosition[0]=orbit.orbitStateVectors[i].x_pos;
    sensorPosition[1]=orbit.orbitStateVectors[i].y_pos;
    sensorPosition[2]=orbit.orbitStateVectors[i].z_pos;
    sensorVelocity[0]=orbit.orbitStateVectors[i].x_vel;
    sensorVelocity[1]=orbit.orbitStateVectors[i].y_vel;
    sensorVelocity[2]=orbit.orbitStateVectors[i].z_vel;
    final double currentFreq=getDopplerFrequency(earthPoint,sensorPosition,sensorVelocity,wavelength);
    if (i == 0 || firstVecFreq * currentFreq > 0) {
      firstVecTime=orbit.orbitStateVectors[i].time_mjd;
      firstVecFreq=currentFreq;
    }
 else {
      secondVecTime=orbit.orbitStateVectors[i].time_mjd;
      secondVecFreq=currentFreq;
      break;
    }
  }
  if (firstVecFreq * secondVecFreq >= 0.0) {
    return NonValidZeroDopplerTime;
  }
  double lowerBoundTime=firstVecTime;
  double upperBoundTime=secondVecTime;
  double lowerBoundFreq=firstVecFreq;
  double upperBoundFreq=secondVecFreq;
  double diffTime=Math.abs(upperBoundTime - lowerBoundTime);
  while (diffTime > Math.abs(lineTimeInterval)) {
    final double midTime=(upperBoundTime + lowerBoundTime) / 2.0;
    orbit.getPositionVelocity(midTime,sensorPosition,sensorVelocity);
    final double midFreq=getDopplerFrequency(earthPoint,sensorPosition,sensorVelocity,wavelength);
    if (midFreq * lowerBoundFreq > 0.0) {
      lowerBoundTime=midTime;
      lowerBoundFreq=midFreq;
    }
 else     if (midFreq * upperBoundFreq > 0.0) {
      upperBoundTime=midTime;
      upperBoundFreq=midFreq;
    }
 else     if (Double.compare(midFreq,0.0) == 0) {
      return midTime;
    }
    diffTime=Math.abs(upperBoundTime - lowerBoundTime);
  }
  return lowerBoundTime - lowerBoundFreq * (upperBoundTime - lowerBoundTime) / (upperBoundFreq - lowerBoundFreq);
}