- Timestamp:
- Jan 22, 2010, 5:32:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.
