Changeset 23199 for branches/cnb_branches/cnb_branch_20090215/ppStack
- Timestamp:
- Mar 5, 2009, 11:24:29 AM (18 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090215
- Files:
-
- 11 edited
-
. (modified) (1 prop)
-
ppStack/src/Makefile.am (modified) (1 diff)
-
ppStack/src/ppStack.c (modified) (1 diff)
-
ppStack/src/ppStack.h (modified) (4 diffs)
-
ppStack/src/ppStackArguments.c (modified) (1 diff)
-
ppStack/src/ppStackLoop.c (modified) (13 diffs)
-
ppStack/src/ppStackPSF.c (modified) (2 diffs)
-
ppStack/src/ppStackPhotometry.c (modified) (1 diff)
-
ppStack/src/ppStackSources.c (modified) (5 diffs)
-
ppStack/src/ppStackThread.c (modified) (1 diff)
-
ppStack/src/ppStackVersion.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090215
- Property svn:mergeinfo changed
/trunk merged: 22727-22752,23115-23126,23128,23137-23157,23159-23174,23182-23195,23198
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090215/ppStack/src/Makefile.am
r19337 r23199 1 1 bin_PROGRAMS = ppStack 2 2 3 ppStack_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) 3 PPSTACK_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 PPSTACK_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 PPSTACK_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 7 # Force recompilation of ppStackVersion.c, since it gets the version information 8 ppStackVersion.c: FORCE 9 touch ppStackVersion.c 10 FORCE: ; 11 12 ppStack_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS) -DPPSTACK_VERSION=\"$(PPSTACK_VERSION)\" -DPPSTACK_BRANCH=\"$(PPSTACK_BRANCH)\" -DPPSTACK_SOURCE=\"$(PPSTACK_SOURCE)\" 4 13 ppStack_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS) $(PPSTATS_LIBS) $(PPSTACK_LIBS) 5 14 -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStack.c
r21536 r23199 33 33 goto die; 34 34 } 35 36 ppStackVersionPrint(); 35 37 36 38 if (!pmModelClassInit()) { -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStack.h
r21477 r23199 10 10 // Mask values for inputs 11 11 typedef enum { 12 PPSTACK_MASK_MATCH = 0x01, // PSF-matching failed 13 PPSTACK_MASK_CHI2 = 0x02, // Chi^2 too deviant 14 PPSTACK_MASK_REJECT = 0x04, // Rejection failed 15 PPSTACK_MASK_BAD = 0x08, // Bad image (too many pixels rejected) 12 PPSTACK_MASK_CAL = 0x01, // Photometric calibration failed 13 PPSTACK_MASK_MATCH = 0x02, // PSF-matching failed 14 PPSTACK_MASK_CHI2 = 0x04, // Chi^2 too deviant 15 PPSTACK_MASK_REJECT = 0x08, // Rejection failed 16 PPSTACK_MASK_BAD = 0x10, // Bad image (too many pixels rejected) 16 17 PPSTACK_MASK_ALL = 0xff // All errors 17 18 } ppStackMask; … … 81 82 pmPSF *ppStackPSF(const pmConfig *config, // Configuration 82 83 int numCols, int numRows, // Size of image 83 const psArray *psfs // List of input PSFs 84 const psArray *psfs, // List of input PSFs 85 const psVector *inputMask // Mask for inputs 84 86 ); 85 87 … … 134 136 psString ppStackVersion(void); 135 137 138 /// Return software source 139 psString ppStackSource(void); 140 136 141 // Return long description of software version 137 142 psString ppStackVersionLong(void); 138 143 139 // Supplement metadatawith software version140 void ppStackVersionMetadata(psMetadata *metadata // Metadatato supplement144 // Supplement header with software version 145 bool ppStackVersionHeader(psMetadata *header // Header to supplement 141 146 ); 147 148 /// Print version information 149 void ppStackVersionPrint(void); 142 150 143 151 /// Convolve image to match specified seeing … … 158 166 /// Corrects the source PSF photometry to a common system. Return the sum of the exposure times. 159 167 float ppStackSourcesTransparency(const psArray *sourceLists, // Sources for each input 168 psVector *inputMask, // Indicates bad input 160 169 const pmFPAview *view, // View to readout 161 170 const pmConfig *config // Configuration -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c
r22722 r23199 294 294 if (dump_file) { 295 295 pmConfigCamerasCull(config, NULL); 296 pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS ");296 pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS,JPEG"); 297 297 298 298 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSTACK.INPUT"); // Input file -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackLoop.c
r22214 r23199 257 257 pmPSF *targetPSF = NULL; // Target PSF 258 258 float sumExposure = NAN; // Sum of exposure times 259 psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs 260 psVectorInit(inputMask, 0); 259 261 if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) { 260 262 pmFPAfileActivate(config->files, false, NULL); … … 283 285 psFree(fileIter); 284 286 psFree(psfs); 287 psFree(inputMask); 285 288 return false; 286 289 } … … 299 302 psFree(fileIter); 300 303 psFree(psfs); 304 psFree(inputMask); 301 305 return false; 302 306 } … … 324 328 psFree(sourceLists); 325 329 psFree(targetPSF); 326 return false; 330 psFree(inputMask); 331 return false; 327 332 } 328 333 … … 333 338 psFree(sourceLists); 334 339 psFree(targetPSF); 340 psFree(inputMask); 335 341 return false; 336 342 } … … 340 346 psFree(sourceLists); 341 347 psFree(targetPSF); 348 psFree(inputMask); 342 349 return false; 343 350 } … … 351 358 352 359 // Zero point calibration 353 sumExposure = ppStackSourcesTransparency(sourceLists, view, config);360 sumExposure = ppStackSourcesTransparency(sourceLists, inputMask, view, config); 354 361 if (!isfinite(sumExposure) || sumExposure <= 0) { 355 362 psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences"); 356 363 psFree(sourceLists); 357 364 psFree(targetPSF); 365 psFree(inputMask); 358 366 return false; 359 367 } 360 368 361 369 // Generate target PSF 362 targetPSF = ppStackPSF(config, numCols, numRows, psfs );370 targetPSF = ppStackPSF(config, numCols, numRows, psfs, inputMask); 363 371 psFree(psfs); 364 372 if (!targetPSF) { … … 366 374 psFree(sourceLists); 367 375 psFree(view); 376 psFree(inputMask); 368 377 return false; 369 378 } … … 409 418 int numGood = 0; // Number of good frames 410 419 int numCols = 0, numRows = 0; // Size of image 411 psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs412 psVectorInit(inputMask, 0);413 420 psVector *matchChi2 = psVectorAlloc(num, PS_TYPE_F32); // chi^2 for stamps when matching 414 421 psVectorInit(matchChi2, NAN); … … 419 426 psArray *covariances = psArrayAlloc(num); // Covariance matrices 420 427 for (int i = 0; i < num; i++) { 428 if (inputMask->data.U8[i]) { 429 continue; 430 } 421 431 psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num); 422 432 pmFPAfileActivate(config->files, false, NULL); … … 1168 1178 fileActivation(config, photFiles, true); 1169 1179 pmFPAview *photView = filesIterateDown(config); 1180 fileActivation(config, combineFiles, true); 1181 1170 1182 if (!ppStackPhotometry(config, outRO, photView)) { 1171 1183 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on output."); 1184 filesIterateUp(config); 1172 1185 psFree(outRO); 1173 1186 psFree(photView); … … 1175 1188 } 1176 1189 psFree(photView); 1177 1178 fileActivation(config, combineFiles, true);1179 1190 1180 1191 if (stats) { … … 1217 1228 hdu->header = psMetadataAlloc(); 1218 1229 } 1219 ppStackVersion Metadata(hdu->header);1230 ppStackVersionHeader(hdu->header); 1220 1231 1221 1232 psFree(outRO); -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackPSF.c
r18918 r23199 9 9 #include "ppStack.h" 10 10 11 pmPSF *ppStackPSF(const pmConfig *config, int numCols, int numRows, const psArray *psfs) 11 pmPSF *ppStackPSF(const pmConfig *config, int numCols, int numRows, 12 const psArray *psfs, const psVector *inputMask) 12 13 { 13 14 // Get the recipe values … … 19 20 const char *psfModel = psMetadataLookupStr(NULL, recipe, "PSF.MODEL"); // Model for PSF 20 21 int psfOrder = psMetadataLookupS32(NULL, recipe, "PSF.ORDER"); // Spatial order for PSF 22 23 for (int i = 0; i < psfs->n; i++) { 24 if (inputMask->data.U8[i]) { 25 psFree(psfs->data[i]); 26 psfs->data[i] = NULL; 27 } 28 } 21 29 22 30 // Solve for the target PSF -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackPhotometry.c
r21536 r23199 149 149 if (!psphotReadoutKnownSources(config, view, inSources)) { 150 150 // Clear the error, so that the output files are written. 151 psWarning("Unable to perform photometry on stacked image."); 152 psErrorStackPrint(stderr, "Error stack from photometry:"); 153 psErrorClear(); 151 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on stacked image."); 152 return false; 154 153 } 155 154 -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackSources.c
r21536 r23199 13 13 #define FAKE_ROWS 4913 14 14 15 float ppStackSourcesTransparency(const psArray *sourceLists, const pmFPAview *view, const pmConfig *config) 15 #ifdef TESTING 16 // Dump matches to a file 17 static void dumpMatches(const char *filename, // File to which to dump 18 int num, // Number of inputs 19 psArray *matches, // Star matches 20 psVector *zp, // Zero points 21 psVector *trans // Transparencies 22 ) 23 { 24 FILE *outMatches = fopen(filename, "w"); // Output matches 25 psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star 26 psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star 27 for (int i = 0; i < matches->n; i++) { 28 pmSourceMatch *match = matches->data[i]; // Match of interest 29 psVectorInit(mag, NAN); 30 psVectorInit(magErr, NAN); 31 for (int j = 0; j < match->num; j++) { 32 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 33 continue; 34 } 35 int index = match->image->data.U32[j]; // Image index 36 mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index]; 37 if (trans) { 38 mag->data.F32[index] -= trans->data.F32[index]; 39 } 40 magErr->data.F32[index] = match->magErr->data.F32[j]; 41 } 42 for (int j = 0; j < num; j++) { 43 fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]); 44 } 45 fprintf(outMatches, "\n"); 46 } 47 psFree(mag); 48 psFree(magErr); 49 fclose(outMatches); 50 return; 51 } 52 #endif 53 54 55 float ppStackSourcesTransparency(const psArray *sourceLists, psVector *inputMask, 56 const pmFPAview *view, const pmConfig *config) 16 57 { 17 58 PS_ASSERT_ARRAY_NON_NULL(sourceLists, NAN); 59 PS_ASSERT_VECTOR_NON_NULL(inputMask, NAN); 60 PS_ASSERT_VECTOR_TYPE(inputMask, PS_TYPE_U8, NAN); 61 PS_ASSERT_VECTOR_SIZE(inputMask, sourceLists->n, NAN); 18 62 PS_ASSERT_PTR_NON_NULL(view, NAN); 19 63 PS_ASSERT_PTR_NON_NULL(config, NAN); 20 64 21 #if def TESTING65 #if defined(TESTING) && 0 22 66 { 23 67 // Deliberately induce a major transparency difference … … 63 107 pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest 64 108 65 #if def TESTING109 #if defined(TESTING) && 0 66 110 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout 67 111 pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image … … 115 159 return NAN; 116 160 } 161 162 #ifdef TESTING 163 dumpMatches("source_match.dat", num, matches, zp, NULL); 164 #endif 165 117 166 psVector *trans = pmSourceMatchRelphot(matches, zp, iter, tol, starLimit, transIter, transRej, 118 167 transThresh, starRej, starSys); // Transparencies for each image 119 120 #ifdef TESTING 121 { 122 // Dump the corrected magnitudes 123 FILE *outMatches = fopen("source_match.dat", "w"); // Output matches 124 psVector *mag = psVectorAlloc(num, PS_TYPE_F32); // Magnitudes for each star 125 psVector *magErr = psVectorAlloc(num, PS_TYPE_F32); // Errors for each star 126 for (int i = 0; i < matches->n; i++) { 127 pmSourceMatch *match = matches->data[i]; // Match of interest 128 psVectorInit(mag, NAN); 129 psVectorInit(magErr, NAN); 130 for (int j = 0; j < match->num; j++) { 131 if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) { 132 continue; 133 } 134 int index = match->image->data.U32[j]; // Image index 135 mag->data.F32[index] = match->mag->data.F32[j] - zp->data.F32[index] - trans->data.F32[index]; 136 magErr->data.F32[index] = match->magErr->data.F32[j]; 137 } 138 for (int j = 0; j < num; j++) { 139 fprintf(outMatches, "%f (%f) ", mag->data.F32[j], magErr->data.F32[j]); 140 } 141 fprintf(outMatches, "\n"); 142 } 143 psFree(mag); 144 psFree(magErr); 145 fclose(outMatches); 146 } 147 #endif 168 if (!trans) { 169 psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies"); 170 return NAN; 171 } 172 173 #ifdef TESTING 174 dumpMatches("source_mags.dat", num, matches, zp, trans); 175 #endif 176 177 for (int i = 0; i < trans->n; i++) { 178 if (!isfinite(trans->data.F32[i])) { 179 inputMask->data.U8[i] = PPSTACK_MASK_CAL; 180 } 181 } 148 182 149 183 // Save best matches SOMEWHERE for future photometry … … 172 206 173 207 psFree(matches); 174 if (!trans) {175 psError(PS_ERR_UNKNOWN, false, "Unable to measure transparencies");176 return NAN;177 }178 208 179 209 // M = m + c0 + c1 * airmass - 2.5log(t) + transparency … … 183 213 // We don't need to know the magnitude zero point for the filter, since it cancels out 184 214 for (int i = 0; i < num; i++) { 215 if (!isfinite(trans->data.F32[i])) { 216 continue; 217 } 185 218 psArray *sources = sourceLists->data[i]; // Sources of interest 186 219 float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i]; -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackThread.c
r21477 r23199 36 36 psFree(stack->threads); 37 37 for (int i = 0; i < stack->imageFits->n; i++) { 38 psFitsClose(stack->imageFits->data[i]); 39 psFitsClose(stack->maskFits->data[i]); 40 psFitsClose(stack->varianceFits->data[i]); 38 if (stack->imageFits->data[i]) { 39 psFitsClose(stack->imageFits->data[i]); 40 } 41 if (stack->maskFits->data[i]) { 42 psFitsClose(stack->maskFits->data[i]); 43 } 44 if (stack->varianceFits->data[i]) { 45 psFitsClose(stack->varianceFits->data[i]); 46 } 41 47 stack->imageFits->data[i] = stack->maskFits->data[i] = stack->varianceFits->data[i] = NULL; 42 48 } -
branches/cnb_branches/cnb_branch_20090215/ppStack/src/ppStackVersion.c
r18419 r23199 7 7 #include <psmodules.h> 8 8 #include <ppStats.h> 9 #include <psphot.h> 9 10 10 11 #include "ppStack.h" 11 12 12 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name13 14 13 psString ppStackVersion(void) 15 14 { 16 psString version = NULL; // Version, to return 17 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 18 return version; 15 #ifndef PPSTACK_VERSION 16 #error "PPSTACK_VERSION is not set" 17 #endif 18 #ifndef PPSTACK_BRANCH 19 #error "PPSTACK_BRANCH is not set" 20 #endif 21 return psStringCopy(PPSTACK_BRANCH "@" PPSTACK_VERSION); 22 } 23 24 psString ppStackSource(void) 25 { 26 #ifndef PPSTACK_SOURCE 27 #error "PPSTACK_SOURCE is not set" 28 #endif 29 return psStringCopy(PPSTACK_SOURCE); 19 30 } 20 31 21 32 psString ppStackVersionLong(void) 22 33 { 23 psString version = ppStackVersion(); // Version, to return 24 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 25 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 26 psFree(tag); 34 psString version = ppStackVersion(); // Version, to return 35 psString source = ppStackSource(); // Source 36 37 psStringPrepend(&version, "ppStack "); 38 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 39 psFree(source); 40 41 #ifdef __OPTIMIZE__ 42 psStringAppend(&version, " optimised"); 43 #else 44 psStringAppend(&version, " unoptimised"); 45 #endif 46 27 47 return version; 28 } 48 }; 29 49 30 50 31 void ppStackVersionMetadata(psMetadata *metadata)51 bool ppStackVersionHeader(psMetadata *header) 32 52 { 33 PS_ASSERT_METADATA_NON_NULL(metadata,); 34 35 psString pslib = psLibVersionLong();// psLib version 36 psString psmodules = psModulesVersionLong(); // psModules version 37 psString ppStats = ppStatsVersionLong(); // ppStats version 38 psString ppStack = ppStackVersionLong(); // ppStack version 53 PS_ASSERT_METADATA_NON_NULL(header, false); 39 54 40 55 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 41 56 psString timeString = psTimeToISO(time); // The time in an ISO string 42 57 psFree(time); 43 psString head = NULL; // Head string 44 psStringAppend(&head, "ppStack processing at %s. Component information:", timeString); 58 psString history = NULL; // History string 59 psStringAppend(&history, "ppStack at %s", timeString); 60 psFree(timeString); 61 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 62 psFree(history); 63 64 psLibVersionHeader(header); 65 psModulesVersionHeader(header); 66 psphotVersionHeader(header); 67 ppStatsVersionHeader(header); 68 69 psString version = ppStackVersion(); // Software version 70 psString source = ppStackSource(); // Software source 71 72 psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTACK.VERSION", PS_META_REPLACE, 73 "Software version", version); 74 psMetadataAddStr(header, PS_LIST_TAIL, "IPP.PPSTACK.SOURCE", PS_META_REPLACE, 75 "S/W source", source); 76 77 psFree(version); 78 psFree(source); 79 80 return true; 81 } 82 83 void ppStackVersionPrint(void) 84 { 85 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 86 psString timeString = psTimeToISO(time); // The time in an ISO string 87 psFree(time); 88 psLogMsg("ppStack", PS_LOG_INFO, "ppStack at %s", timeString); 45 89 psFree(timeString); 46 90 47 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", head);48 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", pslib);49 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", psmodules);50 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStats);51 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, "", ppStack);91 psString pslib = psLibVersionLong();// psLib version 92 psString psmodules = psModulesVersionLong(); // psModules version 93 psString psphot = psphotVersionLong(); // psphot version 94 psString ppStats = ppStatsVersionLong(); // psastro version 95 psString ppStack = ppStackVersionLong(); // ppStack version 52 96 53 psFree(head); 97 psLogMsg("ppStack", PS_LOG_INFO, "%s", pslib); 98 psLogMsg("ppStack", PS_LOG_INFO, "%s", psmodules); 99 psLogMsg("ppStack", PS_LOG_INFO, "%s", psphot); 100 psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStats); 101 psLogMsg("ppStack", PS_LOG_INFO, "%s", ppStack); 102 54 103 psFree(pslib); 55 104 psFree(psmodules); 105 psFree(psphot); 56 106 psFree(ppStats); 57 107 psFree(ppStack);
Note:
See TracChangeset
for help on using the changeset viewer.
