IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12689


Ignore:
Timestamp:
Mar 29, 2007, 4:48:20 PM (19 years ago)
Author:
eugene
Message:

added deblend for saturated stars, fixed AddNoise

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

Legend:

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

    r12665 r12689  
    5151        psphotSourcePlots.c      \
    5252        psphotRadialPlot.c       \
     53        psphotDeblendSatstars.c  \
    5354        psphotMosaicSubimage.c   \
    5455        psphotAddNoise.c         \
  • trunk/psphot/src/psphot.h

    r12665 r12689  
    111111bool psphotSubWithTest (pmSource *source, bool useState);
    112112bool psphotSetState (pmSource *source, bool curState);
     113bool psphotDeblendSatstars (psArray *sources, psMetadata *recipe);
  • trunk/psphot/src/psphotAddNoise.c

    r12635 r12689  
    44
    55    bool status = false;
    6     psTimerStart ("psphot");
     6    psEllipseShape oldshape;
     7    psEllipseShape newshape;
     8    psEllipseAxes axes;
    79
    810    PS_ASSERT (readout, false);
    911    PS_ASSERT (readout->parent, false);
    1012    PS_ASSERT (readout->parent->concepts, false);
     13
     14    psTimerStart ("psphot");
    1115
    1216    // increase variance by factor*(object noise):
     
    1519
    1620    float FACTOR = psMetadataLookupF32 (&status, recipe, "NOISE.FACTOR");
     21    PS_ASSERT (status, false);
     22    float SIZE = psMetadataLookupF32 (&status, recipe, "NOISE.SIZE");
    1723    PS_ASSERT (status, false);
    1824
     
    3945        }
    4046
    41         model->params->data.F32[PM_PAR_I0] *= FACTOR;
     47        psF32 *PAR = model->params->data.F32;
     48
     49        // save original values
     50        float oldI0  = PAR[PM_PAR_I0];
     51        oldshape.sx  = PAR[PM_PAR_SXX];
     52        oldshape.sy  = PAR[PM_PAR_SYY];
     53        oldshape.sxy = PAR[PM_PAR_SXY];
     54
     55        // increase size and height of source
     56        axes = psEllipseShapeToAxes (oldshape, 20.0);
     57        axes.major *= SIZE;
     58        axes.minor *= SIZE;
     59        newshape = psEllipseAxesToShape (axes);
     60        PAR[PM_PAR_I0]  = FACTOR*PS_SQR(oldI0);
     61        PAR[PM_PAR_SXX] = newshape.sx;
     62        PAR[PM_PAR_SYY] = newshape.sy;
     63        PAR[PM_PAR_SXY] = newshape.sxy;
     64
    4265        if (add) {
    4366            pmModelAdd (source->weight, source->mask, model, false, false);
     
    4568            pmModelSub (source->weight, source->mask, model, false, false);
    4669        }
     70       
     71        // restore original values
     72        PAR[PM_PAR_I0]  = oldI0;       
     73        PAR[PM_PAR_SXX] = oldshape.sx;
     74        PAR[PM_PAR_SYY] = oldshape.sy;
     75        PAR[PM_PAR_SXY] = oldshape.sxy;
    4776    }
    4877    if (add) {
  • trunk/psphot/src/psphotBasicDeblend.c

    r11164 r12689  
    11# include "psphot.h"
    22
    3 // 2006.02.07 : no leaks
    43bool psphotBasicDeblend (psArray *sources, psMetadata *recipe) {
    54
  • trunk/psphot/src/psphotEvalPSF.c

    r11167 r12689  
    7373      case PM_MODEL_UNTRIED:
    7474        source->mode &= ~PM_SOURCE_MODE_FITTED;
     75        if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     76            psTrace ("psphot", 5, "satstar was not fitted");
     77        }
    7578        return false;
    7679      case PM_MODEL_BADARGS:
     
    7982      default:
    8083        source->mode |= PM_SOURCE_MODE_FAIL;
     84        if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     85            psTrace ("psphot", 5, "satstar failed fit");
     86        }
    8187        return false;
    8288    }
     
    103109    if (model->params->data.F32[PM_PAR_I0] <= 0) {
    104110        source->mode |= PM_SOURCE_MODE_FAIL;
     111        if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     112            psTrace ("psphot", 5, "satstar failed fit (peak below 0)");
     113        }
    105114        return false;
    106115    }
     
    130139    keep &= (SN > PSF_MIN_SN);
    131140    keep &= (Chi < PSF_MAX_CHI);
     141
     142    if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     143        psTrace ("psphot", 5, "satstar fit results: %f, %f  %d :  %f %f : %f %f : %f %f\n",
     144                     model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], keep,
     145                 dSX, nSx, dSY, nSy, SN, Chi);
     146    }
     147
    132148    if (keep) {
    133149        if (source->mode & PM_SOURCE_MODE_PSFSTAR) {
  • trunk/psphot/src/psphotFindPeaks.c

    r12372 r12689  
    3939    // optionally save example images under trace
    4040    if (psTraceGetLevel("psphot") > 5) {
    41         psphotSaveImage (NULL, smooth_im, "imsmooth.fits");
    42         psphotSaveImage (NULL, smooth_wt, "wtsmooth.fits");
     41        char name[64];
     42        sprintf (name, "imsmooth.v%d.fits", pass);
     43        psphotSaveImage (NULL, smooth_im, name);
     44        sprintf (name, "wtsmooth.v%d.fits", pass);
     45        psphotSaveImage (NULL, smooth_wt, name);
    4346    }
    4447
     
    5861    // optionally save example images under trace
    5962    if (psTraceGetLevel("psphot") > 5) {
    60         psphotSaveImage (NULL, smooth_im, "snsmooth.fits");
     63        char name[64];
     64        sprintf (name, "snsmooth.v%d.fits", pass);
     65        psphotSaveImage (NULL, smooth_im, name);
    6166    }
    6267
  • trunk/psphot/src/psphotReadout.c

    r12665 r12689  
    6161        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL);
    6262    }
     63    pmPeaksWriteText (peaks, "oldpeaks.dat");
    6364
    6465    // construct sources and measure basic stats
     
    7071        return psphotReadoutCleanup(config, readout, recipe, NULL, sources);
    7172    }
     73
     74    psphotDeblendSatstars (sources, recipe);
    7275
    7376    // mark blended peaks PS_SOURCE_BLEND
     
    102105    psphotGuessModels (readout, sources, recipe, psf);
    103106
     107    psphotSaveImage (NULL, readout->image,  "image.v0.fits");
     108
    104109    // linear PSF fit to peaks
    105110    psphotEnsemblePSF (readout, sources, recipe, psf, FALSE);
     111    psphotSaveImage (NULL, readout->image,  "image.v1.fits");
    106112    if (!strcasecmp (breakPt, "ENSEMBLE")) {
    107113        goto finish;
    108114    }
    109115
    110     // plot positive + negative sources (replace, then remove)
    111     psphotSourcePlots (readout, sources, recipe);
    112 
    113116    // non-linear PSF and EXT fit to brighter sources
    114117    psphotBlendFit (readout, sources, recipe, psf);
     118    psphotSaveImage (NULL, readout->image,  "image.v2.fits");
    115119
    116120    // replace all sources
    117121    psphotReplaceAll (sources);
    118 
    119     // plot positive sources
    120     // psphotSourcePlots (readout, sources, recipe);
     122    psphotSaveImage (NULL, readout->image,  "image.v3.fits");
    121123
    122124    // linear PSF fit to remaining peaks
    123125    psphotEnsemblePSF (readout, sources, recipe, psf, TRUE);
     126    psphotSaveImage (NULL, readout->image,  "image.v4.fits");
    124127    if (!strcasecmp (breakPt, "PASS1")) {
    125128        goto finish;
     
    137140    // find the peaks in the image
    138141    psArray *newPeaks = psphotFindPeaks (readout, recipe, 2);
     142    pmPeaksWriteText (newPeaks, "newpeaks.dat");
    139143
    140144    // remove noise for subtracted objects
     
    153157    // replace all sources
    154158    psphotReplaceAll (sources);
     159    psphotSaveImage (NULL, readout->image,  "image.v5.fits");
    155160
    156161    // merge the newly selected peaks into the existing list
     
    160165    // linear PSF fit to remaining peaks
    161166    psphotEnsemblePSF (readout, sources, recipe, psf, TRUE);
     167    psphotSaveImage (NULL, readout->image,  "image.v6.fits");
    162168
    163169finish:
     170
     171    // plot positive sources
     172    psphotSourcePlots (readout, sources, recipe);
    164173
    165174    // measure aperture photometry corrections
Note: See TracChangeset for help on using the changeset viewer.