IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39385 for trunk


Ignore:
Timestamp:
Feb 24, 2016, 10:22:33 AM (10 years ago)
Author:
eugene
Message:

rationalize R,D to be in the range 0,360 & -90,+90

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relastro/src/UpdateMeasures.c

    r37807 r39385  
    99  double DPOS_MAX_ASEC;
    1010
    11   int badImage =
    12     ID_IMAGE_ASTROM_NOCAL |
    13     ID_IMAGE_ASTROM_POOR |
    14     ID_IMAGE_ASTROM_FAIL |
    15     ID_IMAGE_ASTROM_SKIP |
    16     ID_IMAGE_ASTROM_FEW;
    17 
    18   if (RESET_BAD_IMAGES) badImage = 0;
    19 
    2011  image = getimages (&Nimage, NULL);
    2112
    2213  // track measurements which are far from their original position (poor at pole)
    23   int NoffRAave = 0;  int NoffRAori = 0;
    24   int NoffDECave = 0; int NoffDECori = 0;
     14  int NoffRAori = 0;
     15  int NoffDECori = 0;
    2516
    2617  for (i = 0; i < Ncatalog; i++) {
    2718    myAssert (!catalog[i].Nmeasure || catalog[i].measureT, "programming error");
     19    for (j = 0; j < catalog[i].Naverage; j++) {
     20      // normalize R,D to 0,360 & -90,90
     21      Average *average = &catalog[i].average[j];
     22      average[0].R = ohana_normalize_angle_to_midpoint(average[0].R, 180.0);
     23      average[0].D = ohana_normalize_angle_to_midpoint(average[0].D,   0.0);
     24    }
     25
    2826    for (j = 0; j < catalog[i].Nmeasure; j++) {
    2927      MeasureTiny *measureT = &catalog[i].measureT[j];
     
    3836      myAssert (measureT->t <= image[im].tzero + image[im].NX*image[im].trate/5000.0, "image time mismatch (2)");
    3937      // I'm allowing the trate*NX to be a factor of 2x too small
    40 
    41       // skip measurements on images that have failed solutions (divergent or otherwise)
    42       // XXX apply this or not??
    43       if (FALSE && (image[im].flags & badImage)) continue;
    4438
    4539      Coords *moscoords = image[im].coords.mosaic;
     
    6862      XY_to_RD (&R, &D, X, Y, imcoords);
    6963
    70       int n = measureT[0].averef;
    71       Average *average = &catalog[i].average[n];
     64      R = ohana_normalize_angle_to_midpoint(R, 180.0);
     65      D = ohana_normalize_angle_to_midpoint(D,   0.0);
    7266
    73       double dR = 3600.0*(average[0].R - R);
    74       double dD = 3600.0*(average[0].D - D);
     67      double oldR = ohana_normalize_angle_to_midpoint(measureT[0].R, 180.0);
     68      double oldD = ohana_normalize_angle_to_midpoint(measureT[0].D,   0.0);
    7569
    76       // make sure detection is on the same side of the 0,360 boundary as the average
    77       // this will give some funny results withing ~1 arcsec of the pol
    78       if (dR > +180.0*3600.0) {
    79         // average on high end of boundary, move star up
    80         R += 360.0;
    81         dR = 3600.0*(average[0].R - R);
    82       }
    83       if (dR < -180.0*3600.0) {
    84         // average on low end of boundary, move star down
    85         R -= 360.0;
    86         dR = 3600.0*(average[0].R - R);
    87       }
     70      float csdec = cos(oldD * RAD_DEG);
    8871
    89       float csdec = cos(average[0].D * RAD_DEG);
     72      double dR = 3600.0*fabs(csdec*(oldR - R));
     73      double dD = 3600.0*fabs(oldD - R);
    9074
    91       // complain if the new location is far from the average location
    92       // NOTE: This should never happen, or our StarMap tests are not working
    93       if (fabs(dR*csdec) > 3.0*ADDSTAR_RADIUS) {
    94         NoffRAave ++;
     75      // complain if the new location is far from the old location
     76      if (dR > DPOS_MAX_ASEC) {
     77        NoffRAori ++;
    9578        if (VERBOSE2 && catalog[i].measure) {
    96           fprintf (stderr, "measurement is far from average location (R): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, dR*csdec, dD);
    97           dump_measures (&average[0], catalog[i].measure);
     79          fprintf (stderr, "measurement moves far from original location (R): %f %f : %f %f (%f)\n", oldR, oldD, R, D, dR);
    9880        }
    9981      }
    100       if (fabs(dD) > 3.0*ADDSTAR_RADIUS) {
    101         NoffDECave ++;
    102         if (VERBOSE2 && catalog[i].measure) {
    103           fprintf (stderr, "measurement is far from average location (D): %f %f (%f %f)\n", average[0].R, average[0].D, dR, dD);
    104           dump_measures (&average[0], catalog[i].measure);
    105         }
    106       }
    107 
    108       // complain if the new location is far from the old location
    109       if (fabs(csdec*(measureT[0].R - R)) > DPOS_MAX_ASEC) {
    110         NoffRAori ++;
    111         if (VERBOSE2 && catalog[i].measure) {
    112           fprintf (stderr, "measurement moves far from original location (R): %f %f (%f %f %f %f)\n", average[0].R, average[0].D, measureT[0].R, dR, csdec*(measureT[0].R - R), dD);
    113           dump_measures (&average[0], catalog[i].measure);
    114         }
    115       }
    116       if (fabs(measureT[0].D - D) > DPOS_MAX_ASEC) {
     82      if (dD > DPOS_MAX_ASEC) {
    11783        NoffDECori ++;
    11884        if (VERBOSE2 && catalog[i].measure) {
    119           fprintf (stderr, "measurement moves far from original location (D): %f %f (%f %f %f)\n", average[0].R, average[0].D, dR, measureT[0].D, dD);
    120           dump_measures (&average[0], catalog[i].measure);
     85          fprintf (stderr, "measurement moves far from original location (D): %f %f : %f %f (%f)\n", oldR, oldD, R, D, dD);
    12186        }
    12287      }
     
    13196  // printNcatTotal ();
    13297
    133   int Noff = NoffRAave + NoffDECave + NoffRAori + NoffDECori;
    134   if (VERBOSE && (Noff > 0)) fprintf (stderr, "Noff ave RA %d, Noff ave DEC %d, Noff ori RA %d, Noff ori DEC %d\n", NoffRAave, NoffDECave, NoffRAori, NoffDECori);
     98  int Noff = NoffRAori + NoffDECori;
     99  if (VERBOSE && (Noff > 0)) fprintf (stderr, "Noff ori RA %d, Noff ori DEC %d\n", NoffRAori, NoffDECori);
    135100
    136101  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.