Changeset 18865
- Timestamp:
- Aug 1, 2008, 2:50:07 PM (18 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 2 edited
-
psphotChoosePSF.c (modified) (3 diffs)
-
psphotReadout.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotChoosePSF.c
r18582 r18865 64 64 assert (status); 65 65 66 // XXX ROBUST seems to be too agressive given the small numbers. 66 // XXX ROBUST seems to be too agressive given the small numbers. 67 67 // options->stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 68 68 options->stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); … … 74 74 options->psfFieldYo = readout->image->row0; 75 75 76 pmSourceFitModelInit (15, 0.01, PS_SQR(SKY_SIG), options->poissonErrorsPhotLMM); 76 int fitIter = psMetadataLookupS32(&status, recipe, "PSF_FIT_ITER"); // Maximum number of fit iterations 77 if (!status || fitIter <= 0) { 78 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSF_FIT_ITER is not positive"); 79 return false; 80 } 81 float fitTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_TOL"); // Fit tolerance 82 if (!status || !isfinite(fitTol) || fitTol <= 0) { 83 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSF_FIT_TOL is not positive"); 84 return false; 85 } 86 pmSourceFitModelInit(fitIter, fitTol, PS_SQR(SKY_SIG), options->poissonErrorsPhotLMM); 77 87 78 88 psArray *stars = psArrayAllocEmpty (sources->n); … … 188 198 bool mdok; // Status of MD lookup 189 199 if (!psMetadataLookupBool(&mdok, recipe, PSPHOT_RECIPE_PSF_FAKE_ALLOW)) { 190 psFree (modelNames);191 psFree(options);200 psFree (modelNames); 201 psFree(options); 192 202 return NULL; 193 203 } 194 204 195 205 // generate a psf model using the first selection 196 psLogMsg ("psphot.pspsf", PS_LOG_INFO, "Using guess PSF model");206 psLogMsg ("psphot.pspsf", PS_LOG_INFO, "Using guess PSF model"); 197 207 198 208 // unset the PSFSTAR flags (none are used): -
trunk/psphot/src/psphotReadout.c
r18834 r18865 62 62 return psphotReadoutCleanup (config, readout, recipe, detections, psf, NULL); 63 63 } 64 64 65 65 // XXX test write out the footprint image 66 66 if (0) { 67 psImage *footprintImage = pmSetFootprintArrayIDs (detections->footprints, true);68 psphotSaveImage (NULL, footprintImage, "footprints.1.fits");69 psFree (footprintImage);67 psImage *footprintImage = pmSetFootprintArrayIDs (detections->footprints, true); 68 psphotSaveImage (NULL, footprintImage, "footprints.1.fits"); 69 psFree (footprintImage); 70 70 } 71 71 … … 112 112 } 113 113 114 // Define source fitting parameters for everything that follows PSF fits 115 // This allows different parameters to be used from the PSF fitting 116 { 117 bool status = true; // Status of MD lookup 118 int fitIter = psMetadataLookupS32(&status, recipe, "EXT_FIT_ITER"); // Max number of fit iterations 119 if (!status || fitIter <= 0) { 120 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "EXT_FIT_ITER is not positive"); 121 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 122 } 123 float fitTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_TOL"); // Fit tolerance 124 if (!status || !isfinite(fitTol) || fitTol <= 0) { 125 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "EXT_FIT_TOL is not positive"); 126 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 127 } 128 bool poisson = psMetadataLookupBool(&status, recipe, "POISSON.ERRORS.PHOT.LMM"); // Poisson errors? 129 if (!status) { 130 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "POISSON.ERRORS.PHOT.LMM is not defined"); 131 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 132 } 133 float skySig = psMetadataLookupF32(&status, recipe, "SKY_SIG"); 134 if (!status || !isfinite(skySig) || skySig <= 0) { 135 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "SKY_SIG is not positive"); 136 return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources); 137 } 138 pmSourceFitModelInit(fitIter, fitTol, PS_SQR(skySig), poisson); 139 } 140 114 141 // include externally-supplied sources 115 142 psphotLoadExtSources (config, view, sources); … … 124 151 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); 125 152 126 if (0) { 127 FILE *out = fopen ("out.pass1.dat", "w");128 129 for (int i = 0; i < sources->n; i++) {130 pmSource *source = sources->data[i];131 if (!source) continue;132 pmPeak *peak = source->peak;133 if (!peak) continue;134 pmModel *model = source->modelPSF;135 if (!model) continue;136 if (!model->params) continue;137 138 fprintf (out, "%d %f %f %f %f %f %f\n", 139 i, peak->xf, peak->yf, peak->flux, peak->SN,140 model->params->data.F32[PM_PAR_I0],141 model->dparams->data.F32[PM_PAR_I0]);142 }143 fclose (out);153 if (0) { 154 FILE *out = fopen ("out.pass1.dat", "w"); 155 156 for (int i = 0; i < sources->n; i++) { 157 pmSource *source = sources->data[i]; 158 if (!source) continue; 159 pmPeak *peak = source->peak; 160 if (!peak) continue; 161 pmModel *model = source->modelPSF; 162 if (!model) continue; 163 if (!model->params) continue; 164 165 fprintf (out, "%d %f %f %f %f %f %f\n", 166 i, peak->xf, peak->yf, peak->flux, peak->SN, 167 model->params->data.F32[PM_PAR_I0], 168 model->dparams->data.F32[PM_PAR_I0]); 169 } 170 fclose (out); 144 171 } 145 172 … … 178 205 // XXX test write out the footprint image 179 206 if (0) { 180 psImage *footprintImage = pmSetFootprintArrayIDs (detections->footprints, true);181 psphotSaveImage (NULL, footprintImage, "footprints.2.fits");182 psFree (footprintImage);207 psImage *footprintImage = pmSetFootprintArrayIDs (detections->footprints, true); 208 psphotSaveImage (NULL, footprintImage, "footprints.2.fits"); 209 psFree (footprintImage); 183 210 } 184 211 … … 208 235 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE); 209 236 210 if (0) { 211 FILE *out = fopen ("out.pass2.dat", "w");212 213 for (int i = 0; i < sources->n; i++) {214 pmSource *source = sources->data[i];215 if (!source) continue;216 pmPeak *peak = source->peak;217 if (!peak) continue;218 pmModel *model = source->modelPSF;219 if (!model) continue;220 if (!model->params) continue;221 222 fprintf (out, "%d %f %f %f %f %f %f\n", 223 i, peak->xf, peak->yf, peak->flux, peak->SN,224 model->params->data.F32[PM_PAR_I0],225 model->dparams->data.F32[PM_PAR_I0]);226 }227 fclose (out);237 if (0) { 238 FILE *out = fopen ("out.pass2.dat", "w"); 239 240 for (int i = 0; i < sources->n; i++) { 241 pmSource *source = sources->data[i]; 242 if (!source) continue; 243 pmPeak *peak = source->peak; 244 if (!peak) continue; 245 pmModel *model = source->modelPSF; 246 if (!model) continue; 247 if (!model->params) continue; 248 249 fprintf (out, "%d %f %f %f %f %f %f\n", 250 i, peak->xf, peak->yf, peak->flux, peak->SN, 251 model->params->data.F32[PM_PAR_I0], 252 model->dparams->data.F32[PM_PAR_I0]); 253 } 254 fclose (out); 228 255 } 229 256 … … 234 261 235 262 if (0) { 236 psphotSaveImage (NULL, readout->mask, "mask.fits");237 } 238 263 psphotSaveImage (NULL, readout->mask, "mask.fits"); 264 } 265 239 266 psphotExtendedSourceAnalysis (readout, sources, recipe); 240 267 … … 243 270 finish: 244 271 245 // plot positive sources 246 // psphotSourcePlots (readout, sources, recipe); 272 // plot positive sources 273 // psphotSourcePlots (readout, sources, recipe); 247 274 248 275 // measure aperture photometry corrections
Note:
See TracChangeset
for help on using the changeset viewer.
