Changeset 33157
- Timestamp:
- Jan 26, 2012, 5:21:00 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/relphot
- Files:
-
- 9 edited
-
include/relphot.h (modified) (3 diffs)
-
src/ImageOps.c (modified) (11 diffs)
-
src/MosaicOps.c (modified) (8 diffs)
-
src/StarOps.c (modified) (5 diffs)
-
src/args.c (modified) (1 diff)
-
src/help.c (modified) (1 diff)
-
src/plot_scatter.c (modified) (2 diffs)
-
src/plotstuff.c (modified) (1 diff)
-
src/relphot.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/relphot/include/relphot.h
r33117 r33157 79 79 int FREEZE_MOSAICS; 80 80 int USE_GRID; 81 int KEEP_UBERCAL; 81 82 char *OUTROOT; 82 83 int PLOTDELAY; … … 157 158 off_t getImageEntry PROTO((off_t meas, int cat)); 158 159 float getMcal PROTO((off_t meas, int cat, FlatCorrectionTable *flatcorr, Catalog *catalog)); 160 float getMflat PROTO((off_t meas, int cat, FlatCorrectionTable *flatcorr, Catalog *catalog)); 159 161 float getMgrid PROTO((off_t meas, int cat)); 160 162 float getMmos PROTO((off_t meas, int cat)); … … 196 198 int reload_images PROTO((FITS_DB *db)); 197 199 int setExclusions PROTO((Catalog *catalog, int Ncatalog)); 198 void setMcal PROTO((Catalog *catalog, int Poor ));200 void setMcal PROTO((Catalog *catalog, int Poor, FlatCorrectionTable *flatcorr)); 199 201 void setMcalFinal PROTO((void)); 200 202 int setMcalOutput PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr)); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/ImageOps.c
r33117 r33157 1 1 # include "relphot.h" 2 void plot_setMcal (double *list, int Npts, StatType *stats, float clouds); 2 3 3 4 // we have an array of images: image[ImageIndex] (ImageIndex : 0 < Nimage) … … 253 254 } 254 255 256 // returns image.Mcal - ff(x,y) 255 257 float getMcal (off_t meas, int cat, FlatCorrectionTable *flatcorr, Catalog *catalog) { 256 258 … … 268 270 int flat_id = image[i].photom_map_id; 269 271 if (flat_id) { 270 offset = FlatCorrectionOffset (flatcorr, flat_id, catalog[cat].measure [meas].Xccd, catalog[cat].measure[meas].Yccd);271 } 272 value += offset;272 offset = FlatCorrectionOffset (flatcorr, flat_id, catalog[cat].measureT[meas].Xccd, catalog[cat].measureT[meas].Yccd); 273 } 274 value -= offset; 273 275 274 276 return (value); 277 } 278 279 float getMflat (off_t meas, int cat, FlatCorrectionTable *flatcorr, Catalog *catalog) { 280 281 off_t i = MeasureToImage[cat][meas]; 282 if (i == -1) return (NAN); 283 284 float offset = 0.0; 285 286 // to do this, I need to pass in the catalog and flatcorr pointers 287 int flat_id = image[i].photom_map_id; 288 if (flat_id) { 289 offset = FlatCorrectionOffset (flatcorr, flat_id, catalog[cat].measureT[meas].Xccd, catalog[cat].measureT[meas].Yccd); 290 } 291 292 return (offset); 275 293 } 276 294 … … 285 303 286 304 /* determine Mcal values for all images */ 287 void setMcal (Catalog *catalog, int PoorImages ) {305 void setMcal (Catalog *catalog, int PoorImages, FlatCorrectionTable *flatcorr) { 288 306 289 307 off_t i, j, m, c, n, N, Nmax, mark, bad; 290 308 int Nfew, Nbad, Nmos, Ngrid, Nrel, Nsys, Nbright; 291 float Msys, Mrel, Mmos, Mgrid, M calBright, McalBright2;309 float Msys, Mrel, Mmos, Mgrid, Mflat, McalBright, McalBright2; 292 310 double *list, *dlist; 293 311 StatType stats; … … 321 339 if (!bad) continue; 322 340 } 341 342 /* we optionally do not recalibrate images with UBERCAL zero points */ 343 if (KEEP_UBERCAL && (image[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 323 344 324 345 N = 0; … … 348 369 } 349 370 371 // image.Mcal is not supposed to include the flat-field correction, so we need to 372 // apply that offset as well here for this image (in other words, each detection is 373 // being compared to the model, excluding the zero point, Mcal. The model includes 374 // the flat-correction. NOTE the sign of Mflat (Image.Mcal = Measure.Mcal - Mflat) 375 376 Mflat = getMflat (m, c, flatcorr, catalog); 377 350 378 n = catalog[c].measureT[m].averef; 351 379 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); … … 354 382 continue; 355 383 } 356 list[N] = Msys - Mrel - Mmos - Mgrid; 384 385 fprintf (stderr, "%1d, %3d : %3d, %3d : %10.6f %10.6f : %6.3f %6.3f %6.3f %6.3f %6.3f\n", (int) i, (int) j, (int) c, (int) m, catalog[c].averageT[n].R, catalog[c].averageT[n].D, Msys, Mrel, Mmos, Mgrid, Mflat); 386 387 list[N] = Msys - Mrel - Mmos - Mgrid + Mflat; 357 388 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 358 389 if (catalog[c].measureT[m].dM < IMFIT_SYS_SIGMA_LIM) { … … 385 416 image[i].Xm = 100.0*log10(stats.chisq); 386 417 418 plot_setMcal (list, N, &stats, CLOUD_TOLERANCE); 419 387 420 if (image[i].Mcal < -CLOUD_TOLERANCE) { 388 421 image[i].Mcal = 0.0; … … 454 487 } 455 488 489 void plot_setMcal (double *list, int Npts, StatType *stats, float clouds) { 490 491 off_t i; 492 double *xlist; 493 Graphdata graphdata; 494 495 if (!PLOTSTUFF) return; 496 497 ALLOCATE (xlist, double, Npts); 498 499 /**** Mcal vs seq ****/ 500 float minMcal = +100.0; 501 float maxMcal = -100.0; 502 for (i = 0; i < Npts; i++) { 503 xlist[i] = i; 504 minMcal = MIN (list[i], minMcal); 505 maxMcal = MAX (list[i], maxMcal); 506 } 507 508 float McalRange = MAX(1.2*(maxMcal - minMcal), 0.21); 509 float McalCenter = 0.5*(maxMcal + minMcal); 510 511 plot_defaults (&graphdata); 512 graphdata.xmin = -1; 513 graphdata.xmax = Npts + 1; 514 graphdata.ymin = McalCenter - 0.5*McalRange; 515 graphdata.ymax = McalCenter + 0.5*McalRange; 516 plot_list (&graphdata, xlist, list, Npts, "sequence vs Mcal", "%s.seq.png", OUTROOT); 517 518 free (xlist); 519 } 520 456 521 void plot_images () { 457 522 … … 467 532 468 533 /**** dMcal vs airmass ****/ 534 float minAirmass = 1000.0; 535 float maxAirmass = 0.0; 536 float minMcal = +100.0; 537 float maxMcal = -100.0; 538 float mindMcal = +100.0; 539 float maxdMcal = -100.0; 469 540 for (i = 0; i < Nimage; i++) { 470 541 Mlist[i] = image[i].Mcal; 471 542 dlist[i] = image[i].dMcal; 472 543 xlist[i] = image[i].secz; 473 } 544 minAirmass = MIN (image[i].secz, minAirmass); 545 maxAirmass = MAX (image[i].secz, maxAirmass); 546 minMcal = MIN (image[i].Mcal, minMcal); 547 maxMcal = MAX (image[i].Mcal, maxMcal); 548 mindMcal = MIN (image[i].dMcal, mindMcal); 549 maxdMcal = MAX (image[i].dMcal, maxdMcal); 550 } 551 552 float AirmassRange = MAX(1.2*(maxAirmass - minAirmass), 0.25); 553 float AirmassCenter = 0.5*(maxAirmass + minAirmass); 554 555 float McalRange = MAX(1.2*(maxMcal - minMcal), 0.21); 556 float McalCenter = 0.5*(maxMcal + minMcal); 557 558 float dMcalRange = MAX(1.2*(maxdMcal - mindMcal), 0.21); 559 float dMcalCenter = 0.5*(maxdMcal + mindMcal); 474 560 475 561 plot_defaults (&graphdata); 476 graphdata.ymin = PlotdMmin; 477 graphdata.ymax = PlotdMmax; 562 graphdata.xmin = AirmassCenter - 0.5*AirmassRange; 563 graphdata.xmax = AirmassCenter + 0.5*AirmassRange; 564 graphdata.ymin = McalCenter - 0.5*McalRange; 565 graphdata.ymax = McalCenter + 0.5*McalRange; 478 566 plot_list (&graphdata, xlist, Mlist, Nimage, "airmass vs Mcal", "%s.airmass.png", OUTROOT); 567 479 568 plot_defaults (&graphdata); 569 graphdata.xmin = McalCenter - 0.5*McalRange; 570 graphdata.xmax = McalCenter + 0.5*McalRange; 571 graphdata.ymin = dMcalCenter - 0.5*dMcalRange; 572 graphdata.ymax = dMcalCenter + 0.5*dMcalRange; 480 573 plot_list (&graphdata, Mlist, dlist, Nimage, "Mcal vs dMcal", "%s.Mcal.dMcal.png", OUTROOT); 481 574 … … 495 588 plot_defaults (&graphdata); 496 589 graphdata.style = 1; 590 graphdata.xmin = dMcalCenter - 0.5*dMcalRange; 591 graphdata.xmax = dMcalCenter + 0.5*dMcalRange; 497 592 plot_list (&graphdata, xlist, Mlist, NBIN, "dMcal hist", "%s.dMcalhist.png", OUTROOT); 498 593 -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/MosaicOps.c
r33117 r33157 102 102 mosaic[Nmosaic].secz = image[i].secz; 103 103 mosaic[Nmosaic].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode); 104 105 // XXX do we need to do something about flag consistency across a mosaic? 104 106 105 107 /* add image to mosaic image list */ … … 175 177 dMcal += image[m].dMcal; 176 178 Xm += image[m].Xm; 179 180 // XXX: how does this work with UBERCAL? We want to keep the Mcal values supplied by ubercal, but 181 // solve for a single offset for each exposure (Mosaic.Mcal). 182 183 // we also want to keep the flat-field terms for each exposure (regardless of ubercal or not) 184 185 // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value 186 177 187 /* we are using mosaic.Mcal, not image.Mcal. reset image.Mcal */ 178 188 image[m].Mcal = 0.0; … … 215 225 image = getimages (&Nimage, NULL); 216 226 227 // XXX I think this is OK in the ubercal context, but probably need to skip UBERCAL 228 // images? (no need to update them) 229 217 230 // copy the mosaic results to the images. set the mosaic Mcal to 0.0 since we have moved its 218 231 // impact to the images … … 380 393 off_t i, j, m, c, N, Nmax; 381 394 int n, mark, bad, Nfew, Nbad, Ncal, Nrel, Ngrid, Nsys, Nsecfilt; 382 float Msys, Mrel, Mcal, Mgrid ;395 float Msys, Mrel, Mcal, Mgrid, Mflat; 383 396 double *list, *dlist, *Mlist, *dMlist; 384 397 StatType stats; … … 414 427 if (!bad) continue; 415 428 } 429 430 /* we optionally do not recalibrate images with UBERCAL zero points */ 431 if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue; 416 432 417 433 N = 0; … … 441 457 } 442 458 459 // image.Mcal is not supposed to include the flat-field correction, so we need to 460 // apply that offset as well here for this image (in other words, each detection is 461 // being compared to the model, excluding the zero point, Mcal. The model includes 462 // the flat-correction. NOTE the sign of Mflat (Image.Mcal = Measure.Mcal - Mflat) 463 464 Mflat = getMflat (m, c, flatcorr, catalog); 465 443 466 n = catalog[c].measureT[m].averef; 444 467 Msys = PhotSysTiny (&catalog[c].measureT[m], &catalog[c].averageT[n], &catalog[c].secfilt[n*Nsecfilt]); … … 447 470 continue; 448 471 } 449 list[N] = Msys - Mrel - Mcal - Mgrid ;472 list[N] = Msys - Mrel - Mcal - Mgrid + Mflat; 450 473 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 451 474 Mlist[N] = Msys; … … 499 522 // to 0.0. At the same time, we make a guess to the effective impact on all other images, 500 523 // driven by the coupling of common stars. 524 // XXX this function is no longer used because we force significantly negative clouds to 0.0 501 525 int rationalize_mosaics (Catalog *catalog, int Ncatalog) { 502 526 -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/StarOps.c
r33117 r33157 60 60 for (j = 0; j < catalog[i].Naverage; j++) { 61 61 62 // XXX accumulate all secfilt values in a single pass? 63 62 64 int Ns; 63 65 for (Ns = 0; Ns < Nphotcodes; Ns++) { … … 82 84 continue; 83 85 } 86 87 // XXX include the ubercal measurements? yes, of course! these are the well-determined values, supposedly! 88 84 89 // XXX allow REF stars (no Image Entry) to be included in the calculation this 85 90 // should be optionally set, and should allow for REF stars to be downweighted by … … 144 149 } 145 150 151 // setMrel and setMrelOutput are extremely similar, but have slightly different implications: 152 // * setMrel uses the internal Tiny structures only 153 // * setMrelOutput skips stars for which there are too few good measurements 154 // * setMrelOutput is meant to be called repeatedly, relaxing the criteria for 'good' on each pass 146 155 int setMrelOutput (Catalog *catalog, int Ncatalog, int mark, FlatCorrectionTable *flatcorr) { 147 156 … … 167 176 for (i = 0; i < Ncatalog; i++) { 168 177 for (j = 0; j < catalog[i].Naverage; j++) { 178 169 179 /* skip stars already calibrated */ 170 180 if (catalog[i].found[j]) continue; … … 172 182 int Ns; 173 183 for (Ns = 0; Ns < Nphotcodes; Ns++) { 184 174 185 int thisCode = photcodes[Ns][0].code; 175 186 Nsec = GetPhotcodeNsec(thisCode); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/args.c
r31668 r33157 189 189 } 190 190 191 KEEP_UBERCAL = FALSE; 192 if ((N = get_argument (argc, argv, "-keep-ubercal"))) { 193 remove_argument (N, &argc, argv); 194 KEEP_UBERCAL = TRUE; 195 } 196 191 197 MIN_ERROR = 0.001; 192 198 if ((N = get_argument (argc, argv, "-minerror"))) { -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/help.c
r30616 r33157 37 37 fprintf (stderr, " -imfreeze\n"); 38 38 fprintf (stderr, " -grid\n"); 39 fprintf (stderr, " -keep-ubercal : do not change zero point for ubercal-ed images\n"); 39 40 fprintf (stderr, " -area Xmin Xmax Ymin Ymax\n"); 40 41 fprintf (stderr, " -instmag min max\n"); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/plot_scatter.c
r33117 r33157 11 11 for (i = 0; i < Ncatalog; i++) { 12 12 for (j = 0; j < catalog[i].Naverage; j++) { 13 Ntot += catalog[i].average [j].Nmeasure;13 Ntot += catalog[i].averageT[j].Nmeasure; 14 14 } 15 15 } … … 32 32 /* calculate the average value for a single star */ 33 33 if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue; 34 m = catalog[i].average [j].measureOffset;34 m = catalog[i].averageT[j].measureOffset; 35 35 36 for (k = 0; k < catalog[i].average [j].Nmeasure; k++, m++) {36 for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) { 37 37 // skip measurements that do not match the current photcode 38 38 int ecode = GetPhotcodeEquivCodebyCode (catalog[i].measureT[m].photcode); -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/plotstuff.c
r27611 r33157 165 165 graphdata[0].color = black; 166 166 graphdata[0].lweight = 0; 167 graphdata[0].size = 0.5;167 graphdata[0].size = 1.0; 168 168 169 169 graphdata[0].xmin = dUNDEF; -
branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot.c
r33117 r33157 120 120 /* determine fit values */ 121 121 for (i = 0; i < NLOOP; i++) { 122 if (PLOTSTUFF) { 123 plot_scatter (catalog, Ncatalog, flatcorr); 124 } 122 125 setMrel (catalog, Ncatalog, flatcorr); 123 setMcal (catalog, FALSE); 126 if (PLOTSTUFF) { 127 plot_scatter (catalog, Ncatalog, flatcorr); 128 } 129 setMcal (catalog, FALSE, flatcorr); 124 130 setMmos (catalog, FALSE, flatcorr); 125 131 setMgrid (catalog, flatcorr); … … 160 166 161 167 /* set Mcal & Mmos for bad images */ 162 setMcal (catalog, TRUE );168 setMcal (catalog, TRUE, flatcorr); 163 169 setMmos (catalog, TRUE, flatcorr); 164 170 MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
Note:
See TracChangeset
for help on using the changeset viewer.
