Changeset 18346
- Timestamp:
- Jun 27, 2008, 12:05:30 PM (18 years ago)
- Location:
- trunk/ppStack/src
- Files:
-
- 1 added
- 6 edited
-
Makefile.am (modified) (1 diff)
-
ppStack.h (modified) (2 diffs)
-
ppStackArguments.c (modified) (3 diffs)
-
ppStackCamera.c (modified) (5 diffs)
-
ppStackLoop.c (modified) (8 diffs)
-
ppStackMatch.c (modified) (3 diffs)
-
ppStackSources.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/Makefile.am
r16605 r18346 13 13 ppStackPhotometry.c \ 14 14 ppStackVersion.c \ 15 ppStackMatch.c 15 ppStackMatch.c \ 16 ppStackSources.c 16 17 17 18 noinst_HEADERS = \ -
trunk/ppStack/src/ppStack.h
r17255 r18346 61 61 psArray **regions, // Array of regions used in each PSF matching, returned 62 62 psArray **kernels, // Array of kernels used in each PSF matching, returned 63 const p mReadout *sourcesRO, ///< Readout withsources63 const psArray *sources, ///< Array of sources 64 64 const pmPSF *psf, ///< Target PSF 65 65 psRandom *rng, ///< Random number generator … … 67 67 ); 68 68 69 70 /// Add sources to source lists, removing duplicates and solving for magnitude differences 71 /// 72 /// Returns the source lists. 73 psArray *ppStackSourceListAdd(psArray *lists, ///< List to which to add, or NULL 74 const pmReadout *inRO, ///< Readout containing the sources 75 const pmConfig *config ///< Configuration 76 ); 77 78 /// Combine source lists to yield a unique set of sources 79 /// 80 /// Returns the sources 81 psArray *ppStackSourceListCombine(psArray *lists, ///< Source lists 82 const pmConfig *config ///< Configuration 83 ); 84 85 69 86 #endif -
trunk/ppStack/src/ppStackArguments.c
r17255 r18346 24 24 "\tIMAGE(STR): Image filename\n" 25 25 "\tMASK(STR): Mask filename\n" 26 "\tWEIGHT(STR) Weight map filename\n" 27 "\tPSF(STR) PSF filename\n" 26 "\tWEIGHT(STR): Weight map filename\n" 27 "\tPSF(STR): PSF filename\n" 28 "\tSOURCES(STR): Sources filename\n" 28 29 "\tWEIGHTING(F32): Relative weighting to be applied\n", 29 30 program); … … 155 156 psMetadataAddBool(arguments, PS_LIST_TAIL, "-variance", 0, "Use variance for rejection?", false); 156 157 psMetadataAddBool(arguments, PS_LIST_TAIL, "-safe", 0, "Play safe with small numbers of pixels to combine?", false); 158 psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-radius", 0, "Source exclusion radius", NAN); 159 psMetadataAddS32(arguments, PS_LIST_TAIL, "-source-iter", 0, "Source clipping iterations", 0); 160 psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-rej", 0, "Source clipping rejection level", NAN); 161 psMetadataAddS32(arguments, PS_LIST_TAIL, "-source-min", 0, "Source minimum overlap", 0); 157 162 psMetadataAddBool(arguments, PS_LIST_TAIL, "-renorm", 0, "Renormalise variance maps?", false); 158 163 psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-mean", 0, "Statistic for mean in renormalisation", NULL); … … 203 208 VALUE_ARG_RECIPE_INT("-rows", "ROWS", S32, 0); 204 209 210 VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS", F32); 211 VALUE_ARG_RECIPE_INT("-source-iter", "SOURCE.ITER", S32, 0); 212 VALUE_ARG_RECIPE_FLOAT("-source-rej", "SOURCE.REJ", F32); 213 VALUE_ARG_RECIPE_INT("-source-min", "SOURCE.MIN", S32, 0); 214 205 215 VALUE_ARG_RECIPE_INT("-psf-instances", "PSF.INSTANCES", S32, 0); 206 216 VALUE_ARG_RECIPE_FLOAT("-psf-radius", "PSF.RADIUS", F32); -
trunk/ppStack/src/ppStackCamera.c
r17916 r18346 72 72 { 73 73 bool haveWeights = false; // Do we have weight maps? 74 bool havePSFs = false; // Do we have PSFs? 74 bool havePSFs = false; // Do we have PSFs? 75 bool haveSources = (bool)psMetadataLookup(config->arguments, "PPSTACK.SOURCES"); // Have global sources? 75 76 76 77 psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info … … 99 100 psString weight = psMetadataLookupStr(&mdok, input, "WEIGHT"); // Name of weight map 100 101 psString psf = psMetadataLookupStr(&mdok, input, "PSF"); // Name of PSF 102 psString sources = psMetadataLookupStr(&mdok, input, "SOURCES"); // Name of sources 101 103 102 104 float weighting = psMetadataLookupF32(&mdok, input, "WEIGHTING"); // Relative weighting … … 198 200 } 199 201 202 // Add the sources file 203 if (!haveSources) { 204 if (!sources || strlen(sources) == 0) { 205 if (havePSFs) { 206 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find SOURCES %d", i); 207 return false; 208 } 209 } else { 210 if (!havePSFs) { 211 psWarning("SOURCES provided without PSF --- ignoring."); 212 } else { 213 psArray *sourcesFiles = psArrayAlloc(1); // Array of filenames for this FPA 214 sourcesFiles->data[0] = psMemIncrRefCounter(sources); 215 psMetadataAddArray(config->arguments, PS_LIST_TAIL, "SOURCES.FILENAMES", PS_META_REPLACE, 216 "Filenames of SOURCES files", sourcesFiles); 217 psFree(sourcesFiles); 218 219 bool status; 220 pmFPAfile *sourcesFile = pmFPAfileBindFromArgs(&status, imageFile, config, 221 "PPSTACK.INPUT.SOURCES", 222 "SOURCES.FILENAMES"); 223 if (!status) { 224 psError(PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)", 225 i, sources); 226 return false; 227 } 228 if (sourcesFile->type != PM_FPA_FILE_CMF) { 229 psError(PS_ERR_IO, true, "PPSTACK.INPUT.SOURCES is not of type CMF"); 230 return false; 231 } 232 } 233 } 234 } 235 200 236 #if 0 201 237 // Output convolved files … … 238 274 psMetadataRemoveKey(config->arguments, "PSF.FILENAMES"); 239 275 } 276 if (psMetadataLookup(config->arguments, "SOURCES.FILENAMES")) { 277 psMetadataRemoveKey(config->arguments, "SOURCES.FILENAMES"); 278 } 279 280 if (haveSources) { 281 // Global list of sources for use as stamps 282 bool status = false; // Found the file? 283 if (havePSFs) { 284 pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSTACK.INPUT.SOURCES", 285 "PPSTACK.SOURCES"); 286 if (!status) { 287 psError(PS_ERR_IO, false, "Failed to load file definition PPSTACK.INPUT.SOURCES"); 288 return false; 289 } 290 if (sources && sources->type != PM_FPA_FILE_CMF) { 291 psError(PS_ERR_IO, true, "PPSTACK.SOURCES is not of type CMF"); 292 return false; 293 } 294 } 295 } 240 296 241 297 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INPUTS.NUM", 0, "Number of input files", i); 242 298 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "HAVE.PSF", 0, "Have PSFs available?", havePSFs); 299 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "HAVE.SOURCES", 0, "Have global sources?", 300 haveSources); 243 301 244 302 // Output image … … 326 384 } 327 385 328 // Sources for use as stamps329 bool status = false; // Found the file?330 if (havePSFs) {331 pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSTACK.SOURCES", "PPSTACK.SOURCES");332 if (!status) {333 psError(PS_ERR_IO, false, "Failed to load file definition PPSTACK.SOURCES");334 return false;335 }336 if (sources && sources->type != PM_FPA_FILE_CMF) {337 psError(PS_ERR_IO, true, "PPSTACK.SOURCES is not of type CMF");338 return false;339 }340 }341 342 386 return true; 343 387 } -
trunk/ppStack/src/ppStackLoop.c
r18168 r18346 17 17 18 18 // Files required in preparation for convolution 19 static char *prepareFiles[] = { "PPSTACK.INPUT.PSF", "PPSTACK. SOURCES", NULL };19 static char *prepareFiles[] = { "PPSTACK.INPUT.PSF", "PPSTACK.INPUT.SOURCES", NULL }; 20 20 21 21 // Files required for the convolution … … 213 213 // Preparation iteration: Load the sources, and get a target PSF model 214 214 psTrace("ppStack", 1, "Determining target PSF....\n"); 215 p mReadout *sources = NULL; // Readout with sources to use for PSF matching215 psArray *sources = NULL; // Sources to use for PSF matching 216 216 pmPSF *targetPSF = NULL; // Target PSF 217 bool haveSources = psMetadataLookupBool(NULL, config->arguments, "HAVE.SOURCES"); // Global sources? 217 218 if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) { 218 219 pmFPAfileActivate(config->files, false, NULL); … … 223 224 } 224 225 225 // We want to hang on to the 'sources' even when its host FPA is blown away226 sources = psMemIncrRefCounter(pmFPAfileThisReadout(config->files, view, "PPSTACK.SOURCES"));227 if (!sources) {228 psError(PS_ERR_UNKNOWN, true, "Unable to find sources.");229 psFree(view);230 return false;231 }232 233 226 // Generate list of PSFs 234 227 psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, … … 236 229 psMetadataItem *fileItem; // Item from iteration 237 230 psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope 231 psArray *sourceLists = NULL; // Source lists for merging sources from multiple readouts 238 232 int numCols = 0, numRows = 0; // Size of image 239 233 int index = 0; // Index for file … … 247 241 psFree(view); 248 242 psFree(sources); 243 psFree(sourceLists); 249 244 psFree(fileIter); 250 245 psFree(psfs); … … 263 258 psFree(view); 264 259 psFree(sources); 260 psFree(sourceLists); 265 261 psFree(fileIter); 266 262 psFree(psfs); … … 270 266 numCols = naxis1; 271 267 numRows = naxis2; 268 } 269 270 if (!haveSources) { 271 pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources 272 sourceLists = ppStackSourceListAdd(sourceLists, ro, config); 273 if (!sourceLists) { 274 psError(PS_ERR_UNKNOWN, false, "Unable to add sources to list."); 275 psFree(view); 276 psFree(sources); 277 psFree(fileIter); 278 psFree(psfs); 279 return false; 280 } 272 281 } 273 282 } … … 281 290 psFree(sources); 282 291 return false; 292 } 293 294 if (haveSources) { 295 // We want to hang on to the 'sources' even when its host FPA is blown away 296 sources = psMemIncrRefCounter(pmFPAfileThisReadout(config->files, view, "PPSTACK.INPUT.SOURCES")); 297 if (!sources) { 298 psError(PS_ERR_UNKNOWN, true, "Unable to find sources."); 299 psFree(view); 300 return false; 301 } 302 } else { 303 sources = ppStackSourceListCombine(sourceLists, config); 304 psFree(sourceLists); 305 if (!sources) { 306 psError(PS_ERR_UNKNOWN, false, "Unable to add sources to list."); 307 psFree(view); 308 psFree(psfs); 309 return false; 310 } 283 311 } 284 312 -
trunk/ppStack/src/ppStackMatch.c
r18293 r18346 16 16 17 17 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, 18 const p mReadout *sourcesRO, const pmPSF *psf, psRandom *rng, const pmConfig *config)18 const psArray *sources, const pmPSF *psf, psRandom *rng, const pmConfig *config) 19 19 { 20 20 assert(readout); … … 46 46 if (psMetadataLookupBool(&mdok, config->arguments, "HAVE.PSF")) { 47 47 assert(psf); 48 assert(sources RO);48 assert(sources); 49 49 50 50 int order = psMetadataLookupS32(NULL, recipe, "SPATIAL.ORDER"); // Spatial polynomial order … … 80 80 } 81 81 82 psArray *sources = NULL; // Sources in image83 if (sourcesRO) {84 sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");85 }86 87 82 // Generate a fake image to match to 88 83 float maxMag = -INFINITY; // Maximum magnitude of sources
Note:
See TracChangeset
for help on using the changeset viewer.
