IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2007, 4:40:44 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested with psModules (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels. For
this reason, I have left the "gutter" pixels (cell gaps) set to 0
instead of NAN in pmFPAMosaic.

File:
1 edited

Legend:

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

    r13035 r13900  
    22
    33// XXX I don't like this name
    4 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf) {
     4bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal) {
    55
    66    int Nfit = 0;
     
    1414    // source analysis is done in S/N order (brightest first)
    1515    sources = psArraySort (sources, pmSourceSortBySN);
    16    
     16
    1717    // S/N limit to perform full non-linear fits
    1818    float FIT_SN_LIM = psMetadataLookupF32 (&status, recipe, "FULL_FIT_SN_LIM");
     
    3030
    3131    for (int i = 0; i < sources->n; i++) {
    32         // if (i%100 == 0) psphotFitSummary ();
     32        // if (i%100 == 0) psphotFitSummary ();
    3333
    34         pmSource *source = sources->data[i];
     34        pmSource *source = sources->data[i];
    3535
    36         // skip non-astronomical objects (very likely defects)
    37         if (source->mode &  PM_SOURCE_MODE_BLEND) continue;
    38         if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
    39         if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
     36        // skip non-astronomical objects (very likely defects)
     37        if (source->mode &  PM_SOURCE_MODE_BLEND) continue;
     38        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     39        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    4040
    41         // skip DBL second sources (ie, added by psphotFitBlob)
    42         if (source->mode &  PM_SOURCE_MODE_PAIR) continue;
     41        // skip DBL second sources (ie, added by psphotFitBlob)
     42        if (source->mode &  PM_SOURCE_MODE_PAIR) continue;
    4343
    44         // limit selection to some SN limit
    45         // XXX this should use peak?
    46         if (source->moments == NULL) continue;
    47         if (source->moments->SN < FIT_SN_LIM) continue;
     44        // limit selection to some SN limit
     45        // XXX this should use peak?
     46        if (source->moments == NULL) continue;
     47        if (source->moments->SN < FIT_SN_LIM) continue;
    4848
    49         // XXX this should use peak?
    50         if (source->moments->x < AnalysisRegion.x0) continue;
    51         if (source->moments->y < AnalysisRegion.y0) continue;
    52         if (source->moments->x > AnalysisRegion.x1) continue;
    53         if (source->moments->y > AnalysisRegion.y1) continue;
     49        // XXX this should use peak?
     50        if (source->moments->x < AnalysisRegion.x0) continue;
     51        if (source->moments->y < AnalysisRegion.y0) continue;
     52        if (source->moments->x > AnalysisRegion.x1) continue;
     53        if (source->moments->y > AnalysisRegion.y1) continue;
    5454
    55         // if model is NULL, we don't have a starting guess
    56         if (source->modelPSF == NULL) continue;
     55        // if model is NULL, we don't have a starting guess
     56        if (source->modelPSF == NULL) continue;
    5757
    58         // skip sources which are insignificant flux?
    59         if (source->modelPSF->params->data.F32[1] < 0.1) {
    60             psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n",
    61                      source->modelPSF->params->data.F32[1],
    62                      source->modelPSF->params->data.F32[2],
    63                      source->modelPSF->params->data.F32[3]);
    64             continue;
    65         }
     58        // skip sources which are insignificant flux?
     59        if (source->modelPSF->params->data.F32[1] < 0.1) {
     60            psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n",
     61                     source->modelPSF->params->data.F32[1],
     62                     source->modelPSF->params->data.F32[2],
     63                     source->modelPSF->params->data.F32[3]);
     64            continue;
     65        }
    6666
    67         // replace object in image
    68         if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
    69             pmSourceAdd (source, PM_MODEL_OP_FULL);
    70         }
    71         Nfit ++;
     67        // replace object in image
     68        if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
     69            pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
     70        }
     71        Nfit ++;
    7272
    73         // try fitting PSFs, then try extended sources
    74         // these functions subtract the resulting fitted source (XXX and update the modelFlux?)
    75         if (psphotFitBlend (readout, source, psf)) {
    76             psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->moments->x, source->moments->y);
    77             Npsf ++;
    78             continue;
    79         }
    80         if (psphotFitBlob (readout, source, sources, psf)) {
    81             psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->moments->x, source->moments->y);
    82             Next ++;
    83             continue;
    84         }
     73        // try fitting PSFs, then try extended sources
     74        // these functions subtract the resulting fitted source (XXX and update the modelFlux?)
     75        if (psphotFitBlend (readout, source, psf, maskVal)) {
     76            psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->moments->x, source->moments->y);
     77            Npsf ++;
     78            continue;
     79        }
     80        if (psphotFitBlob (readout, source, sources, psf, maskVal)) {
     81            psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->moments->x, source->moments->y);
     82            Next ++;
     83            continue;
     84        }
    8585
    86         psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->moments->x, source->moments->y);
    87         Nfail ++;
     86        psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->moments->x, source->moments->y);
     87        Nfail ++;
    8888
    89         // re-subtract the object, leave local sky
    90         pmSourceCacheModel (source);
    91         pmSourceSub (source, PM_MODEL_OP_FULL);
    92         source->mode |= PM_SOURCE_MODE_SUBTRACTED;
    93         source->mode |= PM_SOURCE_MODE_TEMPSUB;
     89        // re-subtract the object, leave local sky
     90        pmSourceCacheModel (source, maskVal);
     91        pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
     92        source->mode |= PM_SOURCE_MODE_SUBTRACTED;
     93        source->mode |= PM_SOURCE_MODE_TEMPSUB;
    9494    }
    9595
Note: See TracChangeset for help on using the changeset viewer.