IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17316


Ignore:
Timestamp:
Apr 2, 2008, 8:05:38 PM (18 years ago)
Author:
eugene
Message:

make equivalent to fitEXT: does not set source model, returns fitted model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080324/psphot/src/psphotPSFConvModel.c

    r14655 r17316  
    44static psF32 PM_SOURCE_FIT_MODEL_NUM_ITERATIONS = 15;
    55static psF32 PM_SOURCE_FIT_MODEL_TOLERANCE = 0.1;
    6 // static psF32 PM_SOURCE_FIT_MODEL_WEIGHT = 1.0;
    7 // static bool  PM_SOURCE_FIT_MODEL_PIX_WEIGHTS = true;
    86
    97// input source has both modelPSF and modelEXT.  on successful exit, we set the
    108// modelConv to contain the fitted parameters, and the modelFlux to contain the
    119// convolved model image.
    12 bool psphotPSFConvModel (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     10pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize) {
    1311   
    1412    bool status;
    15 
    16     int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE");
    17     if (!status) {
    18         psfSize = 2;
    19     }
    2013
    2114    // make sure we save a cached copy of the psf flux
     
    2316
    2417    // convert the cached cached psf model for this source to a psKernel
    25     // XXX for the moment, hard-wire the kernel to be 5x5 (2 pix radius)
    26     // XXX for the moment, hard-wire the kernel to be 9x9 (4 pix radius)
    2718    psKernel *psf = psphotKernelFromPSF (source, psfSize);
    2819
     
    4132    }
    4233
    43 # if (0)
     34# define USE_DELTA_PSF 0
     35# if (USE_DELTA_PSF)
    4436    // XXX sanity check: convolve with delta function should behave like unconvolved version
    4537    for (int i = 0; i < psf->image->numRows; i++) {
     
    5446    // XXX we could modify the parameter values or even the model
    5547    // here based on the observed seeing (some lookup table...)
    56     pmModel *modelConv = pmModelCopy (source->modelEXT);
     48
     49    // XXX we previously required the unconvolved version to have been fit first
     50    // pmModel *modelConv = pmModelCopy (source->modelEXT);
     51
     52    // use the source moments, etc to guess basic model parameters
     53    pmModel *modelConv = pmSourceModelGuess (source, modelType);
     54    PS_ASSERT (modelConv, NULL);
     55
    5756    psVector *params  = modelConv->params;
    5857    psVector *dparams = modelConv->dparams;
     58
     59    psphotCheckRadiusEXT (readout, source, modelConv);
    5960
    6061    // create the minimization constraints
     
    9192    psTrace ("psphot", 4, "niter: %d, chisq: %f", myMin->iter, myMin->value);
    9293
    93     // renormalize output model image
     94    // renormalize output model image (generated by fitting process)
    9495    float Io = params->data.F32[PM_PAR_I0];
    9596    for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
     
    115116    onPic &= (params->data.F32[PM_PAR_YPOS] >= source->pixels->row0);
    116117    onPic &= (params->data.F32[PM_PAR_YPOS] <  source->pixels->row0 + source->pixels->numRows);
    117     if (!onPic) {
    118         modelConv->flags |= PM_MODEL_STATUS_OFFIMAGE;
    119     }
     118    if (!onPic) modelConv->flags |= PM_MODEL_STATUS_OFFIMAGE;
    120119
    121     source->mode |= PM_SOURCE_MODE_FITTED;
    122     source->modelConv = modelConv;
     120    source->mode |= PM_SOURCE_MODE_FITTED; // XXX is this needed?
    123121
    124122    psFree(myMin);
     
    126124    psFree(constraint);
    127125
    128     bool retval = (onPic && fitStatus);
    129     psTrace("psphot", 5, "---- %s(%d) end ----\n", __func__, retval);
    130     return(retval);
     126    return modelConv;
    131127}
Note: See TracChangeset for help on using the changeset viewer.