# include "mosastro.h"

/* determine an initial guess to field parameters from data */ 
int fake_field_center (double RA, double DEC) {

  field.Rmin = RA  - 0.5;
  field.Rmax = RA  + 0.5;
  field.Dmin = DEC - 0.5;
  field.Dmax = DEC + 0.5;

  /* bore site center guess */
  field.project.crval1 = 0.5*(field.Rmin + field.Rmax);
  field.project.crval2 = 0.5*(field.Dmin + field.Dmax);
  
  return (1);
}

/* set default field parameters (overridden in args_obs) */ 
int fake_field_defaults () {

  int i;

  /* bore site center guess */
  strcpy (field.project.ctype, "DEC--TAN");
  field.project.crpix1 = 0;
  field.project.crpix2 = 0;
  
  /* set TP plate scale */
  field.project.cdelt1 = 1.0/3600.0;
  field.project.cdelt2 = 1.0/3600.0;

  /** allow guess at field rotation?? **/
  field.project.pc1_1  = 1;
  field.project.pc2_2  = 1;
  field.project.pc1_2  = 0;
  field.project.pc2_1  = 0;
  field.project.Npolyterms = 1;

  /** distort only has power in polyterms **/
  strcpy (field.distort.ctype, "DEC--PLY");
  field.distort.crval1 = 0.0;
  field.distort.crval2 = 0.0;
  field.distort.crpix1 = 0.0;
  field.distort.crpix2 = 0.0;
  field.distort.cdelt1 = 1.0;
  field.distort.cdelt2 = 1.0;
  
  field.distort.pc1_1  = 1;
  field.distort.pc2_2  = 1;
  field.distort.pc1_2  = 0;
  field.distort.pc2_1  = 0;

  /* how do we handle renormalization? (fixed at 1000 pixels??) */
  field.distort.Npolyterms = 3;
  for (i = 0; i < 7; i++) {
    field.distort.polyterms[i][0] = 0;
    field.distort.polyterms[i][1] = 0;
  }

  return (1);
}

