Changeset 23573 for trunk/ppStack/src/ppStackPrepare.c
- Timestamp:
- Mar 27, 2009, 11:49:17 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackPrepare.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackPrepare.c
r23341 r23573 127 127 psVectorInit(options->inputMask, 0); 128 128 129 if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {130 pmFPAfileActivate(config->files, false, NULL);131 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true);132 pmFPAview *view = ppStackFilesIterateDown(config);133 if (!view) {134 return false;135 } 136 137 // Generate list of PSFs138 psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD,139 "^PPSTACK.INPUT$"); // Iterator140 psMetadataItem *fileItem; // Item from iteration141 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope142 int numCols = 0, numRows = 0; // Size of image143 int index = 0; // Index forfile144 while ((fileItem = psMetadataGetAndIncrement(fileIter))) { 145 assert(fileItem->type == PS_DATA_UNKNOWN);146 pmFPAfile *inputFile = fileItem->data.V; // An input file129 pmFPAfileActivate(config->files, false, NULL); 130 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 131 pmFPAview *view = ppStackFilesIterateDown(config); 132 if (!view) { 133 return false; 134 } 135 136 psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, "^PPSTACK.INPUT$"); 137 psMetadataItem *fileItem; // Item from iteration 138 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope 139 int numCols = 0, numRows = 0; // Size of image 140 int index = 0; // Index for file 141 while ((fileItem = psMetadataGetAndIncrement(fileIter))) { 142 assert(fileItem->type == PS_DATA_UNKNOWN); 143 pmFPAfile *inputFile = fileItem->data.V; // An input file 144 145 // Get list of PSFs, to determine target PSF 146 if (options->convolve) { 147 147 pmChip *chip = pmFPAviewThisChip(view, inputFile->fpa); // The chip: holds the PSF 148 148 pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF … … 173 173 numRows = naxis2; 174 174 } 175 176 pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources 177 psArray *sources = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.SOURCES"); // Sources 178 if (!sources) { 179 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find sources in readout."); 180 return NULL; 181 } 182 options->sourceLists->data[index] = psMemIncrRefCounter(sources); 183 184 // Re-do photometry if we don't trust the source lists 185 if (psMetadataLookupBool(NULL, recipe, "PHOT")) { 186 psTrace("ppStack", 2, "Photometering input %d of %d....\n", index, num); 187 pmFPAfileActivate(config->files, false, NULL); 188 ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, index); 189 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", index); // File 190 pmFPAview *photView = ppStackFilesIterateDown(config); 191 if (!photView) { 192 psFree(view); 193 return false; 194 } 195 196 pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout of interest 197 198 if (!ppStackInputPhotometer(ro, sources, config)) { 199 psError(PS_ERR_UNKNOWN, false, "Unable to do photometry on input sources"); 200 psFree(view); 201 psFree(photView); 202 return false; 203 } 204 175 } 176 177 178 pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources 179 psArray *sources = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.SOURCES"); // Sources 180 if (!sources) { 181 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find sources in readout."); 182 return NULL; 183 } 184 options->sourceLists->data[index] = psMemIncrRefCounter(sources); 185 186 // Re-do photometry if we don't trust the source lists 187 if (psMetadataLookupBool(NULL, recipe, "PHOT")) { 188 psTrace("ppStack", 2, "Photometering input %d of %d....\n", index, num); 189 pmFPAfileActivate(config->files, false, NULL); 190 ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, index); 191 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", index); // File 192 pmFPAview *photView = ppStackFilesIterateDown(config); 193 if (!photView) { 194 psFree(view); 195 return false; 196 } 197 198 pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout of interest 199 200 if (!ppStackInputPhotometer(ro, sources, config)) { 201 psError(PS_ERR_UNKNOWN, false, "Unable to do photometry on input sources"); 202 psFree(view); 205 203 psFree(photView); 206 if (!ppStackFilesIterateUp(config)) { 207 psFree(view); 208 return false; 209 } 210 pmFPAfileActivate(config->files, false, NULL); 211 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 212 } 213 214 index++; 215 } 216 psFree(fileIter); 217 218 // Zero point calibration 219 options->sumExposure = ppStackSourcesTransparency(options->sourceLists, options->inputMask, 220 view, config); 221 if (!isfinite(options->sumExposure) || options->sumExposure <= 0) { 222 psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences"); 223 psFree(view); 224 return false; 225 } 226 227 // Generate target PSF 204 return false; 205 } 206 207 psFree(photView); 208 if (!ppStackFilesIterateUp(config)) { 209 psFree(view); 210 return false; 211 } 212 pmFPAfileActivate(config->files, false, NULL); 213 ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true); 214 } 215 216 index++; 217 } 218 psFree(fileIter); 219 220 // Generate target PSF 221 if (options->convolve) { 228 222 options->psf = ppStackPSF(config, numCols, numRows, psfs, options->inputMask); 229 223 psFree(psfs); … … 240 234 "Target PSF", options->psf); 241 235 outChip->data_exists = true; 242 236 } 237 238 // Zero point calibration 239 if (!ppStackSourcesTransparency(options, view, config)) { 240 psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences"); 243 241 psFree(view); 244 245 if (!ppStackFilesIterateUp(config)) { 246 return false; 247 } 242 return false; 243 } 244 psFree(view); 245 246 if (!ppStackFilesIterateUp(config)) { 247 return false; 248 248 } 249 249
Note:
See TracChangeset
for help on using the changeset viewer.
