IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23638


Ignore:
Timestamp:
Mar 31, 2009, 2:49:55 PM (17 years ago)
Author:
Paul Price
Message:

Adding QUALITY to the output metadata

Location:
branches/pap/psastro/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/psastro/src/psastro.c

    r23195 r23638  
    1313# include "psastroStandAlone.h"
    1414
    15 static void usage (void) {
    16     fprintf (stderr, "USAGE: psastro [-file image(s)] [-list imagelist] (output)\n");
    17     exit (2);
     15static void usage(void) {
     16    fprintf(stderr, "USAGE: psastro [-file image(s)] [-list imagelist] (output)\n");
     17    exit(PS_EXIT_CONFIG_ERROR);
    1818}
    1919
    20 int main (int argc, char **argv) {
    21 
    22     pmConfig *config = NULL;
    23 
     20int main (int argc, char **argv)
     21{
    2422    psTimerStart ("complete");
    2523
     
    2826    // model inits are needed in pmSourceIO
    2927    // models defined in psphot/src/models are not available in psastro
    30     pmModelClassInit ();
     28    pmModelClassInit();
    3129
    3230    // 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    }
    3535
    3636    psastroVersionPrint();
     
    3939    if (!psastroParseCamera (config)) {
    4040        psErrorStackPrint(stderr, "error setting up the camera\n");
    41         exit (1);
     41        psFree(config);
     42        exit(PS_EXIT_CONFIG_ERROR);
    4243    }
    4344
     
    4647    if (!psastroDataLoad (config)) {
    4748        psErrorStackPrint(stderr, "error loading input data\n");
    48         exit (1);
     49        psFree(config);
     50        exit(PS_EXIT_DATA_ERROR);
    4951    }
    5052
     53    psMetadata *stats = psMetadataAlloc(); // Statistics, for output
     54    psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", 0, "No problems", 0);
     55
    5156    // run the full astrometry analysis (chip and/or mosaic)
    52     if (!psastroAnalysis (config)) {
     57    if (!psastroAnalysis(config, stats)) {
    5358        psErrorStackPrint(stderr, "failure in psastro analysis\n");
    54         exit (1);
     59        psFree(config);
     60        psFree(stats);
     61        exit(PS_EXIT_SYS_ERROR);
    5562    }
    5663
    5764    // write out the results
    58     if (!psastroDataSave (config)) {
     65    if (!psastroDataSave(config, stats)) {
    5966        psErrorStackPrint(stderr, "failed to write out data\n");
    60         exit (1);
     67        psFree(config);
     68        psFree(stats);
     69        exit(PS_EXIT_DATA_ERROR);
    6170    }
    6271
    63     psLogMsg ("psastro", 3, "complete psastro run: %f sec\n", psTimerMark ("complete"));
     72    psFree(stats);
    6473
    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);
    6778}
  • branches/pap/psastro/src/psastro.h

    r23494 r23638  
    4646#endif
    4747
    48 bool              psastroDataSave (pmConfig *config);
     48bool              psastroDataSave (pmConfig *config, psMetadata *stats);
    4949bool              psastroDefineFiles (pmConfig *config, pmFPAfile *input);
    5050bool              psastroDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType);
    51 bool              psastroAnalysis (pmConfig *config);
     51bool              psastroAnalysis (pmConfig *config, psMetadata *stats);
    5252
    5353bool              psastroConvertFPA (pmFPA *fpa, psMetadata *recipe);
     
    125125bool              psastroAstromGuessSetChip (pmFPA *fpa, pmChip *chip, const pmFPAview *view, double pixelScale, bool bilevelAstrometry);
    126126bool              psastroAstromGuessSetFPA (pmFPA *fpa, bool *bilevelAstrometry);
    127 bool              psastroMetadataStats (pmConfig *config);
     127bool              psastroMetadataStats (pmConfig *config, psMetadata *stats);
    128128
    129129bool psastroZeroPoint (pmConfig *config);
  • branches/pap/psastro/src/psastroAnalysis.c

    r23412 r23638  
    11/** @file psastroAnalysis.c
    22 *
    3  *  @brief 
     3 *  @brief
    44 *
    55 *  @ingroup libpsastro
     
    1313# include "psastroInternal.h"
    1414
    15 bool psastroAnalysis (pmConfig *config) {
     15/// Turn save on/off for a file
     16static 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
     31bool psastroAnalysis (pmConfig *config, psMetadata *stats) {
    1632
    1733    bool status;
     
    4056    }
    4157    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;
    4469    }
    4570
  • branches/pap/psastro/src/psastroDataSave.c

    r23169 r23638  
    2222 * this loop saves the photometry/astrometry data files
    2323 */
    24 bool psastroDataSave (pmConfig *config) {
     24bool psastroDataSave (pmConfig *config, psMetadata *stats) {
    2525
    2626    pmChip *chip;
     
    8484
    8585    // Write out summary statistics
    86     if (!psastroMetadataStats (config)) ESCAPE;
     86    if (!psastroMetadataStats (config, stats)) ESCAPE;
    8787
    8888    // activate all files except PSASTRO.OUTPUT
  • branches/pap/psastro/src/psastroMetadataStats.c

    r21409 r23638  
    1313# include "psastroInternal.h"
    1414
    15 bool psastroMetadataStats (pmConfig *config) {
     15bool psastroMetadataStats (pmConfig *config, psMetadata *stats) {
    1616
    1717    bool status;
     
    2424
    2525    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;
    2828    }
    2929
    30     // create output stats metadata
    31     psMetadata *stats = psMetadataAlloc ();
    32 
    33     // extract stats for the complete fpa
     30    // extract stats for the complete fpa
    3431    pmFPAview *view = pmFPAviewAlloc(0);
    3532
    3633    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;
    4138    }
    4239
    4340    // if we did not request any specific stats, the structure is empty
    4441    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;
    4946    }
    5047
     
    5249    char *statsMDC = psMetadataConfigFormat(stats);
    5350    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    }
    5754
    5855    // convert to a real UNIX filename
     
    6057    FILE *statsFile = fopen (resolved, "w");
    6158    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;
    6865    }
    6966
Note: See TracChangeset for help on using the changeset viewer.