Changeset 5058
- Timestamp:
- Sep 15, 2005, 12:12:26 PM (21 years ago)
- Location:
- trunk/psphot
- Files:
-
- 16 edited
-
Makefile (modified) (2 diffs)
-
src/pmPSF.c (modified) (1 diff)
-
src/pmPSF.h (modified) (1 diff)
-
src/pmPSFtry.c (modified) (4 diffs)
-
src/pmPSFtry.h (modified) (2 diffs)
-
src/psLibUtils.h (modified) (2 diffs)
-
src/psphot.c (modified) (1 diff)
-
src/psphot.h (modified) (2 diffs)
-
src/psphotApplyPSF.c (modified) (3 diffs)
-
src/psphotChoosePSF.c (modified) (3 diffs)
-
src/psphotFitGalaxies.c (modified) (2 diffs)
-
src/psphotImageStats.c (modified) (1 diff)
-
src/psphotMarkPSF.c (modified) (3 diffs)
-
src/psphotOutput.c (modified) (12 diffs)
-
src/psphotSetup.c (modified) (2 diffs)
-
src/psphotSourceStats.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/Makefile
r4977 r5058 3 3 @echo "USAGE: make psphot" 4 4 5 # CC = gcc -g -Wall -O2 6 CC = gcc -g -Wall 5 CC = gcc 7 6 SRC = src 8 7 BIN = bin … … 16 15 # LIBS = -lpsmodule $(LPSLIB) 17 16 LIBS = $(LPSLIB) 18 CFLAGS = $(INCS) -std=c99 -Wall -Werror 17 CFLAGS = $(INCS) -std=c99 -Wall -Werror -g 19 18 LFLAGS = $(LIBS) 20 19 -
trunk/psphot/src/pmPSF.c
r4977 r5058 24 24 pmPSF *psf = (pmPSF *) psAlloc(sizeof(pmPSF)); 25 25 26 psf->type = type; 27 psf->chisq = 0.0; 26 psf->type = type; 27 psf->chisq = 0.0; 28 psf->ApResid = 0.0; 29 psf->dApResid = 0.0; 30 psf->skyBias = 0.0; 28 31 29 32 Nparams = pmModelParameterCount (type); -
trunk/psphot/src/pmPSF.h
r4977 r5058 13 13 psArray *params; ///< Model parameters (psPolynomial2D) 14 14 float chisq; ///< PSF goodness statistic 15 float ApResid; 16 float dApResid; 17 float skyBias; 15 18 int nPSFstars; ///< number of stars used to measure PSF 16 19 } -
trunk/psphot/src/pmPSFtry.c
r4977 r5058 31 31 pmPSFtry *pmPSFtryAlloc (psArray *sources, char *modelName) { 32 32 33 pmModelType type; 34 33 35 pmPSFtry *test = (pmPSFtry *) psAlloc(sizeof(pmPSFtry)); 34 36 35 37 // XXX probably need to increment ref counter 36 test->modelType = pmModelSetType (modelName); 37 test->psf = pmPSFAlloc (test->modelType); 38 test->sources = psMemCopy(sources); 39 test->modelFLT = psArrayAlloc (sources->n); 40 test->modelPSF = psArrayAlloc (sources->n); 41 test->metric = psVectorAlloc (sources->n, PS_TYPE_F64); 42 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F64); 43 test->mask = psVectorAlloc (sources->n, PS_TYPE_U8); 44 test->ApResid = 0; 45 test->dApResid = 0; 46 test->skyBias = 0; 38 type = pmModelSetType (modelName); 39 test->psf = pmPSFAlloc (type); 40 test->sources = psMemCopy(sources); 41 test->modelFLT = psArrayAlloc (sources->n); 42 test->modelPSF = psArrayAlloc (sources->n); 43 test->metric = psVectorAlloc (sources->n, PS_TYPE_F64); 44 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F64); 45 test->mask = psVectorAlloc (sources->n, PS_TYPE_U8); 47 46 48 47 for (int i = 0; i < test->modelFLT->n; i++) { … … 84 83 85 84 pmSource *source = try->sources->data[i]; 86 pmModel *model = pmSourceModelGuess (source, try-> modelType);85 pmModel *model = pmSourceModelGuess (source, try->psf->type); 87 86 x = source->peak->x; 88 87 y = source->peak->y; … … 164 163 pmPSFtryMetric (try, RADIUS); 165 164 psLogMsg ("psphot.pspsf", 3, "try model %s, ap-fit: %f +/- %f, sky bias: %f\n", 166 modelName, try-> ApResid, try->dApResid, try->skyBias);165 modelName, try->psf->ApResid, try->psf->dApResid, try->psf->skyBias); 167 166 168 167 return (try); … … 279 278 stats = psVectorStats (stats, daResid, NULL, maskB, 1); 280 279 281 try-> ApResid = poly->coeff[0];282 try-> dApResid = stats->clippedStdev;283 try-> skyBias = poly->coeff[1] / (M_PI * PS_SQR(RADIUS));280 try->psf->ApResid = poly->coeff[0]; 281 try->psf->dApResid = stats->clippedStdev; 282 try->psf->skyBias = poly->coeff[1] / (M_PI * PS_SQR(RADIUS)); 284 283 285 284 psFree (rflux); -
trunk/psphot/src/pmPSFtry.h
r4977 r5058 5 5 // data to try a given PSF model type 6 6 typedef struct { 7 pmModelType modelType;8 7 pmPSF *psf; 9 8 psArray *sources; // pointers to the original sources … … 13 12 psVector *metric; 14 13 psVector *fitMag; 15 float ApResid;16 float dApResid;17 float skyBias;18 14 } pmPSFtry; 19 15 -
trunk/psphot/src/psLibUtils.h
r5049 r5058 15 15 # define psMemCopy(A)(psMemIncrRefCounter((A))) 16 16 17 // XXX EAM : bug : missing from psLib/*.h 18 bool psMinimizeGaussNewtonDelta (psVector *delta, 19 const psVector *params, 20 const psVector *paramMask, 21 const psArray *x, 22 const psVector *y, 23 const psVector *yErr, 24 psMinimizeLMChi2Func func); 25 17 // XXX EAM : my version using varience instead of stdev 26 18 bool psMinimizeGaussNewtonDelta_EAM (psVector *delta, 27 19 const psVector *params, … … 32 24 psMinimizeLMChi2Func func); 33 25 34 // minimize 26 // minimize : using varience vs sigma and parameter limits 35 27 psBool p_psMinLM_GuessABP_EAM (psImage *Alpha, psVector *Beta, psVector *Params, const psImage *alpha, const psVector *beta, const psVector *params, const psVector *paramMask, const psVector *beta_lim, const psVector *params_min, const psVector *params_max, psF64 lambda); 36 28 psBool psMinimizeLMChi2_EAM(psMinimization *min, psImage *covar, psVector *params, const psVector *paramMask, const psArray *x, const psVector *y, const psVector *yErr, psMinimizeLMChi2Func func); -
trunk/psphot/src/psphot.c
r5049 r5058 47 47 48 48 // write out data in appropriate format 49 psphotOutput (imdata, config, sources );49 psphotOutput (imdata, config, sources, psf, sky); 50 50 exit (0); 51 51 } -
trunk/psphot/src/psphot.h
r5049 r5058 26 26 bool psphotApplyPSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 27 27 bool psphotFitGalaxies (eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats); 28 void psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources );28 void psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky); 29 29 30 30 bool psphotMarkPSF (pmSource *source, float shapeNsigma, float minSN, float maxChi, float SATURATE); … … 38 38 39 39 // output functions 40 bool pmSourcesWriteText (eamReadout *imdata, char *filename, psArray *sources );41 bool pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources );42 bool pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources );43 bool pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources );44 bool pmSourcesWriteSX (eamReadout *imdata, char *filename, psArray *sources );40 bool pmSourcesWriteText (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 41 bool pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 42 bool pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 43 bool pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 44 bool pmSourcesWriteSX (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *sky); 45 45 int pmSourcesDophotType (pmSource *source); 46 46 bool pmPeaksWriteText (psArray *sources, char *filename); -
trunk/psphot/src/psphotApplyPSF.c
r5049 r5058 28 28 // set the object surface-brightness limit for fitted pixels 29 29 float FLUX_LIMIT = PSF_FIT_NSIGMA * sky->sampleStdev; 30 psLogMsg ("psphot.apply_psf_model", 3, "fitting pixels with at least %f object counts\n", FLUX_LIMIT);30 psLogMsg ("psphot.apply_psf_model", 4, "fitting pixels with at least %f object counts\n", FLUX_LIMIT); 31 31 32 32 // this function specifies the radius at this the model hits the given flux … … 72 72 psImageKeepCircle (source->mask, x, y, model->radius, "AND", ~PSPHOT_MASK_MARKED); 73 73 if (!status || (model->params->data.F32[1] < 0)) { 74 psLogMsg ("psphot", 3, "PSF fit failed for %f, %f (%d iterations)\n", x, y, model->nIter);74 psLogMsg ("psphot", 5, "PSF fit failed for %f, %f (%d iterations)\n", x, y, model->nIter); 75 75 source->type = PM_SOURCE_FAIL_FIT_PSF; // better choice? 76 76 psFree (model); … … 91 91 92 92 psLogMsg ("psphot", 3, "fit PSF models: %f sec for %d objects (%d total iterations)\n", psTimerMark ("psphot"), Nfit, Niter); 93 psLogMsg ("psphot", 3, "subtracted %d PSF objects\n", Nsub);93 psLogMsg ("psphot", 4, "subtracted %d PSF objects\n", Nsub); 94 94 return (true); 95 95 } -
trunk/psphot/src/psphotChoosePSF.c
r5048 r5058 12 12 13 13 // array to store candidate PSF stars 14 int NSTARS = psMetadataLookupS32 (&status, config, "PSF_MAX_NSTARS"); 15 if (!status) NSTARS = sources->n; 14 16 stars = psArrayAlloc (sources->n); 15 17 stars->n = 0; 16 18 17 19 // select the candidate PSF stars (pointers to original sources) 18 for (int i = 0; i < sources->n; i++) {20 for (int i = 0; (i < sources->n) && (stars->n < NSTARS); i++) { 19 21 pmSource *source = sources->data[i]; 20 22 if (source->type != PM_SOURCE_PSFSTAR) continue; … … 55 57 try = models->data[0]; 56 58 int bestN = 0; 57 float bestM = try-> dApResid;59 float bestM = try->psf->dApResid; 58 60 for (int i = 1; i < models->n; i++) { 59 61 try = models->data[i]; 60 float M = try-> dApResid;62 float M = try->psf->dApResid; 61 63 if (M < bestM) { 62 64 bestM = M; … … 67 69 // keep only the selected model: 68 70 try = models->data[bestN]; 69 modelName = pmModelGetType (try->modelType);70 ps LogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, try->ApResid, try->dApResid);71 pmPSF *psf = psMemCopy(try->psf); 72 psFree (models); // keep only the pmPSF resulting from this analysis 71 73 72 // keep only the pmPSF resulting from this analysis73 p mPSF *psf = psMemCopy(try->psf);74 psFree (models); 74 modelName = pmModelGetType (psf->type); 75 psLogMsg ("psphot.pspsf", 3, "selected psf model %s, ApResid: %f +/- %f\n", modelName, psf->ApResid, psf->dApResid); 76 75 77 return (psf); 76 78 } -
trunk/psphot/src/psphotFitGalaxies.c
r5049 r5058 81 81 if (!status) { 82 82 // if the fit fails, we need to change the classification 83 psLogMsg ("psphot", 3, "GAL fit failed for %f, %f (%d iterations, %f radius)\n", x, y, model->nIter, model->radius);83 psLogMsg ("psphot", 5, "GAL fit failed for %f, %f (%d iterations, %f radius)\n", x, y, model->nIter, model->radius); 84 84 source->type = PM_SOURCE_FAIL_FIT_GAL; // better choice? 85 85 source->modelFLT = model; … … 92 92 if (!goodfit) { 93 93 // if the fit fails, we need to change the classification 94 psLogMsg ("psphot", 3, "GAL fit poor for %f, %f (%d iterations, %f radius)\n", x, y, model->nIter, model->radius);94 psLogMsg ("psphot", 5, "GAL fit poor for %f, %f (%d iterations, %f radius)\n", x, y, model->nIter, model->radius); 95 95 source->type = PM_SOURCE_POOR_FIT_GAL; // better choice? 96 96 source->modelFLT = model; -
trunk/psphot/src/psphotImageStats.c
r5049 r5058 49 49 sky->sampleStdev = sqrt(sky->sampleMean/GAIN + PS_SQR(NOISE)); 50 50 51 psLogMsg ("psphot", 3, "stats: %f sec\n", psTimerMark ("psphot"));51 psLogMsg ("psphot", 4, "stats: %f sec\n", psTimerMark ("psphot")); 52 52 psLogMsg ("psphot", 3, "background: %f +/- %f\n", sky->sampleMean, sky->sampleStdev); 53 53 -
trunk/psphot/src/psphotMarkPSF.c
r5048 r5058 36 36 if (source->modelPSF->params->data.F32[1] >= SATURATE) { 37 37 if (source->type == PM_SOURCE_PSFSTAR) { 38 psLogMsg ("psphot", 3, "PSFSTAR marked SATSTAR\n");38 psLogMsg ("psphot", 5, "PSFSTAR marked SATSTAR\n"); 39 39 } 40 40 source->type = PM_SOURCE_SATSTAR; … … 42 42 } 43 43 if (source->type == PM_SOURCE_SATSTAR) { 44 psLogMsg ("psphot", 4, "SATSTAR marked GOODSTAR (fitted peak below saturation)\n");44 psLogMsg ("psphot", 5, "SATSTAR marked GOODSTAR (fitted peak below saturation)\n"); 45 45 source->type = PM_SOURCE_GOODSTAR; 46 46 } … … 70 70 71 71 if (source->type == PM_SOURCE_PSFSTAR) { 72 psLogMsg ("psphot", 3, "PSFSTAR demoted based on fit quality\n");72 psLogMsg ("psphot", 5, "PSFSTAR demoted based on fit quality\n"); 73 73 } 74 74 -
trunk/psphot/src/psphotOutput.c
r5049 r5058 2 2 3 3 // output functions: we have several fixed modes (sx, obj, cmp) 4 void psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources ) {4 void psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 5 5 6 6 bool status; … … 21 21 } 22 22 if (!strcasecmp (outputMode, "TEXT")) { 23 pmSourcesWriteText (imdata, outputFile, sources );23 pmSourcesWriteText (imdata, outputFile, sources, psf, sky); 24 24 return; 25 25 } 26 26 27 27 if (!strcasecmp (outputMode, "OBJ")) { 28 pmSourcesWriteOBJ (imdata, outputFile, sources );28 pmSourcesWriteOBJ (imdata, outputFile, sources, psf, sky); 29 29 return; 30 30 } 31 31 32 32 if (!strcasecmp (outputMode, "SX")) { 33 pmSourcesWriteSX (imdata, outputFile, sources );33 pmSourcesWriteSX (imdata, outputFile, sources, psf, sky); 34 34 return; 35 35 } 36 36 37 37 if (!strcasecmp (outputMode, "CMP")) { 38 pmSourcesWriteCMP (imdata, outputFile, sources );38 pmSourcesWriteCMP (imdata, outputFile, sources, psf, sky); 39 39 return; 40 40 } 41 41 42 42 if (!strcasecmp (outputMode, "CMF")) { 43 pmSourcesWriteCMF (imdata, outputFile, sources );43 pmSourcesWriteCMF (imdata, outputFile, sources, psf, sky); 44 44 return; 45 45 } … … 47 47 } 48 48 49 bool pmSourcesWriteText (eamReadout *imdata, char *filename, psArray *sources ) {49 bool pmSourcesWriteText (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *sky) { 50 50 51 51 char *name = (char *) psAlloc (strlen(filename) + 10); … … 68 68 69 69 // dophot-style output list with fixed line width 70 bool pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources ) {70 bool pmSourcesWriteOBJ (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 71 71 72 72 int i, type, status; 73 73 pmModel *model; 74 74 psF32 *PAR, *dPAR; 75 float sky , dmag, apMag, fitMag;75 float skyFlux, dmag, apMag, fitMag; 76 76 77 77 psLine *line = psLineAlloc (104); // 104 is dophot-defined line length … … 118 118 119 119 // save local sky for later 120 sky = model->params->data.F32[0];120 skyFlux = model->params->data.F32[0]; 121 121 122 122 // replace source flux … … 124 124 model->params->data.F32[0] = 0; 125 125 pmSourceAddModel (source->pixels, source->mask, model, false); 126 model->params->data.F32[0] = sky ;126 model->params->data.F32[0] = skyFlux; 127 127 128 128 // measure object photometry 129 129 status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask); 130 fitMag += psf->ApResid; 130 131 131 132 // subtract object, leave local sky … … 133 134 model->params->data.F32[0] = 0; 134 135 pmSourceSubModel (source->pixels, source->mask, model, false); 135 model->params->data.F32[0] = sky ;136 model->params->data.F32[0] = skyFlux; 136 137 137 138 if (status == FALSE) continue; … … 159 160 160 161 // elixir/sextractor-style output list with fixed line width 161 bool pmSourcesWriteSX (eamReadout *imdata, char *filename, psArray *sources ) {162 bool pmSourcesWriteSX (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 162 163 163 164 int i, status, flags; … … 224 225 // measure object photometry 225 226 status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask); 227 fitMag += psf->ApResid; 226 228 227 229 // subtract object, leave local sky … … 257 259 258 260 // elixir-style pseudo FITS table (header + ascii list) 259 bool pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources ) {261 bool pmSourcesWriteCMP (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 260 262 261 263 int i, type, status; … … 328 330 // measure object photometry 329 331 status = pmSourcePhotometry (&fitMag, &apMag, model, source->pixels, source->mask); 332 fitMag += psf->ApResid; 330 333 331 334 // subtract object, leave local sky … … 360 363 361 364 // elixir-style FITS table output (header + table in 1st extension) 362 bool pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources ) {365 bool pmSourcesWriteCMF (eamReadout *imdata, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) { 363 366 364 367 // write imdata->header to file -
trunk/psphot/src/psphotSetup.c
r5049 r5058 28 28 psFits *file = psFitsAlloc (input); 29 29 header = psFitsReadHeader (header, file); 30 image = psFitsReadImage (NULL, file, region, 0); 30 psImage *tmpimage = psFitsReadImage (NULL, file, region, 0); 31 image = psImageCopy (NULL, tmpimage, PS_TYPE_F32); 31 32 psFree (file); 33 32 34 // psFree (input); 33 35 // XXX EAM - does the current API expect to get a copy or a view? … … 90 92 } 91 93 92 psLogMsg ("psphot", 3, "load data: %f sec\n", psTimerMark ("psphot"));94 psLogMsg ("psphot", 4, "load data: %f sec\n", psTimerMark ("psphot")); 93 95 94 96 // save the image data & return it -
trunk/psphot/src/psphotSourceStats.c
r5049 r5058 47 47 } 48 48 49 psLogMsg ("psphot", 3, "moments: %f sec\n", psTimerMark ("psphot")); 50 psLogMsg ("psphot", 3, "%d sources\n", sources->n); 51 49 psLogMsg ("psphot", 3, "%d moments: %f sec\n", sources->n, psTimerMark ("psphot")); 52 50 return (sources); 53 51 }
Note:
See TracChangeset
for help on using the changeset viewer.
