IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7758


Ignore:
Timestamp:
Jun 29, 2006, 10:50:09 AM (20 years ago)
Author:
eugene
Message:

added breakpoints, better exit handling on psphotReadout

Location:
trunk/psphot
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/doc/notes.txt

    r6966 r7758  
     1
     22006.06.28
     3
     4  I am adding a few minor features.  First up is the ability to break
     5  the processing at interesting stages.  These will be:
     6
     7  - PEAKS: after sources are generated, but before moments are
     8    measured
     9  - MOMENTS: after moments are measured, before the PSF is measured
     10  - PSFMODEL: after the psf model is measured, before sources are
     11    fitted in bulk
     12  - ENSEMBLE: after the linear ensemble fitting
     13  - DEFAULT: complete processing
    114
    2152006.04.22
  • trunk/psphot/src/psphot.h

    r7677 r7758  
    2121
    2222psArray        *psphotFakeSources ();
    23 int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    2423
    2524// psphotReadout functions
     
    3130pmPSF          *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
    3231bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
     32bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
    3333bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
    3434bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
     
    3737bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf);
    3838bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
     39bool            psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources);
    3940
    4041// basic support functions
     
    5859psMetadata     *psphotDefineHeader (psMetadata *recipe);
    5960bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
     61int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    6062
    6163// PSF / DBL / EXT evaluation functions
  • trunk/psphot/src/psphotBasicDeblend.c

    r6950 r7758  
    125125    psLogMsg ("psphot.deblend", 3, "identified %d blended objects (%f sec)\n", Nblend, psTimerMark ("psphot"));
    126126
    127     char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    128     if (!strcasecmp (breakPt, "DEBLEND")) exit (0);
    129 
    130127    psFree (SN);
    131128    psFree (index);
  • trunk/psphot/src/psphotChoosePSF.c

    r6964 r7758  
    2929
    3030    stars = psArrayAlloc (sources->n);
    31     // DROP stars->n = 0;
    3231
    3332    // select the candidate PSF stars (pointers to original sources)
     
    105104    psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid);
    106105
    107     char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    108     if (!strcasecmp (breakPt, "PSFFIT")) exit (0);
    109 
    110106    return (psf);
    111107}
     
    151147    return true;
    152148}
     149
     150bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources) {
     151
     152    // without the PSF model, we can only rely on the source->moments
     153    // as a measure of the FWHM values
     154
     155    double FWHM_X, FWHM_Y, FWHM_T;
     156    int FWHM_N;
     157
     158    psEllipseMoments moments;
     159    psEllipseAxes axes;
     160
     161    FWHM_N = 0;
     162    FWHM_X = FWHM_Y = 0.0;
     163
     164    for (int i = 0; i < sources->n; i++) {
     165        pmSource *source = sources->data[i];
     166        if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
     167       
     168        // moments->Sx,Sy are roughly sigma_x,y
     169        moments.x2 = PS_SQR(source->moments->Sx);
     170        moments.y2 = PS_SQR(source->moments->Sy);
     171        moments.xy = source->moments->Sxy;
     172
     173        axes = psEllipseMomentsToAxes (moments);
     174
     175        FWHM_X += axes.major * 2.35;
     176        FWHM_Y += axes.minor * 2.35;
     177        FWHM_T += axes.theta;
     178        FWHM_N ++;
     179    }
     180
     181    FWHM_X /= FWHM_N;
     182    FWHM_Y /= FWHM_N;
     183    FWHM_T /= FWHM_N;
     184
     185    psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X);
     186    psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y);
     187    psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE",  PS_DATA_F32 | PS_META_REPLACE, "PSF angle",           FWHM_T);
     188   
     189    return true;
     190}
  • trunk/psphot/src/psphotFindPeaks.c

    r7436 r7758  
    2828    psImage *mask = readout->mask;
    2929
     30    // XXX make this a user-option?
    3031    // psphotSaveImage (NULL, smooth_im, "imsmooth.fits");
    3132    // psphotSaveImage (NULL, smooth_wt, "wtsmooth.fits");
     
    6465    psLogMsg ("psphot", 3, "%d peaks: %f sec\n", peaks->n, psTimerMark ("psphot"));
    6566
    66     char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    67     if (!strcasecmp (breakPt, "PEAKS")) exit (0);
    68 
    6967    return (peaks);
    7068}
  • trunk/psphot/src/psphotReadout.c

    r7731 r7758  
    88    // find the currently selected readout
    99    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT");
     10
     11    // optional break-point for processing
     12    char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT");
    1013
    1114    // XXX does this need to invoke I/O?
     
    3437    // limit moments analysis by S/N?
    3538    psArray *sources = psphotSourceStats (readout, recipe, peaks);
     39    psFree (peaks);
     40
     41    if (!strcasecmp (breakPt, "PEAKS")) {
     42        psphotReadoutCleanup (config, readout, recipe, NULL, sources);
     43        return true;
     44    }
    3645
    3746    // classify sources based on moments, brightness
    3847    // faint sources not classified?
    3948    if (!psphotRoughClass (sources, recipe)) {
    40         psFree (peaks);
    4149        psFree (sources);
    4250        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
     
    4452        pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
    4553        return false;
     54    }
     55    if (!strcasecmp (breakPt, "MOMENTS")) {
     56        psphotReadoutCleanup (config, readout, recipe, NULL, sources);
     57        return true;
    4658    }
    4759
     
    5163    // use bright stellar objects to measure PSF
    5264    pmPSF *psf = psphotChoosePSF (readout, sources, recipe);
    53     psphotPSFstats (readout, recipe, psf);
     65    if (!strcasecmp (breakPt, "PSFMODEL")) {
     66        psphotReadoutCleanup (config, readout, recipe, psf, sources);
     67        return true;
     68    }
    5469
    5570    // linear PSF fit to peaks
    5671    psphotEnsemblePSF (readout, sources, recipe, psf, FALSE);
     72    if (!strcasecmp (breakPt, "ENSEMBLE")) {
     73        psphotReadoutCleanup (config, readout, recipe, psf, sources);
     74        return true;
     75    }
    5776
    5877    // non-linear PSF and EXT fit to brighter sources
     
    8099    psphotMagnitudes (sources, recipe, psf);
    81100
    82     // create an output header with stats results
    83     psMetadata *header = psphotDefineHeader (recipe);
    84 
    85101    // replace background in residual image
    86102    psphotSkyReplace (config, view);
     
    89105    psphotSourceFreePixels (sources);
    90106    // psphotSaveImage (NULL, readout->image, "resid.fits");
     107
     108    // create the exported-metadata and free local data
     109    psphotReadoutCleanup (config, readout, recipe, psf, sources);
     110    return true;
     111}
     112
     113bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources) {
     114
     115    // use the psf-model to measure FWHM stats
     116    if (psf) {
     117        psphotPSFstats (readout, recipe, psf);
     118    } else {
     119        psphotMomentsStats (readout, recipe, sources);
     120    }
     121
     122    // create an output header with stats results
     123    psMetadata *header = psphotDefineHeader (recipe);
    91124
    92125    // save the results of the analysis
     
    99132    pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
    100133
    101     // free up the local copies of the data
    102     psFree (peaks);
    103     psFree (sources);
    104134    psFree (psf);
    105135    psFree (header);
     136    psFree (sources);
     137
    106138    return true;
    107139}
  • trunk/psphot/src/psphotRoughClass.c

    r7507 r7758  
    44bool psphotRoughClass (psArray *sources, psMetadata *recipe) {
    55
    6     bool status;
    76    pmPSFClump   psfClump;
    87
     
    2019    psphotDumpMoments (recipe, sources);
    2120
    22     char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    23     if (!strcasecmp (breakPt, "CLASS")) exit (0);
    24 
    2521    return true;
    2622}
  • trunk/psphot/src/psphotSourceStats.c

    r6950 r7758  
    1414    float OUTER    = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
    1515    float RADIUS   = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS");
     16    char *breakPt  = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    1617
    1718    sources = psArrayAlloc (peaks->n);
    18     // DROP sources->n = 0;
    1919
    2020    for (int i = 0; i < peaks->n; i++) {
     
    2626        // allocate image, weight, mask arrays for each peak (square of radius OUTER)
    2727        pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
     28        if (!strcasecmp (breakPt, "PEAKS")) continue;
    2829
    2930        // XXX skip faint sources?
     
    7273    psLogMsg ("psphot", 3, "%d moments: %f sec\n", sources->n, psTimerMark ("psphot"));
    7374
    74     char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
    75     if (!strcasecmp (breakPt, "STATS")) exit (0);
    76 
    7775    return (sources);
    7876}
Note: See TracChangeset for help on using the changeset viewer.