Changeset 39474 for trunk/Ohana/src/relastro/src/RepairWarpMeasures.c
- Timestamp:
- Mar 23, 2016, 12:26:55 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/relastro/src/RepairWarpMeasures.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relastro/src/RepairWarpMeasures.c
r39471 r39474 9 9 myAssert (!catalog->Nmeasure || catalog->measure, "programming error"); 10 10 11 int NfixChipID = 0, NfixStackID = 0, NfixWarpID = 0, NfixWarpImageID = 0, NmissWarp = 0, NmissStack = 0, NbadWarp = 0; 12 13 int onePercent = catalog->Nmeasure / 100; 14 11 15 for (off_t j = 0; j < catalog->Nmeasure; j++) { 16 if (j % onePercent == 0) fprintf (stderr, "."); 17 12 18 Measure *measure = &catalog->measure[j]; 13 19 14 // we are only going to repair warp detections 15 if (!isGPC1warp(measure->photcode)) { 16 // XXX fix extID 20 // repair extID for non-warps: 21 if (isGPC1chip(measure->photcode)) { 22 double mjd = ohana_sec_to_mjd (measure->t); 23 int ccdnum = measure->photcode % 100; 24 uint64_t extID = CreatePSPSDetectionID (mjd, ccdnum, measure->detID); 25 if (extID != measure->extID) { 26 measure->extID = extID; 27 NfixChipID ++; 28 } 17 29 continue; 18 30 } 31 32 // repair extID for non-warps: 33 if (isGPC1stack(measure->photcode)) { 34 int im = getImageByID (measure->imageID); 35 if (im < 0) { 36 if (NmissStack < 10) fprintf (stderr, "missing stack exposure: %f %f : %d %d\n", measure->R, measure->D, measure->imageID, measure->photcode); 37 NmissStack ++; 38 continue; 39 } 40 uint64_t extID = CreatePSPSStackDetectionID (35, image[im].externID, measure->detID); 41 if (extID != measure->extID) { 42 measure->extID = extID; 43 NfixStackID ++; 44 } 45 continue; 46 } 47 48 // we are only going to repair warp detections 49 if (!isGPC1warp(measure->photcode)) continue; 19 50 20 51 // get the associated average value: … … 23 54 24 55 // double-check for consistency 25 myAssert (average->objID == measure->objID, "mismatch"); 56 myAssert (average->objID == measure->objID, "objID mismatch: %f %f : %d %d\n", average->R, average->D, average->objID, measure->objID); 57 58 // warp coordinates to confirm warp 59 double X = measure->Xccd; 60 double Y = measure->Yccd; 26 61 27 62 // check if this detection is far from its correct location … … 39 74 40 75 // skip detections which are within a small distance of the expected location 76 // NOTE: this actually works surprisingly well near the pole 41 77 double dPos = hypot(dR,dD); 42 if (dPos < 2.0) continue; 43 44 // warp coordinates to confirm warp 45 double X = measure->Xccd; 46 double Y = measure->Yccd; 78 if (dPos < 2.0) { 79 int im = getImageByID (measure->imageID); 80 uint64_t extID = CreatePSPSStackDetectionID (34, image[im].externID, measure->detID); 81 if (extID != measure->extID) { 82 measure->extID = extID; 83 NfixWarpID ++; 84 } 85 continue; 86 } 47 87 48 88 // find the corrected warp ID: 49 int warpID = GetWarpID (image, measure->t, measure->photcode, Rave, Dave, X, Y); 50 myAssert (warpID >= 0, "error finding match"); 89 int warpSeq = GetWarpSeq (image, measure->t, measure->photcode, Rave, Dave, X, Y); 90 if (warpSeq < 0) { 91 if (NmissWarp < 10) fprintf (stderr, "missing warp exposure: %f %f : %d %d\n", Rave, Dave, measure->t, measure->photcode); 92 NmissWarp ++; 93 continue; 94 } 51 95 52 96 // assert on coords being TAN? 53 Coords *imcoords = &image[warp ID].coords;97 Coords *imcoords = &image[warpSeq].coords; 54 98 55 99 double Rnew, Dnew; … … 63 107 double dDnew = 3600.0*(Dnew - Dave); 64 108 65 // skip detections which are within a small distance of the expected location109 // detections should now be repaired; fail if not 66 110 dPos = hypot(dRnew,dDnew); 67 if (dPos > 2.0) { 68 // complain. abort? 69 fprintf (stderr, "measurement still far from average location\n"); 70 abort(); 111 if (dPos > 5.0) { 112 fprintf (stderr, "measurement still far from average location: %f %f vs %f %f : %d %d\n", Rave, Dave, Rnew, Dnew, measure->t, measure->photcode); 113 NbadWarp ++; 71 114 } 72 115 116 measure->imageID = image[warpSeq].imageID; 73 117 measure->R = Rnew; 74 118 measure->D = Dnew; 75 119 76 // XXX fix extID 120 uint64_t extID = CreatePSPSStackDetectionID (34, image[warpSeq].externID, measure->detID); 121 if (extID != measure->extID) { 122 measure->extID = extID; 123 NfixWarpID ++; 124 } 125 NfixWarpImageID ++; 77 126 } 127 128 fprintf (stderr, "\n"); 129 fprintf (stderr, "repaired %s : warp image ID %d : ext ID chip %d stack %d warp %d : missed warp %d stack %d : bad warp: %d\n", catalog->filename, NfixWarpImageID, NfixChipID, NfixStackID, NfixWarpID, NmissWarp, NmissStack, NbadWarp); 130 78 131 return (TRUE); 79 132 }
Note:
See TracChangeset
for help on using the changeset viewer.
