- Timestamp:
- Mar 30, 2006, 10:08:30 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/pmConceptsWrite.c
r6663 r6734 95 95 } 96 96 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 98 static 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 ) 101 102 { 102 103 switch (item->type) { … … 113 114 return psMetadataAddF64(hdu->header, PS_LIST_TAIL, keyword, PS_META_REPLACE, item->comment, 114 115 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 } 115 123 default: 116 124 psLogMsg(__func__, PS_LOG_WARN, "Type of %s is not suitable for a FITS header --- not added.\n", … … 118 126 return false; 119 127 } 128 } 129 130 131 // Write potentially multiple values to a header 132 static 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; 120 159 } 121 160 … … 156 195 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source 157 196 if (mdok && strlen(source) > 0) { 197 psTrace(__func__, 8, "%s is %s\n", nameSource, source); 158 198 if (strcasecmp(source, "HEADER") == 0) { 159 199 if (cameraItem->type != PS_DATA_STRING) { … … 162 202 continue; 163 203 } 204 psTrace(__func__, 8, "Writing %s to header %s\n", name, cameraItem->data.V); 164 205 writeHeader(hdu, cameraItem->data.V, formatted); 165 206 continue; 166 207 } 167 208 if (strcasecmp(source, "VALUE") == 0) { 209 psTrace(__func__, 8, "Checking %s against camera format.\n", name); 168 210 if (! compareConcepts(cameraItem, formatted)) { 169 211 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); 171 213 } 172 214 continue; … … 179 221 if (! compareConcepts(cameraItem, formatted)) { 180 222 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); 182 224 } 183 225 }
Note:
See TracChangeset
for help on using the changeset viewer.
