IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37113


Ignore:
Timestamp:
Jul 24, 2014, 11:14:51 AM (12 years ago)
Author:
eugene
Message:

stack primary bit does not depend on data quality; define stack best, stack primary bits correctly; clean_measures does not touch warp or stack; mean warp limited to same skycell as best stack

Location:
branches/eam_branches/ipp-20140717/Ohana/src/relphot
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140717/Ohana/src/relphot/include/relphot.h

    r37099 r37113  
    440440int MatchImageName (off_t meas, int cat, char *name);
    441441int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID);
     442int FindImageSkycellID (off_t meas, int cat, int *myTessID, int *myProjectionID, int *mySkycellID);
    442443
    443444int load_tess (char *treefile);
  • branches/eam_branches/ipp-20140717/Ohana/src/relphot/src/ImageOps.c

    r37037 r37113  
    491491  if (projectID[i] != myProjectionID) return FALSE;
    492492  if (skycellID[i] != mySkycellID) return FALSE;
     493 
     494  return TRUE;
     495}
     496
     497// returns image.Mcal - ff(x,y)
     498int FindImageSkycellID (off_t meas, int cat, int *myTessID, int *myProjectionID, int *mySkycellID) {
     499
     500  off_t i;
     501
     502  if (!MeasureToImage) return FALSE;
     503
     504  if (meas < 0) return FALSE;
     505
     506  i = MeasureToImage[cat][meas];
     507  if (i == -1) return FALSE;
     508
     509  if (tessID[i]    == -1) return FALSE;
     510  if (projectID[i] == -1) return FALSE;
     511  if (skycellID[i] == -1) return FALSE;
     512
     513  *myTessID = tessID[i];
     514  *myProjectionID = projectID[i];
     515  *mySkycellID =  skycellID[i];
    493516 
    494517  return TRUE;
  • branches/eam_branches/ipp-20140717/Ohana/src/relphot/src/StarOps.c

    r37037 r37113  
    10861086          if (ecode != thisCode) { continue; }
    10871087
     1088          // SKIP gpc1 stack data
     1089          if (isGPC1stack(catalog[i].measureT[m].photcode)) continue;
     1090         
     1091          // SKIP gpc1 forced-warp data
     1092          if (isGPC1warp(catalog[i].measureT[m].photcode)) continue;
     1093         
    10881094          // NOTE: we do not skip MEAS_BAD because this measurement is just an internal assessment of the outliers
    10891095          Mcal  = getMcal  (m, i, flatcorr, catalog);
     
    11311137          if (ecode != thisCode) { continue; }
    11321138
     1139          // SKIP gpc1 stack data
     1140          if (isGPC1stack(catalog[i].measureT[m].photcode)) continue;
     1141         
     1142          // SKIP gpc1 forced-warp data
     1143          if (isGPC1warp(catalog[i].measureT[m].photcode)) continue;
     1144         
    11331145          // NOTE: we do not skip MEAS_BAD because this measurement is just an internal assessment of the outliers
    11341146          Mcal  = getMcal  (m, i, flatcorr, catalog);
  • branches/eam_branches/ipp-20140717/Ohana/src/relphot/src/bcatalog.c

    r37037 r37113  
    7878        int Nsec = GetPhotcodeNsec(thisCode);
    7979
    80         fprintf (stderr, "really use dvo_secfilt_init?");
     80        // fprintf (stderr, "really use dvo_secfilt_init?");
    8181        dvo_secfilt_init (&subcatalog[0].secfilt[Nsecfilt*Naverage+Nsec]);
    8282
  • branches/eam_branches/ipp-20140717/Ohana/src/relphot/src/setMrelCatalog.c

    r37099 r37113  
    441441
    442442// only apply Stack operation on setMrelFinal in first pass
     443// this function has 3 goals, not to be confused:
     444// 1) find and mark the PRIMARY detections (regardless of the quality of the detection)
     445// 2) select the BEST detections per filter (regardless of PRIMARY)
     446// 3) apply the zero point and AB->Jy transformations
    443447int setMrelAverageStack (off_t measureOffset, int cat, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, SecFilt *secfilt, Measure *measure) {
    444448
    445449  off_t k, ID;
    446450
    447   float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0;
     451  float Mcal= 0, Mmos = 0, Mgrid = 0, Finst = 0;
    448452
    449453  // set the primary projection cell and skycell for this coordinate
     
    467471    int haveStack = FALSE;
    468472
    469     // need to find the measurement closest to the center of its skycell, as well as the
    470     // closest for the subset of primary projection cells
    471 
    472     float stackCenterOffsetMin = 1e9;
    473     off_t stackCenterMeasureMin = -1;
    474 
    475     float stackPrimaryOffsetMin = 1e9;
    476     off_t stackPrimaryMeasureMin = -1;
     473    float psfQFbest = 0.0;
     474
     475    off_t stackBestMeasure = -1;
     476    off_t stackPrimaryMeasure = -1;
    477477
    478478    int isBad = FALSE;
     
    481481    off_t meas = measureOffset;
    482482    for (k = 0; k < average[0].Nmeasure; k++, meas++) {
     483
     484      // only examine gpc1 stack data
     485      if (!isGPC1stack(measure[k].photcode)) continue;
    483486
    484487      // skip measurements that do not match the current photcode
     
    489492      // clear this bit for all measurements
    490493      measure[k].dbFlags &= ~ID_MEAS_STACK_PRIMARY;
    491 
    492       // only examine gpc1 stack data
    493       if (!isGPC1stack(measure[k].photcode)) continue;
     494      measure[k].dbFlags &= ~ID_MEAS_STACK_PHOT_SRC;
    494495
    495496      haveStack = TRUE;
    496497      haveStackObject = TRUE;
    497498     
    498       if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS_STACK(Nbad);
    499 
     499      // match measurement to its image (this is just a check, right?)
    500500      if (getImageEntry (meas, cat) < 0) {
    501501        fprintf (stderr, "*** warning : this should be impossible\n");
     
    503503        continue;
    504504      }
     505
     506      // find the PRIMARY measurement
     507
     508      // if we request the primary (USE_TREE_FOR_PRIMARY), this is true if the measurement is from the
     509      // primary skycell for this position
     510      if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) {
     511        stackPrimaryMeasure = k;
     512        measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY;
     513        secfilt[Nsec].stackPrmryOff = meas;
     514      }
     515
     516      // now choose the BEST measurements (may also be PRIMARY)
     517
     518      if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS_STACK(Nbad);
     519
    505520      // measurements without an image are either external reference photometry or
    506521      // data for which the associated image has not been loaded (probably because of
     
    514529      if (isnan(Mgrid)) SKIP_THIS_MEAS_STACK(Ngrid);
    515530
    516       Msys = PhotSys (&measure[k], &average[0], &secfilt[0], MAG_CLASS_PSF);
    517       if (isnan(Msys)) SKIP_THIS_MEAS_STACK(Nsys);
    518 
    519       unsigned int stackImageID;
    520 
    521       // which stack image should we use for the mean value?
    522       // if we request the primary (USE_TREE_FOR_PRIMARY), then find the min distances for data from the primary cell
    523       if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) {
    524         float stackPrimaryOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID);
    525         if (stackPrimaryOffset < stackPrimaryOffsetMin) {
    526           stackPrimaryOffsetMin = stackPrimaryOffset;
    527           // stackPrimaryIDmin = stackImageID;
    528           stackPrimaryMeasureMin = k;
    529         }
    530       }
    531 
    532       // get the center distance for the generic case:
    533       float stackCenterOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID);
    534       if (stackCenterOffset < stackCenterOffsetMin) {
    535         stackCenterOffsetMin = stackCenterOffset;
    536         // stackCenterIDmin = stackImageID;
    537         stackCenterMeasureMin = k;
     531      // NOTE: negative and insignificant vlues values are allowed, but not NAN flux values
     532      Finst = PhotFluxInst (&measure[k], MAG_CLASS_PSF);
     533      if (isnan(Finst)) SKIP_THIS_MEAS_STACK(Ninst);
     534
     535      if (measure[k].psfQFperf > psfQFbest) {
     536        psfQFbest = measure[k].psfQFperf;
     537        stackBestMeasure = k;
    538538      }
    539539
     
    558558
    559559    // measurements which are bad will not have a valid stack entry and are skipped
    560     k = (stackPrimaryMeasureMin >= 0) ? stackPrimaryMeasureMin : stackCenterMeasureMin;
     560    k = (stackBestMeasure >= 0) ? stackBestMeasure : stackPrimaryMeasure;
    561561    if (k < 0) continue;
    562 
    563562
    564563    // we are now populating stackDetectID not stack Image ID in secfilt
     
    609608    secfilt[Nsec].dFapStk   = zpFactor * measure[k].dFluxAp;
    610609
     610    // Jy to AB mags
    611611    secfilt[Nsec].MpsfStk   = (measure[k].FluxPSF  > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FpsfStk) : NAN;
    612612    secfilt[Nsec].MkronStk  = (measure[k].FluxKron > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FkronStk) : NAN;
    613613    secfilt[Nsec].MapStk    = (measure[k].FluxAp   > 0.0) ? 8.9 - 2.5*log10(secfilt[Nsec].FapStk) : NAN;
    614614
    615     secfilt[Nsec].stackDetectID = ID;
    616 
     615    secfilt[Nsec].stackBestOff = k + measureOffset;
     616
     617    // this is the measurement used by secfilt[]
    617618    measure[k].dbFlags |= ID_MEAS_STACK_PHOT_SRC;
    618     if (stackPrimaryMeasureMin >= 0) {
    619       measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY;
     619    if (k == stackPrimaryMeasure) {
    620620      secfilt[Nsec].flags |= ID_SECF_STACK_PRIMARY;
    621621    }
     
    646646
    647647  off_t k;
    648   float Fsys = 0, Mcal= 0;
     648  float Mcal= 0;
    649649
    650650  // we are measuring means for 3 types of FLUXes: psf, ap, kron.  I am using the psf mag
     
    668668
    669669  // option for a test print
    670   if (FALSE && (average[0].objID == 0x7146) && (average[0].catID == 0x49d8)) {
     670  if ((average[0].objID == 0xd6e) && (average[0].catID == 0x4984)) {
    671671    fprintf (stderr, "test obj\n");
    672672    print_measure_set_alt (average, secfilt, measure);
     
    684684    if (found[Nsec]) continue; 
    685685     
     686    // I need to restrict the measurements coming only from the same skycell as the secfilt values
     687    // if we cannot make that association, skip this set of warps
     688    int stkTessID, stkProjID, stkSkycellID;
     689    if (!FindImageSkycellID (secfilt[Nsec].stackBestOff, cat, &stkTessID, &stkProjID, &stkSkycellID)) continue;
     690
    686691    off_t meas = measureOffset;
    687692
     
    698703      if (!code) continue;
    699704      if (code->equiv != thisCode) { continue; }
     705
     706      measure[k].dbFlags &= ~ID_MEAS_WARP_USED;
     707
     708      if (!MatchImageSkycellID (meas, cat, stkTessID, stkProjID, stkSkycellID)) continue;
    700709
    701710      if (measure[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad);
     
    724733      // are small (and not measured)
    725734      float Fpsf = PhotFluxCat (&measure[k], MAG_CLASS_PSF);
    726       if (isnan(Fsys)) SKIP_THIS_MEAS(Nsys);
     735      if (isnan(Fpsf)) SKIP_THIS_MEAS(Nsys);
    727736      // if (Msys <  0.0) SKIP_THIS_MEAS(Nsys);
    728737      // if (Msys > 30.0) SKIP_THIS_MEAS(Nsys);
    729738
    730739      float dFpsf = PhotFluxCatErr (&measure[k], MAG_CLASS_PSF);
     740      if (isnan(dFpsf)) SKIP_THIS_MEAS (Nsys);
     741
     742      int isBad = (measure[k].psfQF < 0.85);
     743      isBad |= isnan(measure[k].psfQF);
     744      if (isBad) SKIP_THIS_MEAS (Nsys);
     745
     746      int isPoor = (measure[k].psfQFperf < 0.85);
     747      if ((pass == 0) && isPoor) SKIP_THIS_MEAS (Nsys);
     748
    731749      dFpsf = MAX (dFpsf, MIN_ERROR*Fpsf); // MIN_ERROR is a fractional error
    732750      Fpsflist[Npsf] = Fpsf * Fcal;
     
    734752      wpsflist[Npsf] = 1.0;
    735753      Npsf ++;
     754
     755      measure[k].dbFlags |= ID_MEAS_WARP_USED;
    736756
    737757      float Fap = PhotFluxCat (&measure[k], MAG_CLASS_APER);
Note: See TracChangeset for help on using the changeset viewer.