Changeset 27838 for branches/tap_branches/pswarp/src/pswarp.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pswarp/src/pswarp.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/pswarp/src/pswarp.c
r23195 r27838 11 11 */ 12 12 13 # include "pswarp.h" 14 15 static void usage (void) { 16 fprintf(stderr, "USAGE: pswarp [-file image(s)] [-list imagelist] [options] (output) (skycell)\n"); 17 fprintf(stderr, " options:\n"); 18 fprintf(stderr, " [-astrom astrom.cmp] : provide an alternative astrometry calibration\n"); 19 fprintf(stderr, " [-mask mask.fits] : provide a corresponding mask image\n"); 20 fprintf(stderr, " [-variance variance.fits] : provide a corresponding variance image\n"); 21 psErrorStackPrint(stderr, "\n"); 22 exit (2); 23 } 13 #include "pswarp.h" 14 #include "pswarpFileNames.h" 24 15 25 16 int main (int argc, char **argv) … … 28 19 29 20 psLibInit(NULL); 30 31 // model inits are needed in pmSourceIO32 // models defined in psphot/src/models are not available in psastro33 21 pmModelClassInit(); 34 35 // init various psphot pieces (errors, models, threads)36 22 psphotInit(); 37 23 24 const char *statsName = NULL; // Filename for statistics 25 psMetadata *stats = NULL; // Container for statistics 26 FILE *statsFile = NULL; // File stream for statistics 27 38 28 pmConfig *config = pswarpArguments(argc, argv); 39 if (!config) usage(); 29 if (!config) { 30 goto DIE; 31 } 40 32 41 33 pswarpVersionPrint(); … … 43 35 // load identify the data sources 44 36 if (!pswarpParseCamera(config)) { 45 psErrorStackPrint(stderr, "error setting up the camera\n"); 46 exit(PS_EXIT_CONFIG_ERROR); 37 goto DIE; 47 38 } 48 39 49 40 if (!pswarpOptions(config)) { 50 psErrorStackPrint(stderr, "error parsing options\n"); 51 exit(PS_EXIT_SYS_ERROR); 41 goto DIE; 52 42 } 53 43 54 44 // load the skycell layout information 55 45 if (!pswarpDefine(config)) { 56 psErrorStackPrint(stderr, "error loading output definition\n"); 57 exit(PS_EXIT_CONFIG_ERROR); 46 goto DIE; 47 } 48 49 // Open the statistics file 50 bool mdok; ///< Status of MD lookup 51 statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); ///< Filename for statistics 52 if (mdok && statsName && strlen(statsName) > 0) { 53 psString resolved = pmConfigConvertFilename(statsName, config, true, true); 54 statsFile = fopen(resolved, "w"); 55 if (!statsFile) { 56 psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved); 57 psFree(resolved); 58 goto DIE; 59 } 60 psFree(resolved); 61 stats = psMetadataAlloc(); 62 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", 0, "No problems", 0); 58 63 } 59 64 60 65 // load and warp 61 if (!pswarpLoop(config)) { 62 psErrorStackPrint(stderr, "error warping data\n"); 63 exit(PS_EXIT_DATA_ERROR); 66 if (!pswarpLoop(config, stats)) { 67 goto DIE; 64 68 } 65 69 66 psLogMsg("pswarp", 3, "complete pswarp run: %f sec\n", psTimerMark("pswarp")); 67 pswarpCleanup(config); 68 psLibFinalize(); 69 exit(PS_EXIT_SUCCESS); 70 psLogMsg("pswarp", PS_LOG_INFO, "complete pswarp run: %f sec\n", psTimerMark("pswarp")); 71 72 DIE: 73 { 74 psExit exitValue = pswarpExitCode(PS_EXIT_SUCCESS); // Exit code 75 76 // Ensure everything is written out, at every level 77 pswarpFileActivation(config, detectorFiles, true); 78 pswarpFileActivation(config, skycellFiles, true); 79 pswarpFileActivation(config, photFiles, true); 80 pswarpFileActivation(config, independentFiles, true); 81 if (!pswarpIOChecksAfter(config)) { 82 psError(psErrorCodeLast(), false, "Unable to write files."); 83 exitValue = pswarpExitCode(exitValue); 84 pmFPAfileFreeSetStrict(false); 85 } 86 87 // Write out summary statistics 88 if (stats) { 89 psMetadataAddF32(stats, PS_LIST_TAIL, "DT_WARP", 0, "Time for warp completion", 90 psTimerMark("pswarp")); 91 92 const char *statsMDC = psMetadataConfigFormat(stats); 93 if (!statsMDC) { 94 psError(psErrorCodeLast(), false, "Unable to get statistics file."); 95 exitValue = pswarpExitCode(exitValue); 96 } 97 psFree(stats); 98 if (fprintf(statsFile, "%s", statsMDC) != strlen(statsMDC)) { 99 psError(PSWARP_ERR_IO, true, "Unable to write statistics file."); 100 exitValue = pswarpExitCode(exitValue); 101 } 102 psFree(statsMDC); 103 if (fclose(statsFile) == EOF) { 104 psError(PSWARP_ERR_IO, true, "Unable to close statistics file."); 105 exitValue = pswarpExitCode(exitValue); 106 } 107 pmConfigRunFilenameAddWrite(config, "STATS", statsName); 108 } 109 110 // Dump configuration 111 psString dump_file = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); 112 if (dump_file) { 113 if (!pmConfigDump(config, dump_file)) { 114 psError(psErrorCodeLast(), false, "Unable to dump configuration"); 115 exitValue = pswarpExitCode(exitValue); 116 } 117 } 118 119 psThreadPoolFinalize(); 120 psMemCheckCorruption(stderr, true); 121 122 psFree(config); 123 124 psTimerStop(); 125 pmVisualClose(); 126 pmModelClassCleanup(); 127 pmConceptsDone(); 128 pmConfigDone(); 129 psLibFinalize(); 130 131 exitValue = pswarpExitCode(exitValue); 132 return exitValue; 133 } 70 134 }
Note:
See TracChangeset
for help on using the changeset viewer.
