IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changes between Version 6 and Version 7 of fullforce_intro


Ignore:
Timestamp:
Dec 26, 2013, 1:26:47 PM (13 years ago)
Author:
bills
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • fullforce_intro

    v6 v7  
    167167
    168168}}}
     169
     170
     171== Processing ==
     172
     173{{{
     174psphotStack output cmf is run through psastro to calibrate zero point
     175and to produce the 'cff' file - the list of objects which will be
     176measured by psphotFullForce
     177
     178The cff is produced by pmSourcesWrite_CFF which is called if
     179a output file "PSPHOT.OUTPUT.CFF" is defined.
     180
     181This file contains a single fits binary table with 1 row for each source.
     182The values in the row depend on whether or not the source is selected
     183for galaxy fitting. The boolean fitGalayx is set to be true if
     184
     1851. The extended model fits were performed on the source and one of
     186   the models was set to be the source's modelEXT
     187and
     1882. The model params SXX, SYY, SXY, and model magnitude are finite
     189
     190Here are the values for each row in the cff file
     191
     192ID              source->seq (IPP_IDET)  (XXX: need to make sure that these are set to the
     193                            same values as the psf extension. Insure that we
     194                            write cmf first.)
     195X               fitGalaxy ? modelEXT->params[PM_PAR_XPOS] : modelPSF->params[PM_PAR_XPOS]
     196Y               fitGalaxy ? modelEXT->params[PM_PAR_YPOS] : modelPSF->params[PM_PAR_YPOS]
     197FLUX            (fitGalaxy ? 10**-0.4*modelEXT->mag : source->psfFlux) / CELL.EXPOSURE
     198AP_RADIUS       source->apRadius
     199KRON_RADIUS     source->moments->Mrf*2.5
     200PETRO_RADIUS    source->extpars ? source->extpars->petrosianRadius : NAN
     201FIT_GALAXY      see above
     202PSF_STAR        source->mode & PM_SOURCE_MODE_PSFSTAR ? true : false
     203R_MAJOR         fitGalaxy ? axes.major : 0
     204R_MINOR         fitGalaxy ? axes.major : 0
     205THETA           fitGalaxy ? axes.theta : 0
     206MODEL_TYPE      fitGalaxy ? modelEXT->type : 0
     207INDEX           fitGalaxy && modelEXT->type == sersic : 0
     208
     209Notes:
     210The flux is converted to counts per second.
     211
     212It would be feasible to fit multiple models for each source but this would require that psphotFullForce and
     213the function that reads cff files to be enhanced to deal with multiple models.
     214
     215
     216Full Force Pipeline
     217-------------------
     218The full force pipeline consists of two stages. First psphotFullForce is run on all warp skycells for each
     219stack. Then the program psphotFullForceSummary combines the results to get a single set of parameters for
     220each source.
     221
     222psphotFullForce
     223---------------
     224INPUTS
     225------
     226The cff file defines the set of sources to be processed.
     227The data is read by a function in psModules and a source is created for each row.
     228A psf model of the type given by the PSFMODEL keyword is created for each source. X and Y are used to set the
     229parameters. A peak is allocated at the position with detValue, rawFlux, and smoothFlux set to the value of
     230the FLUX column. The flux value (in counts per second) is later multipled by the warp exposure time by the
     231function psphotLoadExtSources.
     232
     233moments are allocated with Mx = X, My = Y, Mrf = 0.4 *KRON_RADIUS
     234tmpFlag PM_SOURCE_TMPF_MOMENTS_MEASURED is set. Note that this leaves the higher orde moments NAN
     235
     236if FIT_GALAXY is set and the model type is a recognized galaxy model type and extended source model is created.
     237The model parameters are set based on X, Y, R_MAJOR, R_MINOR, and THETA. If the model type has an 8th parameter
     238it is set to 0.5/SERISC_INDEX (BUG: this will result in INF if sersic index is zero)
     239
     240The warp image, mask, and variance images are read. If passed as an argument the warp stage psf file is read
     241as well. Currently the script does not pass the psf file because Gene told me not to. I don't recall the
     242reason.
     243
     244Processing
     245----------
     246Here are the important steps in full force processing.
     247
     248    psphotSetMaskAndVariance (config, view, filerule);
     249
     250    // generate a background model (median, smoothed image)
     251    if (!psphotModelBackground (config, view, filerule)) {
     252        return psphotReadoutCleanup (config, view, filerule);
     253    }
     254    if (!psphotSubtractBackground (config, view, filerule)) {
     255        return psphotReadoutCleanup (config, view, filerule);
     256    }
     257    if (!strcasecmp (breakPt, "BACKMDL")) {
     258        return psphotReadoutCleanup (config, view, filerule);
     259    }
     260
     261    if (!psphotLoadPSF (config, view, filerule)) {
     262        // this only happens if we had a programming error in psphotLoadPSF
     263        psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model");
     264        return psphotReadoutCleanup (config, view, filerule);
     265    }
     266
     267NOTE: This is where the flux is multiplied by the exposure time to convert from counts per second to counts
     268    // include externally-supplied sources (loaded onto detections->newSources)
     269    psphotLoadExtSources (config, view, filerule);
     270
     271    // merge the newly selected sources into the existing list (detections->allSources)
     272    // NOTE: merge OLD and NEW
     273NOTE: (we only have NEW)
     274    psphotMergeSources (config, view, filerule);
     275
     276    // construct sources and measure moments and other basic stats (saved on detections->allSources)
     277    // all sources use the auto-scaled window appropriate to a PSF, except for the saturated
     278    // stars : these use a larger window (3x the basic window)
     279
     280From comment in psphotFullForceSourceStats
     281// construct pixels and measure moments for sources.
     282// NOTE: this function differs from psphotSourceStats in the following ways:
     283// 1) detections->allSources are used instead of newSources
     284// 2) the sources are used directly (peaks are not assigned to sources here)
     285
     286// NOTE: this function is meant to be used by psphotFullForce, and the mode of the loaded
     287// sources should have (MODE_EXTERNAL) set.  If so, the Mx,My values will not be recalculated
     288
     289
     290    if (!psphotFullForceSourceStats (config, view, filerule, true)) { // pass 1
     291        psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
     292        return psphotReadoutCleanup (config, view, filerule);
     293    }
     294
     295    // generate a psf model for any readouts which need one
     296    // psphotFullForcePSF (config, view, filerule);
     297    // XXX I'm not sure we need a different algorithm here or not : we are supplying the
     298    // sources; we should mark with a flag bit the ones we actually want to use as PSF
     299    // stars (this means we need to supply this info in the load).
     300    psphotChoosePSF (config, view, filerule, false);
     301
     302    // Construct an initial model for each object, set the radius to fitRadius, set circular
     303    // fit mask.  NOTE: only applied to sources without guess models
     304    // XXX this currently only generates a PSF model
     305    psphotGuessModels (config, view, filerule);
     306
     307    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
     308    // XXX this will fit non-PSF sources if they are supplied
     309    psphotFitSourcesLinear (config, view, filerule, false, false);
     310
     311    // measure kron fluxes
     312    psphotKronFlux (config, view, filerule);
     313
     314    // measure petro fluxes
     315    psphotPetroFlux (config, view, filerule);
     316
     317    // measure radial apertures
     318    psphotRadialApertures (config, view, filerule, 0);
     319
     320    // measure galaxy shapes
     321    psphotGalaxyShape (config, view, filerule);
     322
     323    // calculate source magnitudes (psf mag and ap mag)
     324    psphotMagnitudes(config, view, filerule);
     325
     326    // replace background in residual image
     327    psphotSkyReplace (config, view, filerule);
     328
     329Galaxy Fitting
     330--------------
     331Most of the functions performed by psphotFullForce are the same as standard psphot.
     332
     333psphotGalaxyShape is the function that creates extended models for the objects selected for
     334galaxy fitting over a range of galaxy parameters and measures the chisq for each trial.
     335
     336The results of this are saved in a new cmf extension table refered to as 'XGAL'.
     337
     338Currently the only parameters varied are the major an minor radii. The range of values is
     339determined by recipe. Currently 49 combinations are tried with the range in axes of
     3400.85 to 1.15 times the input values in steps of 0.05 * the input values.
     341
     342In processing the source's modelEXT is left equal to the model for the nominal (input values).
     343We do this so that the nominal values are available in psphotFullForceSummary but this yields
     344a less useful residual image.
     345
     346XXX: Perhaps psphotFullForceSummary should just read the CFF file (not as sources
     347but as a table) and get the nominal values from there.
     348
     349
     350OUTPUTS
     351The output of the psphotFullForce consists of a standard cmf file and optionally a residual image.
     352
     353psphotFullForceSummary
     354----------------------
     355Once psphotFullForce has been run on all of the warps for a given skycell filter combination
     356the program psphotFullForceSummary is run to combine the results.
     357
     358Inputs
     359------
     360The cmfs from the full force runs on the individual warps.
     361
     362Computations
     363------------
     364
     365psf measurements
     366
     367petrosian radius and magnitude
     368    TBD mean radius?
     369
     370galaxy fits
     371
     372For each R_MAJOR, R_MINOR combination (i) the chisq of the combintation is measured by summing
     373over the measurements on the indvidual warps (k). Note that sources which are masked in an input
     374are not included in these sums. This is determined by requiring that PSF_QF_PERFECT > 0.9
     375
     376    chisq[i] = sum(chisq[k] * nPix[k]) / sum(nPix[k])
     377    flux[i]  = sum( (flux[k] / dFlux[k])**2) / sum ( 1 / dFlux[k]**2)
     378    dFlux[i] = sum ( 1 / dFlux[k]**2 )
     379
     380Once these values are computed the trial with the lowest chisq value is chosen as the "best fit"
     381and the extended source model paramters are set
     382
     383Outputs
     384-------
     385These values are written to a summary cmf in the standard format
     386
     387
     388}}}
     389