Changeset 6080
- Timestamp:
- Jan 19, 2006, 11:47:06 PM (21 years ago)
- Location:
- branches/eam_rel9_p0/psModules/src
- Files:
-
- 8 edited
-
astrom/pmChipMosaic.c (modified) (6 diffs)
-
astrom/pmConcepts.c (modified) (1 diff)
-
astrom/pmFPA.c (modified) (8 diffs)
-
astrom/pmFPA.h (modified) (4 diffs)
-
astrom/pmFPARead.c (modified) (8 diffs)
-
detrend/pmFlatField.c (modified) (5 diffs)
-
detrend/pmMaskBadPixels.h (modified) (2 diffs)
-
imsubtract/pmSubtractBias.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c
r6062 r6080 37 37 int yMin = INT_MAX; 38 38 int yMax = - INT_MAX; 39 psElemType type = 0; 39 40 for (int i = 0; i < source->n; i++) { 40 41 psImage *image = source->data[i]; // The image of interest … … 43 44 } 44 45 45 assert(image->type.type == PS_TYPE_F32); // Only implemented for F32 images so far. 46 // Only implemented for F32 and U8 images so far. 47 assert(image->type.type == PS_TYPE_F32 || image->type.type == PS_TYPE_U8); 48 // All input types must be the same 49 if (type == 0) { 50 type = image->type.type; 51 } 52 assert(type == image->type.type); 46 53 47 54 // Size of cell in x and y … … 71 78 72 79 psTrace(__func__, 3, "Spliced image will be %dx%d\n", (int)xSize, (int)ySize); 73 psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, PS_TYPE_F32); // The mosaic image80 psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, type); // The mosaic image 74 81 psImageInit(mosaic, 0.0); 75 82 … … 96 103 // In case the original image is binned but the mosaic is not, we need to fill in the 97 104 // values in the mosaic. 98 for (int j = 0; j < yBinSource->data.S32[i]; j++) { 99 int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget); 100 for (int i = 0; i < xBinSource->data.S32[i]; i++) { 101 int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget); 102 103 mosaic->data.F32[yTarget][xTarget] += image->data.F32[y][x]; 104 } 105 } // Iterating over mosaic image for binned input image 105 #define FILL_IN(TYPE) \ 106 for (int j = 0; j < yBinSource->data.S32[i]; j++) { \ 107 int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget); \ 108 for (int i = 0; i < xBinSource->data.S32[i]; i++) { \ 109 int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget); \ 110 mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x]; \ 111 } \ 112 } 113 114 switch (type) { 115 case PS_TYPE_F32: 116 FILL_IN(F32); 117 break; 118 case PS_TYPE_U8: 119 FILL_IN(U8); 120 break; 121 default: 122 psAbort(__func__, "Should never get here.\n"); 123 } 124 106 125 } 107 126 } // Iterating over input image … … 158 177 } 159 178 160 // Trim the image to get rid of the overscan161 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");162 psTrace(__func__, 7, "Cell %d trimsec: [%.0f:%.0f,%.0f:%.0f]\n", i, trimsec->x0, trimsec->x1,163 trimsec->y0, trimsec->y1);164 179 psArray *readouts = cell->readouts; // The array of readouts 165 180 if (readouts->n > 1) { … … 167 182 "be mosaicked.\n", i); 168 183 } 169 p sImage *image = ((pmReadout*)readouts->data[0])->image; // The image to put into the mosaic170 psImage *weight = ((pmReadout*)readouts->data[0])->weight; 171 psImage *mask = ((pmReadout*)readouts->data[0])->weight;172 images->data[i] = psImageSubset(image, *trimsec); // Trimmed image173 weights->data[i] = weight ? psImageSubset(weight, *trimsec) : NULL;174 masks->data[i] = mask ? psImageSubset(mask, *trimsec) : NULL;184 pmReadout *readout = readouts->data[0]; // The only readout we'll bother with 185 186 // The images to put into the mosaic 187 images->data[i] = readout->image; 188 weights->data[i] = readout->weight; 189 masks->data[i] = readout->mask; 175 190 } 176 191 // Mosaic the images together and we're done -
branches/eam_rel9_p0/psModules/src/astrom/pmConcepts.c
r6062 r6080 160 160 while ((item = psMetadataGetAndIncrement(iter))) { 161 161 const char *name = item->name; // Name of the concept 162 if (!strcmp(name, "CELL.NAME") || !strcmp(name, "CHIP.NAME")) { 163 // These concepts are not written out; they are set from things like the FITS extname 164 continue; 165 } 162 166 psMetadataItem *specItem = psMetadataLookup(*specs, name); // Specification for the concept 163 167 if (specItem) { -
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 -
branches/eam_rel9_p0/psModules/src/astrom/pmFPA.h
r6062 r6080 7 7 * @author GLG, MHPCC 8 8 * 9 * @version $Revision: 1.1.2. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-01-20 0 2:36:41$9 * @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-01-20 09:47:06 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 153 153 psImage *mask; ///< Mask of input image 154 154 psImage *weight; ///< Weight of input image 155 psList *bias; ///< Overscan images 155 156 psMetadata *analysis; ///< Readout-level analysis metadata 156 157 pmCell *parent; ///< Parent cell … … 261 262 ); 262 263 264 bool pmChipSelectCell(pmChip *chip, 265 int cellNum 266 ); 267 263 268 /** 264 269 * … … 275 280 ); 276 281 282 int pmChipExcludeCell(pmChip *chip, 283 int cellNum 284 ); 277 285 278 286 // Set the weights and masks within a cell, based on the gain and RN -
branches/eam_rel9_p0/psModules/src/astrom/pmFPARead.c
r6077 r6080 1 1 #include <stdio.h> 2 2 #include <strings.h> 3 #include <assert.h> 3 4 #include "pslib.h" 4 5 … … 105 106 { 106 107 psArray *images = hdu->images; // Array of images (each of which is a readout) 107 psArray *masks = hdu->masks; // Array of masks (one for each readout) 108 109 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); 110 psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC"); 111 108 112 // Iterate over each of the image planes 109 113 for (int i = 0; i < images->n; i++) { 110 114 psImage *image = images->data[i]; // The i-th plane 111 psImage *mask = NULL; // The mask112 if (masks) {113 mask = masks->data[i];114 }115 116 115 pmReadout *readout = pmReadoutAlloc(cell); 117 readout->image = image; 118 readout->mask = mask; 119 psFree(readout); 116 117 readout->image = psImageSubset(image, *trimsec); // The image corresponding to the trim region 118 119 // Get the list of overscans 120 psListIterator *iter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, false); // Iterator 121 psRegion *biassec = NULL; // A BIASSEC region from the list 122 while ((biassec = psListGetAndIncrement(iter))) { 123 psImage *overscan = psImageSubset(image, *biassec); 124 psListAdd(readout->bias, PS_LIST_TAIL, overscan); 125 psFree(overscan); 126 } 127 psFree(iter); 128 129 readout->mask = NULL; 130 readout->weight = NULL; 131 132 psFree(readout); // Drop reference 120 133 } 121 134 … … 164 177 pmChip *chip = chips->data[i]; // The chip 165 178 166 // Only read chips marked to " process"167 if (! chip->process ) {179 // Only read chips marked to "read" 180 if (! chip->process || chip->exists) { 168 181 psTrace(__func__, 2, "Ignoring chip %d...\n", i); 169 182 continue; … … 187 200 pmCell *cell = cells->data[j]; // The cell 188 201 189 // Only read cells marked to " process"190 if (! cell->process ) {202 // Only read cells marked to "read" 203 if (! cell->process || cell->exists) { 191 204 psTrace(__func__, 3, "Ignoring chip %d...\n", i); 192 205 continue; … … 400 413 for (int chipNum = 0; chipNum < chips->n; chipNum++) { 401 414 pmChip *chip = chips->data[chipNum]; // The current chip of interest 402 if (chip->process ) {415 if (chip->process && !chip->exists) { 403 416 if (chip->hdu) { 404 417 hdu = chip->hdu; … … 407 420 for (int cellNum = 0; cellNum < cells->n; cellNum++) { 408 421 pmCell *cell = cells->data[cellNum]; // The current cell of interest 409 if (cell->process ) {422 if (cell->process && !cell->exists) { 410 423 if (cell->hdu) { 411 424 hdu = cell->hdu; … … 538 551 for (int chipNum = 0; chipNum < chips->n; chipNum++) { 539 552 pmChip *chip = chips->data[chipNum]; // The current chip of interest 540 if (chip->process ) {553 if (chip->process && !chip->exists) { 541 554 if (chip->hdu) { 542 555 hdu = chip->hdu; … … 545 558 for (int cellNum = 0; cellNum < cells->n; cellNum++) { 546 559 pmCell *cell = cells->data[cellNum]; // The current cell of interest 547 if (cell->process ) {560 if (cell->process && !cell->exists) { 548 561 if (cell->hdu) { 549 562 hdu = cell->hdu; -
branches/eam_rel9_p0/psModules/src/detrend/pmFlatField.c
r6076 r6080 24 24 * @author Ross Harman, MHPCC 25 25 * 26 * @version $Revision: 1.4.8.1.2. 2$ $Name: not supported by cvs2svn $27 * @date $Date: 2006-01-20 0 6:01:02$26 * @version $Revision: 1.4.8.1.2.3 $ $Name: not supported by cvs2svn $ 27 * @date $Date: 2006-01-20 09:47:06 $ 28 28 * 29 29 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 53 53 psElemType flatType; 54 54 psElemType maskType; 55 psImage *inImage = NULL;56 psImage *inMask = NULL;57 psImage *flatImage = NULL;58 59 55 60 56 // Check for nulls … … 67 63 } 68 64 69 // Get the TRIMSEC of each image 70 { 71 psRegion *trimsec = psMetadataLookupPtr(NULL, in->parent->concepts, "CELL.TRIMSEC"); 72 inImage = psImageSubset(in->image, *trimsec); 73 trimsec = psMetadataLookupPtr(NULL, flat->parent->concepts, "CELL.TRIMSEC"); 74 flatImage = psImageSubset(flat->image, *trimsec); 75 } 65 psImage *inImage = in->image; // Input image 66 psImage *inMask = in->mask; // Mask for input image 67 psImage *flatImage = flat->image; // Flat-field image 68 69 // Offsets on the chip 70 int x0in = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.X0"); 71 int y0in = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.Y0"); 72 int x0flat = psMetadataLookupS32(NULL, flat->parent->concepts, "CELL.X0"); 73 int y0flat = psMetadataLookupS32(NULL, flat->parent->concepts, "CELL.Y0"); 76 74 77 75 if (inImage == NULL) { … … 84 82 return false; 85 83 } 86 inMask = in->mask;87 84 88 85 // Check input image and its mask are not larger than flat image … … 102 99 103 100 // Determine total offset based on image offset with chip offset 104 totOffCol = inImage->col0 + in->col0;105 totOffRow = inImage->row0 + in->row0;101 totOffCol = inImage->col0 + y0in - flatImage->col0 - y0flat; 102 totOffRow = inImage->row0 + x0in - flatImage->row0 - x0flat; 106 103 107 104 // Check that offsets are within image limits -
branches/eam_rel9_p0/psModules/src/detrend/pmMaskBadPixels.h
r6062 r6080 24 24 * @author Ross Harman, MHPCC 25 25 * 26 * @version $Revision: 1.2.8.1.2. 1$ $Name: not supported by cvs2svn $27 * @date $Date: 2006-01-20 0 2:38:28$26 * @version $Revision: 1.2.8.1.2.2 $ $Name: not supported by cvs2svn $ 27 * @date $Date: 2006-01-20 09:47:06 $ 28 28 * 29 29 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 PM_MASK_BADCOL = 0x0002, ///< The pixel is a bad column. 39 39 PM_MASK_SAT = 0x0004, ///< The pixel is saturated. 40 PM_MASK_FLAT = 0x0008 ///< The pixel is non-positive in the flat-field. 40 PM_MASK_BAD = 0x0008, ///< The pixel is low 41 PM_MASK_FLAT = 0x0010 ///< The pixel is non-positive in the flat-field. 41 42 } pmMaskValue; 42 43 -
branches/eam_rel9_p0/psModules/src/imsubtract/pmSubtractBias.c
r6078 r6080 11 11 * @author GLG, MHPCC 12 12 * 13 * @version $Revision: 1.6.8.1.2. 3$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-01-20 0 6:03:29$13 * @version $Revision: 1.6.8.1.2.4 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-01-20 09:47:06 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 102 102 assert(sub); 103 103 104 // Get the trim sections 105 psRegion *inTrimsec = psMetadataLookupPtr(NULL, in->parent->concepts, "CELL.TRIMSEC"); 106 psRegion *subTrimsec = psMetadataLookupPtr(NULL, sub->parent->concepts, "CELL.TRIMSEC"); 107 psImage *inImage = psImageSubset(in->image, *inTrimsec); // The input image 108 psImage *subImage = psImageSubset(sub->image, *subTrimsec); // The image to be subtracted 109 psImage *inMask = in->mask ? psImageSubset(in->mask, *inTrimsec) : NULL; // The input mask 110 psImage *subMask = sub->mask ? psImageSubset(sub->mask, *subTrimsec) : NULL; // The input mask 104 psImage *inImage = in->image; // The input image 105 psImage *inMask = in->mask; // The input mask 106 psImage *subImage = sub->image; // The image to be subtracted 107 psImage *subMask = sub->mask; // The mask for the subtraction image 111 108 112 109 // Offsets of the cells … … 425 422 PS_ASSERT_READOUT_TYPE(in, PS_TYPE_F32, NULL); 426 423 427 pmCell *cell = in->parent; // The parent cell 428 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // The trim region 429 psImage *image = psImageSubset(in->image, *trimsec); // The image corresponding to the trim region 424 psImage *image = in->image; // The input image 430 425 431 426 // Overscan processing … … 438 433 } 439 434 440 // Get the list of overscans 441 psList *overscanRegions = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC"); 442 psList *overscans = psListAlloc(NULL); // List of the overscan images 443 psListIterator *iter = psListIteratorAlloc(overscanRegions, PS_LIST_HEAD, false); // Iterator 444 psRegion *biassec = NULL; // A BIASSEC region from the list 445 while ((biassec = psListGetAndIncrement(iter))) { 446 psImage *overscan = psImageSubset(in->image, *biassec); 447 psListAdd(overscans, PS_LIST_TAIL, overscan); 448 psFree(overscan); 449 } 450 psFree(iter); 435 psList *overscans = in->bias; // List of the overscan images 451 436 452 437 psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // A new psStats, to avoid clobbering original … … 482 467 483 468 // We do the regular overscan subtraction 484 bool readRows = psMetadataLookupBool(NULL, cell->concepts, "CELL.READDIR"); // Read direction 469 470 bool readRows = psMetadataLookupBool(NULL, in->parent->concepts, "CELL.READDIR");// Read direction 485 471 486 472 if (readRows) {
Note:
See TracChangeset
for help on using the changeset viewer.
