IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4395


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

Can automatically identify FITS files

Location:
trunk/archive/scripts/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/src/gpc1_raw.config

    r4386 r4395  
    33# How to identify this type
    44RULE    METADATA
    5         TELESCOP        STR     PS1
    6         DETECTOR        STR     GPC1
     5#       TELESCOP        STR     PS1
     6#       DETECTOR        STR     GPC1
    77        EXTEND          BOOL    T
     8        NEXTEND         S32     64
     9        NAMPS           S32     64
    810END
    911
  • trunk/archive/scripts/src/ipprc.config

    r4386 r4395  
    1212        MEGACAM_SPLICE  STR     megacam_splice.config
    1313        GPC1_RAW        STR     gpc1_raw.config
    14         PS1_COMCAM      STR     ps1_comcam.config
     14        LRIS_BLUE       STR     lris_blue.config
     15        LRIS_RED        STR     lris_red.config
    1516END
    1617
  • trunk/archive/scripts/src/lris_blue.config

    r4386 r4395  
    2626        AMPPSIZE        STR     [1:1024,1:4096]
    2727        NAXIS1          S32     4620
    28         NAXIS2          STR     4096
     28        NAXIS2          S32     4096
    2929END
    3030
  • trunk/archive/scripts/src/lris_red.config

    r4386 r4395  
    1818RULE    METADATA
    1919        TELESCOP        STR     Keck I
    20         DETECTOR        STR     LRIS
     20        INSTRUME        STR     LRIS
    2121        AMPLIST         STR     2,1,0,0
    2222        WINDOW          STR     0,0,0,2048,2048
  • trunk/archive/scripts/src/megacam_raw.config

    r4386 r4395  
    158158                ccd28   S32     1
    159159                ccd29   S32     1
    160                 ccd20   S32     1
     160                ccd30   S32     1
    161161                ccd31   S32     1
    162162                ccd32   S32     1
  • trunk/archive/scripts/src/megacam_splice.config

    r4386 r4395  
    1 # The processed MecaCam data is stored in single files for each chip
     1# The spliced MecaCam data is stored in single extensions for each chip
    22
    33# How to recognise this type
    44RULE    METADATA
    5         TELESCOP        STR     CFHT
     5        TELESCOP        STR     CFHT 3.6m
    66        DETECTOR        STR     MegaCam
    7         EXTEND          BOOL    F
     7        EXTEND          BOOL    T
     8        NEXTEND         S32     36
    89END
    910
  • 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}
  • trunk/archive/scripts/src/pmCameraFromHeader.h

    r4092 r4395  
    33
    44// Work out what camera we have, based on the FITS header and a set of rules specified in the IPP
    5 // configuration
    6 char *pmCameraFromHeader(const psMetadata *header, // The FITS header
    7                          const psMetadata *ipprc // The IPP configuration
     5// configuration; return the camera configuration
     6psMetadata *pmCameraFromHeader(const psMetadata *header, // The FITS header
     7                               const psMetadata *ipprc // The IPP configuration
    88    );
    99
  • trunk/archive/scripts/src/test_pmFPARead.c

    r4386 r4395  
    2525#endif
    2626
    27     (void)psTraceSetLevel(".", 10);
     27    (void)psTraceSetLevel(".", 0);
    2828    (void)psTraceSetLevel("readMultipleRegions", 0);
    2929    (void)psTraceSetLevel("portions", 0);
    3030    (void)psTraceSetLevel("pmFPARead", 10);
    3131    (void)psTraceSetLevel("pmFPAfromHeader", 10);
     32    (void)psTraceSetLevel("pmCameraFromHeader", 10);
     33
     34
    3235
    3336    if (argc != 3) {
    34         printf("Usage: %s CONFIG IMAGE\n", argv[0]);
     37        printf("Usage: %s IPP_CONFIG IMAGE\n", argv[0]);
    3538        exit(EXIT_FAILURE);
    3639    }
    37     const char *cameraName = argv[1];
     40    const char *ipprcName = argv[1];
    3841    const char *imageName = argv[2];
    3942
    4043    int badLines = 0;                   // Number of bad lines in camera configuration
    41     psMetadata *camera = psMetadataConfigParse(NULL, &badLines, cameraName, true); // Read camera config file
     44    psMetadata *ipprc = psMetadataConfigParse(NULL, &badLines, ipprcName, true); // Read IPP config file
    4245    if (badLines > 0) {
    43         psLogMsg(__func__, PS_LOG_WARN, "%d bad lines encountered while reading camera configuration %s\n",
    44                  badLines, cameraName);
     46        psLogMsg(__func__, PS_LOG_WARN, "%d bad lines encountered while reading IPP configuration %s\n",
     47                 badLines, ipprcName);
    4548    }
    4649
    4750    psFits *fits = psFitsAlloc(imageName);
     51    psMetadata *header = psFitsReadHeader(NULL, fits);
     52
     53    psMetadata *camera = pmCameraFromHeader(header, ipprc);
     54
    4855    papFPA *fpa = pmFPARead(fits, camera, NULL);
    4956    (void)pmFPAPrint(fpa);
     
    5562    printf("Test: %d %d\n", psCellGetValueS32(fpa, "ccd15", "left", "CELL.YPARITY"),
    5663           psCellGetValueS32(fpa, "ccd15", "right", "CELL.YPARITY"));
    57 
    58 //    (void)pmFPAPrint(fpa);
    5964
    6065    // Tidy up
Note: See TracChangeset for help on using the changeset viewer.