IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41559 for trunk


Ignore:
Timestamp:
Apr 28, 2021, 6:02:02 PM (5 years ago)
Author:
eugene
Message:

when nights go bad, propagate the last Mcal to the exposures (same when exposures go bad); do not redeem nights

Location:
trunk/Ohana/src/relphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r41557 r41559  
    772772  // this mosaic has been identified as poor.
    773773  mosaic[myMosaic].flags |= ID_IMAGE_MOSAIC_POOR;
    774   mosaic[myMosaic].McalPSF  = 0.0;
    775   mosaic[myMosaic].McalAPER = 0.0;
    776774
    777775  image = getimages (&Nimage, NULL);
    778776
    779777  // all images should be marked as coming from a bad mosaic
    780   // these will be fitted independently
     778  // these will be fitted independently.  Make the starting solution consistent by
     779  // setting the image McalPSF for the current best fit from the mosaic
     780
    781781  for (off_t i = 0; i < MosaicN_Image[myMosaic]; i++) {
    782782    off_t im = MosaicToImage[myMosaic][i];
    783783    image[im].flags |= ID_IMAGE_MOSAIC_POOR;
    784   }
     784    image[im].McalPSF = mosaic[myMosaic].McalPSF;
     785    image[im].McalAPER = mosaic[myMosaic].McalAPER;
     786  }
     787
     788  mosaic[myMosaic].McalPSF  = 0.0;
     789  mosaic[myMosaic].McalAPER = 0.0;
    785790}
    786791
     
    13591364  }
    13601365 
    1361   fprintf (stderr, "MOSAIC time %.6f photcode %d Mcal: %f, dMcal: %f, chisq: %f, %d of %d\n",
    1362            ohana_sec_to_mjd(myMosaic[0].start), myMosaic[0].photcode, myMosaic[0].McalPSF, myMosaic[0].dMcal, myMosaic[0].McalChiSq, myMosaic[0].nFitPhotom, myMosaic[0].nValPhotom);
     1366  fprintf (stderr, "MOSAIC time %.6f photcode %d Mcal: %f, dMcal: %f, chisq: %f, %d of %d, useMmos: %d\n",
     1367           ohana_sec_to_mjd(myMosaic[0].start), myMosaic[0].photcode, psfStars->bSaveArray[0][0], myMosaic[0].dMcal, myMosaic[0].McalChiSq, myMosaic[0].nFitPhotom, myMosaic[0].nValPhotom, useMmos);
    13631368
    13641369  return TRUE;
     
    18601865
    18611866/* mark mosaic if: abs(Mcal - <Mcal>) too large, dMcal too large */
     1867
     1868static float MinMaxChiSq = NAN;
     1869static float MinMaxScatter = NAN;
     1870
    18621871void clean_mosaics () {
    18631872
     
    18711880  ALLOCATE (mlist, double, Nmosaic);
    18721881  ALLOCATE (slist, double, Nmosaic);
     1882
     1883  // Measure the good/bad statistics using mosaics which are actually calibrated.
     1884  // But they could be applied to all mosaics below (allowing bad mosaics to become good)
     1885  // However, for now, we will NOT allow mosaics to be redeemed (bad -> good)
    18731886
    18741887  int N = 0;
     
    18851898
    18861899  liststats (mlist, NULL, NULL, N, &stats);
    1887   float MaxChiSq = stats.Upper90;
     1900  float ChiSqUpper90 = stats.Upper90;
     1901  if (isnan (MinMaxChiSq)) MinMaxChiSq = 2.0*stats.median;
     1902  float MaxChiSq = MAX (MinMaxChiSq, ChiSqUpper90);
    18881903
    18891904  liststats (slist, NULL, NULL, N, &stats);
    1890   float MaxScatter = stats.Upper90;
    1891 
    1892   fprintf (stderr, "MOSAIC: Max ChiSq: %f, Max Scatter: %f\n", MaxChiSq, MaxScatter);
     1905  float ScatterUpper90 = stats.Upper90;
     1906  if (isnan (MinMaxScatter)) MinMaxScatter = 2.0*stats.median;
     1907  float MaxScatter = MAX (MinMaxScatter, ScatterUpper90);
     1908
     1909  fprintf (stderr, "MOSAIC: Max ChiSq: %f, Max Scatter: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", MaxChiSq, MaxScatter, ChiSqUpper90, ScatterUpper90);
    18931910 
    1894   int Ntotal = 0, Nmark = 0, Nscatter = 0, Nfew = 0, Nchisq = 0;
     1911  int Ntotal = 0, Npoor = 0, Nmark = 0, Nscatter = 0, Nfew = 0, Nchisq = 0;
    18951912  for (int i = 0; i < Nmosaic; i++) {
    18961913    // if we are keeping ubercal sacrosanct, then we should not be allowed to break them...
     
    19021919
    19031920    int mark = FALSE;
     1921
     1922    // we do not allow bad nights to be redeemed
     1923    if (mosaic[i].flags & ID_IMAGE_MOSAIC_POOR) {
     1924      Npoor ++;
     1925      continue;
     1926    }
    19041927
    19051928    if (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW) {
     
    19231946  }
    19241947
    1925   fprintf (stderr, "%d of %d mosaics marked poor (%d scatter, %d chisq, %d few)\n",  Nmark, Ntotal, Nscatter, Nchisq, Nfew);
     1948  fprintf (stderr, "%d + %d of %d mosaics marked poor (%d scatter, %d chisq, %d few)\n",  Nmark, Npoor, Ntotal, Nscatter, Nchisq, Nfew);
    19261949
    19271950  free (mlist);
  • trunk/Ohana/src/relphot/src/TGroupOps.c

    r41557 r41559  
    453453  // this tgroup has been identified as poor.
    454454  tgroup->flags |= ID_IMAGE_NIGHT_POOR;
    455   tgroup->McalPSF  = 0.0;
    456   tgroup->McalAPER = 0.0;
    457   tgroup->dKlam    = 0.0;
    458455
    459456  // all associated mosaics should be marked as coming from a bad night
    460   // these will be fitted independently
     457  // these will be fitted independently.  Make the starting solution consistent by
     458  // setting the mosaic McalPSF for the current best fit from the tgroup
     459
    461460  for (off_t j = 0; j < tgroup->Nmosaic; j++) {
    462     tgroup->mosaic[j]->flags |= ID_IMAGE_NIGHT_POOR;
     461    Mosaic *mos = tgroup->mosaic[j];
     462    mos->flags |= ID_IMAGE_NIGHT_POOR;
     463    mos->McalPSF = (TGROUP_FIT_AIRMASS) ? tgroup->McalPSF + tgroup->dKlam*(mos->secz - 1.0) : tgroup->McalPSF;
     464    mos->McalAPER = (TGROUP_FIT_AIRMASS) ? tgroup->McalAPER + tgroup->dKlam*(mos->secz - 1.0) : tgroup->McalAPER;
    463465  }
    464466
     
    470472    image[im].flags |= ID_IMAGE_NIGHT_POOR;
    471473  }
    472 }
    473 
     474
     475  // reset the tgroup to have no impact on the solution
     476  tgroup->McalPSF  = 0.0;
     477  tgroup->McalAPER = 0.0;
     478  tgroup->dKlam    = 0.0;
     479}
     480
     481// for now, we do not allow a night to be redeemed, so this
     482// operation should have no impact.
    474483void markGoodTGroup (TGroup *tgroup) {
    475484
     
    793802  // for testing, supply the MJD of a night or nights here to dump the full list of measurements
    794803  int testImage = FALSE;
    795   // testImage |= (abs(mjdStart - 57353) < 0.1);
     804  testImage |= (abs(mjdStart - 58064) < 0.1);
     805  testImage |= (abs(mjdStart - 58082) < 0.1);
     806  testImage |= (abs(mjdStart - 58770) < 0.1);
     807  testImage |= (abs(mjdStart - 55843) < 0.1);
     808  testImage |= (abs(mjdStart - 56967) < 0.1);
     809  testImage |= (abs(mjdStart - 57329) < 0.1);
     810  testImage |= (abs(mjdStart - 56614) < 0.1);
    796811
    797812  FILE *fout = NULL;
     
    930945  double altSigma = (stats.Upper80 - stats.Lower20) / 1.6;
    931946
    932   TGTimes *mygroup = (TGTimes *) myTGroup->parent;
    933   fprintf (stderr, "TGroup Stats %f,%d : %d %d %6.3f %6.3f\n", ohana_sec_to_mjd(mygroup->start), myTGroup->photcode, (int) N, (int) myTGroup->Nmeasure, stats.median, altSigma);
    934 
    935947  // do anything special with identified good nights?
    936948  // (myTGroup->flags & ID_IMAGE_PHOTOM_UBERCAL)
     
    961973  // bright end scatter (systematic error)
    962974  myTGroup->dMsys = brightStars->sigma;
     975
     976  TGTimes *mygroup = (TGTimes *) myTGroup->parent;
     977  fprintf (stderr, "TGroup Stats %f,%d : %d %d %6.3f %6.3f %6.3f %d\n", ohana_sec_to_mjd(mygroup->start), myTGroup->photcode, (int) N, (int) myTGroup->Nmeasure, psfStars->bSaveArray[0][0], stats.median, altSigma, useMgrp);
    963978
    964979  if (testImage) {
     
    12421257 */
    12431258
     1259static float MinMaxChiSq = NAN;
     1260static float MinMaxScatter = NAN;
     1261
    12441262void clean_tgroups () {
    12451263
     
    12541272
    12551273  // measure the good/bad statistics using nights which are actually calibrated
    1256   // but they will be applied to all nights below (allowing bad nights to become good)
     1274  // But they could be applied to all nights below (allowing bad nights to become good)
     1275  // However, for now, we will NOT allow nights to be redeemed (bad -> good)
    12571276  int N = 0;
    12581277  for (int i = 0; i < NtgroupTimes; i++) {
     
    12701289
    12711290  liststats (mlist, NULL, NULL, N, &stats);
    1272   float MaxChiSq = stats.Upper90;
     1291  float ChiSqUpper90 = stats.Upper90;
     1292  if (isnan (MinMaxChiSq)) MinMaxChiSq = 2.0*stats.median;
     1293  float MaxChiSq = MAX (MinMaxChiSq, ChiSqUpper90);
    12731294
    12741295  liststats (slist, NULL, NULL, N, &stats);
    1275   float MaxScatter = stats.Upper90;
    1276 
    1277   fprintf (stderr, "TGROUPS: Max ChiSq: %f, Max Scatter: %f\n", MaxChiSq, MaxScatter);
     1296  float ScatterUpper90 = stats.Upper90;
     1297  if (isnan (MinMaxScatter)) MinMaxScatter = 2.0*stats.median;
     1298  float MaxScatter = MAX (MinMaxScatter, ScatterUpper90);
     1299
     1300  fprintf (stderr, "TGROUPS: Max ChiSq: %f, Max Scatter: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", MaxChiSq, MaxScatter, ChiSqUpper90, ScatterUpper90);
    12781301 
    1279   int Ntotal = 0, Nmark = 0, Nscatter = 0, Nchisq = 0, NfewNights = 0, NfewExp = 0;
     1302  int Ntotal = 0, Npoor = 0, Nmark = 0, Nscatter = 0, Nchisq = 0, NfewNights = 0, NfewExp = 0;
    12801303  for (int i = 0; i < NtgroupTimes; i++) {
    12811304    TGroup *tgroup = tgroupTimes[i][0].byCode;
     
    12851308
    12861309      int mark = FALSE;
     1310
     1311      // we do not allow bad nights to be redeemed
     1312      if (tgroup[j].flags & ID_IMAGE_NIGHT_POOR) {
     1313        fprintf (stderr, "TGroup Already Poor, not redeemed %f,%d : %6.3f %6.3f %6.3f\n", ohana_sec_to_mjd(tgroupTimes[i][0].start), tgroup[j].photcode, tgroup[j].McalPSF, tgroup[j].stdev, tgroup[j].McalChiSq);
     1314        Npoor ++;
     1315        continue;
     1316      }
    12871317
    12881318      // too few measurements (set in setMgrp_tgroup)
     
    13091339        Nmark ++;
    13101340        markBadTGroup(&tgroup[j]); // mark the tgroup & associated images & mosaics with a bad night
     1341        fprintf (stderr, "TGroup Poor %f,%d : %6.3f %6.3f %6.3f\n", ohana_sec_to_mjd(tgroupTimes[i][0].start), tgroup[j].photcode, tgroup[j].McalPSF, tgroup[j].stdev, tgroup[j].McalChiSq);
    13111342      } else {
    13121343        markGoodTGroup(&tgroup[j]); // mark the tgroup & associated images & mosaics with a good night
     
    13151346  }
    13161347
    1317   fprintf (stderr, "%d of %d tgroups marked poor (%d scatter, %d few nights, %d few exposures, %d chisq)\n",  Nmark, Ntotal, Nscatter, NfewNights, NfewExp, Nchisq);
     1348  fprintf (stderr, "%d + %d of %d tgroups marked poor (%d scatter, %d few nights, %d few exposures, %d chisq)\n",  Nmark, Npoor, Ntotal, Nscatter, NfewNights, NfewExp, Nchisq);
    13181349
    13191350  free (mlist);
Note: See TracChangeset for help on using the changeset viewer.