# include "relastro.h"

double getMeanR (Measure *measure, Average *average, SecFilt *secfilt) {

  double ra;

  /* the measure carries the instantaneous mean position at the epoch t */ 
  ra = average[0].R - measure[0].dR / 3600.0;

  /* possible corrections to mean ra:

  - proper-motion and parallax
  - abberation
  - precession and nutation, etc
  - refraction
  - DCR

  */

  return (ra);
}

double getMeanD (Measure *measure, Average *average, SecFilt *secfilt) {

  double dec;

  /* the measure carries the instantaneous mean position at the epoch t */ 
  dec = average[0].D - measure[0].dD / 3600.0;

  /* possible corrections to mean ra:

  - proper-motion and parallax
  - abberation
  - precession and nutation, etc
  - refraction
  - DCR

  */

  return (dec);
}

int setMeanR (double ra_fit, Measure *measure, Average *average, SecFilt *secfilt) {

  /* math to get from new fitted position to new measure offset
     ra_obs = average[0].R - measure[0].dR / 3600.0;
     measure[0].dR = (ra_fit - ra_obs) * 3600.0;
     measure[0].dR = (ra_fit - average[0].R + measure[0].dR/3600) * 3600.0
     measure[0].dR = (ra_fit - average[0].R) * 3600.0 + measure[0].dR;
  */

  /* the measure carries the instantaneous mean position at the epoch t */ 
  measure[0].dR += (ra_fit - average[0].R) * 3600.0;

  /* possible corrections to mean ra:

  - proper-motion and parallax
  - abberation
  - precession and nutation, etc
  - refraction
  - DCR

  */

  return (TRUE);
}

int setMeanD (double dec_fit, Measure *measure, Average *average, SecFilt *secfilt) {

  /* math to get from new fitted position to new measure offset
     dec_obs = average[0].D - measure[0].dD / 3600.0;
     measure[0].dD = (dec_fit - dec_obs) * 3600.0;
     measure[0].dD = (dec_fit - average[0].D + measure[0].dD/3600) * 3600.0
     measure[0].dD = (dec_fit - average[0].D) * 3600.0 + measure[0].dD;
  */

  /* the measure carries the instantaneous mean position at the epoch t */ 
  measure[0].dD += (dec_fit - average[0].D) * 3600.0;

  /* possible corrections to mean ra:

  - proper-motion and parallax
  - abberation
  - precession and nutation, etc
  - refraction
  - DCR

  */

  return (TRUE);
}
