IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30749


Ignore:
Timestamp:
Feb 24, 2011, 9:04:26 AM (15 years ago)
Author:
eugene
Message:

add macro to get internal vs I/O readout; add feature to mask objects in the background model and re-run model (disabled for now); add optional 3rd pass to psphotReadout for extended sources (disabled for now)

Location:
branches/eam_branches/ipp-20110213/psphot/src
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psphot/src/Makefile.am

    r30624 r30749  
    129129        psphotReadoutMinimal.c         \
    130130        psphotModelBackground.c        \
     131        psphotMaskBackground.c         \
    131132        psphotSubtractBackground.c     \
    132133        psphotFindDetections.c         \
  • branches/eam_branches/ipp-20110213/psphot/src/psphot.h

    r30707 r30749  
    1212
    1313#define PSPHOT_RECIPE_PSF_FAKE_ALLOW "PSF.FAKE.ALLOW" // Name for recipe component permitting fake PSFs
     14
     15# define READOUT_OR_INTERNAL(VIEW,FILE)((FILE)->mode == PM_FPA_MODE_INTERNAL) ? (FILE)->readout : pmFPAviewThisReadout((VIEW), (FILE)->fpa)
    1416
    1517// top-level psphot functions
     
    5254bool            psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filerule);
    5355bool            psphotModelBackgroundReadoutFileIndex (pmConfig *config, const pmFPAview *view, const char *filerule, int index);
     56
     57bool            psphotMaskBackground (pmConfig *config, const pmFPAview *view, const char *filerule);
     58bool            psphotMaskBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe);
    5459
    5560bool            psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filerule);
  • branches/eam_branches/ipp-20110213/psphot/src/psphotModelBackground.c

    r29936 r30749  
    5858    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    5959    assert (maskVal);
     60
     61    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     62    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
     63    assert (markVal);
     64
     65    // apply both MASK and MARK to make background model
     66    maskVal |= markVal;
    6067
    6168    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS);
     
    308315    }
    309316
     317    if (psTraceGetLevel("psphot") > 5) {
     318        char name[256];
     319        sprintf (name, "backfill.%02d.fits", npass);
     320        psphotSaveImage (NULL, model, name);
     321        sprintf (name, "backfist.%02d.fits", npass);
     322        psphotSaveImage (NULL, modelStdev, name);
     323    }
     324
    310325    psLogMsg ("psphot", PS_LOG_INFO, "built background image: %f sec\n", psTimerMark ("psphot.background"));
    311326
  • branches/eam_branches/ipp-20110213/psphot/src/psphotOutput.c

    r30624 r30749  
    2929}
    3030
    31 pmReadout *psphotSelectBackground (pmConfig *config,
    32                                    const pmFPAview *view) {
     31pmReadout *psphotSelectBackground (pmConfig *config, const pmFPAview *view) {
    3332
    3433    bool status;
    35     pmReadout *background;
     34   
    3635
    3736    pmFPAfile *file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKMDL");
    3837    if (!file) return NULL;
    39     if (file->mode == PM_FPA_MODE_INTERNAL) {
    40         background = file->readout;
    41     } else {
    42         background = pmFPAviewThisReadout (view, file->fpa);
    43     }
     38
     39    pmReadout *background = READOUT_OR_INTERNAL(view, file);
    4440    return background;
    4541}
    4642
    47 pmReadout *psphotSelectBackgroundStdev (pmConfig *config,
    48                                         const pmFPAview *view) {
     43pmReadout *psphotSelectBackgroundStdev (pmConfig *config, const pmFPAview *view) {
    4944
    5045    bool status;
    51     pmReadout *background;
    5246
    5347    pmFPAfile *file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKMDL.STDEV");
    5448    if (!file) return NULL;
    55     if (file->mode == PM_FPA_MODE_INTERNAL) {
    56         background = file->readout;
    57     } else {
    58         background = pmFPAviewThisReadout (view, file->fpa);
    59     }
     49
     50    pmReadout *background = READOUT_OR_INTERNAL(view, file);
    6051    return background;
    6152}
  • branches/eam_branches/ipp-20110213/psphot/src/psphotReadout.c

    r30707 r30749  
    5252    }
    5353
     54# if (0)
     55    // XXX test to mask outliers, not very helpful
     56    // mask the high values in the image (with MARK)
     57    if (!psphotMaskBackground (config, view, filerule)) {
     58        return psphotReadoutCleanup (config, view, filerule);
     59    }
     60
     61    // generate a background model (median, smoothed image)
     62    if (!psphotModelBackground (config, view, filerule)) {
     63        return psphotReadoutCleanup (config, view, filerule);
     64    }
     65# endif
     66
    5467    if (!psphotSubtractBackground (config, view, filerule)) {
    5568        return psphotReadoutCleanup (config, view, filerule);
     
    157170    // NOTE: possibly re-measure background model here with objects subtracted / or masked
    158171
    159     // add noise for subtracted objects
    160     psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources)
    161 
    162     // find fainter sources
    163     // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections
    164     psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints)
    165 
    166     // remove noise for subtracted objects (ie, return to normal noise level)
    167     // NOTE: this needs to operate only on the OLD sources
    168     psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources)
    169 
    170     // define new sources based on only the new peaks
    171     // NOTE: new sources are saved on detections->newSources
    172     psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources)
    173 
    174     // set source type
    175     // NOTE: apply only to detections->newSources
    176     if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources)
    177         psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    178         return psphotReadoutCleanup (config, view, filerule);
    179     }
    180 
    181     // create full input models, set the radius to fitRadius, set circular fit mask
    182     // NOTE: apply only to detections->newSources
    183     psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)
    184 
    185     // replace all sources so fit below applies to all at once
    186     // NOTE: apply only to OLD sources (which have been subtracted)
    187     psphotReplaceAllSources (config, view, filerule); // pass 2
    188 
    189     // merge the newly selected sources into the existing list
    190     // NOTE: merge OLD and NEW
    191     // XXX check on free of sources...
    192     psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
    193 
    194     // NOTE: apply to ALL sources
    195     psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
     172    // NOTE: this block performs the 2nd pass low-significance PSF detection stage
     173    {
     174        // add noise for subtracted objects
     175        psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources)
     176
     177        // find fainter sources
     178        // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections
     179        psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints)
     180
     181        // remove noise for subtracted objects (ie, return to normal noise level)
     182        // NOTE: this needs to operate only on the OLD sources
     183        psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources)
     184
     185        // define new sources based on only the new peaks
     186        // NOTE: new sources are saved on detections->newSources
     187        psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources)
     188
     189        // set source type
     190        // NOTE: apply only to detections->newSources
     191        if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources)
     192            psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
     193            return psphotReadoutCleanup (config, view, filerule);
     194        }
     195
     196        // create full input models, set the radius to fitRadius, set circular fit mask
     197        // NOTE: apply only to detections->newSources
     198        psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)
     199
     200        // replace all sources so fit below applies to all at once
     201        // NOTE: apply only to OLD sources (which have been subtracted)
     202        psphotReplaceAllSources (config, view, filerule); // pass 2
     203
     204        // merge the newly selected sources into the existing list
     205        // NOTE: merge OLD and NEW
     206        // XXX check on free of sources...
     207        psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
     208
     209        // NOTE: apply to ALL sources
     210        psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
     211    }
     212
     213    // NOTE: this block performs the 2nd pass low-significance EXT detection stage (smooth or rebin by NxN times PSF size)
     214    if (0) {
     215        // add noise for subtracted objects
     216        psphotAddNoise (config, view, filerule); // pass 1 (detections->allSources)
     217
     218        // find fainter sources
     219        // NOTE: finds new peaks and new footprints, OLD and FULL set are saved on detections
     220        psphotFindDetections (config, view, filerule, false); // pass 2 (detections->peaks, detections->footprints)
     221
     222        // remove noise for subtracted objects (ie, return to normal noise level)
     223        // NOTE: this needs to operate only on the OLD sources
     224        psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources)
     225
     226        // define new sources based on only the new peaks
     227        // NOTE: new sources are saved on detections->newSources
     228        psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources)
     229
     230        // set source type
     231        // NOTE: apply only to detections->newSources
     232        if (!psphotRoughClass (config, view, filerule)) { // pass 2 (detections->newSources)
     233            psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
     234            return psphotReadoutCleanup (config, view, filerule);
     235        }
     236
     237        // create full input models, set the radius to fitRadius, set circular fit mask
     238        // NOTE: apply only to detections->newSources
     239        psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)
     240
     241        // replace all sources so fit below applies to all at once
     242        // NOTE: apply only to OLD sources (which have been subtracted)
     243        psphotReplaceAllSources (config, view, filerule); // pass 2
     244
     245        // merge the newly selected sources into the existing list
     246        // NOTE: merge OLD and NEW
     247        // XXX check on free of sources...
     248        psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
     249
     250        // NOTE: apply to ALL sources
     251        psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
     252    }
    196253
    197254pass1finish:
  • branches/eam_branches/ipp-20110213/psphot/src/psphotSubtractBackground.c

    r29936 r30749  
    2424    assert (modelFile);
    2525
    26     pmReadout *model = NULL;
    27     if (modelFile->mode == PM_FPA_MODE_INTERNAL) {
    28         model = modelFile->readout;
    29     } else {
    30         model = pmFPAviewThisReadout (view, modelFile->fpa);
    31     }
     26    pmReadout *model = READOUT_OR_INTERNAL(view, modelFile);
    3227    assert (model);
    3328
     
    4439    if (file) {
    4540        // we are using PSPHOT.BACKGND as an I/O file: select readout or create
    46         if (file->mode == PM_FPA_MODE_INTERNAL) {
    47             background = file->readout;
    48         } else {
    49             background = pmFPAviewThisReadout (view, file->fpa);
    50         }
     41        background = READOUT_OR_INTERNAL(view, file);
    5142        if (background == NULL) {
    5243            // readout does not yet exist: create from input
  • branches/eam_branches/ipp-20110213/psphot/src/psphotVisual.c

    r30624 r30749  
    293293bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout) {
    294294
    295     pmReadout *backgnd;
    296 
    297295    if (!pmVisualTestLevel("psphot.image.backgnd", 2)) return true;
    298296
     
    303301    pmFPAfile *file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKGND");
    304302
    305     if (file->mode == PM_FPA_MODE_INTERNAL) {
    306         backgnd = file->readout;
    307     } else {
    308         backgnd = pmFPAviewThisReadout (view, file->fpa);
    309     }
     303    pmReadout *backgnd = READOUT_OR_INTERNAL(view, file);
    310304
    311305    psphotVisualScaleImage (kapa, backgnd->image, readout->mask, "backgnd", 2);
Note: See TracChangeset for help on using the changeset viewer.