Changeset 7758
- Timestamp:
- Jun 29, 2006, 10:50:09 AM (20 years ago)
- Location:
- trunk/psphot
- Files:
-
- 8 edited
-
doc/notes.txt (modified) (1 diff)
-
src/psphot.h (modified) (4 diffs)
-
src/psphotBasicDeblend.c (modified) (1 diff)
-
src/psphotChoosePSF.c (modified) (3 diffs)
-
src/psphotFindPeaks.c (modified) (2 diffs)
-
src/psphotReadout.c (modified) (7 diffs)
-
src/psphotRoughClass.c (modified) (2 diffs)
-
src/psphotSourceStats.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/doc/notes.txt
r6966 r7758 1 2 2006.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 1 14 2 15 2006.04.22 -
trunk/psphot/src/psphot.h
r7677 r7758 21 21 22 22 psArray *psphotFakeSources (); 23 int psphotSaveImage (psMetadata *header, psImage *image, char *filename);24 23 25 24 // psphotReadout functions … … 31 30 pmPSF *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe); 32 31 bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf); 32 bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources); 33 33 bool psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final); 34 34 bool psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); … … 37 37 bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf); 38 38 bool psphotSkyReplace (pmConfig *config, pmFPAview *view); 39 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources); 39 40 40 41 // basic support functions … … 58 59 psMetadata *psphotDefineHeader (psMetadata *recipe); 59 60 bool psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf); 61 int psphotSaveImage (psMetadata *header, psImage *image, char *filename); 60 62 61 63 // PSF / DBL / EXT evaluation functions -
trunk/psphot/src/psphotBasicDeblend.c
r6950 r7758 125 125 psLogMsg ("psphot.deblend", 3, "identified %d blended objects (%f sec)\n", Nblend, psTimerMark ("psphot")); 126 126 127 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");128 if (!strcasecmp (breakPt, "DEBLEND")) exit (0);129 130 127 psFree (SN); 131 128 psFree (index); -
trunk/psphot/src/psphotChoosePSF.c
r6964 r7758 29 29 30 30 stars = psArrayAlloc (sources->n); 31 // DROP stars->n = 0;32 31 33 32 // select the candidate PSF stars (pointers to original sources) … … 105 104 psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid); 106 105 107 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");108 if (!strcasecmp (breakPt, "PSFFIT")) exit (0);109 110 106 return (psf); 111 107 } … … 151 147 return true; 152 148 } 149 150 bool 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 28 28 psImage *mask = readout->mask; 29 29 30 // XXX make this a user-option? 30 31 // psphotSaveImage (NULL, smooth_im, "imsmooth.fits"); 31 32 // psphotSaveImage (NULL, smooth_wt, "wtsmooth.fits"); … … 64 65 psLogMsg ("psphot", 3, "%d peaks: %f sec\n", peaks->n, psTimerMark ("psphot")); 65 66 66 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");67 if (!strcasecmp (breakPt, "PEAKS")) exit (0);68 69 67 return (peaks); 70 68 } -
trunk/psphot/src/psphotReadout.c
r7731 r7758 8 8 // find the currently selected readout 9 9 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT"); 10 11 // optional break-point for processing 12 char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT"); 10 13 11 14 // XXX does this need to invoke I/O? … … 34 37 // limit moments analysis by S/N? 35 38 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 } 36 45 37 46 // classify sources based on moments, brightness 38 47 // faint sources not classified? 39 48 if (!psphotRoughClass (sources, recipe)) { 40 psFree (peaks);41 49 psFree (sources); 42 50 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); … … 44 52 pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND"); 45 53 return false; 54 } 55 if (!strcasecmp (breakPt, "MOMENTS")) { 56 psphotReadoutCleanup (config, readout, recipe, NULL, sources); 57 return true; 46 58 } 47 59 … … 51 63 // use bright stellar objects to measure PSF 52 64 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 } 54 69 55 70 // linear PSF fit to peaks 56 71 psphotEnsemblePSF (readout, sources, recipe, psf, FALSE); 72 if (!strcasecmp (breakPt, "ENSEMBLE")) { 73 psphotReadoutCleanup (config, readout, recipe, psf, sources); 74 return true; 75 } 57 76 58 77 // non-linear PSF and EXT fit to brighter sources … … 80 99 psphotMagnitudes (sources, recipe, psf); 81 100 82 // create an output header with stats results83 psMetadata *header = psphotDefineHeader (recipe);84 85 101 // replace background in residual image 86 102 psphotSkyReplace (config, view); … … 89 105 psphotSourceFreePixels (sources); 90 106 // 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 113 bool 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); 91 124 92 125 // save the results of the analysis … … 99 132 pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND"); 100 133 101 // free up the local copies of the data102 psFree (peaks);103 psFree (sources);104 134 psFree (psf); 105 135 psFree (header); 136 psFree (sources); 137 106 138 return true; 107 139 } -
trunk/psphot/src/psphotRoughClass.c
r7507 r7758 4 4 bool psphotRoughClass (psArray *sources, psMetadata *recipe) { 5 5 6 bool status;7 6 pmPSFClump psfClump; 8 7 … … 20 19 psphotDumpMoments (recipe, sources); 21 20 22 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");23 if (!strcasecmp (breakPt, "CLASS")) exit (0);24 25 21 return true; 26 22 } -
trunk/psphot/src/psphotSourceStats.c
r6950 r7758 14 14 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 15 15 float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS"); 16 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 16 17 17 18 sources = psArrayAlloc (peaks->n); 18 // DROP sources->n = 0;19 19 20 20 for (int i = 0; i < peaks->n; i++) { … … 26 26 // allocate image, weight, mask arrays for each peak (square of radius OUTER) 27 27 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 28 if (!strcasecmp (breakPt, "PEAKS")) continue; 28 29 29 30 // XXX skip faint sources? … … 72 73 psLogMsg ("psphot", 3, "%d moments: %f sec\n", sources->n, psTimerMark ("psphot")); 73 74 74 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT");75 if (!strcasecmp (breakPt, "STATS")) exit (0);76 77 75 return (sources); 78 76 }
Note:
See TracChangeset
for help on using the changeset viewer.
