Changeset 41387 for branches/eam_branches/relphot.20200519/src/TGroupOps.c
- Timestamp:
- Jul 7, 2020, 9:30:05 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/relphot.20200519/src/TGroupOps.c
r41362 r41387 36 36 // load the photometric nights from a file : these will be used to define the tgroups 37 37 // XXX call this in args.c where TGROUP_ZEROPT is set 38 // XXX cannot call this in args.c : the Nphotcodes have not yet been loaded. 38 39 void loadTGroups (char *filename) { 39 40 … … 73 74 tgroup[Nt].McalPSF = 0.0; // note : at the end, tgroup.Mcal is added back to the input images 74 75 tgroup[Nt].McalAPER = 0.0; // note : tgroup stores only offsets relative to the original image values 76 tgroup[Nt].dKlam = 0.0; 75 77 tgroup[Nt].dMcal = 0.0; // note : at the end, tgroup.Mcal is added back to the input images 76 78 tgroup[Nt].dMsys = 0.0; … … 111 113 112 114 // ignore non-GPC1 images 113 if (!isGPC1chip(subset[i].photcode)) { 114 Nsimple ++; 115 // if (!isGPC1chip(subset[i].photcode)) { 116 // Nsimple ++; 117 // continue; 118 // } 119 120 // ignore mosaic images (photcode == 0) 121 if (!subset[i].photcode) { 115 122 continue; 116 123 } … … 138 145 139 146 fprintf (stderr, "matched %d images to %d tgroups, %d simple chips not matched to tgroups\n", (int) (Nsubset - Nsimple), (int) Ntgroup, (int) Nsimple); 147 return; 148 } 149 150 void freeTGroups (void) { 151 152 if (!TGROUP_ZEROPT) return; 153 154 free (ImageToTGroup); 155 free (tgroupTimes); 156 157 for (int i = 0; i < Ntgroup; i++) { 158 free (tgroup[i].image); 159 free (tgroup[i].measure); 160 free (tgroup[i].catalog); 161 } 162 free (tgroup); 140 163 return; 141 164 } … … 221 244 // if start is not in this range, return -1 222 245 if (start < tgroupTimes[Nlo]) return (-1); 223 if (start > tgroupTimes[Nhi] ) return (-1);246 if (start > tgroupTimes[Nhi] + 86399) return (-1); // 1-day range for tgroup for now 224 247 225 248 while (Nhi - Nlo > 4) { … … 259 282 for (j = 0; j < tgroup[i].Nimage; j++) { 260 283 im = tgroup[i].image[j]; 261 image[im].McalPSF += tgroup[i].McalPSF; 262 image[im].McalAPER += tgroup[i].McalAPER; 284 double Mgrp = (TGROUP_FIT_AIRMASS) ? tgroup[i].McalPSF + tgroup[i].dKlam*(image[im].secz - 1.0) : tgroup[i].McalPSF; 285 image[im].McalPSF += Mgrp; 286 image[im].McalAPER += Mgrp; 263 287 image[im].dMcal = tgroup[i].dMcal; 264 288 image[im].McalChiSq = tgroup[i].McalChiSq; … … 267 291 image[im].flags |= (tgroup[i].flags & ID_IMAGE_PHOTOM_FEW); 268 292 image[im].flags |= (tgroup[i].flags & ID_IMAGE_PHOTOM_POOR); 293 294 fprintf (stderr, "TG to IMAGE: %f -> %f (%d)\n", tgroup[i].McalPSF, image[im].McalPSF, tgroup[i].nFitPhotom); 269 295 } 270 296 tgroup[i].McalPSF = 0.0; 271 297 tgroup[i].McalAPER = 0.0; 298 tgroup[i].dKlam = 0.0; 272 299 } 273 300 } … … 287 314 } 288 315 289 void freeTGroupBins (int Ncatalog , int doTGroupList) {316 void freeTGroupBins (int Ncatalog) { 290 317 291 318 off_t i; … … 329 356 } 330 357 } 331 // fprintf (stderr, "matched %d detections to tgroups\n", Nmatch); 358 fprintf (stderr, "Matched %d detections to tgroups\n", Nmatch); 359 for (i = 0; i < Ntgroup; i++) { 360 fprintf (stderr, " TGROUP time %d, Nmeasure: %d, Nimage: %d\n", tgroup[i].start, (int) tgroup[i].Nmeasure, (int) tgroup[i].Nimage); 361 } 332 362 return (TRUE); 333 363 } … … 380 410 } 381 411 382 float getMgrp (off_t meas, int cat ) {412 float getMgrp (off_t meas, int cat, float airmass) { 383 413 384 414 off_t i; … … 392 422 393 423 // if (tgroup[i].flags & IMAGE_BAD) return (NAN); 394 value = tgroup[i].McalPSF ;424 value = tgroup[i].McalPSF + tgroup[i].dKlam*(airmass - 1.0); 395 425 return (value); 396 426 } … … 419 449 int PoorImages; 420 450 double *psfMagList; 451 double *psfAirList; 421 452 double *psfErrList; 422 453 double *brightMagList; … … 456 487 if (allocLists) { 457 488 ALLOCATE (info->psfMagList, double, Nmax); 489 ALLOCATE (info->psfAirList, double, Nmax); 458 490 ALLOCATE (info->psfErrList, double, Nmax); 459 491 ALLOCATE (info->kronMagList, double, Nmax); … … 466 498 void SetMgrpInfoFree (SetMgrpInfo *info) { 467 499 free (info->psfMagList ); 500 free (info->psfAirList ); 468 501 free (info->psfErrList ); 469 502 free (info->kronMagList ); … … 522 555 image = getimages (&N, NULL); 523 556 524 fprintf (stderr, "limiting negative clouds to %f\n", CLOUD_TOLERANCE);525 526 557 if (PoorImages) { 527 558 // XXX use bad stars and measurements for PoorImages? or not? … … 543 574 for (i = 0; i < Ntgroup; i++) { 544 575 setMgrp_tgroup (&tgroup[i], i, image, catalog, &info, flatcorr); 576 fprintf (stderr, "TGROUP Mcal: %f, dK: %f, limiting negative clouds to %f\n", tgroup[i].McalPSF, tgroup[i].dKlam, CLOUD_TOLERANCE); 545 577 } 546 578 SetMgrpInfoFree (&info); … … 575 607 576 608 double *psfMagList = info->psfMagList; 609 double *psfAirList = info->psfAirList; 577 610 double *psfErrList = info->psfErrList; 578 611 double *kronMagList = info->kronMagList; … … 593 626 594 627 int testImage = FALSE; 595 // testImage |= (abs(myTGroup[0].start - 1324104046) < 10);628 testImage |= (abs(myTGroup[0].start - 1245283200) < 10); 596 629 // testImage |= (abs(myTGroup[0].start - 1324103823) < 10); 597 630 … … 633 666 int isBad = (catalog[c].measureT[m].dbFlags & MEAS_BAD); 634 667 635 fprintf (fout, "%f %f : %f %f %f %f %f : %f % d\n", catalog[c].averageT[n].R, catalog[c].averageT[n].D, MsysPSF, MrelPSF, Mcal, Mgrid, Mflat, delta, isBad);668 fprintf (fout, "%f %f : %f %f %f %f %f : %f %f %d\n", catalog[c].averageT[n].R, catalog[c].averageT[n].D, MsysPSF, MrelPSF, Mcal, Mgrid, Mflat, catalog[c].measureT[m].airmass, delta, isBad); 636 669 } 637 670 … … 697 730 698 731 psfMagList[N] = MsysPSF - MrelPSF - Mcal - Mgrid + Mflat; 732 psfAirList[N] = (catalog[c].measureT[m].airmass - 1.0); 699 733 psfErrList[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 700 734 kronMagList[N] = MsysKron - MrelKron - Mcal - Mgrid + Mflat; … … 725 759 } 726 760 727 liststats (psfMagList, psfErrList, NULL, N, &stats); 761 double dk = 0.0; 762 if (TGROUP_FIT_AIRMASS) { 763 liststats_fit1d (psfMagList, psfErrList, psfAirList, N, &stats, &dk); 764 } else { 765 liststats (psfMagList, psfErrList, NULL, N, &stats); 766 } 728 767 if (VERBOSE2 && info->PoorImages) fprintf (stderr, "Mgrp: %f %f %d %d\n", stats.mean, stats.sigma, stats.Nmeas, N); 729 768 … … 733 772 myTGroup[0].McalChiSq = stats.chisq; 734 773 myTGroup[0].nFitPhotom = N; 774 myTGroup[0].dKlam = dk; 735 775 736 776 // drop this for tgroups?
Note:
See TracChangeset
for help on using the changeset viewer.
