- Timestamp:
- May 31, 2021, 11:45:18 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/relphot.20210521/src/setMrelFinal.c
r41624 r41625 13 13 ResetAverageAndMeasure (catalog); 14 14 15 // this sets flags in the measureT element, not the measure element 15 // This sets ID_MEAS flags in the measureT element, not the measure element 16 // These bits are thus ephemeral and not saved. 16 17 setExclusions (catalog, 1, VERBOSE); /* mark by area */ 17 // XXXXX THis probably does not make sense18 18 19 19 /* set catalog[0].found[i] = FALSE */ … … 31 31 setMrelOutput (catalog, 1); // sets the values secfilt.MpsfChp = <measure.M - image.Mcal - measure.Mflat> 32 32 setMcalOutput (catalog, 1); // sets measure.Mcal = image.Mcal 33 34 // clear ID_OBJ_POOR, ID_OBJ_FEW, ID_MEAS_NOCAL values before writing35 // These are internal bits, so they should be cleared36 // XXX are these still used?37 // XXX eventually: move these internal flags to an internal-only catalog->FOO element (like found)38 for (i = 0; i < catalog[0].Naverage; i++) {39 catalog[0].average[i].flags &= ~ID_OBJ_FEW;40 catalog[0].average[i].flags &= ~ID_OBJ_POOR;41 off_t j;42 for (j = 0; j < Nsecfilt; j++) {43 catalog[0].secfilt[i*Nsecfilt+j].flags &= ~ID_OBJ_FEW;44 catalog[0].secfilt[i*Nsecfilt+j].flags &= ~ID_OBJ_POOR;45 }46 off_t m = catalog[0].average[i].measureOffset;47 for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) {48 catalog[0].measure[m].dbFlags &= ~ID_MEAS_NOCAL;49 }50 }51 33 } 52 53 /* ID_MEAS_SKIP marks measurements which were not used to calculate Mrel */54 // For each star & photcode, we are selecting the measurements to use in the average55 // photometry value. This function is called several times, lowering the bar to56 // acceptance on each pass. The rejections at the different passes are:57 58 // 0 : only use measurements thought to be GOOD (photflags not POOR or BAD)59 // 1 : accept measurements thought to be POOR based on photflags60 // 2 : accept the measurements marked as outliers; accept images marked as outliers61 // 3 : accept measurements thought to be BAD based on photflags62 // 4 : accept the measurements outside of the instrumental magnitude limits (eg, SAT)63 64 // XXX if I'm reading this correctly, passes 0, 1, 2 are identical & accept all65 // non-outliers with Imag range66 34 67 35 // int print_measure_set (Average *average, SecFilt *secfilt, Measure *measure) { … … 84 52 // } 85 53 86 int print_measure_set (Average *average, SecFilt *secfilt, Measure *measure); 87 88 // XXX this function is no longer used: 89 void skip_measurements (Catalog *catalog, int pass) { 90 91 off_t i, k, m; 92 off_t Ntot, Ntry, Nkeep, Nskip; 93 float mag; 94 95 int Nsecfilt = GetPhotcodeNsecfilt (); 96 97 Ntot = Ntry = Nskip = Nkeep = 0; 98 99 /* allow measures from images marked POOR and FEW */ 100 if (pass >= 3) IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL; 101 102 /* allow measures marked as outliers (POOR) and off image region (AREA) */ 103 if (pass >= 3) { 104 MEAS_BAD = ID_MEAS_NOCAL | ID_MEAS_SKIP_PHOTOM; 105 } else { 106 MEAS_BAD = ID_MEAS_NOCAL | ID_MEAS_POOR_PHOTOM | ID_MEAS_SKIP_PHOTOM | ID_MEAS_AREA; 107 } 108 109 /* mark measures which should be ignored on this pass */ 110 for (i = 0; i < catalog[0].Naverage; i++) { 111 Ntot += catalog[0].average[i].Nmeasure; 112 113 if (FALSE && (catalog[0].average[i].objID == 0x46a4) && (catalog[0].average[i].catID == 0xf40e)) { 114 fprintf (stderr, "test obj\n"); 115 print_measure_set (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], catalog[0].measure); 116 } 117 118 // mark measurements for each secfilt separately 119 int Ns; 120 for (Ns = 0; Ns < Nphotcodes; Ns++) { 121 122 int thisCode = photcodes[Ns][0].code; 123 int Nsec = GetPhotcodeNsec(thisCode); 124 125 /* star/photcodes already calibrated */ 126 if (catalog[0].found_t[Nsecfilt*i+Nsec]) continue; 127 128 m = catalog[0].average[i].measureOffset; 129 for (k = 0; k < catalog[0].average[i].Nmeasure; k++, m++) { 130 Ntry++; 131 132 // skip measurements not related to this photcode 133 PhotCode *code = GetPhotcodebyCode (catalog[0].measure[m].photcode); 134 if (!code) continue; 135 if (code->equiv != thisCode) continue; 136 137 // skip measurements by time range (mark as skipped for this secfilt) 138 // XXX note that this is a bit dangerous : some objects may never get calibrated 139 if (TimeSelect) { 140 if (catalog[0].measure[m].t < TSTART) goto skip; 141 if (catalog[0].measure[m].t > TSTOP) goto skip; 142 } 143 144 // we now have a measurement relavant to this photcode (and time range) 145 146 // clear SKIP for all measures at first 147 catalog[0].measureT[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 148 catalog[0].measure [m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 149 150 // skip measurements from BAD images and mosaics (not REF mags) 151 // do NOT skip measurements without a matching image (REF mags) 152 off_t Nim = getImageEntry (m, 0); 153 if (Nim > -1) { 154 if (isnan(getMcal (m, 0, MAG_CLASS_PSF))) goto skip; 155 if (isnan(getMmos (m, 0))) goto skip; 156 } 157 158 // PASS 4 : skip measurements by inst mag limit (not REF mags) 159 if ((pass < 4) && ImagSelect) { 160 if (Nim > -1) { 161 mag = PhotInst (&catalog[0].measure[m], MAG_CLASS_PSF); 162 if (mag < ImagMin) goto skip; 163 if (mag > ImagMax) goto skip; 164 } 165 } 166 167 // PASS 3 : accept bad measurements (eg, SAT, CR), internal outliers 168 if (pass < 3) { 169 if (catalog[0].measure[m].photFlags & code->photomBadMask) goto skip; 170 if ((catalog[0].measure[m].photcode > 10000) && (catalog[0].measure[m].photcode < 10500)) { 171 if (catalog[0].measure[m].psfQF < 0.85) goto skip; 172 } 173 } 174 175 // PASS 2 : (no additional cut) 176 177 // PASS 1 : accept poor measurements as well (eg, POOR FIT, etc) 178 if ((pass < 1) && (catalog[0].measure[m].photFlags & code->photomPoorMask)) goto skip; 179 180 // PASS 0 : skip poor, outlier, bad measurements as well (eg, POOR FIT, etc) 181 182 Nkeep ++; 183 184 continue; 185 186 skip: 187 catalog[0].measure [m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 188 catalog[0].measureT[m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 189 Nskip ++; 190 } 191 } 192 } 193 if (VERBOSE) fprintf (stderr, "pass %d, Ntot: "OFF_T_FMT", Ntry: "OFF_T_FMT", Nskip: "OFF_T_FMT", Nkeep: "OFF_T_FMT"\n", 194 pass, Ntot, Ntry, Nskip, Nkeep); 195 } 196 197 // XXX review this, especially the good/bad images 198 // by this point, we have propagated the mosaic and tgroup flags to each image 54 // This function is only called for the final output step. By this point, we have 55 // propagated the mosaic and tgroup flags to each image. 199 56 void setMeasureRank (Catalog *catalog) { 200 57 201 58 int i; 202 59 203 // make these global204 int IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL;205 int IMAGE_POOR = ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_SKIP;206 int MEAS_BAD = ID_MEAS_NOCAL | ID_MEAS_SKIP_PHOTOM;207 int MEAS_POOR = ID_MEAS_POOR_PHOTOM | ID_MEAS_AREA;208 209 60 Measure *measure = catalog[0].measure; 210 MeasureTiny *measureT = catalog[0].measureT;211 61 char *measureRank = catalog[0].measureRank; 212 62 … … 215 65 measureRank[i] = 11; // start at a low rank 216 66 217 // clear SKIP for all measures at first 218 measureT[i].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 219 measure [i].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 220 221 // skip measurements without a valid photcode 67 // measurements without a valid photcode have lowest rank (should not be used anyway) 222 68 PhotCode *code = GetPhotcodebyCode (measure[i].photcode); 223 69 if (!code) continue; … … 225 71 // measurements outside time range have poor rank 226 72 if (TimeSelect) { 227 if (measure[i].t < TSTART) { measureRank[i] = 10; continue; }228 if (measure[i].t > TSTOP) { measureRank[i] = 10; continue; }73 if (measure[i].t < TSTART) { measureRank[i] = 10; continue; } 74 if (measure[i].t > TSTOP) { measureRank[i] = 10; continue; } 229 75 } 230 76 231 // measurements from BAD images and mosaics (not REF mags)232 off_t Nim = getImageEntry (i, 0);77 // Nim < 0 for REF mags, imageFlags have bits for IMAGE, MOSAIC, NIGHT 78 off_t Nim = getImageEntry (i, 0); 233 79 int imageFlags = getImageFlags (i, 0); 234 int mosaicFlags = getMosaicFlags (i, 0);235 80 236 81 if (Nim > -1) { 237 if (imageFlags & IMAGE_BAD) { measureRank[i] = 9; continue; }238 239 if (mosaicFlags & IMAGE_BAD) { measureRank[i] = 9; continue; }240 241 82 // measurements ranked by inst mag limit (not REF mags) 242 83 if (ImagSelect) { 243 84 float mag = PhotInst (&measure[i], MAG_CLASS_PSF); 244 if (mag < ImagMin) { measureRank[i] = 8; continue; }245 if (mag > ImagMax) { measureRank[i] = 8; continue; }85 if (mag < ImagMin) { measureRank[i] = 9; continue; } 86 if (mag > ImagMax) { measureRank[i] = 9; continue; } 246 87 } 247 88 } 248 89 249 // RANK 1 : BAD photFlags 250 if (measure[i].dbFlags & MEAS_BAD) { measureRank[i] = 7; continue; } 251 252 // RANK 3 : BAD photFlags (eg, SAT, CR), internal outliers 253 if (measure[i].photFlags & code->photomBadMask) { measureRank[i] = 6; continue; } 254 90 // RANK 8 : Poor image 255 91 if (Nim > -1) { 256 if (imageFlags & IMAGE_POOR) { measureRank[i] = 5; continue; } 257 if (mosaicFlags & IMAGE_POOR) { measureRank[i] = 5; continue; } 92 if (imageFlags & ID_IMAGE_PHOTOM_POOR) { measureRank[i] = 8; continue; } 258 93 } 259 94 260 // RANK 2 : psfQF value 261 if (!isfinite(measure[i].psfQF) || measure[i].psfQF < 0.85) { measureRank[i] = 4; continue; } 95 // RANK 7 : BAD photFlags (eg, SAT, CR), internal outliers 96 if (measure[i].photFlags & code->photomBadMask) { measureRank[i] = 7; continue; } 97 98 // RANK 6 : bad psfQF value 99 if (!isfinite(measure[i].psfQF) || measure[i].psfQF < 0.85) { measureRank[i] = 6; continue; } 262 100 263 // RANK 1 : POOR photFlags264 if (measure[i].dbFlags & MEAS_POOR) { measureRank[i] = 3; continue; }101 // RANK 5 : not in valid chip region 102 if (measure[i].dbFlags & ID_MEAS_AREA) { measureRank[i] = 5; continue; } 265 103 266 // RANK 1: POOR photFlags267 if (measure[i].photFlags & code->photomPoorMask) { measureRank[i] = 2; continue; }104 // RANK 4 : POOR photFlags 105 if (measure[i].photFlags & code->photomPoorMask) { measureRank[i] = 4; continue; } 268 106 269 // RANK 1 :psfQFperfect value270 if (!isfinite(measure[i].psfQFperf) || measure[i].psfQFperf < 0.85) { measureRank[i] = 1; continue; }107 // RANK 3 : bad psfQFperfect value 108 if (!isfinite(measure[i].psfQFperf) || measure[i].psfQFperf < 0.85) { measureRank[i] = 3; continue; } 271 109 110 // RANK 2 : Poor mosaic 111 if (Nim > -1) { 112 if (imageFlags & ID_IMAGE_MOSAIC_POOR) { measureRank[i] = 2; continue; } 113 } 114 115 // RANK 1 : Poor night 116 if (Nim > -1) { 117 if (imageFlags & ID_IMAGE_NIGHT_POOR) { measureRank[i] = 1; continue; } 118 } 272 119 // RANK 0 : perfect measurement: 273 120 measureRank[i] = 0;
Note:
See TracChangeset
for help on using the changeset viewer.
