- Timestamp:
- Jan 21, 2006, 12:23:58 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel9_p0/psModules/src/astrom/pmConceptsStandard.c
r6080 r6124 321 321 { 322 322 psList *biassecs = psListAlloc(NULL); // List of bias sections 323 psMetadataItem *item = psMetadataItemAlloc("CELL.BIASSEC", PS_DATA_LIST, "Bias sections", biassecs); 324 psFree(biassecs); // Drop reference 323 325 324 326 psMetadataItem *secItem = pmConceptRead(fpa, chip, cell, db, "CELL.BIASSEC"); 325 327 if (! secItem) { 326 328 psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.\n"); 327 } else if (secItem->type != PS_DATA_STRING) { 329 return item; 330 } 331 if (secItem->type != PS_DATA_STRING) { 328 332 psError(PS_ERR_IO, true, "CELL.BIASSEC is not of type STR (%x)\n", secItem->type); 329 } else { 330 psString sections = secItem->data.V; // The section string 331 332 psMetadataItem *sourceItem = pmConceptRead(fpa, chip, cell, db, "CELL.BIASSEC.SOURCE"); 333 if (! sourceItem) { 334 psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.SOURCE.\n"); 335 } else if (sourceItem->type != PS_DATA_STRING) { 336 psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE is not of type STR (%x)\n", sourceItem->type); 333 return item; 334 } 335 336 psString sections = secItem->data.V; // The section string 337 338 psMetadataItem *sourceItem = pmConceptRead(fpa, chip, cell, db, "CELL.BIASSEC.SOURCE"); 339 if (! sourceItem) { 340 psError(PS_ERR_IO, false, "Couldn't find CELL.BIASSEC.SOURCE.\n"); 341 return item; 342 } else if (sourceItem->type != PS_DATA_STRING) { 343 psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE is not of type STR (%x)\n", sourceItem->type); 344 return item; 345 } 346 347 psString source = sourceItem->data.V; // The source string 348 349 if (! strcasecmp(source, "NONE")) { 350 return item; // There is no biassec 351 } 352 353 psList *secList = psStringSplit(sections, " ;"); // List of sections 354 psListIterator *secIter = psListIteratorAlloc(secList, PS_LIST_HEAD, false); // Iterator over 355 // sections 356 psString aSection = NULL; // A section from the list 357 while ((aSection = psListGetAndIncrement(secIter))) { 358 psRegion *region = psAlloc(sizeof(psRegion)); // Make space for a psRegion (usually passed by 359 // value) 360 361 if (strcasecmp(source, "VALUE") == 0) { 362 *region = psRegionFromString(aSection); 363 } else if (strcasecmp(source, "HEADER") == 0) { 364 psMetadata *header = NULL; // The FITS header 365 if (cell->hdu) { 366 header = cell->hdu->header; 367 } else if (chip->hdu) { 368 header = chip->hdu->header; 369 } else if (fpa->hdu) { 370 header = fpa->hdu->header; 371 } 372 if (! header) { 373 psError(PS_ERR_IO, true, "Unable to find FITS header!\n"); 374 *region = psRegionSet(0.0,0.0,0.0,0.0); 375 } else { 376 bool mdok = true; // Status of MD lookup 377 psString secValue = psMetadataLookupStr(&mdok, header, aSection); 378 if (! mdok || ! secValue) { 379 psError(PS_ERR_IO, false, "Unable to locate header %s\n", aSection); 380 *region = psRegionSet(0.0,0.0,0.0,0.0); 381 } else { 382 *region = psRegionFromString(secValue); 383 } 384 } 337 385 } else { 338 psString source = sourceItem->data.V; // The source string 339 340 psList *secList = psStringSplit(sections, " ;"); // List of sections 341 psListIterator *secIter = psListIteratorAlloc(secList, PS_LIST_HEAD, false); // Iterator over 342 // sections 343 psString aSection = NULL; // A section from the list 344 while ((aSection = psListGetAndIncrement(secIter))) { 345 psRegion *region = psAlloc(sizeof(psRegion)); // Make space for a psRegion (usually passed 346 // by value) 347 348 if (strcasecmp(source, "VALUE") == 0) { 349 *region = psRegionFromString(aSection); 350 } else if (strcasecmp(source, "HEADER") == 0) { 351 psMetadata *header = NULL; // The FITS header 352 if (cell->hdu) { 353 header = cell->hdu->header; 354 } else if (chip->hdu) { 355 header = chip->hdu->header; 356 } else if (fpa->hdu) { 357 header = fpa->hdu->header; 358 } 359 if (! header) { 360 psError(PS_ERR_IO, true, "Unable to find FITS header!\n"); 361 *region = psRegionSet(0.0,0.0,0.0,0.0); 362 } else { 363 bool mdok = true; // Status of MD lookup 364 psString secValue = psMetadataLookupStr(&mdok, header, aSection); 365 if (! mdok || ! secValue) { 366 psError(PS_ERR_IO, false, "Unable to locate header %s\n", aSection); 367 *region = psRegionSet(0.0,0.0,0.0,0.0); 368 } else { 369 *region = psRegionFromString(secValue); 370 } 371 } 372 } else { 373 psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE (%s) is not HEADER or VALUE --- trying " 374 "VALUE.\n", source); 375 *region = psRegionFromString(aSection); 376 } // Value of CELL.BIASSEC.SOURCE 377 378 psListAdd(biassecs, PS_LIST_TAIL, region); 379 psFree(region); 380 } // Iterating over multiple sections 381 psFree(secIter); 382 psFree(secList); 383 } // Looking up CELL.BIASSEC.SOURCE 384 } // Looking up CELL.BIASSEC 385 386 psMetadataItem *item = psMetadataItemAlloc("CELL.BIASSEC", PS_DATA_LIST, "Bias sections", biassecs); 387 psFree(biassecs); 386 psError(PS_ERR_IO, true, "CELL.BIASSEC.SOURCE (%s) is not HEADER or VALUE --- trying " 387 "VALUE.\n", source); 388 *region = psRegionFromString(aSection); 389 } // Value of CELL.BIASSEC.SOURCE 390 391 psListAdd(biassecs, PS_LIST_TAIL, region); 392 psFree(region); 393 } // Iterating over multiple sections 394 psFree(secIter); 395 psFree(secList); 396 388 397 return item; 389 398 } … … 689 698 psMetadataItem *biassecItem = psMetadataLookup(cell->concepts, "CELL.BIASSEC"); 690 699 psList *biassecs = biassecItem->data.V; // The biassecs region list 700 701 if (biassecs->n == 0) { 702 psMetadataItem *noneItem = psMetadataItemAllocStr("CELL.BIASSEC", "Bias section", "NONE"); 703 pmConceptWriteItem(fpa, chip, cell, db, noneItem); 704 return true; 705 } 706 691 707 psString source = pmConceptReadString(fpa, chip, cell, db, "CELL.TRIMSEC.SOURCE"); // The source string 692 708
Note:
See TracChangeset
for help on using the changeset viewer.
