IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 24, 2005, 4:48:22 PM (21 years ago)
Author:
Paul Price
Message:

Can automatically identify FITS files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/src/pmCameraFromHeader.c

    r4309 r4395  
    55
    66// Work out what camera we have, based on the FITS header and a set of rules specified in the IPP
    7 // configuration
    8 char *pmCameraFromHeader(const psMetadata *header, // The FITS header
    9                          const psMetadata *ipprc // The IPP configuration
     7// configuration; return the camera configuration
     8psMetadata *pmCameraFromHeader(const psMetadata *header, // The FITS header
     9                               const psMetadata *ipprc // The IPP configuration
    1010    )
    1111{
     
    1717    }
    1818
    19     char *winner = NULL;                // The instrument whose rule first matches the supplied header
     19    psMetadata *winner = NULL;          // The instrument configuration whose rule first matches the supplied
     20                                        // header
    2021
    2122    // Iterate over the instruments
     
    3132        } else if (instrumentItem->type == PS_META_STR) {
    3233            psTrace(__func__, 5, "Reading instrument configuration for %s...\n", instrumentItem->name);
    33             instrument = psMetadataConfigParse(NULL, NULL, instrumentItem->data.V, true);
     34            int badLines = 0;           // Number of bad lines in reading instrument configuration
     35            instrument = psMetadataConfigParse(NULL, &badLines, instrumentItem->data.V, true);
     36            if (badLines > 0) {
     37                psLogMsg(__func__, PS_LOG_WARN, "%d bad lines encountered while reading camera"
     38                         "configuration %s\n", badLines, instrumentItem->name);
     39            }
    3440        }
    3541
     
    5864                        switch (ruleItem->type) {
    5965                          case PS_META_STR:
    60                             match = (strcmp(ruleItem->data.V, headerItem->data.V) == 0) ? true : false;
     66                            psTrace(__func__, 8, "Matching %s: '%s' vs '%s'\n", ruleItem->name,
     67                                    ruleItem->data.V, headerItem->data.V);
     68                            match = (strncmp(ruleItem->data.V, headerItem->data.V,
     69                                             strlen(ruleItem->data.V)) == 0) ? true : false;
    6170                            break;
    6271                          case PS_TYPE_S32:
     72                          case PS_TYPE_BOOL:
     73                            psTrace(__func__, 8, "Matching %s: %d vs %d\n", ruleItem->name,
     74                                    ruleItem->data.S32, headerItem->data.S32);
    6375                            if (ruleItem->data.S32 != headerItem->data.S32) {
    6476                                match = false;
     
    6678                            break;
    6779                          case PS_TYPE_F32:
     80                            psTrace(__func__, 8, "Matching %s: %f vs %f\n", ruleItem->name,
     81                                    ruleItem->data.F32, headerItem->data.F32);
    6882                            if (ruleItem->data.F32 != headerItem->data.F32) {
    6983                                match = false;
     
    7185                            break;
    7286                          case PS_TYPE_F64:
     87                            psTrace(__func__, 8, "Matching %s: %g vs %g\n", ruleItem->name,
     88                                    ruleItem->data.F64, headerItem->data.F64);
    7389                            if (ruleItem->data.F64 != headerItem->data.F64) {
    7490                                match = false;
     
    85101                    if (! winner) {
    86102                        // This is the first match
    87                         winner = instrumentItem->name;
     103                        winner = instrument;
     104                        psLogMsg(__func__, PS_LOG_INFO, "FITS header matches instrument %s\n",
     105                                 instrumentItem->name);
    88106                    } else {
    89107                        // We have a duplicate match
     
    100118    psFree(iterator);
    101119
     120    if (! winner) {
     121        psError(PS_ERR_IO, true, "Unable to find an instrument that matches input FITS header!\n");
     122    }
     123
    102124    return winner;
    103125}
Note: See TracChangeset for help on using the changeset viewer.