IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33963 for trunk/psphot/src


Ignore:
Timestamp:
May 30, 2012, 1:46:12 PM (14 years ago)
Author:
eugene
Message:

merge changes from eam_branches/ipp-20120405

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psphot

  • trunk/psphot/src

  • trunk/psphot/src/psphot.h

    r33883 r33963  
    9999
    100100bool            psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final);
    101 bool            psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final);
     101bool            psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode);
    102102
    103103bool            psphotSourceSize (pmConfig *config, const pmFPAview *view, const char *filerule, bool getPSFsize);
  • trunk/psphot/src/psphotDefineFiles.c

    r25983 r33963  
    8585        output->save = true;
    8686    }
     87//    // optionally save the smoothed variance model (small FITS image)
     88//    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
     89//        int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
     90//        int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
     91//        pmFPAfile *output = pmFPAfileDefineFromFile (config, input, DX, DY, "PSPHOT.VARMDL");
     92//        if (!output) {
     93//            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.VARMDL");
     94//            return false;
     95//        }
     96//        output->save = true;
     97//    }
     98//    // optionally save the smoothed variance model's standard deviation (small FITS image)
     99//    if (psMetadataLookupBool(NULL, recipe, "SAVE.VARMDL.STDEV")) {
     100//        int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
     101//        int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
     102//        pmFPAfile *output = pmFPAfileDefineFromFile (config, input, DX, DY, "PSPHOT.VARMDL.STDEV");
     103//        if (!output) {
     104//            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.VARMDL.STDEV");
     105//            return false;
     106//        }
     107//        output->save = true;
     108//    }
    87109    // optionally save the PSF Model
    88110    if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
  • trunk/psphot/src/psphotEfficiency.c

    r32695 r33963  
    420420
    421421    // psphotFitSourcesLinearReadout subtracts the model fits
    422     if (!psphotFitSourcesLinearReadout(recipe, readout, fakeSourcesAll, psf, true)) {
     422    if (!psphotFitSourcesLinearReadout(recipe, readout, fakeSourcesAll, psf, true, PM_SOURCE_PHOTFIT_CONST)) {
    423423        psError(PS_ERR_UNKNOWN, false, "Unable to perform linear fit on fake sources.");
    424424        psFree(fakeSources);
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r32996 r33963  
    1212static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal);
    1313
     14bool psphotGenerateModelVariance (pmConfig *config, const pmFPAview *view, pmFPAfile *file, int index, psMetadata *recipe, pmReadout *readout, psArray *sources);
     15pmSourceFitVarMode psphotGetFitVarMode (psMetadata *recipe);
     16bool psphotFreeModelVariance (pmReadout *readout, psArray *sources);
     17
    1418// for now, let's store the detections on the readout->analysis for each readout
    1519bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, const char *filerule, bool final)
     
    2428    assert (recipe);
    2529
     30    pmSourceFitVarMode fitVarMode = psphotGetFitVarMode (recipe);
     31    if (!fitVarMode) {
     32        psError (PSPHOT_ERR_CONFIG, true, "failed to get LINEAR_FIT_VARIANCE_MODE");
     33        return false;
     34    }
     35    // MODEL_VAR requires 2 passes -- in the first, we get the rough fluxes; in the second, we
     36    // use the flux to define the model variance before fitting the objects.  Other modes only
     37    // do a single pass.
     38    pmSourceFitVarMode fitVarModePass1 = (fitVarMode == PM_SOURCE_PHOTFIT_MODEL_VAR) ? PM_SOURCE_PHOTFIT_CONST : fitVarMode;
     39
    2640    int num = psphotFileruleCount(config, filerule);
    2741
     
    5064        psAssert (psf, "missing psf?");
    5165
    52         if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final)) {
     66        if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1)) {
    5367            psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i);
    5468            return false;
    5569        }
     70
     71        // the MODEL_VAR weighting scheme requires knowledge of the model fluxes to generate the variance
     72        // after we have determined the initial set of fits, then we can generate the variance image and
     73        // re-run the fit against that variance.
     74        if (fitVarMode == PM_SOURCE_PHOTFIT_MODEL_VAR) {
     75            // generate the model variance image & source pointers
     76            if (!psphotGenerateModelVariance (config, view, file, i, recipe, readout, sources)) {
     77                psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i);
     78                return false;
     79            }
     80
     81            // replace all sources (use TMPF_SUBTRACTED as test)
     82            psphotReplaceAllSourcesReadout (config, view, filerule, i, recipe, false);
     83
     84            // rerun fit with correct fitVarMode
     85            if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarMode)) {
     86                psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i);
     87                return false;
     88            }
     89
     90            // free the model variance image & source pointers
     91            if (!psphotFreeModelVariance (readout, sources)) {
     92                psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i);
     93                return false;
     94            }
     95        }
    5696
    5797        psphotVisualShowResidualImage (readout, (num > 0));
     
    62102}
    63103
    64 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final) {
     104// look up the fit variance mode from the recipe; older recipes do not have the value
     105// 'LINEAR_FIT_VARIANCE_MODE'; in those cases, look for 'CONSTANT_PHOTOMETRIC_WEIGHTS' as a boolean and
     106// set the value to either CONST or IMAGE_VAR
     107pmSourceFitVarMode psphotGetFitVarMode (psMetadata *recipe) {
     108
     109    bool status = false;
     110
     111    char *fitVarModeString = psMetadataLookupStr(&status, recipe, "LINEAR_FIT_VARIANCE_MODE");
     112    if (!status) {
     113        bool CONSTANT_PHOTOMETRIC_WEIGHTS = psMetadataLookupBool(&status, recipe, "CONSTANT_PHOTOMETRIC_WEIGHTS");
     114        if (!status) {
     115            psAbort("You must provide a value for LINEAR_FIT_VARIANCE_MODE or CONSTANT_PHOTOMETRIC_WEIGHTS");
     116        }
     117        pmSourceFitVarMode fitVarMode = CONSTANT_PHOTOMETRIC_WEIGHTS ? PM_SOURCE_PHOTFIT_CONST : PM_SOURCE_PHOTFIT_IMAGE_VAR;
     118        return fitVarMode;
     119    }
     120    if (!strcasecmp(fitVarModeString, "CONSTANT") || !strcasecmp(fitVarModeString, "CONST")) {
     121        return PM_SOURCE_PHOTFIT_CONST;
     122    }
     123    if (!strcasecmp(fitVarModeString, "IMAGE") || !strcasecmp(fitVarModeString, "IMAGE_VAR")) {
     124        return PM_SOURCE_PHOTFIT_IMAGE_VAR;
     125    }
     126    if (!strcasecmp(fitVarModeString, "MODEL") || !strcasecmp(fitVarModeString, "MODEL_VAR")) {
     127        return PM_SOURCE_PHOTFIT_MODEL_VAR;
     128    }
     129    psError (PSPHOT_ERR_CONFIG, false, "Invalid value for LINEAR_FIT_VARIANCE_MODE (%s)", fitVarModeString);
     130    return PM_SOURCE_PHOTFIT_NONE;
     131}
     132
     133bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode) {
    65134
    66135    bool status;
     
    99168    if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined");
    100169
    101     bool CONSTANT_PHOTOMETRIC_WEIGHTS =
    102         psMetadataLookupBool(&status, recipe, "CONSTANT_PHOTOMETRIC_WEIGHTS");
    103     if (!status) {
    104         psAbort("You must provide a value for the BOOL recipe CONSTANT_PHOTOMETRIC_WEIGHTS");
    105     }
    106170    int SKY_FIT_ORDER = psMetadataLookupS32(&status, recipe, "SKY_FIT_ORDER");
    107171    if (!status) {
     
    231295    psSparseBorder *border = psSparseBorderAlloc (sparse, nBorder);
    232296
     297    // if fitVarMode is MODEL_VAR, then we need to generate the model image variance
     298    // XXX we have two possibilities here:
     299
     300    // 1) do 2 passes, where in the first case we use the CONST weighting, and in the second
     301    // use the fitted model values to define the model
     302
     303    // 2) do a single pass, and use the model guess to define the model variance (but do I trust the Model Guess?)
     304
    233305    // fill out the sparse matrix elements and border elements (B)
    234306    // SRCi is the current source of interest
     
    238310
    239311        // diagonal elements of the sparse matrix (auto-cross-product)
    240         f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     312        f = pmSourceModelDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
    241313        psSparseMatrixElement (sparse, i, i, f);
    242314
    243         // the formal error depends on the weighting scheme
    244         if (CONSTANT_PHOTOMETRIC_WEIGHTS) {
    245             float var = pmSourceModelDotModel (SRCi, SRCi, false, covarFactor, maskVal);
     315        // if we have used CONSTANT errors, then we need to calculate the value of the parameter error
     316        if (fitVarMode != PM_SOURCE_PHOTFIT_IMAGE_VAR) {
     317            float var = pmSourceModelDotModel (SRCi, SRCi, PM_SOURCE_PHOTFIT_IMAGE_VAR, covarFactor, maskVal);
    246318            errors->data.F32[i] = 1.0 / sqrt(var);
    247319        } else {
     
    251323
    252324        // find the image x model value
    253         f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     325        f = pmSourceDataDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal);
    254326        psSparseVectorElement (sparse, i, f);
    255327
     
    257329        switch (SKY_FIT_ORDER) {
    258330          case 1:
    259             f = pmSourceModelWeight (SRCi, 1, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     331            f = pmSourceModelWeight (SRCi, 1, fitVarMode, covarFactor, maskVal);
    260332            psSparseBorderElementB (border, i, 1, f);
    261             f = pmSourceModelWeight (SRCi, 2, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     333            f = pmSourceModelWeight (SRCi, 2, fitVarMode, covarFactor, maskVal);
    262334            psSparseBorderElementB (border, i, 2, f);
    263335
    264336          case 0:
    265             f = pmSourceModelWeight (SRCi, 0, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     337            f = pmSourceModelWeight (SRCi, 0, fitVarMode, covarFactor, maskVal);
    266338            psSparseBorderElementB (border, i, 0, f);
    267339            break;
     
    283355
    284356            // got an overlap; calculate cross-product and add to output array
    285             f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal);
     357            f = pmSourceModelDotModel (SRCi, SRCj, fitVarMode, covarFactor, maskVal);
    286358            psSparseMatrixElement (sparse, j, i, f);
    287359        }
     
    321393
    322394    // set the sky, sky_x, sky_y components of border matrix
    323     SetBorderMatrixElements (border, readout, fitSources, CONSTANT_PHOTOMETRIC_WEIGHTS, SKY_FIT_ORDER, markVal);
     395    SetBorderMatrixElements (border, readout, fitSources, (fitVarMode == PM_SOURCE_PHOTFIT_CONST), SKY_FIT_ORDER, markVal);
    324396
    325397    psSparseConstraint constraint;
     
    479551    return true;
    480552}
     553
     554bool psphotModelBackgroundReadout(psImage *model,  // Model image
     555                                  psImage *modelStdev, // Model stdev image
     556                                  psMetadata *analysis, // Analysis metadata for outputs
     557                                  pmReadout *readout, // Readout for which to generate a background model
     558                                  psImageBinning *binning, // Binning parameters
     559                                  const pmConfig *config,// Configuration
     560                                  bool useVarianceImage
     561    );
     562
     563bool psphotGenerateModelVariance (pmConfig *config, const pmFPAview *view, pmFPAfile *file, int index, psMetadata *recipe, pmReadout *readout, psArray *sources) {
     564
     565    bool status = false;
     566    psRegion fullRegion = psRegionSet (0, 0, 0, 0);
     567
     568    // bit-masks to test for good/bad pixels
     569    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     570    assert (maskVal);
     571
     572    // bit-mask to mark pixels not used in analysis
     573    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
     574    assert (markVal);
     575
     576    // maskVal is used to test for rejected pixels, and must include markVal
     577    maskVal |= markVal;
     578
     579    // create a model variance image
     580    psImage *modelVar = psImageCopy (NULL, readout->variance, PS_TYPE_F32);
     581
     582    // find the binning information
     583    psImageBinning *backBinning = psphotBackgroundBinning (modelVar, config);
     584    assert (backBinning);
     585   
     586    psImage *varModel = psImageAlloc(backBinning->nXruff, backBinning->nYruff, PS_TYPE_F32); // Background model
     587    psImage *varModelStdev = psImageAlloc(backBinning->nXruff, backBinning->nYruff, PS_TYPE_F32); // Background model
     588
     589    if (!psphotModelBackgroundReadout(varModel, varModelStdev, NULL, readout, backBinning, config, true)) {
     590        psError(PS_ERR_UNKNOWN, false, "Unable to generate background model");
     591        psFree (varModel);
     592        psFree (varModelStdev);
     593        return false;
     594    }
     595
     596    // linear interpolation to full-scale
     597    if (!psImageUnbin (modelVar, varModel, backBinning)) {
     598        psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for unbinning");
     599        psFree (varModel);
     600        psFree (varModelStdev);
     601        return false;
     602    }
     603
     604    psFree (varModel);
     605    psFree (varModelStdev);
     606
     607    // XXX for a test:
     608    psphotSaveImage (NULL, modelVar, "model.bck.fits");
     609
     610    // insert all of the source models
     611    for (int i = 0; i < sources->n; i++) {
     612
     613        // source of interest
     614        pmSource *source = sources->data[i];
     615
     616        // skip sources which were not fitted already
     617        if (!(source->mode & PM_SOURCE_MODE_LINEAR_FIT)) continue;
     618
     619        // pixel region appropriate for the source
     620        psRegion region = psRegionForImage (source->pixels, fullRegion);
     621
     622        // define the source->modelVar pixels (view on modelVar image)
     623        psAssert (!source->modelVar, "programming error : modelVar should be NULL here");
     624        psAssert (source->modelFlux, "programming error : modelFlux should not be NULL here");
     625        psAssert (source->modelFlux->data.F32, "programming error : modelFlux should not be NULL here");
     626        source->modelVar = psImageSubset(modelVar, region);
     627
     628        // add the source model to the model variance image
     629        pmSourceAdd (source, PM_MODEL_OP_MODELVAR, maskVal);
     630    }
     631
     632    // XXX for a test:
     633    psphotSaveImage (NULL, modelVar, "model.var.fits");
     634    psphotSaveImage (NULL, readout->variance, "image.var.fits");
     635
     636    // we save the model variance for future reference
     637    psMetadataAddImage(readout->analysis, PS_LIST_TAIL, "PSPHOT.MODEL.VAR", PS_META_REPLACE, "model variance", modelVar);
     638    psFree (modelVar);
     639
     640    return true;
     641}
     642
     643bool psphotFreeModelVariance (pmReadout *readout, psArray *sources) {
     644
     645    bool status = false;
     646
     647    // find the binning information
     648    psImage *modelVar = psMetadataLookupPtr(&status, readout->analysis, "PSPHOT.MODEL.VAR");
     649    assert (modelVar);
     650
     651    psMetadataRemoveKey (readout->analysis, "PSPHOT.MODEL.VAR");
     652
     653    // clear modelVar pointers for all of the source models
     654    for (int i = 0; i < sources->n; i++) {
     655
     656        // source of interest
     657        pmSource *source = sources->data[i];
     658        psFree (source->modelVar);
     659    }
     660
     661    return true;
     662}
  • trunk/psphot/src/psphotModelBackground.c

    r32348 r33963  
    3737// corresponding to the model.  Other information about the background model is saved on the
    3838// readout->analysis
    39 static bool psphotModelBackgroundReadout(psImage *model,  // Model image
    40                                   psImage *modelStdev, // Model stdev image
    41                                   psMetadata *analysis, // Analysis metadata for outputs
    42                                   pmReadout *readout, // Readout for which to generate a background model
    43                                   psImageBinning *binning, // Binning parameters
    44                                   const pmConfig *config // Configuration
     39bool psphotModelBackgroundReadout(psImage *model,  // Model image
     40                                  psImage *modelStdev, // Model stdev image
     41                                  psMetadata *analysis, // Analysis metadata for outputs
     42                                  pmReadout *readout, // Readout for which to generate a background model
     43                                  psImageBinning *binning, // Binning parameters
     44                                  const pmConfig *config,// Configuration
     45                                  bool useVarianceImage
    4546    )
    4647{
     
    4950    bool status = true;
    5051
    51     psImage *image = readout->image, *mask = readout->mask; // Image and mask for readout
     52    psImage *image = useVarianceImage ? readout->variance : readout->image;
     53    psImage *mask = readout->mask; // Image and mask for readout
    5254
    5355    // select the appropriate recipe information
     
    143145
    144146    // we save the binning structure for use in psphotMagnitudes
    145     psMetadataAddPtr(analysis, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning);
     147    if (!useVarianceImage) {
     148        psMetadataAddPtr(analysis, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning);
     149    }
    146150
    147151    psVector *dQ = psVectorAllocEmpty (100, PS_TYPE_F32);
     
    159163
    160164    // measure clipped median for subimages
    161     psRegion ruffRegion = {0,0,0,0};
    162     psRegion fineRegion = {0,0,0,0};
     165    psRegion ruffRegion = psRegionSet (0,0,0,0);
     166    psRegion fineRegion = psRegionSet (0,0,0,0);
    163167    for (int iy = 0; iy < model->numRows; iy++) {
    164168        for (int ix = 0; ix < model->numCols; ix++) {
     
    330334    psVectorStats (statsDQ, dQ, NULL, NULL, 0);
    331335
    332     psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_MEAN",  PS_META_REPLACE, "sky mean", Value);
    333     psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_STDEV", PS_META_REPLACE, "sky stdev", ValueStdev);
    334     psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_DQ",    PS_META_REPLACE, "sky quartile slope", statsDQ->sampleMedian);
    335     psLogMsg ("psphot", PS_LOG_INFO, "image sky : mean %f, stdev %f, dQ %f", Value, ValueStdev, statsDQ->sampleMedian);
    336 
    337     // measure image and background stats and save for later output
    338     psStats *statsBck = psStatsAlloc (PS_STAT_SAMPLE_MEAN |
    339                                       PS_STAT_SAMPLE_STDEV |
    340                                       PS_STAT_MIN |
    341                                       PS_STAT_MAX);
    342     psImageStats (statsBck, model, NULL, 0);
    343     psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MN",  PS_META_REPLACE, "sky model mean",          statsBck->sampleMean);
    344     psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_SIG", PS_META_REPLACE, "sky model stdev",         statsBck->sampleStdev);
    345     psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_DEV", PS_META_REPLACE, "sky stdev",               ValueStdev);
    346     psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_DQ",  PS_META_REPLACE, "sky quartile slope",      statsDQ->sampleMedian);
    347     psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MAX", PS_META_REPLACE, "sky model maximum value", statsBck->max);
    348     psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MIN", PS_META_REPLACE, "sky model minimum value", statsBck->min);
    349     psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "MSKY_NX", PS_META_REPLACE, "sky model size (x)",      model->numCols);
    350     psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "MSKY_NY", PS_META_REPLACE, "sky model size (y)",      model->numRows);
    351     psLogMsg ("psphot", PS_LOG_INFO, "background sky : min %f mean %f max %f stdev %f",
    352               statsBck->min, statsBck->sampleMean, statsBck->max, statsBck->sampleStdev);
     336    if (!useVarianceImage) {
     337        psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_MEAN",  PS_META_REPLACE, "sky mean", Value);
     338        psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_STDEV", PS_META_REPLACE, "sky stdev", ValueStdev);
     339        psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SKY_DQ",    PS_META_REPLACE, "sky quartile slope", statsDQ->sampleMedian);
     340        psLogMsg ("psphot", PS_LOG_INFO, "image sky : mean %f, stdev %f, dQ %f", Value, ValueStdev, statsDQ->sampleMedian);
     341
     342        // measure image and background stats and save for later output
     343        psStats *statsBck = psStatsAlloc (PS_STAT_SAMPLE_MEAN |
     344                                          PS_STAT_SAMPLE_STDEV |
     345                                          PS_STAT_MIN |
     346                                          PS_STAT_MAX);
     347        psImageStats (statsBck, model, NULL, 0);
     348        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MN",  PS_META_REPLACE, "sky model mean",          statsBck->sampleMean);
     349        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_SIG", PS_META_REPLACE, "sky model stdev",         statsBck->sampleStdev);
     350        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_DEV", PS_META_REPLACE, "sky stdev",               ValueStdev);
     351        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_DQ",  PS_META_REPLACE, "sky quartile slope",      statsDQ->sampleMedian);
     352        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MAX", PS_META_REPLACE, "sky model maximum value", statsBck->max);
     353        psMetadataAddF32 (readout->analysis, PS_LIST_TAIL, "MSKY_MIN", PS_META_REPLACE, "sky model minimum value", statsBck->min);
     354        psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "MSKY_NX", PS_META_REPLACE, "sky model size (x)",      model->numCols);
     355        psMetadataAddS32 (readout->analysis, PS_LIST_TAIL, "MSKY_NY", PS_META_REPLACE, "sky model size (y)",      model->numRows);
     356        psLogMsg ("psphot", PS_LOG_INFO, "background sky : min %f mean %f max %f stdev %f",
     357                  statsBck->min, statsBck->sampleMean, statsBck->max, statsBck->sampleStdev);
     358        psFree(statsBck);
     359    } else {
     360        psLogMsg ("psphot", PS_LOG_INFO, "variance data : mean %f, stdev %f, dQ %f", Value, ValueStdev, statsDQ->sampleMedian);
     361    }
    353362
    354363    psFree(statsDQ);
     
    356365
    357366    psFree(stats);
    358     psFree(statsBck);
    359367    psFree(statsDefaults);
    360368    psFree(binning);
     
    375383    psImage *modelStdev = psImageAlloc(binning->nXruff, binning->nYruff, PS_TYPE_F32); // Standard deviation
    376384
    377     if (!psphotModelBackgroundReadout(model, modelStdev, readout->analysis, readout, binning, config)) {
     385    if (!psphotModelBackgroundReadout(model, modelStdev, readout->analysis, readout, binning, config, false)) {
    378386        psFree(model);
    379387        psFree(modelStdev);
     
    400408    pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning, index);
    401409
    402     if (!psphotModelBackgroundReadout(model->image, modelStdev->image, model->analysis, readout, binning, config)) {
     410    if (!psphotModelBackgroundReadout(model->image, modelStdev->image, model->analysis, readout, binning, config, false)) {
    403411        psError(PS_ERR_UNKNOWN, false, "Unable to generate background model");
    404412        return false;
  • trunk/psphot/src/psphotStackImageLoop.c

  • trunk/psphot/src/psphotTest.c

    r33089 r33963  
    103103# if (0)
    104104
    105     psRegion region = {0,0,0,0};        // a region representing the entire array
     105psRegion region = psRegionSet (0,0,0,0);        // a region representing the entire array
    106106    psphotTestArguments (&argc, argv);
    107107
  • trunk/psphot/src/psphotTestSourceOutput.c

    r21183 r33963  
    136136
    137137            // generate working image for this source
    138             psRegion region = {ix - dx, ix + dx, iy - dy, iy + dy};
     138            psRegion region = psRegionSet(ix - dx, ix + dx, iy - dy, iy + dy);
    139139
    140140            psImage *vM = psImageSubset (imMo, region);
Note: See TracChangeset for help on using the changeset viewer.