Changeset 23638
- Timestamp:
- Mar 31, 2009, 2:49:55 PM (17 years ago)
- Location:
- branches/pap/psastro/src
- Files:
-
- 5 edited
-
psastro.c (modified) (4 diffs)
-
psastro.h (modified) (2 diffs)
-
psastroAnalysis.c (modified) (3 diffs)
-
psastroDataSave.c (modified) (2 diffs)
-
psastroMetadataStats.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psastro/src/psastro.c
r23195 r23638 13 13 # include "psastroStandAlone.h" 14 14 15 static void usage (void) {16 fprintf (stderr, "USAGE: psastro [-file image(s)] [-list imagelist] (output)\n");17 exit (2);15 static void usage(void) { 16 fprintf(stderr, "USAGE: psastro [-file image(s)] [-list imagelist] (output)\n"); 17 exit(PS_EXIT_CONFIG_ERROR); 18 18 } 19 19 20 int main (int argc, char **argv) { 21 22 pmConfig *config = NULL; 23 20 int main (int argc, char **argv) 21 { 24 22 psTimerStart ("complete"); 25 23 … … 28 26 // model inits are needed in pmSourceIO 29 27 // models defined in psphot/src/models are not available in psastro 30 pmModelClassInit ();28 pmModelClassInit(); 31 29 32 30 // load configuration information 33 config = psastroArguments (argc, argv); 34 if (!config) usage (); 31 pmConfig *config = config = psastroArguments(argc, argv); 32 if (!config) { 33 usage(); 34 } 35 35 36 36 psastroVersionPrint(); … … 39 39 if (!psastroParseCamera (config)) { 40 40 psErrorStackPrint(stderr, "error setting up the camera\n"); 41 exit (1); 41 psFree(config); 42 exit(PS_EXIT_CONFIG_ERROR); 42 43 } 43 44 … … 46 47 if (!psastroDataLoad (config)) { 47 48 psErrorStackPrint(stderr, "error loading input data\n"); 48 exit (1); 49 psFree(config); 50 exit(PS_EXIT_DATA_ERROR); 49 51 } 50 52 53 psMetadata *stats = psMetadataAlloc(); // Statistics, for output 54 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", 0, "No problems", 0); 55 51 56 // run the full astrometry analysis (chip and/or mosaic) 52 if (!psastroAnalysis (config)) {57 if (!psastroAnalysis(config, stats)) { 53 58 psErrorStackPrint(stderr, "failure in psastro analysis\n"); 54 exit (1); 59 psFree(config); 60 psFree(stats); 61 exit(PS_EXIT_SYS_ERROR); 55 62 } 56 63 57 64 // write out the results 58 if (!psastroDataSave (config)) {65 if (!psastroDataSave(config, stats)) { 59 66 psErrorStackPrint(stderr, "failed to write out data\n"); 60 exit (1); 67 psFree(config); 68 psFree(stats); 69 exit(PS_EXIT_DATA_ERROR); 61 70 } 62 71 63 ps LogMsg ("psastro", 3, "complete psastro run: %f sec\n", psTimerMark ("complete"));72 psFree(stats); 64 73 65 psastroCleanup (config); 66 exit (EXIT_SUCCESS); 74 psLogMsg("psastro", 3, "complete psastro run: %f sec\n", psTimerMark ("complete")); 75 76 psastroCleanup(config); 77 exit(PS_EXIT_SUCCESS); 67 78 } -
branches/pap/psastro/src/psastro.h
r23494 r23638 46 46 #endif 47 47 48 bool psastroDataSave (pmConfig *config );48 bool psastroDataSave (pmConfig *config, psMetadata *stats); 49 49 bool psastroDefineFiles (pmConfig *config, pmFPAfile *input); 50 50 bool psastroDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType); 51 bool psastroAnalysis (pmConfig *config );51 bool psastroAnalysis (pmConfig *config, psMetadata *stats); 52 52 53 53 bool psastroConvertFPA (pmFPA *fpa, psMetadata *recipe); … … 125 125 bool psastroAstromGuessSetChip (pmFPA *fpa, pmChip *chip, const pmFPAview *view, double pixelScale, bool bilevelAstrometry); 126 126 bool psastroAstromGuessSetFPA (pmFPA *fpa, bool *bilevelAstrometry); 127 bool psastroMetadataStats (pmConfig *config );127 bool psastroMetadataStats (pmConfig *config, psMetadata *stats); 128 128 129 129 bool psastroZeroPoint (pmConfig *config); -
branches/pap/psastro/src/psastroAnalysis.c
r23412 r23638 1 1 /** @file psastroAnalysis.c 2 2 * 3 * @brief 3 * @brief 4 4 * 5 5 * @ingroup libpsastro … … 13 13 # include "psastroInternal.h" 14 14 15 bool psastroAnalysis (pmConfig *config) { 15 /// Turn save on/off for a file 16 static void fileSave(pmConfig *config, // Configuration 17 const char *name, // Name of file 18 bool save // Save file? 19 ) 20 { 21 pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, 0); // File of interest 22 if (!file) { 23 psErrorClear(); 24 return; 25 } 26 file->save = save; 27 return; 28 } 29 30 31 bool psastroAnalysis (pmConfig *config, psMetadata *stats) { 16 32 17 33 bool status; … … 40 56 } 41 57 if (nStars == 0) { 42 psLogMsg ("psastro", 2, "skipping astrometry analysis : no stars\n"); 43 return false; 58 // This is likely a data quality issue 59 psWarning("No stars for astrometry analysis --- suspect bad data quality"); 60 if (stats && psMetadataLookupS32(NULL, stats, "QUALITY") == 0) { 61 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE, 62 "No stars for astrometry", PSASTRO_ERR_DATA); 63 } 64 fileSave(config, "PSASTRO.OUTPUT", false); 65 fileSave(config, "PSASTRO.OUTPUT.MASK", false); 66 fileSave(config, "PSASTRO.OUT.REFSTARS", false); 67 psErrorClear(); 68 return true; 44 69 } 45 70 -
branches/pap/psastro/src/psastroDataSave.c
r23169 r23638 22 22 * this loop saves the photometry/astrometry data files 23 23 */ 24 bool psastroDataSave (pmConfig *config ) {24 bool psastroDataSave (pmConfig *config, psMetadata *stats) { 25 25 26 26 pmChip *chip; … … 84 84 85 85 // Write out summary statistics 86 if (!psastroMetadataStats (config )) ESCAPE;86 if (!psastroMetadataStats (config, stats)) ESCAPE; 87 87 88 88 // activate all files except PSASTRO.OUTPUT -
branches/pap/psastro/src/psastroMetadataStats.c
r21409 r23638 13 13 # include "psastroInternal.h" 14 14 15 bool psastroMetadataStats (pmConfig *config ) {15 bool psastroMetadataStats (pmConfig *config, psMetadata *stats) { 16 16 17 17 bool status; … … 24 24 25 25 if (!output) { 26 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find output file (PSASTRO.OUTPUT).");27 return false;26 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find output file (PSASTRO.OUTPUT)."); 27 return false; 28 28 } 29 29 30 // create output stats metadata 31 psMetadata *stats = psMetadataAlloc (); 32 33 // extract stats for the complete fpa 30 // extract stats for the complete fpa 34 31 pmFPAview *view = pmFPAviewAlloc(0); 35 32 36 33 if (!ppStatsMetadata(stats, output->fpa, view, 0, config)) { 37 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate stats for image.");38 psFree(view);39 psFree(stats);40 return false;34 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate stats for image."); 35 psFree(view); 36 psFree(stats); 37 return false; 41 38 } 42 39 43 40 // if we did not request any specific stats, the structure is empty 44 41 if (stats && stats->list->n == 0) { 45 psWarning ("stats output specified, but no requested stats entries in headers");46 psFree(view);47 psFree(stats);48 return true;42 psWarning ("stats output specified, but no requested stats entries in headers"); 43 psFree(view); 44 psFree(stats); 45 return true; 49 46 } 50 47 … … 52 49 char *statsMDC = psMetadataConfigFormat(stats); 53 50 if (!statsMDC || strlen(statsMDC) == 0) { 54 psError(PS_ERR_IO, false, "Unable to serialize stats metadata.\n");55 return false;56 } 51 psError(PS_ERR_IO, false, "Unable to serialize stats metadata.\n"); 52 return false; 53 } 57 54 58 55 // convert to a real UNIX filename … … 60 57 FILE *statsFile = fopen (resolved, "w"); 61 58 if (!statsFile) { 62 psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);63 psFree(stats);64 psFree(view);65 psFree(statsMDC);66 psFree(resolved);67 return false;59 psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved); 60 psFree(stats); 61 psFree(view); 62 psFree(statsMDC); 63 psFree(resolved); 64 return false; 68 65 } 69 66
Note:
See TracChangeset
for help on using the changeset viewer.
