Changeset 6580 for branches/rel10_ifa/psModules/src/astrom/pmConceptsRead.c
- Timestamp:
- Mar 13, 2006, 6:40:37 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/pmConceptsRead.c
r6575 r6580 175 175 } 176 176 177 177 178 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 178 179 // Public functions … … 201 202 bool mdok = true; // Status of MD lookup 202 203 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) { 215 205 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; 216 211 } 217 conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);218 212 } 219 213 } … … 253 247 } 254 248 249 255 250 bool pmConceptsReadFromHeader(psMetadata *specs, // The concept specifications 256 251 pmFPA *fpa, // The FPA … … 265 260 psMetadata *transSpec = psMetadataLookupMD(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec 266 261 if (mdok && transSpec) { 267 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level268 psMetadata *cameraFormat = hdu->format; // The camera format269 262 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 270 263 psMetadataItem *specItem = NULL; // Item from the specs metadata … … 272 265 pmConceptSpec *spec = specItem->data.V; // The specification 273 266 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); 289 278 } 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 293 280 } 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); 299 308 } 300 309 psFree(specsIter); … … 303 312 return false; 304 313 } 314 305 315 306 316 // XXX --- the below code has NOT been tested!
Note:
See TracChangeset
for help on using the changeset viewer.
