Changeset 35563 for trunk/pswarp/src/pswarp.c
- Timestamp:
- May 9, 2013, 12:26:48 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/pswarp/src/pswarp.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarp.c
r34800 r35563 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 45 if (!pswarpDefine(config)) { 46 goto DIE; 47 } 48 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND.MODEL")) { 49 if (!pswarpDefineBackground(config)) { 50 goto DIE; 51 } 41 // load the input & output astrometry, find the output overlaps, generate the output pixels 42 if (!pswarpDefineLayout(config)) { 43 pswarpCleanup(config, statsFile); 52 44 } 53 45 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); 46 // load input pixels & and warp 47 if (!pswarpLoop(config, statsFile->md)) { 48 pswarpCleanup(config, statsFile); 68 49 } 69 50 70 // load and warp 71 if (!pswarpLoop(config, stats)) { 72 goto DIE; 73 } 74 if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND.MODEL")) { 75 if (!pswarpLoopBackground(config, stats)) { 76 fprintf(stderr,"Dying!\n"); 77 goto DIE; 78 } 51 // load input pixels & and warp 52 if (!pswarpLoopBackground(config, statsFile->md)) { 53 pswarpCleanup(config, statsFile); 79 54 } 80 55 56 // output and free 57 // NOTE: pswarpCleanup calls exit 81 58 psLogMsg("pswarp", PS_LOG_INFO, "complete pswarp run: %f sec\n", psTimerMark("pswarp")); 82 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 } 59 pswarpCleanup(config, statsFile); 145 60 }
Note:
See TracChangeset
for help on using the changeset viewer.
