Changeset 33610
- Timestamp:
- Mar 24, 2012, 10:27:28 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/relphot/src
- Files:
-
- 4 edited
-
StarOps.c (modified) (6 diffs)
-
bcatalog.c (modified) (6 diffs)
-
relphot.c (modified) (1 diff)
-
setMrelFinal.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/StarOps.c
r33605 r33610 153 153 } 154 154 155 int print_measure_set (Average *average, SecFilt *secfilt, Measure *measure) { 156 157 off_t k; 158 159 int Nsecfilt = GetPhotcodeNsecfilt (); 160 161 off_t m = average[0].measureOffset; 162 163 for (k = 0; k < average[0].Nmeasure; k++, m++) { 164 fprintf (stderr, "meas: %08x\n", measure[m].dbFlags); 165 } 166 167 int Ns; 168 for (Ns = 0; Ns < Nsecfilt; Ns++) { 169 fprintf (stderr, "secf: %08x\n", secfilt[Ns].flags); 170 } 171 return 1; 172 } 173 174 # define MARK_SKIP_MEAS \ 175 catalog[i].measureT[m].dbFlags |= ID_MEAS_SKIP_PHOTOM; \ 176 catalog[i].measure [m].dbFlags |= ID_MEAS_SKIP_PHOTOM; 177 155 178 // setMrel and setMrelOutput are extremely similar, but have slightly different implications: 156 179 // * setMrel uses the internal Tiny structures only … … 190 213 for (j = 0; j < catalog[i].Naverage; j++) { 191 214 215 if (FALSE && (catalog[i].average[j].objID == 0x46a4) && (catalog[i].average[j].catID == 0xf40e)) { 216 fprintf (stderr, "test obj\n"); 217 print_measure_set (&catalog[i].average[j], &catalog[i].secfilt[j*Nsecfilt], catalog[i].measure); 218 } 219 192 220 int minUbercalDist = 1000; 193 221 … … 205 233 int haveSynth = FALSE; 206 234 int haveUbercal = FALSE; 235 int isRefPhot = FALSE; 207 236 208 237 N = 0; … … 221 250 // these detetions have no image (eg, ref values such as 2MASS) 222 251 Mcal = Mmos = Mgrid = 0; 252 isRefPhot = TRUE; 223 253 } else { 224 254 Mcal = getMcal (m, i, flatcorr, catalog); 225 if (isnan(Mcal)) continue; 255 if (isnan(Mcal)) { 256 MARK_SKIP_MEAS; 257 continue; 258 } 226 259 Mmos = getMmos (m, i); 227 if (isnan(Mmos)) continue; 260 if (isnan(Mmos)) { 261 MARK_SKIP_MEAS; 262 continue; 263 } 228 264 Mgrid = getMgrid (m, i); 229 if (isnan(Mgrid)) continue; 265 if (isnan(Mgrid)) { 266 MARK_SKIP_MEAS; 267 continue; 268 } 230 269 } 231 270 232 271 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt]); 233 if (isnan(Msys)) { continue; } 272 if (isnan(Msys)) { 273 if (!isRefPhot) { 274 MARK_SKIP_MEAS; 275 } 276 continue; 277 } 234 278 list[N] = Msys - Mcal - Mmos - Mgrid; 235 279 … … 255 299 if ((pass == 0) && !(catalog[i].measure[m].photFlags & 0x00000007)) { 256 300 // detections without one of these bits should only be used in PASS_1 301 MARK_SKIP_MEAS; 257 302 continue; 258 303 } … … 260 305 // ignore SYNTH photocdes until PASS == 4 (where we also accept saturated stars) 261 306 if ((catalog[i].measure[m].photcode >= 3001) && (catalog[i].measure[m].photcode <= 3005)) { 262 if (pass < 4) continue; 307 if (pass < 4) { 308 MARK_SKIP_MEAS; 309 continue; 310 } 263 311 haveSynth = TRUE; 264 312 } -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/bcatalog.c
r33564 r33610 1 1 # include "relphot.h" 2 3 int LimitDensityCatalog_ByNmeasure (Catalog *subcatalog, Catalog *oldcatalog); 2 4 3 5 int bcatalog (Catalog *subcatalog, Catalog *catalog) { … … 212 214 // limit the total number of stars in the catalog 213 215 if (MaxDensityUse) { 214 LimitDensityCatalog (subcatalog, catalog);216 LimitDensityCatalog_ByNmeasure (subcatalog, catalog); 215 217 } 216 218 … … 224 226 } 225 227 226 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog) { 228 // sort by decreasing Nmeasure (X) 229 void sort_by_Nmeasure (int *X, off_t *Y, off_t N) { 230 231 # define SWAPFUNC(A,B){ int tmpI; off_t tmpT; \ 232 tmpI = X[A]; X[A] = X[B]; X[B] = tmpI; \ 233 tmpT = Y[A]; Y[A] = Y[B]; Y[B] = tmpT; \ 234 } 235 # define COMPARE(A,B)(X[A] > X[B]) 236 237 OHANA_SORT (N, COMPARE, SWAPFUNC); 238 239 # undef SWAPFUNC 240 # undef COMPARE 241 242 } 243 244 int LimitDensityCatalog_ByNmeasure (Catalog *subcatalog, Catalog *oldcatalog) { 227 245 228 246 Catalog tmpcatalog; … … 232 250 int Nsecfilt = GetPhotcodeNsecfilt (); 233 251 234 gfits_scan (& catalog[0].header, "RA0", "%lf", 1, &Rmin);235 gfits_scan (& catalog[0].header, "DEC0", "%lf", 1, &Dmin);236 gfits_scan (& catalog[0].header, "RA1", "%lf", 1, &Rmax);237 gfits_scan (& catalog[0].header, "DEC1", "%lf", 1, &Dmax);252 gfits_scan (&oldcatalog[0].header, "RA0", "%lf", 1, &Rmin); 253 gfits_scan (&oldcatalog[0].header, "DEC0", "%lf", 1, &Dmin); 254 gfits_scan (&oldcatalog[0].header, "RA1", "%lf", 1, &Rmax); 255 gfits_scan (&oldcatalog[0].header, "DEC1", "%lf", 1, &Dmax); 238 256 239 257 if (VERBOSE2) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax); … … 255 273 256 274 // we are going to select Nmax entries by generating a random-sorted index list 257 off_t *index, tmp, i, j, ave; 275 int *value; 276 off_t *index, i, j, ave; 258 277 ALLOCATE (index, off_t, Naverage); 278 ALLOCATE (value, int, Naverage); 259 279 for (i = 0; i < Naverage; i++) { 260 280 index[i] = i; 261 } 262 for (i = 0; i < Naverage; i++) { 263 j = (Naverage - i) * drand48() + i; // a number between i and Naverage 264 tmp = index[j]; 265 index[j] = index[i]; 266 index[i] = tmp; 267 } 281 value[i] = subcatalog[0].averageT[i].Nmeasure; 282 } 283 sort_by_Nmeasure (value, index, Naverage); 268 284 269 285 // count the number of measurements this selection will yield … … 298 314 299 315 if (VERBOSE) { 316 char *basename = filebasename (oldcatalog[0].filename); 317 fprintf (stderr, "limited to "OFF_T_FMT" ("OFF_T_FMT" subset, "OFF_T_FMT" total) stars, "OFF_T_FMT" ("OFF_T_FMT" subset, "OFF_T_FMT" total) measures for catalog %s\n", 318 Nmax, subcatalog[0].Naverage, oldcatalog[0].Naverage, Nmeasure, subcatalog[0].Nmeasure, oldcatalog[0].Nmeasure, basename); 319 free (basename); 320 } 321 322 free (index); 323 free (value); 324 free (subcatalog[0].averageT); 325 free (subcatalog[0].measureT); 326 free (subcatalog[0].secfilt); 327 328 subcatalog[0].averageT = tmpcatalog.averageT; 329 subcatalog[0].measureT = tmpcatalog.measureT; 330 subcatalog[0].secfilt = tmpcatalog.secfilt; 331 subcatalog[0].Naverage = Nmax; 332 subcatalog[0].Nmeasure = Nmeasure; 333 subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt; 334 subcatalog[0].Nsecf_mem = Naverage * oldcatalog[0].Nsecfilt; 335 336 return (TRUE); 337 } 338 339 int LimitDensityCatalog (Catalog *subcatalog, Catalog *catalog) { 340 341 Catalog tmpcatalog; 342 343 double Rmin, Rmax, Dmin, Dmax; 344 345 int Nsecfilt = GetPhotcodeNsecfilt (); 346 347 gfits_scan (&catalog[0].header, "RA0", "%lf", 1, &Rmin); 348 gfits_scan (&catalog[0].header, "DEC0", "%lf", 1, &Dmin); 349 gfits_scan (&catalog[0].header, "RA1", "%lf", 1, &Rmax); 350 gfits_scan (&catalog[0].header, "DEC1", "%lf", 1, &Dmax); 351 352 if (VERBOSE2) fprintf (stderr, "extracting from catalog covering region %f,%f to %f,%f\n", Rmin, Dmin, Rmax, Dmax); 353 354 float AREA = fabs(Dmax - Dmin) * fabs(Rmax - Rmin) * cos (0.5*RAD_DEG*(Dmax + Dmin)); 355 assert (AREA > 0); 356 357 off_t Nmax = MaxDensityValue * AREA; 358 if (subcatalog[0].Naverage <= Nmax) { 359 if (VERBOSE) { 360 fprintf (stderr, "subcatalog has less than the max density\n"); 361 } 362 return (TRUE); 363 } 364 365 off_t Naverage = subcatalog[0].Naverage; 366 367 // select a random subset of Nmax stars from subcatalog using Fisher-Yates 368 369 // we are going to select Nmax entries by generating a random-sorted index list 370 off_t *index, tmp, i, j, ave; 371 ALLOCATE (index, off_t, Naverage); 372 for (i = 0; i < Naverage; i++) { 373 index[i] = i; 374 } 375 for (i = 0; i < Naverage; i++) { 376 j = (Naverage - i) * drand48() + i; // a number between i and Naverage 377 tmp = index[j]; 378 index[j] = index[i]; 379 index[i] = tmp; 380 } 381 382 // count the number of measurements this selection will yield 383 off_t NMEASURE = 0; 384 for (i = 0; i < Nmax; i++) { 385 ave = index[i]; 386 NMEASURE += subcatalog[0].averageT[ave].Nmeasure; 387 } 388 389 // allocate the output data 390 ALLOCATE (tmpcatalog.averageT, AverageTiny, Nmax); 391 ALLOCATE (tmpcatalog.measureT, MeasureTiny, NMEASURE); 392 ALLOCATE (tmpcatalog.secfilt, SecFilt, Nmax * Nsecfilt); 393 394 off_t Nmeasure = 0; 395 396 // copy the Nmax selected entries from subcatalog to tmpcatalog (adjusting links) 397 for (i = 0; i < Nmax; i++) { 398 ave = index[i]; 399 tmpcatalog.averageT[i] = subcatalog[0].averageT[ave]; 400 tmpcatalog.averageT[i].measureOffset = Nmeasure; 401 for (j = 0; j < tmpcatalog.averageT[i].Nmeasure; j++) { 402 off_t offset = subcatalog[0].averageT[ave].measureOffset + j; 403 tmpcatalog.measureT[Nmeasure] = subcatalog[0].measureT[offset]; 404 tmpcatalog.measureT[Nmeasure].averef = i; 405 Nmeasure ++; 406 } 407 for (j = 0; j < Nsecfilt; j++) { 408 tmpcatalog.secfilt[i*Nsecfilt + j] = subcatalog[0].secfilt[ave*Nsecfilt + j]; 409 } 410 } 411 412 if (VERBOSE) { 300 413 fprintf (stderr, "limited to "OFF_T_FMT" of "OFF_T_FMT" stars ("OFF_T_FMT" of "OFF_T_FMT" measures) for catalog %s\n", 301 414 Nmax, subcatalog[0].Naverage, Nmeasure, subcatalog[0].Nmeasure, catalog[0].filename); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot.c
r33608 r33610 230 230 MARKTIME("-- save Image.dat.bck: %f sec\n", dtime); 231 231 } 232 233 /* at this point, we have correct cal coeffs in the image/mosaic structures */ 234 for (i = 0; i < Ncatalog; i++) { 235 free_tiny_values (&catalog[i]); 236 dvo_catalog_free (&catalog[i]); 237 } 238 freeImageBins (Ncatalog, TRUE); 239 freeMosaicBins (Ncatalog, TRUE); 240 freeGridBins (Ncatalog); 241 232 242 } // (NLOOP > 0) : this loop determines the offsets per chip 233 243 234 // only change the real database if -update is requested 244 reload_images (&db); 245 246 // only change the real database files if -update is requested 235 247 if (!UPDATE) exit (0); 236 248 237 reload_images (&db);238 239 /* at this point, we have correct cal coeffs in the image/mosaic structures */240 for (i = 0; i < Ncatalog; i++) {241 free_tiny_values (&catalog[i]);242 dvo_catalog_free (&catalog[i]);243 }244 freeImageBins (Ncatalog, TRUE);245 freeMosaicBins (Ncatalog, TRUE);246 freeGridBins (Ncatalog);247 248 249 /* load catalog data from region files, update Mrel include all data */ 249 250 reload_catalogs (skylist, flatcorr, 0, NULL); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/setMrelFinal.c
r33608 r33610 123 123 // non-outliers with Imag range 124 124 125 // int print_measure_set (Average *average, SecFilt *secfilt, Measure *measure) { 126 // 127 // off_t k; 128 // 129 // int Nsecfilt = GetPhotcodeNsecfilt (); 130 // 131 // off_t m = average[0].measureOffset; 132 // 133 // for (k = 0; k < average[0].Nmeasure; k++, m++) { 134 // fprintf (stderr, "meas: %08x\n", measure[m].dbFlags); 135 // } 136 // 137 // int Ns; 138 // for (Ns = 0; Ns < Nsecfilt; Ns++) { 139 // fprintf (stderr, "secf: %08x\n", secfilt[Ns].flags); 140 // } 141 // return 1; 142 // } 143 144 int print_measure_set (Average *average, SecFilt *secfilt, Measure *measure); 145 125 146 void skip_measurements (Catalog *catalog, int pass, FlatCorrectionTable *flatcorr) { 126 147 … … 137 158 138 159 /* allow measures marked as outliers (POOR) and off image region (AREA) */ 139 if (pass >= 2) MEAS_BAD = ID_MEAS_NOCAL | ID_MEAS_SKIP_PHOTOM; 160 if (pass >= 2) { 161 MEAS_BAD = ID_MEAS_NOCAL | ID_MEAS_SKIP_PHOTOM; 162 } else { 163 MEAS_BAD = ID_MEAS_NOCAL | ID_MEAS_POOR_PHOTOM | ID_MEAS_SKIP_PHOTOM | ID_MEAS_AREA; 164 } 140 165 141 166 /* mark measures which should be ignored on this pass */ 142 167 for (i = 0; i < catalog[0].Naverage; i++) { 143 168 Ntot += catalog[0].average[i].Nmeasure; 169 170 if (FALSE && (catalog[0].average[i].objID == 0x46a4) && (catalog[0].average[i].catID == 0xf40e)) { 171 fprintf (stderr, "test obj\n"); 172 print_measure_set (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], catalog[0].measure); 173 } 144 174 145 175 // mark measurements for each secfilt separately … … 173 203 // clear SKIP for all measures at first 174 204 catalog[0].measureT[m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 175 176 // skip measurements from BAD images and mosaics 177 // do NOT skip measurements without a matching image 178 if (isnan(getMcal (m, 0, flatcorr, catalog))) goto skip; 179 if (isnan(getMmos (m, 0))) goto skip; 180 181 // PASS 4 : skip measurements by inst mag limit 205 catalog[0].measure [m].dbFlags &= ~ID_MEAS_SKIP_PHOTOM; 206 207 // skip measurements from BAD images and mosaics (not REF mags) 208 // do NOT skip measurements without a matching image (REF mags) 209 off_t Nim = getImageEntry (m, 0); 210 if (Nim > -1) { 211 if (isnan(getMcal (m, 0, flatcorr, catalog))) goto skip; 212 if (isnan(getMmos (m, 0))) goto skip; 213 } 214 215 // PASS 4 : skip measurements by inst mag limit (not REF mags) 182 216 if ((pass < 4) && ImagSelect) { 183 mag = PhotInst (&catalog[0].measure[m]); 184 if (mag < ImagMin) goto skip; 185 if (mag > ImagMax) goto skip; 217 if (Nim > -1) { 218 mag = PhotInst (&catalog[0].measure[m]); 219 if (mag < ImagMin) goto skip; 220 if (mag > ImagMax) goto skip; 221 } 186 222 } 187 223
Note:
See TracChangeset
for help on using the changeset viewer.
