Changeset 6080 for branches/eam_rel9_p0/psModules/src/astrom/pmFPA.c
- Timestamp:
- Jan 19, 2006, 11:47:06 PM (21 years ago)
- File:
-
- 1 edited
-
branches/eam_rel9_p0/psModules/src/astrom/pmFPA.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel9_p0/psModules/src/astrom/pmFPA.c
r6062 r6080 12 12 * XXX: Should we implement non-linear cell->chip transforms? 13 13 * 14 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-01-20 0 2:36:41$14 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-01-20 09:47:06 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include <string.h> 24 24 #include <math.h> 25 #include <assert.h> 25 26 #include "pslib.h" 26 27 27 28 #include "pmFPA.h" 28 29 #include "pmConcepts.h" 30 #include "pmMaskBadPixels.h" 29 31 30 32 /****************************************************************************** … … 163 165 tmpReadout->mask = NULL; 164 166 tmpReadout->weight = NULL; 167 tmpReadout->bias = psListAlloc(NULL); 165 168 tmpReadout->analysis = psMetadataAlloc(); 166 169 tmpReadout->parent = cell; … … 390 393 } 391 394 395 bool pmChipSelectCell(pmChip *chip, 396 int cellNum 397 ) 398 { 399 assert(chip); 400 401 psArray *cells = chip->cells; // Component cells 402 if (!cells || cellNum > cells->n) { 403 return false; 404 } 405 406 for (int i = 0; i < cells->n; i++) { 407 pmCell *cell = cells->data[i]; 408 if (!cell) { 409 continue; 410 } 411 cell->process = (i == cellNum); 412 } 413 414 return true; 415 } 392 416 393 417 /***************************************************************************** … … 437 461 } 438 462 463 int pmChipExcludeCell(pmChip *chip, 464 int cellNum 465 ) 466 { 467 assert(chip); 468 469 psArray *cells = chip->cells; // The component cells 470 if (!cells || cellNum > cells->n) { 471 return 0; 472 } 473 474 int numCells = 0; // Number of cells to be processed 475 for (int i = 0; i < cells->n; i++) { 476 pmCell *cell = cells->data[i]; 477 if (!cell) { 478 continue; 479 } 480 if (i == cellNum) { 481 cell->process = false; 482 } else { 483 numCells++; 484 } 485 } 486 487 return numCells; 488 } 489 439 490 440 491 bool pmCellSetWeights(pmCell *cell // Cell for which to set weights … … 444 495 float readnoise = psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE"); // Cell read noise 445 496 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // Trim section 497 float saturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION"); // Saturation level 498 float bad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD"); // Bad level 446 499 447 500 p_pmHDU *hdu = cell->hdu; // The data unit, containing the weight and mask originals … … 478 531 psImage *image = pixels->data[i]; 479 532 masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8); 480 psImageInit(masks->data[i], 0);481 533 } 482 534 hdu->masks = masks; … … 489 541 490 542 if (! readout->weight) { 491 readout->weight = weights->data[i];543 readout->weight = psImageSubset(weights->data[i], *trimsec); 492 544 } 493 545 if (! readout->mask) { 494 readout->mask = masks->data[i]; 495 } 496 497 // Mask is already set to 0 546 readout->mask = psImageSubset(masks->data[i], *trimsec); 547 } 548 549 // Set up the mask 550 psImage *image = readout->image;// Pixels 551 psImage *mask = readout->mask; // Mask image 552 for (int i = 0; i < image->numRows; i++) { 553 for (int j = 0; j < image->numCols; j++) { 554 if (image->data.F32[i][j] > saturation) { 555 mask->data.F32[i][j] = PM_MASK_SAT; 556 } 557 if (image->data.F32[i][j] < bad) { 558 mask->data.F32[i][j] = PM_MASK_BAD; 559 } 560 } 561 } 498 562 499 563 // Set weight image to the variance = g*f + rn^2 500 psImage *image = psImageSubset(readout->image, *trimsec); // The pixels 501 psImage *weight = psImageSubset(readout->weight, *trimsec); // The weight map 502 psBinaryOp(weight, image, "*", psScalarAlloc(gain, PS_TYPE_F32)); 503 psBinaryOp(weight, weight, "+", psScalarAlloc(readnoise*readnoise, PS_TYPE_F32)); 564 psBinaryOp(readout->weight, image, "*", psScalarAlloc(gain, PS_TYPE_F32)); 565 psBinaryOp(readout->weight, readout->weight, "+", psScalarAlloc(readnoise*readnoise, PS_TYPE_F32)); 504 566 } 505 567
Note:
See TracChangeset
for help on using the changeset viewer.
