IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 13, 2006, 6:40:37 PM (20 years ago)
Author:
Paul Price
Message:

Compiled, but concept ingest not yet working, so can't read FPA

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsRead.c

    r6575 r6580  
    175175}
    176176
     177
    177178//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    178179// Public functions
     
    201202                bool mdok = true;       // Status of MD lookup
    202203                psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
    203                 if (mdok && strlen(source)) {
    204                     if (strcasecmp(source, "HEADER") == 0 && conceptItem->type == PS_DATA_STRING) {
    205                         value = psMetadataLookup(hdu->header, conceptItem->data.V);
    206                     } else if (strcasecmp(source, "VALUE") == 0) {
    207                         value = psMemIncrRefCounter(conceptItem);
    208                     } else {
    209                         psError(PS_ERR_IO, true, "%s isn't HEADER or VALUE --- can't read %s\n", source,
    210                                 name);
    211                         continue;
    212                     }
    213                 } else {
    214                     // Assume it's specified by value
     204                if (mdok && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) {
    215205                    value = psMemIncrRefCounter(conceptItem);
     206                    conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);
     207                } else if (source && (strlen(source) == 0 || strcasecmp(source, "HEADER") != 0)) {
     208                    // We leave "HEADER" to pmConceptsReadFromHeader
     209                    psError(PS_ERR_IO, true, "%s isn't HEADER or VALUE --- can't read %s\n", source, name);
     210                    continue;
    216211                }
    217                 conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);
    218212            }
    219213        }
     
    253247}
    254248
     249
    255250bool pmConceptsReadFromHeader(psMetadata *specs, // The concept specifications
    256251                              pmFPA *fpa, // The FPA
     
    265260    psMetadata *transSpec = psMetadataLookupMD(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec
    266261    if (mdok && transSpec) {
    267         pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    268         psMetadata *cameraFormat = hdu->format; // The camera format
    269262        psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
    270263        psMetadataItem *specItem = NULL;    // Item from the specs metadata
     
    272265            pmConceptSpec *spec = specItem->data.V; // The specification
    273266            psString name = specItem->name; // The concept name
    274             psString keywords = psMetadataLookupStr(&mdok, transSpec, name); // The FITS keywords
    275             if (mdok && strlen(keywords) > 0) {
    276                 // In case there are multiple headers
    277                 psList *keys = psStringSplit(keywords, " ,;"); // List of keywords
    278                 psMetadataItem *headerItem = NULL; // The item, to be returned
    279                 if (keys->n == 1) {
    280                     // Only one key --- proceed as usual
    281                     headerItem = psMetadataLookup(hdu->header, keywords);
    282                 } else {
    283                     psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator
    284                     psString key = NULL; // Item from iteration
    285                     psList *values = psListAlloc(NULL); // List containing the values
    286                     while ((key = psListGetAndIncrement(keysIter))) {
    287                         psMetadataItem *value = psMetadataLookup(hdu->header, key);
    288                         psListAdd(values, PS_LIST_TAIL, value);
     267            psMetadataItem *headerItem = NULL; // The value of the concept from the header
     268            // First check the cell configuration
     269            if (cell && cell->config) {
     270                psMetadataItem *conceptItem = psMetadataLookup(cell->config, name); // The concept, or NULL
     271                if (conceptItem) {
     272                    // Check the SOURCE
     273                    psString nameSource = NULL; // String with the concept name and ".SOURCE" added
     274                    psStringAppend(&nameSource, "%s.SOURCE", name);
     275                    psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
     276                    if (mdok && strlen(source) && strcasecmp(source, "HEADER") == 0) {
     277                        headerItem = psMetadataLookup(hdu->header, conceptItem->data.V);
    289278                    }
    290                     psFree(keysIter);
    291                     headerItem = psMetadataItemAlloc(name, PS_DATA_LIST, specItem->comment, values);
    292                     psFree(values);
     279                    // Leave the error handling to pmConceptsFromCamera, which should already have been called
    293280                }
    294                 psFree(keys);
    295 
    296                 // This will also clean up the name
    297                 conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell);
    298             }
     281            }
     282            if (! headerItem) {
     283                psString keywords = psMetadataLookupStr(&mdok, transSpec, name); // The FITS keywords
     284                if (mdok && strlen(keywords) > 0) {
     285                    // In case there are multiple headers
     286                    psList *keys = psStringSplit(keywords, " ,;"); // List of keywords
     287                    if (keys->n == 1) {
     288                        // Only one key --- proceed as usual
     289                        headerItem = psMetadataLookup(hdu->header, keywords);
     290                    } else {
     291                        psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator
     292                        psString key = NULL; // Item from iteration
     293                        psList *values = psListAlloc(NULL); // List containing the values
     294                        while ((key = psListGetAndIncrement(keysIter))) {
     295                            psMetadataItem *value = psMetadataLookup(hdu->header, key);
     296                            psListAdd(values, PS_LIST_TAIL, value);
     297                        }
     298                        psFree(keysIter);
     299                        headerItem = psMetadataItemAlloc(name, PS_DATA_LIST, specItem->comment, values);
     300                        psFree(values);
     301                    }
     302                    psFree(keys);
     303                }
     304            }
     305
     306            // This will also clean up the name
     307            conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell);
    299308        }
    300309        psFree(specsIter);
     
    303312    return false;
    304313}
     314
    305315
    306316// XXX --- the below code has NOT been tested!
Note: See TracChangeset for help on using the changeset viewer.