Changeset 35421 for branches/eam_branches/ipp-20130419/pswarp/src/pswarp.c
- Timestamp:
- Apr 19, 2013, 4:45:57 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130419
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pswarp/src/pswarp.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130419
-
branches/eam_branches/ipp-20130419/pswarp/src/pswarp.c
r34800 r35421 12 12 13 13 #include "pswarp.h" 14 #include "pswarpFileNames.h"15 14 16 15 int main (int argc, char **argv) … … 22 21 psphotInit(); 23 22 24 const char *statsName = NULL; // Filename for statistics25 psMetadata *stats = NULL; // Container for statistics26 FILE *statsFile = NULL; // File stream for statistics27 28 23 pmConfig *config = pswarpArguments(argc, argv); 29 24 if (!config) { 30 goto DIE;25 pswarpCleanup(config, NULL); 31 26 } 27 28 pswarpStatsFile *statsFile = pswarpStatsFileOpen (config); 32 29 33 30 pswarpVersionPrint(); … … 35 32 // load identify the data sources 36 33 if (!pswarpParseCamera(config)) { 37 goto DIE;34 pswarpCleanup(config, statsFile); 38 35 } 39 36 40 37 if (!pswarpOptions(config)) { 41 goto DIE;38 pswarpCleanup(config, statsFile); 42 39 } 43 40 44 // load the skycell layout information 41 // load the skycell layout information: 42 // read the output astrometry description 43 // generate the output pixels 44 // convert header astrometry to pmFPA astrometry structures 45 45 if (!pswarpDefine(config)) { 46 goto DIE;46 pswarpCleanup(config, statsFile); 47 47 } 48 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND.MODEL")) { 49 if (!pswarpDefineBackground(config)) { 50 goto DIE; 51 } 52 } 53 54 // Open the statistics file 55 bool mdok; ///< Status of MD lookup 56 statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); ///< Filename for statistics 57 if (mdok && statsName && strlen(statsName) > 0) { 58 psString resolved = pmConfigConvertFilename(statsName, config, true, true); 59 statsFile = fopen(resolved, "w"); 60 if (!statsFile) { 61 psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved); 62 psFree(resolved); 63 goto DIE; 64 } 65 psFree(resolved); 66 stats = psMetadataAlloc(); 67 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", 0, "No problems", 0); 48 if (!pswarpDefineBackground(config)) { 49 pswarpCleanup(config, statsFile); 68 50 } 69 51 70 52 // load and warp 71 if (!pswarpLoop(config, stats )) {72 goto DIE;53 if (!pswarpLoop(config, statsFile->md)) { 54 pswarpCleanup(config, statsFile); 73 55 } 74 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND.MODEL")) { 75 if (!pswarpLoopBackground(config, stats)) { 56 if (!pswarpLoopBackground(config, statsFile->md)) { 76 57 fprintf(stderr,"Dying!\n"); 77 goto DIE; 78 } 58 pswarpCleanup(config, statsFile); 79 59 } 80 60 81 61 psLogMsg("pswarp", PS_LOG_INFO, "complete pswarp run: %f sec\n", psTimerMark("pswarp")); 62 pswarpCleanup(config, statsFile); 63 } 82 64 83 DIE: 84 { 85 psExit exitValue = pswarpExitCode(PS_EXIT_SUCCESS); // Exit code 86 87 // Ensure everything is written out, at every level 88 pswarpFileActivation(config, detectorFiles, true); 89 pswarpFileActivation(config, skycellFiles, true); 90 pswarpFileActivation(config, photFiles, true); 91 pswarpFileActivation(config, independentFiles, true); 92 if (!pswarpIOChecksAfter(config)) { 93 psError(psErrorCodeLast(), false, "Unable to write files."); 94 exitValue = pswarpExitCode(exitValue); 95 pmFPAfileFreeSetStrict(false); 96 } 97 98 // Write out summary statistics 99 if (stats && statsFile) { 100 psMetadataAddF32(stats, PS_LIST_TAIL, "DT_WARP", 0, "Time for warp completion", 101 psTimerMark("pswarp")); 102 103 const char *statsMDC = psMetadataConfigFormat(stats); 104 if (!statsMDC) { 105 psError(psErrorCodeLast(), false, "Unable to get statistics file."); 106 exitValue = pswarpExitCode(exitValue); 107 } 108 psFree(stats); 109 if (fprintf(statsFile, "%s", statsMDC) != strlen(statsMDC)) { 110 psError(PSWARP_ERR_IO, true, "Unable to write statistics file."); 111 exitValue = pswarpExitCode(exitValue); 112 } 113 psFree(statsMDC); 114 if (fclose(statsFile) == EOF) { 115 psError(PSWARP_ERR_IO, true, "Unable to close statistics file."); 116 exitValue = pswarpExitCode(exitValue); 117 } 118 pmConfigRunFilenameAddWrite(config, "STATS", statsName); 119 } 120 121 // Dump configuration 122 psString dump_file = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); 123 if (dump_file) { 124 if (!pmConfigDump(config, dump_file)) { 125 psError(psErrorCodeLast(), false, "Unable to dump configuration"); 126 exitValue = pswarpExitCode(exitValue); 127 } 128 } 129 130 psThreadPoolFinalize(); 131 psMemCheckCorruption(stderr, true); 132 133 psFree(config); 134 135 psTimerStop(); 136 pmVisualClose(); 137 pmModelClassCleanup(); 138 pmConceptsDone(); 139 pmConfigDone(); 140 psLibFinalize(); 141 142 exitValue = pswarpExitCode(exitValue); 143 return exitValue; 144 } 145 } 65 // NOTE: pswarpCleanup calls exit
Note:
See TracChangeset
for help on using the changeset viewer.
