- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ppStack/src (modified) (1 prop)
-
ppStack/src/ppStackFinish.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ppStack/src
- Property svn:ignore
-
old new 10 10 stamp-h1 11 11 ppStackVersionDefinitions.h 12 ppStackErrorCodes.c 13 ppStackErrorCodes.h
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/ppStack/src/ppStackFinish.c
r23753 r27840 4 4 5 5 #include <stdio.h> 6 #include <unistd.h> 6 7 #include <pslib.h> 7 8 #include <psmodules.h> 8 #include <p pStats.h>9 #include <psphot.h> 9 10 10 11 #include "ppStack.h" … … 21 22 psAssert(recipe, "We've thrown an error on this before."); 22 23 23 // Statistics on output 24 if (options->stats) { 25 psTrace("ppStack", 1, "Gathering statistics on stacked image....\n"); 26 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad 27 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 24 bool mdok; // Status of MD lookup 25 bool tempDelete = psMetadataLookupBool(&mdok, recipe, "TEMP.DELETE"); // Delete temporary files? 28 26 29 pmFPAview *view = pmFPAviewAlloc(0); // View to readout 30 view->chip = view->cell = view->readout = 0; 27 // Delete temporary images 28 if (tempDelete && options->convolve) { 29 for (int i = 0; i < options->num; i++) { 30 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 31 continue; 32 } 31 33 32 ppStatsFPA(options->stats, options->outRO->parent->parent->parent, view, maskBad, config); 33 34 psFree(view); 35 } 36 37 ppStackMemDump("stats"); 38 39 psFree(options->outRO); options->outRO = NULL; 40 41 // Write out the output files 42 if (!ppStackFilesIterateUp(config)) { 43 return false; 34 psString imageResolved = pmConfigConvertFilename(options->convImages->data[i], 35 config, false, false); 36 psString maskResolved = pmConfigConvertFilename(options->convMasks->data[i], 37 config, false, false); 38 psString varianceResolved = pmConfigConvertFilename(options->convVariances->data[i], 39 config, false, false); 40 if (unlink(imageResolved) == -1 || unlink(maskResolved) == -1 || 41 unlink(varianceResolved) == -1) { 42 psWarning("Unable to delete temporary files for image %d", i); 43 } 44 psFree(imageResolved); 45 psFree(maskResolved); 46 psFree(varianceResolved); 47 } 44 48 } 45 49 46 50 47 // Write out summary statistics 48 if (options->stats) { 49 psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_STACK", 0, 50 "Total time", psTimerClear("PPSTACK_TOTAL")); 51 return true; 52 } 51 53 52 const char *statsMDC = psMetadataConfigFormat(options->stats); 53 if (!statsMDC || strlen(statsMDC) == 0) { 54 psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n"); 55 } else { 56 fprintf(options->statsFile, "%s", statsMDC); 57 } 58 psFree((void *)statsMDC); 59 fclose(options->statsFile); options->statsFile = NULL; 60 pmConfigRunFilenameAddWrite(config, "STATS", psMetadataLookupStr(NULL, config->arguments, "STATS")); 54 55 psExit ppStackExitCode(psExit exitValue) 56 { 57 if (exitValue != PS_EXIT_SUCCESS) { 58 return exitValue; 61 59 } 62 60 63 64 // Dump configuration 65 bool mdok; // Status of MD lookup 66 psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config 67 if (dump) { 68 pmConfigDump(config, dump); 61 psErrorCode errorCode = psErrorCodeLast(); // Error code 62 if (errorCode != PS_ERR_NONE) { 63 psErrorStackPrint(stderr, "Unable to perform stack."); 64 switch (errorCode) { 65 case PPSTACK_ERR_UNKNOWN: 66 case PS_ERR_UNKNOWN: 67 psLogMsg("ppStack", PS_LOG_WARN, "Unknown error code: %x", errorCode); 68 exitValue = PS_EXIT_UNKNOWN_ERROR; 69 break; 70 case PS_ERR_IO: 71 case PS_ERR_DB_CLIENT: 72 case PS_ERR_DB_SERVER: 73 case PS_ERR_BAD_FITS: 74 case PS_ERR_OS_CALL_FAILED: 75 case PM_ERR_SYS: 76 case PPSTACK_ERR_IO: 77 psLogMsg("ppStack", PS_LOG_WARN, "I/O error code: %x", errorCode); 78 exitValue = PS_EXIT_SYS_ERROR; 79 break; 80 case PS_ERR_BAD_PARAMETER_VALUE: 81 case PS_ERR_BAD_PARAMETER_TYPE: 82 case PS_ERR_BAD_PARAMETER_NULL: 83 case PS_ERR_BAD_PARAMETER_SIZE: 84 case PPSTACK_ERR_ARGUMENTS: 85 case PPSTACK_ERR_CONFIG: 86 psLogMsg("ppStack", PS_LOG_WARN, "Configuration error code: %x", errorCode); 87 exitValue = PS_EXIT_CONFIG_ERROR; 88 break; 89 case PPSTACK_ERR_PSF: 90 case PSPHOT_ERR_PSF: 91 case PM_ERR_STAMPS: 92 case PM_ERR_SMALL_AREA: 93 case PPSTACK_ERR_REJECTED: 94 case PPSTACK_ERR_DATA: 95 psLogMsg("ppStack", PS_LOG_WARN, "Data error code: %x", errorCode); 96 exitValue = PS_EXIT_DATA_ERROR; 97 break; 98 case PS_ERR_UNEXPECTED_NULL: 99 case PS_ERR_PROGRAMMING: 100 case PPSTACK_ERR_NOT_IMPLEMENTED: 101 case PPSTACK_ERR_PROG: 102 psLogMsg("ppStack", PS_LOG_WARN, "Programming error code: %x", errorCode); 103 exitValue = PS_EXIT_PROG_ERROR; 104 break; 105 default: 106 // It's a programming error if we're not dealing with the error correctly 107 psLogMsg("ppStack", PS_LOG_WARN, "Unrecognised error code: %x", errorCode); 108 exitValue = PS_EXIT_PROG_ERROR; 109 break; 110 } 69 111 } 70 71 return true; 112 return exitValue; 72 113 }
Note:
See TracChangeset
for help on using the changeset viewer.
