IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30142


Ignore:
Timestamp:
Dec 22, 2010, 6:28:58 AM (15 years ago)
Author:
eugene
Message:

define concept of source parent; psf-matched apertures used the source children

Location:
branches/eam_branches/ipp-20101205
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psModules/src/objects/pmSource.c

    r30139 r30142  
    127127    source->diffStats = NULL;
    128128    source->radialAper = NULL;
     129    source->parent = NULL;
    129130
    130131    source->region = psRegionSet(NAN, NAN, NAN, NAN);
  • branches/eam_branches/ipp-20101205/psModules/src/objects/pmSource.h

    r30139 r30142  
    5454    pmPeak  *peak;                      ///< Description of peak pixel.
    5555    psImage *pixels;                    ///< Rectangular region including object pixels.
    56     psImage *variance;                    ///< Image variance.
     56    psImage *variance;                  ///< Image variance.
    5757    psImage *maskObj;                   ///< unique mask for this object which marks included pixels associated with objects.
    5858    psImage *maskView;                  ///< view into global image mask for this object region
    5959    psImage *modelFlux;                 ///< cached copy of the best model for this source
    60     psImage *psfImage;                   ///< cached copy of the psf model for this source
     60    psImage *psfImage;                  ///< cached copy of the psf model for this source
    6161    pmMoments *moments;                 ///< Basic moments measured for the object.
    6262    pmModel *modelPSF;                  ///< PSF Model fit (parameters and type)
     
    9090    pmSourceDiffStats *diffStats;       ///< extra parameters for difference detections
    9191    psArray *radialAper;                ///< radial flux in circular apertures
     92    pmSource *parent;                   ///< reference to the master source from which this is derived
    9293    int imageID;
    9394};
     95
     96/* a pmSource is the information about a (possible) blob of flux in a specific image.  A source
     97 * may represent an insignificant or undetected source.  There may be multiple representations
     98 * of an image (eg, alternate smoothed copies); sources on alternate images may have a pointer
     99 * to the version on the primary image (source->parent).  A set of sources on different, but
     100 * related images (eg, multiple exposures or different filters) which (may) represent the same
     101 * astronomical object are grouped together with the pmPhotObj type (set pmPhotObj.h).
     102 *
     103 * A single source may be fitted with multiple models (not at the same time!).  The PSF model
     104 * fit is a fit of the position (optionally) and the flux to the PSF model at the location of
     105 * the source.  Alternate model fits are extended source models. The best model fit is used to
     106 * subtract the object from the image.
     107 */
    94108
    95109/** pmPSFClump data structure
  • branches/eam_branches/ipp-20101205/psphot/src/psphotFindDetections.c

    r29936 r30142  
    108108    }
    109109
     110    // XXX do a second (or third?) pass with rebinning (to detected more extended sources)
     111
    110112    psFree (significance);
    111113
  • branches/eam_branches/ipp-20101205/psphot/src/psphotMergeSources.c

    r29936 r30142  
    513513    }
    514514
    515     return true;
    516 }
    517 
     515    // loop over the sources, redefine their pixels to point at the new filerule image,
     516    // copy the source data, and add a reference back to the original source
     517   
     518
     519    return true;
     520}
     521
     522// copy the detections from one pmFPAfile to another
     523bool psphotSourceChildren (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc)
     524{
     525    bool status = true;
     526
     527    int num = psphotFileruleCount(config, ruleSrc);
     528
     529    // skip the chisq image because it is a duplicate of the detection version
     530    int chisqNum = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.CHISQ.NUM");
     531    if (!status) chisqNum = -1;
     532
     533    // loop over the available readouts
     534    for (int i = 0; i < num; i++) {
     535        if (i == chisqNum) continue; // skip chisq image
     536        if (!psphotSourceChildrenReadout (config, view, ruleOut, ruleSrc, i)) {
     537            psError (PSPHOT_ERR_CONFIG, false, "failed to copy sources from %s to %s entry %d", ruleSrc, ruleOut, i);
     538            return false;
     539        }
     540    }
     541    return true;
     542}
     543
     544// add newly selected sources to the existing list of sources
     545bool psphotSourceChildrenReadout (pmConfig *config, const pmFPAview *view, const char *ruleOut, const char *ruleSrc, int index) {
     546
     547    bool status;
     548
     549    // find the currently selected readout
     550    pmFPAfile *fileSrc = pmFPAfileSelectSingle(config->files, ruleSrc, index); // File of interest
     551    psAssert (fileSrc, "missing file?");
     552
     553    pmReadout *readoutSrc = pmFPAviewThisReadout(view, fileSrc->fpa);
     554    psAssert (readoutSrc, "missing readout?");
     555
     556    pmDetections *detectionsSrc = psMetadataLookupPtr (&status, readoutSrc->analysis, "PSPHOT.DETECTIONS");
     557    psAssert (detectionsSrc, "missing detections?");
     558
     559    psArray *sourcesSrc = detectionsSrc->allSources;
     560    psAssert (sourcesSrc, "missing sources?");
     561
     562    // find the currently selected readout
     563    pmFPAfile *fileOut = pmFPAfileSelectSingle(config->files, ruleOut, index); // File of interest
     564    psAssert (fileOut, "missing file?");
     565
     566    pmReadout *readoutOut = pmFPAviewThisReadout(view, fileOut->fpa);
     567    psAssert (readoutOut, "missing readout?");
     568
     569    // loop over the sources, redefine their pixels to point at the new filerule image,
     570    // copy the source data, and add a reference back to the original source
     571   
     572    // XXX currently, this is only used by psphotStackReadout (sources go on allSources so that psphotChoosePSF can be called repeatedly)
     573    pmDetections *detectionsOut = psMetadataLookupPtr (&status, readoutOut->analysis, "PSPHOT.DETECTIONS");
     574    if (!detectionsOut) {
     575        detectionsOut = pmDetectionsAlloc();
     576        detectionsOut->allSources = psArrayAllocEmpty (100);
     577        // save detections on the readout->analysis
     578        if (!psMetadataAddPtr (readoutOut->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot detections", detectionsOut)) {
     579            psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
     580            return false;
     581        }
     582        psFree(detectionsOut); // a copy remains on the analysis metadata
     583    }
     584
     585    // copy the sources from sourceSrcs to the new detection structure
     586    for (int i = 0; i < sourcesSrc->n; i++) {
     587      pmSource *sourceSrc = sourcesSrc->data[i];
     588
     589      pmSource *sourceOut = pmSourceCopy(sourceSrc);
     590      sourceOut->parent = sourceSrc;
     591     
     592      // does this copy all model data?
     593
     594      // drop the references to the original image pixels:
     595      // pmSourceFreePixels (sourceOut);
     596
     597      // allocate image, weight, mask for the new image for each peak (square of radius OUTER)
     598      pmSourceRedefinePixels (sourceOut, readout, sourceOut->peak->x, sourceOut->peak->y, sourceSrc->fitRadius, true);
     599
     600      // XXX source ID, imageID : how are they really used?
     601      sourceOut->imageID = sourceSrc->imageID;
     602      // P_PM_SOURCE_SET_ID(source, i);
     603
     604      psArrayAdd (detections->allSources, 100, sourceOut);
     605    }
     606    psLogMsg ("psphot", 3, "%ld known sources supplied", detections->allSources->n);
     607
     608
     609    return true;
     610}
     611
  • branches/eam_branches/ipp-20101205/psphot/src/psphotRadialApertures.c

    r30140 r30142  
    137137bool psphotRadialApertureSource (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal, const psVector *aperRadii, int entry) {
    138138
    139     psAssert(source->radialAper->data[entry] == NULL, "why is this already defined?");
     139    // if we are a child source, save the results to the parent source radial aperture array
     140    psArray *radialAperSet = source->radialAper;
     141    if (source->parent) {
     142        radialAperSet = source->parent->radialAper;
     143    }
     144
     145    psAssert(radialAperSet->data[entry] == NULL, "why is this already defined?");
    140146
    141147    pmSourceRadialApertures *radialAper = pmSourceRadialAperturesAlloc ();
    142     source->radialAper->data[entry] = radialAper;
     148    radialAperSet->data[entry] = radialAper;
    143149
    144150    // storage for the derived pixel values
  • branches/eam_branches/ipp-20101205/psphot/src/psphotStackReadout.c

    r30141 r30142  
    190190    psphotSourceSize (config, view, STACK_SRC, TRUE);
    191191
     192    // XXX do we want to do a preliminary (unconvolved) model fit here, and then
     193    // do a second detection pass? (like standard psphot)
     194
    192195    // measure aperture photometry corrections
    193196    if (!psphotApResid (config, view, STACK_SRC)) {
     
    209212
    210213    // copy the detections from SRC to OUT (for radial aperture photometry)
    211     if (!psphotCopySources (config, view, STACK_OUT, STACK_SRC)) {
     214    if (!psphotSourceChildren (config, view, STACK_OUT, STACK_SRC)) {
    212215        psFree(objects);
    213216        psError (PSPHOT_ERR_UNKNOWN, false, "failure in peak analysis");
     
    217220    bool smoothAgain = true;
    218221    for (int nMatchedPSF = 0; smoothAgain; nMatchedPSF++) {
    219         psphotRedefinePixels (config, view, STACK_OUT);
    220 
     222
     223        // XXX we probably can drop this if we redefine the pixels in CopySources
     224        // psphotRedefinePixels (config, view, STACK_OUT);
     225
     226        // re-measure the PSF for the smoothed image 
    221227        psphotChoosePSF (config, view, STACK_OUT, false);
    222228
     229        // this is necessary to update the models based on the new PSF
    223230        psphotResetModels (config, view, STACK_OUT);
    224231
     232        // this is necessary to get the right normalization for the new models
    225233        psphotFitSourcesLinear (config, view, STACK_OUT, false);
    226234
     
    228236        psphotRadialAperturesByObject (config, objects, view, STACK_OUT, nMatchedPSF);
    229237
     238        // replace the flux in the image so it is returned to its original state
    230239        psphotReplaceAllSources (config, view, STACK_OUT);
    231240
     241        // smooth to the next FWHM, or set 'smoothAgain' to false if no more
    232242        psphotStackMatchPSFsNext(&smoothAgain, config, view, STACK_OUT, nMatchedPSF);
    233243    }
Note: See TracChangeset for help on using the changeset viewer.