Changeset 16946
- Timestamp:
- Mar 12, 2008, 10:30:21 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotChoosePSF.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotChoosePSF.c
r16908 r16946 22 22 pmPSFOptions *options = pmPSFOptionsAlloc (); 23 23 24 // load user options from the recipe. no need to check existence -- they are 24 // load user options from the recipe. no need to check existence -- they are 25 25 // array to store candidate PSF stars 26 26 int NSTARS = psMetadataLookupS32 (&status, recipe, "PSF_MAX_NSTARS"); … … 49 49 options->psfTrendMode = pmTrend2DModeFromString (psMetadataLookupStr (&status, recipe, "PSF.TREND.MODE")); 50 50 assert (status); 51 51 52 52 options->psfTrendNx = psMetadataLookupS32 (&status, recipe, "PSF.TREND.NX"); 53 53 assert (status); … … 101 101 } else { 102 102 if (item->type != PS_DATA_METADATA_MULTI) psAbort("missing PSF_MODEL selection"); 103 modelNames = psListToArray (item->data.list);103 modelNames = psListToArray (item->data.list); 104 104 } 105 105 106 106 // generate a psf model using the first selection 107 107 if (stars->n == 0) { 108 // XXX optionally give up here 109 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 110 psErrorStackPrint (stderr, "Using guess PSF model"); 111 psErrorClear (); 112 113 // unset the PSFSTAR flags (none are used): 114 for (int i = 0; i < sources->n; i++) { 115 pmSource *source = sources->data[i]; 116 source->mode &= ~PM_SOURCE_MODE_PSFSTAR; 117 } 118 119 // XXX set sxx, etc from FWHM in recipe 120 pmPSF *psf = pmPSFBuildSimple (modelNames->data[0], 1.0, 1.0, 0.0, 1.0); 121 psf->fieldNx = readout->image->numCols; 122 psf->fieldNy = readout->image->numRows; 123 psFree (modelNames); 124 125 bool status = true; 126 status &= psphotMakeFluxScale (readout->image, recipe, psf); 127 status &= psphotPSFstats (readout, recipe, psf); 128 if (!status) { 129 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 130 psFree (psf); 131 return NULL; 132 } 133 134 // XXX set DSX_MEAN, etc? 108 // XXX optionally give up here 109 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 110 psErrorStackPrint (stderr, "Using guess PSF model"); 111 psErrorClear (); 112 113 psFree(options); 114 115 // unset the PSFSTAR flags (none are used): 116 for (int i = 0; i < sources->n; i++) { 117 pmSource *source = sources->data[i]; 118 source->mode &= ~PM_SOURCE_MODE_PSFSTAR; 119 } 120 121 // XXX set sxx, etc from FWHM in recipe 122 pmPSF *psf = pmPSFBuildSimple (modelNames->data[0], 1.0, 1.0, 0.0, 1.0); 123 psf->fieldNx = readout->image->numCols; 124 psf->fieldNy = readout->image->numRows; 125 psFree (modelNames); 126 127 bool status = true; 128 status &= psphotMakeFluxScale (readout->image, recipe, psf); 129 status &= psphotPSFstats (readout, recipe, psf); 130 if (!status) { 131 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 132 psFree (psf); 133 return NULL; 134 } 135 136 // XXX set DSX_MEAN, etc? 135 137 return psf; 136 138 } … … 171 173 if (bestN < 0) { 172 174 psFree (models); 173 psFree (stars); 174 175 // XXX optionally give up here 176 // generate a psf model using the first selection 177 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 178 psErrorStackPrint (stderr, "Using guess PSF model"); 179 psErrorClear (); 180 181 // unset the PSFSTAR flags (none are used): 182 for (int i = 0; i < sources->n; i++) { 183 pmSource *source = sources->data[i]; 184 source->mode &= ~PM_SOURCE_MODE_PSFSTAR; 185 } 186 187 // XXX set sxx, etc from FWHM in recipe 188 pmPSF *psf = pmPSFBuildSimple (modelNames->data[0], 1.0, 1.0, 0.0, 1.0); 189 psf->fieldNx = readout->image->numCols; 190 psf->fieldNy = readout->image->numRows; 191 psFree (modelNames); 192 193 bool status = true; 194 status &= psphotMakeFluxScale (readout->image, recipe, psf); 195 status &= psphotPSFstats (readout, recipe, psf); 196 if (!status) { 197 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 198 psFree (psf); 199 return NULL; 200 } 201 202 // XXX set DSX_MEAN, etc? 175 psFree (stars); 176 177 // XXX optionally give up here 178 // generate a psf model using the first selection 179 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 180 psErrorStackPrint (stderr, "Using guess PSF model"); 181 psErrorClear (); 182 183 psFree(options); 184 185 // unset the PSFSTAR flags (none are used): 186 for (int i = 0; i < sources->n; i++) { 187 pmSource *source = sources->data[i]; 188 source->mode &= ~PM_SOURCE_MODE_PSFSTAR; 189 } 190 191 // XXX set sxx, etc from FWHM in recipe 192 pmPSF *psf = pmPSFBuildSimple (modelNames->data[0], 1.0, 1.0, 0.0, 1.0); 193 psf->fieldNx = readout->image->numCols; 194 psf->fieldNy = readout->image->numRows; 195 psFree (modelNames); 196 197 bool status = true; 198 status &= psphotMakeFluxScale (readout->image, recipe, psf); 199 status &= psphotPSFstats (readout, recipe, psf); 200 if (!status) { 201 psError(PSPHOT_ERR_PSF, false, "Failed to fit any models when choosing PSF"); 202 psFree (psf); 203 return NULL; 204 } 205 206 // XXX set DSX_MEAN, etc? 203 207 return psf; 204 208 } … … 280 284 psError(PSPHOT_ERR_PSF, false, "Unable to construct residual table for PSF"); 281 285 psFree (models); 286 psFree(options); 282 287 return NULL; 283 288 } … … 287 292 psError(PSPHOT_ERR_PSF, false, "Unable to construct flux scale for PSF"); 288 293 psFree (models); 294 psFree(options); 289 295 return NULL; 290 296 } … … 354 360 pmSourcesWritePSFs (try->sources, "psfstars.dat"); 355 361 pmSourcesWriteEXTs (try->sources, "extstars.dat", false); 356 // XXX need alternative output function362 // XXX need alternative output function 357 363 // psMetadata *psfData = pmPSFtoMetadata (NULL, try->psf); 358 364 // psMetadataConfigWrite (psfData, "psfmodel.dat"); … … 369 375 if (!psphotPSFstats (readout, recipe, psf)) { 370 376 psError(PSPHOT_ERR_PSF, false, "cannot measure PSF shape terms"); 377 psFree(options); 371 378 psFree(psf); 372 379 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
