Changeset 7555
- Timestamp:
- Jun 13, 2006, 3:53:11 PM (20 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 2 edited
-
pmFPARead.c (modified) (4 diffs)
-
pmFPARead.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPARead.c
r7469 r7555 21 21 // Carve a readout from the image pixels 22 22 static bool readoutCarve(pmReadout *readout, // Readout to be carved up 23 psImage **target, // Target pointer for the carved image 23 24 psImage *image, // Image that will be carved 24 25 const psRegion *trimsec, // Trim section … … 47 48 psFree(readout->image); // Make way! 48 49 } 49 readout->image= psMemIncrRefCounter(psImageSubset(image, region));50 *target = psMemIncrRefCounter(psImageSubset(image, region)); 50 51 51 52 // Get the list of overscans … … 346 347 } 347 348 348 pmReadout *readout = pmReadoutAlloc(cell); 349 if (!readoutCarve(readout, image, trimsec, biassecs)) { 349 pmReadout *readout; // Readout into which to read 350 if (cell->readouts->n > i && cell->readouts->data[i]) { 351 readout = psMemIncrRefCounter(cell->readouts->data[i]); 352 } else { 353 readout = pmReadoutAlloc(cell); 354 } 355 if (!readoutCarve(readout, &readout->image, image, trimsec, biassecs)) { 350 356 psError(PS_ERR_UNEXPECTED_NULL, false, 351 357 "Unable to carve readout into image and bias sections for %d the plane.", i); 352 358 return NULL; 353 359 } 354 readout->mask = NULL;355 readout->weight = NULL;356 360 psFree(readout); // Drop reference 357 361 } … … 415 419 } 416 420 421 422 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 423 // Reading the mask 424 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 425 426 // Read the mask into the cell, and allocate the readouts 427 bool pmCellReadMask(pmCell *cell, // Cell to read into 428 psFits *fits, // FITS file from which to read 429 psDB *db // Database handle, for "concepts" ingest 430 ) 431 { 432 PS_ASSERT_PTR_NON_NULL(cell, false); 433 PS_ASSERT_PTR_NON_NULL(fits, false); 434 435 pmHDU *hdu = pmHDUFromCell(cell); // The HDU 436 if (!hdu) { 437 return false; // Nothing to see here; move along 438 } 439 if (!hdu->images && !pmHDURead(hdu, fits)) { 440 psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n"); 441 return false; 442 } 443 444 if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) { 445 psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell"); 446 return false; 447 } 448 449 // Having read the cell, we now have to cut it up 450 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); 451 452 // Iterate over each of the image planes 453 for (int i = 0; i < hdu->images->n; i++) { 454 psImage *image = hdu->images->data[i]; // The i-th plane 455 456 if (image->type.type != PS_TYPE_U8) { 457 psImage *temp = psImageCopy(NULL, image, PS_TYPE_U8); // Temporary image 458 psFree(hdu->images->data[i]); 459 hdu->images->data[i] = temp; 460 image = temp; 461 } 462 463 pmReadout *readout; // Readout into which to read 464 if (cell->readouts->n > i && cell->readouts->data[i]) { 465 readout = psMemIncrRefCounter(cell->readouts->data[i]); 466 } else { 467 readout = pmReadoutAlloc(cell); 468 } 469 if (!readoutCarve(readout, &readout->mask, image, trimsec, NULL)) { 470 psError(PS_ERR_UNEXPECTED_NULL, false, 471 "Unable to carve readout into image and bias sections for %d the plane.", i); 472 return NULL; 473 } 474 psFree(readout); // Drop reference 475 } 476 477 pmCellSetDataStatus(cell, true); 478 return true; 479 } 480 481 // Read the mask into the component cells 482 bool pmChipReadMask(pmChip *chip, // Chip to read into 483 psFits *fits, // FITS file from which to read 484 psDB *db // Database handle, for "concepts" ingest 485 ) 486 { 487 PS_ASSERT_PTR_NON_NULL(chip, false); 488 PS_ASSERT_PTR_NON_NULL(fits, false); 489 490 bool success = false; // Were we able to read at least one HDU? 491 psArray *cells = chip->cells; // Array of cells 492 for (int i = 0; i < cells->n; i++) { 493 pmCell *cell = cells->data[i]; // The cell of interest 494 success |= pmCellReadMask(cell, fits, db); 495 } 496 if (success) { 497 if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) { 498 psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n"); 499 return false; 500 } 501 // XXX probably could just use chip->data_exists 502 pmChipSetDataStatus(chip, true); 503 } 504 505 return success; 506 } 507 508 // Read the mask into the component chips 509 bool pmFPAReadMask(pmFPA *fpa, // FPA to read into 510 psFits *fits, // FITS file from which to read 511 psDB *db // Database handle, for "concepts" ingest 512 ) 513 { 514 PS_ASSERT_PTR_NON_NULL(fpa, false); 515 PS_ASSERT_PTR_NON_NULL(fits, false); 516 517 bool success = false; // Were we able to read at least one HDU? 518 psArray *chips = fpa->chips; // Array of chips 519 for (int i = 0; i < chips->n; i++) { 520 pmChip *chip = chips->data[i]; // The cell of interest 521 success |= pmChipReadMask(chip, fits, db); 522 } 523 if (success) { 524 if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) { 525 psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n"); 526 return false; 527 } 528 } else { 529 psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA"); 530 } 531 532 return success; 533 } 534 535 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 536 // Reading the weight map 537 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 538 539 // Read the weight map into the cell, and allocate the readouts 540 bool pmCellReadWeight(pmCell *cell, // Cell to read into 541 psFits *fits, // FITS file from which to read 542 psDB *db // Database handle, for "concepts" ingest 543 ) 544 { 545 PS_ASSERT_PTR_NON_NULL(cell, false); 546 PS_ASSERT_PTR_NON_NULL(fits, false); 547 548 pmHDU *hdu = pmHDUFromCell(cell); // The HDU 549 if (!hdu) { 550 return false; // Nothing to see here; move along 551 } 552 if (!hdu->images && !pmHDURead(hdu, fits)) { 553 psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n"); 554 return false; 555 } 556 557 if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) { 558 psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell"); 559 return false; 560 } 561 562 // Having read the cell, we now have to cut it up 563 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); 564 565 // Iterate over each of the image planes 566 for (int i = 0; i < hdu->images->n; i++) { 567 psImage *image = hdu->images->data[i]; // The i-th plane 568 569 if (image->type.type != PS_TYPE_F32) { 570 psImage *temp = psImageCopy(NULL, image, PS_TYPE_F32); // Temporary image 571 psFree(hdu->images->data[i]); 572 hdu->images->data[i] = temp; 573 image = temp; 574 } 575 576 pmReadout *readout; // Readout into which to read 577 if (cell->readouts->n > i && cell->readouts->data[i]) { 578 readout = psMemIncrRefCounter(cell->readouts->data[i]); 579 } else { 580 readout = pmReadoutAlloc(cell); 581 } 582 if (!readoutCarve(readout, &readout->weight, image, trimsec, NULL)) { 583 psError(PS_ERR_UNEXPECTED_NULL, false, 584 "Unable to carve readout into image and bias sections for %d the plane.", i); 585 return NULL; 586 } 587 psFree(readout); // Drop reference 588 } 589 590 pmCellSetDataStatus(cell, true); 591 return true; 592 } 593 594 // Read the weight map into the component cells 595 bool pmChipReadWeight(pmChip *chip, // Chip to read into 596 psFits *fits, // FITS file from which to read 597 psDB *db // Database handle, for "concepts" ingest 598 ) 599 { 600 PS_ASSERT_PTR_NON_NULL(chip, false); 601 PS_ASSERT_PTR_NON_NULL(fits, false); 602 603 bool success = false; // Were we able to read at least one HDU? 604 psArray *cells = chip->cells; // Array of cells 605 for (int i = 0; i < cells->n; i++) { 606 pmCell *cell = cells->data[i]; // The cell of interest 607 success |= pmCellReadWeight(cell, fits, db); 608 } 609 if (success) { 610 if (!pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, true, true, NULL)) { 611 psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n"); 612 return false; 613 } 614 // XXX probably could just use chip->data_exists 615 pmChipSetDataStatus(chip, true); 616 } 617 618 return success; 619 } 620 621 // Read the weight map into the component chips 622 bool pmFPAReadWeight(pmFPA *fpa, // FPA to read into 623 psFits *fits, // FITS file from which to read 624 psDB *db // Database handle, for "concepts" ingest 625 ) 626 { 627 PS_ASSERT_PTR_NON_NULL(fpa, false); 628 PS_ASSERT_PTR_NON_NULL(fits, false); 629 630 bool success = false; // Were we able to read at least one HDU? 631 psArray *chips = fpa->chips; // Array of chips 632 for (int i = 0; i < chips->n; i++) { 633 pmChip *chip = chips->data[i]; // The cell of interest 634 success |= pmChipReadWeight(chip, fits, db); 635 } 636 if (success) { 637 if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, true, NULL)) { 638 psError(PS_ERR_IO, false, "Failed to read concepts for FPA.\n"); 639 return false; 640 } 641 } else { 642 psError(PS_ERR_UNKNOWN, false, "Unable to read any chips in FPA"); 643 } 644 645 return success; 646 } 647 -
trunk/psModules/src/camera/pmFPARead.h
r7017 r7555 25 25 psDB *db // Database handle, for "concepts" ingest 26 26 ); 27 28 bool pmCellReadMask(pmCell *cell, // Cell to read into 29 psFits *fits, // FITS file from which to read 30 psDB *db // Database handle, for "concepts" ingest 31 ); 32 33 bool pmChipReadMask(pmChip *chip, // Chip to read into 34 psFits *fits, // FITS file from which to read 35 psDB *db // Database handle, for "concepts" ingest 36 ); 37 38 bool pmFPAReadMask(pmFPA *fpa, // FPA to read into 39 psFits *fits, // FITS file from which to read 40 psDB *db // Database handle, for "concepts" ingest 41 ); 42 43 bool pmCellReadWeight(pmCell *cell, // Cell to read into 44 psFits *fits, // FITS file from which to read 45 psDB *db // Database handle, for "concepts" ingest 46 ); 47 48 bool pmChipReadWeight(pmChip *chip, // Chip to read into 49 psFits *fits, // FITS file from which to read 50 psDB *db // Database handle, for "concepts" ingest 51 ); 52 53 bool pmFPAReadWeight(pmFPA *fpa, // FPA to read into 54 psFits *fits, // FITS file from which to read 55 psDB *db // Database handle, for "concepts" ingest 56 ); 27 57 28 58 bool pmCellReadPHU(pmCell *cell, // Cell to read into
Note:
See TracChangeset
for help on using the changeset viewer.
