#include "shape.h"

double magnitude_corrections(double inmag, double *pos_earth, double *pos_sun, double *phase) {

  double r ;
  double delta ;
  double distmag ;
  double phasemag ;
  double outmag ;
  
  r = sqrt(fvector_dot(pos_earth,pos_earth)) ;
  delta = sqrt(fvector_dot(pos_sun,pos_sun)) ;
  distmag = 5.*log10(r*delta) ;
  phasemag = phase[0]*(exp(-phase[3]/phase[1]) - 1.) + phase[2]*phase[3] ;
 
  if (debug) {
      printf(" %8.2lf  %8.2lf  %8.2lf %8.2lf  ", r, delta, distmag, phasemag/log(10)) ;
  }
  outmag = inmag + distmag - phasemag / log(10);
  
  return(outmag) ;
}
