Changeset 39600
- Timestamp:
- Jun 16, 2016, 4:55:58 PM (10 years ago)
- Location:
- trunk/Ohana/src/relastro
- Files:
-
- 3 edited
-
include/relastro.h (modified) (3 diffs)
-
src/RepairWarpMeasures.c (modified) (11 diffs)
-
src/RepairWarps.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/relastro/include/relastro.h
r39580 r39600 244 244 } FrameCorrectionSet; 245 245 246 247 246 typedef struct { 248 247 double *Rave; … … 252 251 int Nicrfobj; 253 252 } ICRFobj; 253 254 typedef struct { 255 int NfixChipID; 256 int NfixStackID; 257 int NfixWarpID; 258 int NfixWarpImageID; 259 int NfixWarpCoord; 260 int NmissWarp; 261 int NmissStack; 262 int NbadWarp; 263 int NbadWarpTime; 264 int NwarpNoImage; 265 } WarpRepairResult; 254 266 255 267 # define ID_MEAS_OBJECT_HAS_2MASS ID_MEAS_POOR_PHOTOM … … 802 814 803 815 int RepairWarps (SkyList *skylist, int hostID, char *hostpath); 804 int RepairWarpMeasures (Catalog *catalog);816 WarpRepairResult RepairWarpMeasures (Catalog *catalog); 805 817 806 818 int FindWarpGroups (void); -
trunk/Ohana/src/relastro/src/RepairWarpMeasures.c
r39580 r39600 2 2 3 3 // XXX need to load_images first and generate some lookup tables 4 int RepairWarpMeasures (Catalog *catalog) {4 WarpRepairResult RepairWarpMeasures (Catalog *catalog) { 5 5 6 6 off_t Nimage; … … 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, NwarpNoImage = 0; 11 WarpRepairResult result; 12 result.NfixChipID = 0; 13 result.NfixStackID = 0; 14 result.NfixWarpID = 0; 15 result.NfixWarpImageID = 0; 16 result.NfixWarpCoord = 0; 17 result.NmissWarp = 0; 18 result.NmissStack = 0; 19 result.NbadWarp = 0; 20 result.NbadWarpTime = 0; 21 result.NwarpNoImage = 0; 12 22 13 23 int onePercent = catalog->Nmeasure / 100; … … 25 35 if (extID != measure->extID) { 26 36 measure->extID = extID; 27 NfixChipID ++;37 result.NfixChipID ++; 28 38 } 29 39 continue; … … 34 44 int im = getImageByID (measure->imageID); 35 45 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 ++;46 if (result.NmissStack < 10) fprintf (stderr, "missing stack exposure: %f %f : %d %d\n", measure->R, measure->D, measure->imageID, measure->photcode); 47 result.NmissStack ++; 38 48 continue; 39 49 } … … 41 51 if (extID != measure->extID) { 42 52 measure->extID = extID; 43 NfixStackID ++;53 result.NfixStackID ++; 44 54 } 45 55 continue; … … 64 74 double Dwrp = measure->D; 65 75 76 /* 77 we have a warp detection. X,Y are correct (never modified). things which might be wrong: 78 * imageID (thus the Mcal, R,D, extID may all be broken) 79 */ 80 81 int coordsDiffer = FALSE; 66 82 if (USE_IMAGE_COORDS_FOR_REPAIR) { 67 83 off_t idx = getImageByID (measure->imageID); 68 84 if (idx == -1) { 69 85 if (VERBOSE2) fprintf (stderr, "can't match detection to image?\n"); 70 NwarpNoImage ++;86 result.NwarpNoImage ++; 71 87 continue; 72 88 } 73 89 74 90 Coords *imcoords = &image[idx].coords; 91 92 // save the original warp coordinates for comparison 93 double Rold = ohana_normalize_angle_to_midpoint(Rwrp, 180.0); 94 double Dold = ohana_normalize_angle_to_midpoint(Dwrp, 0.0); 75 95 76 96 XY_to_RD (&Rwrp, &Dwrp, X, Y, imcoords); … … 78 98 Rwrp = ohana_normalize_angle_to_midpoint(Rwrp, 180.0); 79 99 Dwrp = ohana_normalize_angle_to_midpoint(Dwrp, 0.0); 100 101 // check if the new Rwrp, Dwrp is different from the current R,D: 102 float csdec = cos(Dold * RAD_DEG); 103 104 // find the ra,dec displacement in arcsec: 105 double dR = 3600.0*(Rwrp - Rold)*csdec; 106 double dD = 3600.0*(Dwrp - Dold); 107 108 // skip detections which are within a small distance of the expected location 109 // NOTE: this actually works surprisingly well near the pole 110 double dPos = hypot(dR,dD); 111 if (dPos > 0.5) { 112 // in this case, we should double-check measure.R,D values below 113 coordsDiffer = TRUE; 114 } 80 115 } 81 116 … … 93 128 double dPos = hypot(dR,dD); 94 129 if (dPos < 2.0) { 130 // image coord agrees with average coord 131 if (coordsDiffer) { 132 // measure coord disagrees with image coord: replace with image coord 133 measure->R = Rwrp; 134 measure->D = Dwrp; 135 result.NfixWarpCoord ++; 136 } 137 // check that the current extID value is good for warp detection: 95 138 int im = getImageByID (measure->imageID); 96 139 uint64_t extID = CreatePSPSStackDetectionID (34, image[im].externID, measure->detID); 97 140 if (extID != measure->extID) { 98 141 measure->extID = extID; 99 NfixWarpID ++; 100 } 101 continue; 142 result.NfixWarpID ++; 143 } 144 // check match of obstime: 145 if ((measure->t != image[im].tzero) && (result.NbadWarpTime < 10)) { 146 fprintf (stderr, "inconsistent warp measurement times: %d vs %d for %f, %f (%d, %ld)", measure->t, image[im].tzero, Rwrp, Dwrp, measure->photcode, extID); 147 result.NbadWarpTime ++; 148 continue; 149 } 102 150 } 103 151 … … 105 153 int warpSeq = GetWarpSeq (image, measure->t, measure->photcode, Rave, Dave, X, Y); 106 154 if (warpSeq < 0) { 107 if ( NmissWarp < 10) fprintf (stderr, "missing warp exposure: %f %f : %d %d\n", Rave, Dave, measure->t, measure->photcode);108 NmissWarp ++;155 if (result.NmissWarp < 10) fprintf (stderr, "missing warp exposure: %f %f : %d %d\n", Rave, Dave, measure->t, measure->photcode); 156 result.NmissWarp ++; 109 157 continue; 110 158 } … … 127 175 if (dPos > 5.0) { 128 176 fprintf (stderr, "measurement still far from average location: %f %f vs %f %f : %d %d\n", Rave, Dave, Rnew, Dnew, measure->t, measure->photcode); 129 NbadWarp ++;177 result.NbadWarp ++; 130 178 } 131 179 … … 137 185 if (extID != measure->extID) { 138 186 measure->extID = extID; 139 NfixWarpID ++;140 } 141 NfixWarpImageID ++;187 result.NfixWarpID ++; 188 } 189 result.NfixWarpImageID ++; 142 190 } 143 191 144 192 fprintf (stderr, "\n"); 145 fprintf (stderr, "repaired %s : warp image ID %d : ext ID chip %d stack %d warp %d : missed warp %d stack %d : bad warp: %d : warp no image: %d\n", catalog->filename, NfixWarpImageID, NfixChipID, NfixStackID, NfixWarpID, NmissWarp, NmissStack, NbadWarp, NwarpNoImage); 146 147 return (TRUE); 193 fprintf (stderr, "repaired %s : warp image ID %d : ext ID chip %d stack %d warp %d : missed warp %d stack %d : bad warp: %d : warp no image: %d : badWarpTime: %d, fixWarpCoord: %d\n", 194 catalog->filename, 195 result.NfixWarpImageID, result.NfixChipID, result.NfixStackID, 196 result.NfixWarpID, result.NmissWarp, result.NmissStack, 197 result.NbadWarp, result.NwarpNoImage, result.NbadWarpTime, 198 result.NfixWarpCoord); 199 200 return (result); 148 201 } -
trunk/Ohana/src/relastro/src/RepairWarps.c
r39580 r39600 45 45 46 46 // update the detection coordinates using the new image parameters 47 RepairWarpMeasures (&catalog);47 WarpRepairResult result = RepairWarpMeasures (&catalog); 48 48 49 // track number of corrections and only update if corrections are made 50 int Nmods = 0; 51 Nmods += result.NfixChipID; 52 Nmods += result.NfixStackID; 53 Nmods += result.NfixWarpID; 54 Nmods += result.NfixWarpImageID; 55 Nmods += result.NfixWarpCoord; 56 Nmods += result.NmissWarp; 57 Nmods += result.NmissStack; 58 Nmods += result.NbadWarp; 59 Nmods += result.NbadWarpTime; 60 Nmods += result.NwarpNoImage; 61 if (!Nmods) { 62 fprintf (stderr, "no changes to %s, no output\n", catalog.filename); 63 dvo_catalog_unlock (&catalog); 64 dvo_catalog_free (&catalog); 65 continue; 66 } 67 68 if (!UPDATE) { 69 dvo_catalog_unlock (&catalog); 70 dvo_catalog_free (&catalog); 71 continue; 72 } 73 49 74 char history[128]; 50 75 struct timeval now; … … 55 80 free (moddate); 56 81 57 if (!UPDATE) { 58 dvo_catalog_unlock (&catalog); 59 dvo_catalog_free (&catalog); 60 continue; 82 // add metadata to define number of corrections 83 char line[128]; 84 snprintf (line, 60, "ChipID %d, StackID %d, warpID %d", result.NfixChipID, result.NfixStackID, result.NfixWarpID); 85 gfits_modify (&catalog.header, "REPAIR_1", "%s", 1, line); 86 snprintf (line, 60, "WarpImageID %d, WarpCoord %d, WarpNoImage %d", result.NfixWarpImageID, result.NfixWarpCoord, result.NwarpNoImage); 87 gfits_modify (&catalog.header, "REPAIR_2", "%s", 1, line); 88 snprintf (line, 60, "missWarp %d, badWarp %d, badWarpTime %d, missStack %d", result.NmissWarp, result.NbadWarp, result.NbadWarpTime, result.NmissStack); 89 gfits_modify (&catalog.header, "REPAIR_3", "%s", 1, line); 90 91 // save backup of original cpm file 92 if (!dvo_catalog_backup (&catalog, "rp0", TRUE)) { 93 fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", catalog.filename); 94 exit (1); 61 95 } 62 96 63 97 // write the updated detections to disk 64 98 save_catalogs (&catalog, 1);
Note:
See TracChangeset
for help on using the changeset viewer.
