Changeset 26674
- Timestamp:
- Jan 22, 2010, 5:32:32 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/ppStack/src
- Files:
-
- 7 edited
-
ppStackMatch.c (modified) (1 diff)
-
ppStackOptions.c (modified) (3 diffs)
-
ppStackOptions.h (modified) (2 diffs)
-
ppStackPhotometry.c (modified) (2 diffs)
-
ppStackReadout.c (modified) (2 diffs)
-
ppStackSetup.c (modified) (1 diff)
-
ppStackSources.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ppStack/src/ppStackMatch.c
r26671 r26674 317 317 float poorFrac = psMetadataLookupF32(&mdok, ppsub, "POOR.FRACTION"); // Fraction for "poor" 318 318 319 bool scale = psMetadataLookupBool(NULL, recipe, "SCALE"); // Scale kernel parameters?320 float scaleRef = psMetadataLookupF32(NULL, recipe, "SCALE.REF"); // Reference for scaling321 float scaleMin = psMetadataLookupF32(NULL, recipe, "SCALE.MIN"); // Minimum for scaling322 float scaleMax = psMetadataLookupF32(NULL, recipe, "SCALE.MAX"); // Maximum for scaling319 bool scale = psMetadataLookupBool(NULL, ppsub, "SCALE"); // Scale kernel parameters? 320 float scaleRef = psMetadataLookupF32(NULL, ppsub, "SCALE.REF"); // Reference for scaling 321 float scaleMin = psMetadataLookupF32(NULL, ppsub, "SCALE.MIN"); // Minimum for scaling 322 float scaleMax = psMetadataLookupF32(NULL, ppsub, "SCALE.MAX"); // Maximum for scaling 323 323 if (!isfinite(scaleRef) || !isfinite(scaleMin) || !isfinite(scaleMax)) { 324 324 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 325 "Scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in recipe.",325 "Scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in PPSUB recipe.", 326 326 scaleRef, scaleMin, scaleMax); 327 327 return false; -
branches/eam_branches/20091201/ppStack/src/ppStackOptions.c
r26671 r26674 24 24 psFree(options->sourceLists); 25 25 psFree(options->norm); 26 psFree(options->sources); 26 27 psFree(options->cells); 27 28 psFree(options->kernels); … … 44 45 options->convolve = true; 45 46 options->matchZPs = true; 47 options->photometry = false; 46 48 options->stats = NULL; 47 49 options->statsFile = NULL; … … 60 62 options->sourceLists = NULL; 61 63 options->norm = NULL; 64 options->sources = NULL; 62 65 options->cells = NULL; 63 66 options->kernels = NULL; -
branches/eam_branches/20091201/ppStack/src/ppStackOptions.h
r26671 r26674 10 10 bool convolve; // Convolve images? 11 11 bool matchZPs; // Adjust relative fluxes based on transparency analysis? 12 bool photometry; // Perform photometry? 12 13 psMetadata *stats; // Statistics for output 13 14 FILE *statsFile; // File to which to write statistics … … 24 25 psArray *sourceLists; // Individual lists of sources for matching 25 26 psVector *norm; // Normalisation for each image 27 psArray *sources; // Matched sources 26 28 // Convolve 27 29 psArray *cells; // Cells for convolved images --- a handle for reading again -
branches/eam_branches/20091201/ppStack/src/ppStackPhotometry.c
r24216 r26674 19 19 psAssert(recipe, "We've thrown an error on this before."); 20 20 21 bool mdok; // Status of MD lookup 22 if (!psMetadataLookupBool(&mdok, recipe, "PHOTOMETRY")) { 21 if (!options->photometry) { 23 22 // Nothing to do 24 23 return true; … … 60 59 "Bits to use for mark", markValue); 61 60 62 pmCell *sourcesCell = pmFPAfileThisCell(config->files, photView, "PPSTACK.OUTPUT"); 63 psArray *inSources = psMetadataLookupPtr(NULL, sourcesCell->analysis, "PSPHOT.SOURCES"); 61 psArray *inSources = options->sources; 64 62 if (!inSources) { 65 63 psError(PS_ERR_UNKNOWN, false, "Unable to find input sources"); -
branches/eam_branches/20091201/ppStack/src/ppStackReadout.c
r26475 r26674 126 126 int kernelSize = psMetadataLookupS32(NULL, ppsub, "KERNEL.SIZE"); // Kernel half-size 127 127 128 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK. IN"); // Name of bits to mask going in128 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in 129 129 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch 130 130 psString maskSuspectStr = psMetadataLookupStr(NULL, recipe, "MASK.SUSPECT"); // Name of suspect mask bits … … 219 219 bool safe = psMetadataLookupBool(&mdok, recipe, "SAFE"); // Be safe when combining small numbers of pixels 220 220 221 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK. IN"); // Name of bits to mask going in221 psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in 222 222 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch 223 223 psString maskSuspectStr = psMetadataLookupStr(NULL, recipe, "MASK.SUSPECT"); // Name of suspect mask bits -
branches/eam_branches/20091201/ppStack/src/ppStackSetup.c
r26475 r26674 22 22 psAssert(recipe, "We've thrown an error on this before."); 23 23 24 options->matchZPs = psMetadataLookupBool(NULL, recipe, "MATCH.ZERO.POINTS"); // Adjust zero points based on tranparency analysis? 24 options->matchZPs = psMetadataLookupBool(NULL, recipe, "ZP"); // Adjust zero points? 25 26 options->photometry = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY"); // Perform photometry? 25 27 26 28 options->convolve = psMetadataLookupBool(NULL, recipe, "CONVOLVE"); // Convolve images? -
branches/eam_branches/20091201/ppStack/src/ppStackSources.c
r26475 r26674 61 61 PS_ASSERT_PTR_NON_NULL(config, false); 62 62 63 if (!options->matchZPs ) {64 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs65 options->norm = psVectorAlloc(num, PS_TYPE_F32);66 psVectorInit (options->norm, 0.0);67 68 // XXX do I need to set this?69 // options->sumExposure = sumExpTime;70 71 return true;63 if (!options->matchZPs && !options->photometry) { 64 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs 65 options->norm = psVectorAlloc(num, PS_TYPE_F32); 66 psVectorInit (options->norm, 0.0); 67 68 // XXX do I need to set this? 69 // options->sumExposure = sumExpTime; 70 71 return true; 72 72 } 73 73 … … 191 191 #endif 192 192 193 psVector *trans = pmSourceMatchRelphot(matches, zp, tol, iter1, starRej1, starSys1, 194 iter2, starRej2, starSys2, starLimit, 195 transIter, transRej, transThresh); // Transparencies for each image 196 if (!trans) { 197 psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies"); 198 return false; 199 } 193 if (options->matchZPs) { 194 psVector *trans = pmSourceMatchRelphot(matches, zp, tol, iter1, starRej1, starSys1, 195 iter2, starRej2, starSys2, starLimit, 196 transIter, transRej, transThresh); // Transparencies per image 197 if (!trans) { 198 psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies"); 199 return false; 200 } 201 for (int i = 0; i < trans->n; i++) { 202 if (!isfinite(trans->data.F32[i])) { 203 inputMask->data.U8[i] |= PPSTACK_MASK_CAL; 204 } 205 } 206 // M = m + c0 + c1 * airmass - 2.5log(t) + transparency 207 // Want sources to have m corresponding to airmass = 1 and t = sumExpTime and transparency = 0 208 // m_0 + c1 * airmass_0 + 2.5log(t_0) - trans_0 = m_1 + c1 * airmass_1 + 2.5log(t_1) - trans_1 209 // m_0 = m_1 + zp_1 + trans_1 - c1 * airmass_0 - 2.5log(t_0) 210 // We don't need to know the magnitude zero point for the filter, since it cancels out 211 if (options->matchZPs) { 212 options->norm = psVectorAlloc(num, PS_TYPE_F32); 213 for (int i = 0; i < num; i++) { 214 if (!isfinite(trans->data.F32[i])) { 215 continue; 216 } 217 psArray *sources = sourceLists->data[i]; // Sources of interest 218 float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i]; 219 options->norm->data.F32[i] = magCorr; 220 psLogMsg("ppStack", PS_LOG_INFO, "Applying magnitude correction to image %d: %f\n", 221 i, magCorr); 222 223 for (int j = 0; j < sources->n; j++) { 224 pmSource *source = sources->data[j]; // Source of interest 225 if (!source) { 226 continue; 227 } 228 source->psfMag += magCorr; 229 } 230 } 231 } 232 233 #ifdef TESTING 234 dumpMatches("source_mags.dat", num, matches, zp, trans); 235 #endif 236 psFree(trans); 237 238 #ifdef TESTING 239 // Double check: all transparencies should be zero 240 { 241 psArray *matches = pmSourceMatchSources(sourceLists, radius); // List of matches 242 if (!matches) { 243 psError(PS_ERR_UNKNOWN, false, "Unable to match sources"); 244 psFree(zp); 245 return false; 246 } 247 psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej, 248 transThresh, starRej, starSys); 249 for (int i = 0; i < num; i++) { 250 fprintf(stderr, "Transparency of image %d: %f\n", i, trans->data.F32[i]); 251 } 252 psFree(trans); 253 } 254 #endif 255 } 256 200 257 201 258 #if 0 … … 216 273 #endif 217 274 218 #ifdef TESTING 219 dumpMatches("source_mags.dat", num, matches, zp, trans); 220 #endif 221 222 for (int i = 0; i < trans->n; i++) { 223 if (!isfinite(trans->data.F32[i])) { 224 inputMask->data.U8[i] |= PPSTACK_MASK_CAL; 225 } 226 } 227 228 // Save best matches SOMEWHERE for future photometry 229 // XXX this is a really poor output location; clean up the pmFPAfiles used in ppStack 230 pmCell *sourcesCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); 231 psArray *sourcesBest = psArrayAllocEmpty(matches->n); 232 233 // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible 234 int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required 235 for (int i = 0; i < matches->n; i++) { 236 pmSourceMatch *match = matches->data[i]; // Match of interest 237 if (match->num < minMatches) { 238 continue; 239 } 240 241 // We need to grab a single instance of this source: just take the first available 242 int image = match->image->data.S32[0]; // Index of image 243 int index = match->index->data.S32[0]; // Index of source within image 244 psArray *sources = sourceLists->data[image]; // Sources for image 245 pmSource *source = sources->data[index]; // Source of interest 246 247 psArrayAdd(sourcesBest, sourcesBest->n, source); 248 } 249 psMetadataAdd(sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, 250 "psphot sources", sourcesBest); 251 psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n); 252 psFree(sourcesBest); 275 if (options->photometry) { 276 // Save best matches for future photometry 277 psArray *sourcesBest = options->sources = psArrayAllocEmpty(matches->n); 278 279 // XXX something of a hack: require at least 2 detections or the nominated fraction of the max possible 280 int minMatches = PS_MAX(2, fracMatch * num);// Minimum number of matches required 281 for (int i = 0; i < matches->n; i++) { 282 pmSourceMatch *match = matches->data[i]; // Match of interest 283 if (match->num < minMatches) { 284 continue; 285 } 286 287 // We need to grab a single instance of this source: just take the first available 288 int image = match->image->data.S32[0]; // Index of image 289 int index = match->index->data.S32[0]; // Index of source within image 290 psArray *sources = sourceLists->data[image]; // Sources for image 291 pmSource *source = sources->data[index]; // Source of interest 292 293 psArrayAdd(sourcesBest, sourcesBest->n, source); 294 } 295 psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis", sourcesBest->n); 296 } 253 297 254 298 psFree(matches); 255 256 // M = m + c0 + c1 * airmass - 2.5log(t) + transparency257 // Want sources to have m corresponding to airmass = 1 and t = sumExpTime and transparency = 0258 // m_0 + c1 * airmass_0 + 2.5log(t_0) - trans_0 = m_1 + c1 * airmass_1 + 2.5log(t_1) - trans_1259 // m_0 = m_1 + zp_1 + trans_1 - c1 * airmass_0 - 2.5log(t_0)260 // We don't need to know the magnitude zero point for the filter, since it cancels out261 options->norm = psVectorAlloc(num, PS_TYPE_F32);262 for (int i = 0; i < num; i++) {263 if (!isfinite(trans->data.F32[i])) {264 continue;265 }266 psArray *sources = sourceLists->data[i]; // Sources of interest267 float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i];268 options->norm->data.F32[i] = magCorr;269 psLogMsg("ppStack", PS_LOG_INFO, "Applying magnitude correction to image %d: %f\n", i, magCorr);270 271 for (int j = 0; j < sources->n; j++) {272 pmSource *source = sources->data[j]; // Source of interest273 if (!source) {274 continue;275 }276 source->psfMag += magCorr;277 }278 }279 psFree(trans);280 281 #ifdef TESTING282 // Double check: all transparencies should be zero283 {284 psArray *matches = pmSourceMatchSources(sourceLists, radius); // List of matches285 if (!matches) {286 psError(PS_ERR_UNKNOWN, false, "Unable to match sources");287 psFree(zp);288 return false;289 }290 psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej,291 transThresh, starRej, starSys);292 for (int i = 0; i < num; i++) {293 fprintf(stderr, "Transparency of image %d: %f\n", i, trans->data.F32[i]);294 }295 psFree(trans);296 }297 #endif298 299 299 300 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
