Changeset 41387
- Timestamp:
- Jul 7, 2020, 9:30:05 AM (6 years ago)
- Location:
- branches/eam_branches/relphot.20200519
- Files:
-
- 11 edited
-
include/relphot.h (modified) (8 diffs)
-
src/GridOps.c (modified) (10 diffs)
-
src/ImageOps.c (modified) (8 diffs)
-
src/MosaicOps.c (modified) (5 diffs)
-
src/StarOps.c (modified) (4 diffs)
-
src/TGroupOps.c (modified) (22 diffs)
-
src/args.c (modified) (3 diffs)
-
src/liststats.c (modified) (2 diffs)
-
src/reload_catalogs.c (modified) (3 diffs)
-
src/relphot_images.c (modified) (3 diffs)
-
src/setMrelCatalog.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/relphot.20200519/include/relphot.h
r41362 r41387 96 96 float McalPSF; 97 97 float McalAPER; 98 float dKlam; 98 99 float dMcal; 99 100 float dMsys; … … 110 111 off_t *measure; 111 112 112 off_t Ncatalog; 113 off_t NCATALOG; 113 off_t Ncatalog; // XX not needed 114 off_t NCATALOG; // XX not needed 114 115 off_t *catalog; 115 116 } TGroup; … … 332 333 int MOSAIC_ZEROPT; 333 334 int TGROUP_ZEROPT; 335 int TGROUP_FIT_AIRMASS; 334 336 335 337 int TEST_IMAGE1; … … 457 459 void freeImageBins PROTO((int Ncatalog, int doImageList)); 458 460 void freeMosaicBins PROTO((int Ncatalog, int doMosaicList)); 459 void freeTGroupBins PROTO((int Ncatalog , int doTGroupList));461 void freeTGroupBins PROTO((int Ncatalog)); 460 462 461 463 void free_catalogs PROTO((Catalog *catalog, int Ncatalog)); … … 468 470 float getMgrid PROTO((off_t meas, int cat)); 469 471 float getMmos PROTO((off_t meas, int cat)); 470 float getMgrp PROTO((off_t meas, int cat ));472 float getMgrp PROTO((off_t meas, int cat, float airmass)); 471 473 float getMrel PROTO((Catalog *catalog, off_t meas, int cat, dvoMagClassType class, dvoMagSourceType source)); 472 474 short getUbercalDist PROTO((off_t meas, int cat)); … … 485 487 void initMosaics PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage)); 486 488 void initTGroups PROTO((Image *subset, off_t *LineNumber, off_t Nsubset)); 489 void freeTGroups PROTO((void)); 487 490 void initTGroupBins PROTO((Catalog *catalog, int Ncatalog)); 488 491 void initMrel PROTO((Catalog *catalog, int Ncatalog)); … … 493 496 int liststats_init PROTO((StatType *stats)); 494 497 int liststats_irls PROTO((StatDataSet *dataset, int Npoints, StatType *stats)); 498 int liststats_fit1d PROTO((double *value, double *err, double *x, int Npts, StatType *stats, double *dk)); 495 499 496 500 unsigned int *ReadTGroupFile PROTO((FILE *f, int *nelem)); … … 721 725 void RepairWarpMeasuresOpenLogfile (); 722 726 void RepairWarpMeasuresCloseLogfile (); 727 728 int save_images_backup (FITS_DB *db); -
branches/eam_branches/relphot.20200519/src/GridOps.c
r40291 r41387 289 289 290 290 int **gotstar, **gridmeas; 291 int i, j, k, Ngood, Nbad, Nmos, Ncal, Nrel, Nsys ;291 int i, j, k, Ngood, Nbad, Nmos, Ncal, Nrel, Nsys, Ngrp; 292 292 double **A, **B, *Mjx, *Wjx; 293 float Msys, Mcal, Mmos, M err, Wsys;293 float Msys, Mcal, Mmos, Mgrp, Merr, Wsys; 294 294 double Mj, Wj; 295 295 … … 305 305 } 306 306 307 Ngood = Nbad = Ncal = Nmos = Nrel = Nsys = 0;307 Ngood = Nbad = Ncal = Nmos = Nrel = Nsys = Ngrp = 0; 308 308 309 309 ALLOCATE (gotstar, int *, Ncatalog); … … 411 411 if (isnan(Mmos)) { 412 412 Nmos ++; 413 continue; 414 } 415 416 // skip mosaics marked as BAD 417 Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 418 if (isnan(Mgrp)) { 419 Ngrp ++; 413 420 continue; 414 421 } … … 526 533 void setMgrid (Catalog *catalog, FlatCorrectionTable *flatcorr) { 527 534 528 int i, j, m, c, n, N, Nmax, Nbad, Nmos, N cal, Nrel, Nsys, Nfit;535 int i, j, m, c, n, N, Nmax, Nbad, Nmos, Ngrp, Ncal, Nrel, Nsys, Nfit; 529 536 double *list, *dlist; 530 float Msys, Mrel, Mcal, Mmos ;537 float Msys, Mrel, Mcal, Mmos, Mgrp; 531 538 532 539 StatType stats; … … 544 551 ALLOCATE (dlist, double, Nmax); 545 552 546 Nbad = Ncal = Nmos = N rel = Nsys = Nfit = 0;553 Nbad = Ncal = Nmos = Ngrp = Nrel = Nsys = Nfit = 0; 547 554 548 555 for (i = 0; i < Ngrid; i++) { … … 568 575 continue; 569 576 } 577 Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 578 if (isnan(Mgrp)) { 579 Ngrp ++; 580 continue; 581 } 570 582 Mrel = getMrel (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); 571 583 if (isnan(Mrel)) { … … 580 592 continue; 581 593 } 582 list[N] = Msys - Mrel - Mcal - Mmos ;594 list[N] = Msys - Mrel - Mcal - Mmos - Mgrp; 583 595 dlist[N] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 584 596 N++; … … 616 628 617 629 int i, j, m, c, n, N, Narea; 618 float Msys, Mrel, Mcal, Mmos ;630 float Msys, Mrel, Mcal, Mmos, Mgrp; 619 631 double *xlist, *Mlist, *dlist, *ylist; 620 632 Graphdata graphdata; … … 649 661 Mmos = getMmos (m, c); 650 662 if (isnan(Mmos)) continue; 663 Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 664 if (isnan(Mgrp)) continue; 651 665 Mrel = getMrel (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); 652 666 if (isnan(Mrel)) continue; … … 657 671 xlist[N] = Xmeas[c][m]; 658 672 ylist[N] = Ymeas[c][m]; 659 Mlist[N] = Msys - Mrel - Mcal - Mmos ;660 dlist[N] = Msys - Mrel - Mcal - Mmos - gridM[i];673 Mlist[N] = Msys - Mrel - Mcal - Mmos - Mgrp; 674 dlist[N] = Msys - Mrel - Mcal - Mmos - Mgrp - gridM[i]; 661 675 N++; 662 676 } -
branches/eam_branches/relphot.20200519/src/ImageOps.c
r40291 r41387 586 586 587 587 off_t i, j, m, c, n; 588 int mark, bad, Nfew, Nbad, Nmos, N rel, Ngrid, Nsys;588 int mark, bad, Nfew, Nbad, Nmos, Ngrp, Nrel, Ngrid, Nsys; 589 589 590 590 StatType stats; … … 612 612 StatDataSet *brightStars = StatDataSetAlloc (1, Nmax); 613 613 614 Nfew = Nbad = Nmos = Ngr id = Nrel = Nsys = 0;614 Nfew = Nbad = Nmos = Ngrp = Ngrid = Nrel = Nsys = 0; 615 615 616 616 int Ncalibrated = 0; … … 631 631 632 632 // only freeze the gpc1 chips 633 if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 633 // XXX : when do we FREEZE_IMAGES in a mix of GPC1, GPC2, etc? 634 // if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue; 635 if (FREEZE_IMAGES) continue; 634 636 if (image[i].photcode == 0) continue; // skip the PHU images 635 637 … … 666 668 continue; 667 669 } 670 float Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 671 if (isnan(Mgrp)) { 672 Ngrp ++; 673 continue; 674 } 668 675 float Mgrid = getMgrid (m, c); 669 676 if (isnan(Mgrid)) { … … 706 713 707 714 skip: 708 psfStars->flxlist[Nref] = MsysPSF - MrelPSF - Mmos - Mgr id + Mflat;715 psfStars->flxlist[Nref] = MsysPSF - MrelPSF - Mmos - Mgrp - Mgrid + Mflat; 709 716 psfStars->errlist[Nref] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 710 717 psfStars->wgtlist[Nref] = 1; … … 718 725 719 726 if (isfinite(MrelKron) && isfinite(MsysKron)) { 720 kronStars->flxlist[Nkron] = MsysKron - MrelKron - Mmos - Mgr id + Mflat;727 kronStars->flxlist[Nkron] = MsysKron - MrelKron - Mmos - Mgrp - Mgrid + Mflat; 721 728 kronStars->errlist[Nkron] = MAX (catalog[c].measureT[m].dM, MIN_ERROR); 722 729 kronStars->wgtlist[Nkron] = 1; … … 1023 1030 off_t i, j, m, c, n, N; 1024 1031 double *list, *dlist; 1025 float Mcal, Mmos, Mgr id;1032 float Mcal, Mmos, Mgrp, Mgrid; 1026 1033 1027 1034 StatType stats; … … 1050 1057 Mmos = getMmos (m, c); 1051 1058 if (isnan(Mmos)) continue; 1059 Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 1060 if (isnan(Mgrp)) continue; 1052 1061 Mgrid = getMgrid (m, c); 1053 1062 if (isnan(Mgrid)) continue; -
branches/eam_branches/relphot.20200519/src/MosaicOps.c
r41362 r41387 919 919 int Nbad; 920 920 int Ncal; 921 int Ngrp; 921 922 int Ngrid; 922 923 int Nrel; … … 1154 1155 if (fout) { 1155 1156 float Mcal = getMcal (m, c, MAG_CLASS_PSF); 1157 // float Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 1156 1158 float Mgrid = getMgrid (m, c); 1157 1159 float MrelPSF = getMrel (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); … … 1175 1177 if (isnan(Mcal)) { 1176 1178 info->Ncal++; 1179 continue; 1180 } 1181 float Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 1182 if (isnan(Mgrp)) { 1183 info->Ngrp++; 1177 1184 continue; 1178 1185 } … … 1692 1699 off_t i, j, m, c, n, N; 1693 1700 double *list, *dlist; 1694 float Mcal, Mgr id, Mrel;1701 float Mcal, Mgrp, Mgrid, Mrel; 1695 1702 StatType stats; 1696 1703 … … 1716 1723 Mcal = getMcal (m, c, MAG_CLASS_PSF); 1717 1724 if (isnan(Mcal)) continue; 1725 Mgrp = getMgrp (m, c, catalog[c].measureT[m].airmass); 1726 if (isnan(Mgrp)) continue; 1718 1727 Mgrid = getMgrid (m, c); 1719 1728 if (isnan(Mgrid)) continue; -
branches/eam_branches/relphot.20200519/src/StarOps.c
r41362 r41387 491 491 float Mmos = getMmos (m, i); 492 492 if (isnan(Mmos)) continue; 493 float Mgrp = getMgrp (m, i );493 float Mgrp = getMgrp (m, i, catalog[i].measureT[m].airmass); 494 494 if (isnan(Mgrp)) continue; 495 495 float Mgrid = getMgrid (m, i); … … 507 507 508 508 // set the output calibration 509 float Moff = Mmos + Mgrp + Mgrid; 509 // float Moff = Mmos + Mgrp + Mgrid; 510 float Moff = Mmos + Mgrid; // Mgrp has already been applied to the image.Mcal 510 511 catalog[i].measure[m].McalPSF = McalPSF + Moff; 511 512 catalog[i].measure[m].McalAPER = useStackAper ? McalAPER + Moff : McalPSF + Moff; … … 730 731 Mmos = getMmos (m, i); 731 732 if (isnan(Mmos)) { Nmos ++; continue; } 732 Mgrp = getMgrp (m, i );733 Mgrp = getMgrp (m, i, catalog[i].measureT[m].airmass); 733 734 if (isnan(Mgrp)) { Ngrp ++; continue; } 734 735 Mgrid = getMgrid (m, i); … … 736 737 737 738 Msys = PhotSysTiny (&catalog[i].measureT[m], &catalog[i].averageT[j], &catalog[i].secfilt[j*Nsecfilt], MAG_CLASS_PSF); 738 list[N] = Msys - Mcal - Mmos - Mgr id;739 list[N] = Msys - Mcal - Mmos - Mgrp - Mgrid; 739 740 dlist[N] = MAX (catalog[i].measureT[m].dM, MIN_ERROR); 740 741 N++; -
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? -
branches/eam_branches/relphot.20200519/src/args.c
r41362 r41387 317 317 } 318 318 319 FREEZE_IMAGES = FALSE; 320 if ((N = get_argument (argc, argv, "-imfreeze"))) { 321 remove_argument (N, &argc, argv); 322 FREEZE_IMAGES = TRUE; 323 } 324 FREEZE_MOSAICS = FALSE; 325 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 326 remove_argument (N, &argc, argv); 327 FREEZE_MOSAICS = TRUE; 328 } 329 CALIBRATE_STACKS_AND_WARPS = FALSE; 330 if ((N = get_argument (argc, argv, "-only-stacks-and-warps"))) { 331 remove_argument (N, &argc, argv); 332 CALIBRATE_STACKS_AND_WARPS = TRUE; 333 } 334 USE_MCAL_PSF_FOR_STACK_APER = FALSE; 335 if ((N = get_argument (argc, argv, "-use-mcal-psf-for-stack-aper"))) { 336 remove_argument (N, &argc, argv); 337 USE_MCAL_PSF_FOR_STACK_APER = TRUE; 338 } 339 319 340 // calibrate the photometry by night / time period 320 341 TGROUP_ZEROPT = FALSE; 342 char *TGROUP_FILENAME = NULL; 321 343 if ((N = get_argument (argc, argv, "-tgroup"))) { 322 344 TGROUP_ZEROPT = TRUE; 323 345 remove_argument (N, &argc, argv); 324 loadTGroups (argv[N]); 325 remove_argument (N, &argc, argv); 326 } 327 328 FREEZE_IMAGES = FALSE; 329 if ((N = get_argument (argc, argv, "-imfreeze"))) { 346 TGROUP_FILENAME = strcreate(argv[N]); 330 347 remove_argument (N, &argc, argv); 331 348 FREEZE_IMAGES = TRUE; 332 349 } 333 FREEZE_MOSAICS = FALSE; 334 if ((N = get_argument (argc, argv, "-mosfreeze"))) { 335 remove_argument (N, &argc, argv); 336 FREEZE_MOSAICS = TRUE; 337 } 338 CALIBRATE_STACKS_AND_WARPS = FALSE; 339 if ((N = get_argument (argc, argv, "-only-stacks-and-warps"))) { 340 remove_argument (N, &argc, argv); 341 CALIBRATE_STACKS_AND_WARPS = TRUE; 342 } 343 USE_MCAL_PSF_FOR_STACK_APER = FALSE; 344 if ((N = get_argument (argc, argv, "-use-mcal-psf-for-stack-aper"))) { 345 remove_argument (N, &argc, argv); 346 USE_MCAL_PSF_FOR_STACK_APER = TRUE; 350 if ((N = get_argument (argc, argv, "-tgroups"))) { 351 if (TGROUP_ZEROPT) { 352 fprintf (stderr, "use only one of -tgroups and -tgroup (same meaning)\n"); 353 exit (2); 354 } 355 TGROUP_ZEROPT = TRUE; 356 remove_argument (N, &argc, argv); 357 TGROUP_FILENAME = strcreate(argv[N]); 358 remove_argument (N, &argc, argv); 359 FREEZE_IMAGES = TRUE; 360 } 361 TGROUP_FIT_AIRMASS = FALSE; 362 if ((N = get_argument (argc, argv, "-tgroup-fit-airmass"))) { 363 if (!TGROUP_ZEROPT) { 364 fprintf (stderr, "-tgroup-fit-airmass requires -tgroup (filename) option\n"); 365 exit (2); 366 } 367 TGROUP_FIT_AIRMASS = TRUE; 368 remove_argument (N, &argc, argv); 347 369 } 348 370 … … 528 550 if (argc != 1) relphot_usage (); 529 551 552 if (TGROUP_ZEROPT) { 553 loadTGroups (TGROUP_FILENAME); 554 free (TGROUP_FILENAME); 555 } 556 530 557 return mode; 531 558 } … … 551 578 FreePhotcodeTable(); 552 579 580 freeTGroups(); 581 553 582 ohana_memcheck (VERBOSE); 554 583 ohana_memdump (VERBOSE); -
branches/eam_branches/relphot.20200519/src/liststats.c
r40291 r41387 172 172 for (i = ks; i < ke; i++) { 173 173 M = SQ (value[i] - Mo); 174 dM = SQ (dvalue[i]); 175 X2 += M / dM; 174 if (dvalue) { 175 dM = SQ (dvalue[i]); 176 X2 += M / dM; 177 } 176 178 dS += M; 177 179 } 178 X2 = X2 / (Nm - 1);180 X2 = dvalue ? X2 / (Nm - 1) : NAN; 179 181 dS = sqrt (dS / (Nm - 1)); 180 182 … … 187 189 return (TRUE); 188 190 } 191 192 int liststats_fit1d (double *value, double *err, double *x, int Npts, StatType *stats, double *dk) { 193 194 double M = 0.0, MZ = 0.0, Z1 = 0.0, Z2 = 0.0, R = 0.0; 195 196 for (int i = 0; i < Npts; i++) { 197 double wt = 1.0 / (err[i]*err[i]); 198 double V = value[i]; 199 double Z = x[i]; 200 M += V * wt; 201 MZ += V*Z * wt; 202 Z1 += Z * wt; 203 Z2 += Z*Z * wt; 204 R += 1.0 * wt; 205 } 206 207 double DetInv = (R*Z2 - Z1*Z1); 208 double Det = (fabs(DetInv) < -1e6) ? 0.0 : 1.0 / DetInv; // do not allow unstable solutions 209 210 double zp = (M*Z2 - Z1*MZ)*Det; 211 *dk = (MZ*R - M*Z1)*Det; 212 213 stats->mean = zp; 214 stats->chisq = NAN; 215 return TRUE; 216 } 217 189 218 190 219 // These should probably be tunable: -
branches/eam_branches/relphot.20200519/src/reload_catalogs.c
r41341 r41387 86 86 initImageBins (&catalog, 1, FALSE); 87 87 initMosaicBins (&catalog, 1, FALSE); 88 initTGroupBins (&catalog, 1); 89 88 90 initGridBins (&catalog, 1); 89 91 TIMESTAMP(time3b); … … 91 93 findImages (&catalog, 1, FALSE); 92 94 findMosaics (&catalog, 1, FALSE); 95 findTGroups (&catalog, 1); 96 93 97 TIMESTAMP(time4); 94 98 … … 117 121 TIMESTAMP(time6); 118 122 123 // XXX freeTgroupBins here: 124 119 125 freeImageBins (1, FALSE); 120 126 freeMosaicBins (1, FALSE); 127 freeTGroupBins (1); 121 128 freeGridBins (1); 122 129 TIMESTAMP(time7); -
branches/eam_branches/relphot.20200519/src/relphot_images.c
r41362 r41387 81 81 MARKTIME("-- set up mosaic indexes: %f sec\n", dtime); 82 82 83 findTGroups (catalog, Ncatalog); /* also sets Grid values */83 findTGroups (catalog, Ncatalog); 84 84 MARKTIME("-- set up mosaic indexes: %f sec\n", dtime); 85 85 … … 158 158 if ((i > 8) && (i % 8 == 3)) clean_stars (catalog, Ncatalog); 159 159 if ((i > 8) && (i % 8 == 5)) clean_mosaics (); 160 if ((i > 8) && (i % 8 == 5)) clean_tgroups (); 160 161 if ((i > 8) && (i % 8 == 5)) clean_images (); 161 162 … … 258 259 freeImageBins (Ncatalog, TRUE); 259 260 freeMosaicBins (Ncatalog, TRUE); 261 freeTGroupBins (Ncatalog); 260 262 freeGridBins (Ncatalog); 261 263 -
branches/eam_branches/relphot.20200519/src/setMrelCatalog.c
r40373 r41387 221 221 222 222 // ** Choose the calibration (depends on the mode : do I have an image reference or not?) 223 float Mcal = 0.0, Mmos = 0.0, Mgrid = 0.0, Mflat = 0.0 ;223 float Mcal = 0.0, Mmos = 0.0, Mgrid = 0.0, Mflat = 0.0, Mgrp = 0.0; 224 224 off_t meas = measureOffset + k; 225 225 if (getImageEntry (meas, cat) < 0) { … … 235 235 Mmos = getMmos (meas, cat); 236 236 if (isnan(Mmos)) SKIP_THIS_MEAS(Nmos); 237 Mgrp = getMgrp (meas, cat, measureT[k].airmass); 238 if (isnan(Mgrp)) SKIP_THIS_MEAS(Ngrp); 237 239 Mgrid = getMgrid (meas, cat); 238 240 if (isnan(Mgrid)) SKIP_THIS_MEAS(Ngrid); … … 261 263 if (CHECK_VALID_MAG(Map, dMap)) { 262 264 int Nap = results->aperData[Nsec].Nlist; 263 results->aperData[Nsec].flxlist[Nap] = Map - Mflat - Mcal - Mmos - Mgr id; // this is consistent with PhotRel265 results->aperData[Nsec].flxlist[Nap] = Map - Mflat - Mcal - Mmos - Mgrp - Mgrid; // this is consistent with PhotRel 264 266 results->aperData[Nsec].errlist[Nap] = dMap; 265 267 results->aperData[Nsec].wgtlist[Nap] = useUbercalWeight ? UBERCAL_WEIGHT : 1.0; … … 281 283 if (CHECK_VALID_MAG(Mkron, dMkron)) { 282 284 int Nkron = results->kronData[Nsec].Nlist; 283 results->kronData[Nsec].flxlist[Nkron] = Mkron - Mflat - Mcal - Mmos - Mgr id; // this is consistent with PhotRel285 results->kronData[Nsec].flxlist[Nkron] = Mkron - Mflat - Mcal - Mmos - Mgrp - Mgrid; // this is consistent with PhotRel 284 286 results->kronData[Nsec].errlist[Nkron] = dMkron; 285 287 results->kronData[Nsec].wgtlist[Nkron] = isUbercal ? UBERCAL_WEIGHT : 1.0; … … 294 296 if (CHECK_VALID_MAG(Mpsf, dMpsf)) { 295 297 int Npsf = results->psfData[Nsec].Nlist; 296 results->psfData[Nsec].flxlist[Npsf] = Mpsf - Mflat - Mcal - Mmos - Mgr id; // this is consistent with PhotRel298 results->psfData[Nsec].flxlist[Npsf] = Mpsf - Mflat - Mcal - Mmos - Mgrp - Mgrid; // this is consistent with PhotRel 297 299 results->psfData[Nsec].errlist[Npsf] = dMpsf; 298 300 results->psfData[Nsec].wgtlist[Npsf] = isUbercal ? UBERCAL_WEIGHT : 1.0; … … 711 713 Mmos = getMmos (measSeq, cat); 712 714 Mgrid = getMgrid (measSeq, cat); 715 // XXX can Mmos and Mgrid exist for stacks? 713 716 } 714 717
Note:
See TracChangeset
for help on using the changeset viewer.
