- Timestamp:
- Sep 27, 2009, 10:40:16 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psModules/src/objects/pmPSFtryFitPSF.c
r25526 r25596 1 /** @file pmPSFtry.c 2 * 3 * XXX: need description of file purpose 1 /** @file pmPSFtryFitPSF.c 2 * @brief Fit the PSF model to the candidate PSF stars (part of PSF model generation) 4 3 * 5 4 * @author EAM, IfA … … 8 7 * @date $Date: 2009-01-27 06:39:38 $ 9 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 10 *11 9 */ 12 10 … … 48 46 maskVal |= markVal; 49 47 48 // DEBUG code: save the PSF model fit data in detail 49 # ifdef DEBUG 50 char filename[64]; 51 snprintf (filename, 64, "psffit.%dx%d.dat", psfTry->psf->trendNx, psfTry->psf->trendNy); 52 FILE *f = fopen (filename, "w"); 53 psAssert (f, "failed open"); 54 # endif 55 50 56 int Npsf = 0; 51 57 for (int i = 0; i < psfTry->sources->n; i++) { … … 80 86 // skip poor fits 81 87 if (!status) { 82 psImage KeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal));88 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 83 89 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL; 84 90 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y); … … 87 93 88 94 // set object mask to define valid pixels for APERTURE magnitude 89 if (options->fitRadius < options->apRadius) { 90 // this is not really a recommended situation... 91 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal)); 92 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal); 93 } 94 if (options->fitRadius > options->apRadius) { 95 // ensure the aperture is defined 95 if (options->fitRadius != options->apRadius) { 96 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 96 97 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal); 97 98 } 98 99 99 100 // This function calculates the psf and aperture magnitudes 100 status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal); 101 status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal); // raw PSF mag, AP mag 101 102 if (!status || isnan(source->apMag)) { 102 psImage KeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "AND", PS_NOT_IMAGE_MASK(markVal));103 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 103 104 psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT; 104 105 psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y); … … 107 108 108 109 // clear object mask to define valid pixels 109 psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "AND", PS_NOT_IMAGE_MASK(markVal)); 110 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask 110 111 111 112 psfTry->fitMag->data.F32[i] = source->psfMag; 112 // psfTry->metric->data.F32[i] = -2.5*log10(source->moments->Sum) - source->psfMag;113 113 psfTry->metric->data.F32[i] = source->apMag - source->psfMag; 114 114 psfTry->metricErr->data.F32[i] = source->errMag; 115 116 // XXX this did not work: modifies shape of psf too much 117 // psfTry->metric->data.F32[i] = -2.5*log10(source->moments->Sum) - source->psfMag; 118 119 # ifdef DEBUG 120 fprintf (f, "%6.1f %6.1f : %6.1f %6.1f : %8.3f %8.3f %8.3f : %f : %f %f %f : %f\n", 121 source->peak->xf, source->peak->yf, 122 source->modelPSF->params->data.F32[PM_PAR_XPOS], source->modelPSF->params->data.F32[PM_PAR_YPOS], 123 source->psfMag, source->apMag, source->errMag, 124 source->modelPSF->params->data.F32[PM_PAR_I0], 125 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY], 126 source->modelPSF->params->data.F32[PM_PAR_SYY], source->modelPSF->params->data.F32[PM_PAR_7]); 127 # endif 115 128 116 129 psTrace ("psModules.object", 6, "keeping source %d (%d) of %ld\n", i, Npsf, psfTry->sources->n); … … 119 132 psfTry->psf->nPSFstars = Npsf; 120 133 121 // XXX test code: 134 # ifdef DEBUG 135 fclose (f); 136 # endif 137 122 138 pmSourceVisualShowModelFits (psfTry->psf, psfTry->sources, maskVal); 123 139
Note:
See TracChangeset
for help on using the changeset viewer.
