IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 8, 2012, 6:32:36 AM (14 years ago)
Author:
eugene
Message:

ifdef-ed out all modelVar related code from recent updates. turn on or off with pmModel.h HAVE_MODEL_VAR

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r33963 r33993  
    1212static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal);
    1313
     14# if (HAVE_MODEL_VAR)
    1415bool psphotGenerateModelVariance (pmConfig *config, const pmFPAview *view, pmFPAfile *file, int index, psMetadata *recipe, pmReadout *readout, psArray *sources);
    1516pmSourceFitVarMode psphotGetFitVarMode (psMetadata *recipe);
    1617bool psphotFreeModelVariance (pmReadout *readout, psArray *sources);
     18# endif
    1719
    1820// for now, let's store the detections on the readout->analysis for each readout
     
    2830    assert (recipe);
    2931
     32# if (HAVE_MODEL_VAR)
    3033    pmSourceFitVarMode fitVarMode = psphotGetFitVarMode (recipe);
    3134    if (!fitVarMode) {
     
    3740    // do a single pass.
    3841    pmSourceFitVarMode fitVarModePass1 = (fitVarMode == PM_SOURCE_PHOTFIT_MODEL_VAR) ? PM_SOURCE_PHOTFIT_CONST : fitVarMode;
     42# endif
    3943
    4044    int num = psphotFileruleCount(config, filerule);
     
    6468        psAssert (psf, "missing psf?");
    6569
     70# if (HAVE_MODEL_VAR)
    6671        if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1)) {
     72# else
     73        if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final)) {
     74# endif
    6775            psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i);
    6876            return false;
    6977        }
    7078
     79# if (HAVE_MODEL_VAR)
    7180        // the MODEL_VAR weighting scheme requires knowledge of the model fluxes to generate the variance
    7281        // after we have determined the initial set of fits, then we can generate the variance image and
     
    94103            }
    95104        }
     105# endif
    96106
    97107        psphotVisualShowResidualImage (readout, (num > 0));
     
    102112}
    103113
     114# if (HAVE_MODEL_VAR)
    104115// look up the fit variance mode from the recipe; older recipes do not have the value
    105116// 'LINEAR_FIT_VARIANCE_MODE'; in those cases, look for 'CONSTANT_PHOTOMETRIC_WEIGHTS' as a boolean and
     
    130141    return PM_SOURCE_PHOTFIT_NONE;
    131142}
    132 
     143# endif
     144
     145# if (HAVE_MODEL_VAR)
    133146bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode) {
     147# else
     148bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final) {
     149# endif
    134150
    135151    bool status;
     
    168184    if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined");
    169185
     186# if (!HAVE_MODEL_VAR)
     187    bool CONSTANT_PHOTOMETRIC_WEIGHTS =
     188        psMetadataLookupBool(&status, recipe, "CONSTANT_PHOTOMETRIC_WEIGHTS");
     189    if (!status) {
     190        psAbort("You must provide a value for the BOOL recipe CONSTANT_PHOTOMETRIC_WEIGHTS");
     191    }
     192# endif
    170193    int SKY_FIT_ORDER = psMetadataLookupS32(&status, recipe, "SKY_FIT_ORDER");
    171194    if (!status) {
     
    295318    psSparseBorder *border = psSparseBorderAlloc (sparse, nBorder);
    296319
     320# if (HAVE_MODEL_VAR)
    297321    // if fitVarMode is MODEL_VAR, then we need to generate the model image variance
    298322    // XXX we have two possibilities here:
     
    302326
    303327    // 2) do a single pass, and use the model guess to define the model variance (but do I trust the Model Guess?)
     328# endif
    304329
    305330    // fill out the sparse matrix elements and border elements (B)
     
    310335
    311336        // diagonal elements of the sparse matrix (auto-cross-product)
     337# if (HAVE_MODEL_VAR)
    312338        f = pmSourceModelDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
     339# else
     340        f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     341# endif
    313342        psSparseMatrixElement (sparse, i, i, f);
    314343
     344# if (HAVE_MODEL_VAR)
    315345        // if we have used CONSTANT errors, then we need to calculate the value of the parameter error
    316346        if (fitVarMode != PM_SOURCE_PHOTFIT_IMAGE_VAR) {
     
    320350            errors->data.F32[i] = 1.0 / sqrt(f);
    321351        }
    322 
     352# else
     353        // the formal error depends on the weighting scheme
     354        if (CONSTANT_PHOTOMETRIC_WEIGHTS) {
     355            float var = pmSourceModelDotModel (SRCi, SRCi, false, covarFactor, maskVal);
     356            errors->data.F32[i] = 1.0 / sqrt(var);
     357        } else {
     358            errors->data.F32[i] = 1.0 / sqrt(f);
     359        }
     360# endif
    323361
    324362        // find the image x model value
     363# if (HAVE_MODEL_VAR)
    325364        f = pmSourceDataDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
     365# else
     366        f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     367# endif
    326368        psSparseVectorElement (sparse, i, f);
    327369
     
    329371        switch (SKY_FIT_ORDER) {
    330372          case 1:
     373# if (HAVE_MODEL_VAR)
    331374            f = pmSourceModelWeight (SRCi, 1, fitVarMode, covarFactor, maskVal);
    332375            psSparseBorderElementB (border, i, 1, f);
    333376            f = pmSourceModelWeight (SRCi, 2, fitVarMode, covarFactor, maskVal);
    334377            psSparseBorderElementB (border, i, 2, f);
     378# else
     379            f = pmSourceModelWeight (SRCi, 1, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     380            psSparseBorderElementB (border, i, 1, f);
     381            f = pmSourceModelWeight (SRCi, 2, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     382            psSparseBorderElementB (border, i, 2, f);
     383# endif
    335384
    336385          case 0:
     386# if (HAVE_MODEL_VAR)
    337387            f = pmSourceModelWeight (SRCi, 0, fitVarMode, covarFactor, maskVal);
     388# else
     389            f = pmSourceModelWeight (SRCi, 0, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     390# endif
    338391            psSparseBorderElementB (border, i, 0, f);
    339392            break;
     
    355408
    356409            // got an overlap; calculate cross-product and add to output array
     410# if (HAVE_MODEL_VAR)
    357411            f = pmSourceModelDotModel (SRCi, SRCj, fitVarMode, covarFactor, maskVal);
     412# else
     413            f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     414# endif
    358415            psSparseMatrixElement (sparse, j, i, f);
    359416        }
     
    393450
    394451    // set the sky, sky_x, sky_y components of border matrix
     452# if (HAVE_MODEL_VAR)
    395453    SetBorderMatrixElements (border, readout, fitSources, (fitVarMode == PM_SOURCE_PHOTFIT_CONST), SKY_FIT_ORDER, markVal);
     454# else
     455    SetBorderMatrixElements (border, readout, fitSources, CONSTANT_PHOTOMETRIC_WEIGHTS, SKY_FIT_ORDER, markVal);
     456# endif
    396457
    397458    psSparseConstraint constraint;
     
    552613}
    553614
     615# if (HAVE_MODEL_VAR)
    554616bool psphotModelBackgroundReadout(psImage *model,  // Model image
    555617                                  psImage *modelStdev, // Model stdev image
     
    661723    return true;
    662724}
     725# endif
Note: See TracChangeset for help on using the changeset viewer.