IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41607


Ignore:
Timestamp:
May 21, 2021, 4:49:23 PM (5 years ago)
Author:
eugene
Message:

add code to set Mflat based on Mgrid before final Mrel calculation

Location:
branches/eam_branches/relphot.20210521
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/relphot.20210521/include/relphot.h

    r41606 r41607  
    500500RelphotStages STAGES;
    501501
    502 # ifdef GRID_V1
    503 int setGridMeasure (off_t meas, int cat, double X, double Y);
    504 # endif
    505 
    506 # ifdef GRID_V2
    507 int setGridMeasure (off_t meas, int cat, double X, double Y, int ccdnum);
    508 # endif
    509 
    510502/*** relphot prototypes ***/
    511503void          ConfigInit          PROTO((int *argc, char **argv));
     
    568560void          global_stats        PROTO((Catalog *catalog, int Ncatalog, int nloop));
    569561void          initGrid            PROTO(());
     562void          setMflatFromGrid    PROTO((Catalog *catalog));
    570563void          initGridBins        PROTO(());
    571564void          initImageBins       PROTO((Catalog *catalog, int Ncatalog, int doImageList));
  • branches/eam_branches/relphot.20210521/src/GridOps.c

    r41603 r41607  
    301301  return Mgrid;
    302302}
     303
     304// for historical reasons, Mflat and Mgrid have opposite signs
     305void setMflatFromGrid (Catalog *catalog) {
     306  if (!GRID_ZEROPT) return;
     307  for (off_t j = 0; j < catalog->Nmeasure; j++) {
     308    float Mgrid = getMgrid (&catalog->measure[j]);
     309    catalog->measure[j].Mflat -= Mgrid;
     310  }
     311}
     312
  • branches/eam_branches/relphot.20210521/src/StarOps.c

    r41606 r41607  
    291291
    292292// setMrel and setMrelOutput are extremely similar, but have slightly different implications:
    293 // * setMrel uses the internal Tiny structures only
    294 // * setMrelOutput skips stars for which there are too few good measurements
    295 // * setMrelOutput is meant to be called repeatedly, relaxing the criteria for 'good' on each pass
     293// * setMrel only uses the internal Tiny structures
     294// * setMrel skips stars for which there are too few good measurements (setMrelOutput assigns an average mag with only 1)
     295// * setMrelOutput sets psfQF, psfQFperf, extNsigma, rank info, etc
     296// * setMrelOutput sets average Map
    296297// * setMrelOutput updates 2MASS average flags
    297298// * setMrelOutput updates average EXT flags (PS1 and 2MASS)
     299// * setMrelOutput sets average stack & warp photometry (if requested)
    298300
    299301int setMrel (Catalog *catalog, int Ncatalog) {
  • branches/eam_branches/relphot.20210521/src/reload_catalogs.c

    r41606 r41607  
    100100
    101101    initMrel (&catalog, 1);
     102
     103    setMflatFromGrid (&catalog); // Mgrid is used to set Mflat; Mgrid is the ignored in setMrelFinal/setMrelCatalog.c
    102104    setMrelFinal (&catalog, FALSE);
    103105    TIMESTAMP(time5);
  • branches/eam_branches/relphot.20210521/src/relphot_images.c

    r41606 r41607  
    8989      SetZptIteration (i);
    9090
    91       setMrel  (catalog, Ncatalog); // threaded
     91      setMrel  (catalog, Ncatalog); // threaded (calls setMrel_catalog_alt in setMrelCatalog.c)
    9292
    9393      setMcal  (catalog);
     
    160160     clients */
    161161  if (!CALIBRATE_STACKS_AND_WARPS) {
    162     reload_catalogs (skylist, 0, NULL);
     162    reload_catalogs (skylist, 0, NULL); // calls setMrelFinal which setMrelOutput which calls setMrel_catalog_alt
    163163    MARKTIME("-- updated all catalogs: %f sec\n", dtime);
    164164  }
  • branches/eam_branches/relphot.20210521/src/setMrelCatalog.c

    r41606 r41607  
    233233      // data for which the associated image has not been loaded (probably because of
    234234      // overlaps).  Msys + measure.Mcal is our best guess of the true magnitude
    235       Mmos = Mgrid = 0;
    236235      Mcal = measureT[k].McalPSF; // check that this is zero for loaded REF value
    237236    } else {
     
    243242      Mgrp  = getMgrp  (meas, cat, measureT[k].airmass, &dMgrp);
    244243      if (isnan(Mgrp))  SKIP_THIS_MEAS(Ngrp);
    245       Mgrid = getMgridTiny (&measureT[k]);
     244      Mgrid = isSetMrelFinal ? 0.0 : getMgridTiny (&measureT[k]);
    246245      if (isnan(Mgrid)) SKIP_THIS_MEAS(Ngrid);
    247246      Mflat = isnan (measureT[k].Mflat) ? 0.0 : measureT[k].Mflat;
    248247    }
     248    // on the final calculation of Mrel the value of Mgrid has been applied to Mflat, but
     249    // it has not been removed from the GridOps.c structures.  In order to avoid double-counting,
     250    // we need to skip Mgrid on the final calculation.
    249251
    250252    int myUbercalDist = getUbercalDist(meas, cat);
     
    562564  SecFilt *secfilt = &catalog[0].secfilt[ave*Nsecfilt];
    563565
    564   float McalPSF = 0, McalAPER = 0, Mmos = 0, Mgrid = 0;
     566  float McalPSF = 0, McalAPER = 0;
    565567
    566568  // set the primary projection cell and skycell for this coordinate
     
    726728      McalPSF  = measure[meas].McalPSF; // check that this is zero for loaded REF value
    727729      McalAPER = McalPSF; // check that this is zero for loaded REF value
    728       Mmos     = 0.0;
    729       Mgrid    = 0.0;
    730730    } else {
    731731      McalPSF   = getMcal  (measSeq, cat, MAG_CLASS_PSF);
    732732      McalAPER  = USE_MCAL_PSF_FOR_STACK_APER ? getMcal  (measSeq, cat, MAG_CLASS_PSF) : getMcal  (measSeq, cat, MAG_CLASS_KRON);
    733       Mmos      = getMmos  (measSeq, cat);
    734       Mgrid     = getMgrid (&measure[meas]);
    735       // XXX can Mmos and Mgrid exist for stacks?
    736733    }
    737734   
     
    769766    // get the zero point for the selected image
    770767    // Use a different zero point for the PSF-like and APERTURE-like magnitudes
    771     float zpPSF  = PhotZeroPoint (&measure[meas], &average[0], &secfilt[0]) - (McalPSF  + Mmos + Mgrid);
    772     float zpAPER = PhotZeroPoint (&measure[meas], &average[0], &secfilt[0]) - (McalAPER + Mmos + Mgrid);
     768    float zpPSF  = PhotZeroPoint (&measure[meas], &average[0], &secfilt[0]) - McalPSF;
     769    float zpAPER = PhotZeroPoint (&measure[meas], &average[0], &secfilt[0]) - McalAPER;
    773770
    774771    // zpFactor to go from instrumental flux to Janskies
  • branches/eam_branches/relphot.20210521/src/setMrelFinal.c

    r41606 r41607  
    101101  }
    102102
    103   // XXX make this optional? (do not clean for -averages?)
    104   // XXX : for the moment, disable clean_measures
    105   if (!simpleAverage && FALSE) clean_measures (catalog, 1, TRUE);    /* mark outliers ID_MEAS_POOR_PHOTOM */
    106 
    107103  ALLOCATE (catalog[0].measureRank, char, catalog[0].Nmeasure);
    108104  setMeasureRank (catalog);
     
    271267}
    272268
     269// XXX review this, especially the good/bad images
     270// by this point, we have propagated the mosaic and tgroup flags to each image
    273271void setMeasureRank (Catalog *catalog) {
    274272
Note: See TracChangeset for help on using the changeset viewer.