IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 30, 2006, 10:08:30 AM (20 years ago)
Author:
Paul Price
Message:

pmFPACopy now working

File:
1 edited

Legend:

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

    r6663 r6734  
    9595}
    9696
    97 static bool writeHeader(pmHDU *hdu,     // HDU for which to add to the header
    98                         const char *keyword, // Keyword to add
    99                         psMetadataItem *item // Item to add to the header
    100                        )
     97// Write a single value to a header
     98static bool writeSingleHeader(pmHDU *hdu, // HDU for which to add to the header
     99                              const char *keyword, // Keyword to add
     100                              psMetadataItem *item // Item to add to the header
     101                             )
    101102{
    102103    switch (item->type) {
     
    113114        return psMetadataAddF64(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment,
    114115                                item->data.F64);
     116    case PS_DATA_REGION: {
     117            psString region = psRegionToString(*(psRegion*)item->data.V);
     118            bool result = psMetadataAddStr(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment,
     119                                           region);
     120            psFree(region);
     121            return result;
     122        }
    115123    default:
    116124        psLogMsg(__func__, PS_LOG_WARN, "Type of %s is not suitable for a FITS header --- not added.\n",
     
    118126        return false;
    119127    }
     128}
     129
     130
     131// Write potentially multiple values to a header
     132static bool writeHeader(pmHDU *hdu,     // HDU for which to add to the header
     133                        const char *keywords, // Keywords to add
     134                        psMetadataItem *item // Item to add to the header
     135                       )
     136{
     137    bool status = true;                 // Status of writing headers, to be returned
     138    if (item->type == PS_DATA_LIST) {
     139        psList *values = item->data.V;  // List of outputs
     140        psList *keys = psStringSplit(keywords, " ,;"); // List of keywords
     141        if (keys->n != values->n) {
     142            psLogMsg(__func__, PS_LOG_WARN, "Number of keywords (%d) does not match number of values (%d).\n",
     143                     keys->n, values->n);
     144        }
     145        psListIterator *keysIter = psListIteratorAlloc(keys, PS_LIST_HEAD, false); // Iterator for keywords
     146        psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values
     147        psString key = NULL;            // Keyword from iteration
     148        psMetadataItem *value = NULL;   // Value from iteration
     149        while ((key = psListGetAndIncrement(keysIter)) && (value = psListGetAndIncrement(valuesIter))) {
     150            status |= writeSingleHeader(hdu, key, value);
     151        }
     152        psFree(keysIter);
     153        psFree(valuesIter);
     154        psFree(keys);
     155    } else {
     156        status = writeSingleHeader(hdu, keywords, item);
     157    }
     158    return status;
    120159}
    121160
     
    156195                psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
    157196                if (mdok && strlen(source) > 0) {
     197                    psTrace(__func__, 8, "%s is %s\n", nameSource, source);
    158198                    if (strcasecmp(source, "HEADER") == 0) {
    159199                        if (cameraItem->type != PS_DATA_STRING) {
     
    162202                            continue;
    163203                        }
     204                        psTrace(__func__, 8, "Writing %s to header %s\n", name, cameraItem->data.V);
    164205                        writeHeader(hdu, cameraItem->data.V, formatted);
    165206                        continue;
    166207                    }
    167208                    if (strcasecmp(source, "VALUE") == 0) {
     209                        psTrace(__func__, 8, "Checking %s against camera format.\n", name);
    168210                        if (! compareConcepts(cameraItem, formatted)) {
    169211                            psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera "
    170                                      "format, but the values don't match.\n");
     212                                     "format, but the values don't match.\n", name);
    171213                        }
    172214                        continue;
     
    179221                if (! compareConcepts(cameraItem, formatted)) {
    180222                    psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera "
    181                              "format, but the values don't match.\n");
     223                             "format, but the values don't match.\n", name);
    182224                }
    183225            }
Note: See TracChangeset for help on using the changeset viewer.