IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19869


Ignore:
Timestamp:
Oct 2, 2008, 11:49:42 AM (18 years ago)
Author:
eugene
Message:

updates from eam_branch_20080926

Location:
trunk/psphot/src
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/Makefile.am

    r19566 r19869  
    7474        psphotMakeFluxScale.c          \
    7575        psphotCheckStarDistribution.c  \
     76        psphotVisual.c                 \
    7677        psphotAddNoise.c
    7778
  • trunk/psphot/src/psphot.h

    r18838 r19869  
    113113bool            psphotRadialPlot (int *kapa, const char *filename, pmSource *source);
    114114bool            psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe);
    115 bool            psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY);
     115bool            psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY, bool normalize);
    116116
    117117bool            psphotAddWithTest (pmSource *source, bool useState, psMaskType maskVal);
     
    132132bool            psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal);
    133133bool            psphotKron (pmSource *source, psMetadata *recipe, psMaskType maskVal);
     134
     135// psphotVisual functions
     136bool psphotSetVisual (bool mode);
     137bool psphotVisualShowImage (pmConfig *config, pmReadout *readout);
     138bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout);
     139bool psphotVisualShowSignificance (psImage *image);
     140bool psphotVisualShowPeaks (pmConfig *config, const pmFPAview *view, pmDetections *detections);
     141bool psphotVisualShowFootprints (pmConfig *config, const pmFPAview *view, pmDetections *detections);
     142bool psphotVisualShowMoments (pmConfig *config, const pmFPAview *view, psArray *sources);
     143bool psphotVisualShowRoughClass (pmConfig *config, const pmFPAview *view, psArray *sources);
     144bool psphotVisualShowPSFStars (pmConfig *config, const pmFPAview *view, pmPSF *psf, psArray *sources);
     145bool psphotVisualShowSatStars (pmConfig *config, const pmFPAview *view, pmPSF *psf, psArray *sources);
     146bool psphotVisualShowLinearFit (pmConfig *config, pmReadout *readout);
     147bool psphotVisualShowPSFModel (pmConfig *config, pmReadout *readout, pmPSF *psf);
    134148
    135149// structures & functions to support psf-convolved model fitting
  • trunk/psphot/src/psphotArguments.c

    r13416 r19869  
    6767    }
    6868
     69    // visual : interactive display mode
     70    if ((N = psArgumentGet (argc, argv, "-visual"))) {
     71        psArgumentRemove (N, &argc, argv);
     72        psphotSetVisual (true);
     73    }
     74
    6975    // break : used from recipe throughout psphotReadout
    7076    if ((N = psArgumentGet (argc, argv, "-break"))) {
  • trunk/psphot/src/psphotBlendFit.c

    r18555 r19869  
    8383        Nfit ++;
    8484
     85        // XXX TEST
     86        // if ((fabs(source->peak->x - 1202) < 2) && (fabs(source->peak->y - 1065) < 2)) {
     87        // psTraceSetLevel ("psLib.math.psMinimizeLMChi2", 6);
     88        // }
     89
    8590        // try fitting PSFs, then try extended sources
    8691        // these functions subtract the resulting fitted source (XXX and update the modelFlux?)
  • trunk/psphot/src/psphotFindDetections.c

    r17870 r19869  
    4141    psImage *significance = psphotSignificanceImage (readout, recipe, pass, maskVal);
    4242
     43    // display the backsub and backgnd images
     44    psphotVisualShowSignificance (significance);
     45
    4346    // detect the peaks in the significance image
    4447    detections->peaks = psphotFindPeaks (significance, readout, recipe, threshold, NMAX);
  • trunk/psphot/src/psphotFindFootprints.c

    r17870 r19869  
    3333    // find the raw footprints & assign the peaks to those footprints
    3434    psArray *footprints = pmFootprintsFind (significance, threshold, npixMin);
     35
    3536    pmFootprintsAssignPeaks(footprints, detections->peaks);
    3637    // XXX handle the error conditions here
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r18555 r19869  
    6666        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
    6767        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    68         if (source->type == PM_SOURCE_TYPE_STAR &&
    69             source->mode & PM_SOURCE_MODE_SATSTAR) continue;
     68
     69        // if (source->type == PM_SOURCE_TYPE_STAR &&
     70        // source->mode & PM_SOURCE_MODE_SATSTAR) continue;
     71
    7072        if (final) {
    7173            if (source->mode &  PM_SOURCE_MODE_SUBTRACTED) continue;
  • trunk/psphot/src/psphotMosaicSubimage.c

    r14953 r19869  
    22
    33// insert the source image into the outimage at Xo, Yo
    4 bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY) {
     4bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY, bool normalize) {
    55
    66    psRegion inRegion, outRegion;
     
    3535    for (int iy = 0; iy < newImage->numRows; iy++) {
    3636        for (int ix = 0; ix < newImage->numCols; ix++) {
    37             newImage->data.F32[iy][ix] = subImage->data.F32[iy][ix] / peak;
     37            if (normalize) {
     38                newImage->data.F32[iy][ix] = subImage->data.F32[iy][ix] / peak;
     39            } else {
     40                newImage->data.F32[iy][ix] = subImage->data.F32[iy][ix] / peak;
     41            }
    3842        }
    3943    }
  • trunk/psphot/src/psphotReadout.c

    r18973 r19869  
    3636    }
    3737
     38    // set up the Visual display, display the image, weight, mask (ch 1,2,3)
     39    psphotVisualShowImage (config, readout);
     40
    3841    // generate a background model (median, smoothed image)
    3942    if (!psphotModelBackground (config, view, "PSPHOT.INPUT")) {
     
    4649        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL);
    4750    }
     51
     52    // display the backsub and backgnd images
     53    psphotVisualShowBackground (config, view, readout);
    4854
    4955    // run a single-model test if desired (exits from here if test is run)
     
    6369    }
    6470 
     71    // display the backsub and backgnd images
     72    psphotVisualShowPeaks (config, view, detections);
     73    psphotVisualShowFootprints (config, view, detections);
     74
    6575    // XXX test write out the footprint image
    6676    if (0) {
     
    6878        psphotSaveImage (NULL, footprintImage, "footprints.1.fits");
    6979        psFree (footprintImage);
    70     }
    71 
    72     // XXX test write out the footprint image
    73     if (0) {
    74         psImage *footprintImage = pmSetFootprintArrayIDs (detections->footprints, true);
    75         psphotSaveImage (NULL, footprintImage, "footprints.1.fits");
    76         psFree (footprintImage);
    7780    }
    7881
     
    8487    }
    8588
     89    psphotVisualShowMoments (config, view, sources);
     90
    8691    // find blended neighbors of very saturated stars
    8792    // XXX merge this with Basic Deblend?
     
    102107        return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources);
    103108    }
     109
     110    psphotVisualShowRoughClass (config, view, sources);
    104111
    105112    // if we were not supplied a PSF, choose one here
     
    119126    }
    120127
     128    psphotVisualShowPSFModel (config, readout, psf);
     129
    121130    // Define source fitting parameters for everything that follows PSF fits
    122131    // This allows different parameters to be used from the PSF fitting
     
    158167    psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE);
    159168
     169    // XXX we have to place this here because the models are not realized until psphotGuessModels
     170    // or fitted until psphotFitSourcesLinear.  There is an example of generating a residual image
     171    // in pmPSFtry.c
     172
     173    psphotVisualShowPSFStars (config, view, psf, sources);
     174    psphotVisualShowSatStars (config, view, psf, sources);
     175    psphotVisualShowLinearFit (config, readout);
     176
    160177    if (0) {
    161178        FILE *out = fopen ("out.pass1.dat", "w");
     
    184201    }
    185202
     203    // XXX psphotVisualShowSourceSize (config, view, sources);
     204
    186205    // non-linear PSF and EXT fit to brighter sources
    187206    psphotBlendFit (readout, sources, recipe, psf);
     207
     208    // XXX psphotVisualShowNonLinearFit (config, view, sources);
    188209
    189210    // replace all sources
  • trunk/psphot/src/psphotReplaceUnfit.c

    r17828 r19869  
    7171}
    7272
    73 // add source, if the source has been subtracted (or if we ignore the state)
     73// add source, if the source has been subtracted; do not modify state
    7474bool psphotAddWithTest (pmSource *source, bool useState, psMaskType maskVal) {
    7575
     
    7878    if (state && useState) return true;
    7979
    80     // replace the model if 1) state says it is missing or 2) useState is false (just do it)
    81     if (!state || !useState) {
    82         pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    83     }
     80    pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
    8481    return true;
    8582}
    8683
    87 // sub source, if the source has been added (or if we ignore the state)
     84// sub source, if the source has been added; do not modify state
    8885bool psphotSubWithTest (pmSource *source, bool useState, psMaskType maskVal) {
    8986
     
    9289    if (state && useState) return true;
    9390
    94     // replace the model if 1) state says it is missing or 2) useState is false (just do it)
    95     if (!state || !useState) {
    96         pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    97     }
     91    pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    9892    return true;
    9993}
    10094
    101 // add or sub source replace or if the source has
     95// add or sub source to match recorded state: supply current state as true (add) or false (sub)
    10296bool psphotSetState (pmSource *source, bool curState, psMaskType maskVal) {
    10397
  • trunk/psphot/src/psphotSavePSFStars.c

    r13219 r19869  
    100100                psphotAddWithTest (source, true); // replace source if subtracted
    101101                psphotRadialPlot (&kapa, "radial.plots.ps", source);
    102                 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
     102                psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);
    103103
    104104                psphotSubWithTest (source, false); // remove source (force)
    105                 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
     105                psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);
    106106
    107107                psphotSetState (source, false); // replace source (has been subtracted)
     
    115115                psphotAddWithTest (source, true); // replace source if subtracted
    116116                psphotRadialPlot (&kapa, "radial.plots.ps", source);
    117                 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
     117                psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);
    118118
    119119                psphotSubWithTest (source, false); // remove source (force)
    120                 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
     120                psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);
    121121                psphotSetState (source, false); // replace source (has been subtracted)
    122122
     
    128128            psphotAddWithTest (source, true); // replace source if subtracted
    129129            psphotRadialPlot (&kapa, "radial.plots.ps", source);
    130             psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
     130            psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);
    131131
    132132            psphotSubWithTest (source, false); // remove source (force)
    133             psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
     133            psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);
    134134            psphotSetState (source, false); // replace source (has been subtracted)
    135135
  • trunk/psphot/src/psphotSourceFits.c

    r18555 r19869  
    1616bool psphotFitSummary () {
    1717
    18     fprintf (stderr, "fitted %5d psf, %5d blend, %5d ext, %5d dbl : %6.2f sec\n",
     18    psLogMsg ("psphot.pspsf", PS_LOG_INFO, "fitted %5d psf, %5d blend, %5d ext, %5d dbl : %6.2f sec\n",
    1919             NfitPSF, NfitBlend, NfitEXT, NfitDBL, psTimerMark ("psphot.fits"));
    2020    return true;
     
    4747    psArray *sourceSet = psArrayAllocEmpty (source->blends->n + 1);
    4848    psArrayAdd (sourceSet, 16, source);
     49
     50    psTrace ("psphot", 4, "fitting blended source at %f %f : %f\n", source->peak->xf, source->peak->yf, source->peak->flux);
    4951
    5052    // we need to include all blends in the fit (unless primary is saturated?)
     
    7779        psArrayAdd (modelSet, 16, model);
    7880        psArrayAdd (sourceSet, 16, blend);
     81
     82        psTrace ("psphot", 5, "adding source at %f %f : %f\n", blend->peak->xf, blend->peak->yf, blend->peak->flux);
    7983
    8084        // free to avoid double counting model
  • trunk/psphot/src/psphotSourcePlots.c

    r16820 r19869  
    113113                psphotAddWithTest (source, true, maskVal); // replace source if subtracted
    114114                psphotRadialPlot (&kapa, "radial.plots.ps", source);
    115                 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
     115                psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);
    116116
    117117                psphotSubWithTest (source, false, maskVal); // remove source (force)
    118                 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
     118                psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);
    119119
    120120                psphotSetState (source, false, maskVal); // replace source (has been subtracted)
     
    128128                psphotAddWithTest (source, true, maskVal); // replace source if subtracted
    129129                psphotRadialPlot (&kapa, "radial.plots.ps", source);
    130                 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
     130                psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);
    131131
    132132                psphotSubWithTest (source, false, maskVal); // remove source (force)
    133                 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
     133                psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);
    134134                psphotSetState (source, false, maskVal); // replace source (has been subtracted)
    135135
     
    141141            psphotAddWithTest (source, true, maskVal); // replace source if subtracted
    142142            psphotRadialPlot (&kapa, "radial.plots.ps", source);
    143             psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY);
     143            psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);
    144144
    145145            psphotSubWithTest (source, false, maskVal); // remove source (force)
    146             psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY);
     146            psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);
    147147            psphotSetState (source, false, maskVal); // replace source (has been subtracted)
    148148
Note: See TracChangeset for help on using the changeset viewer.