- Timestamp:
- Jun 15, 2010, 11:22:56 AM (16 years ago)
- Location:
- branches/czw_branch/20100519
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
ppBackground (modified) (1 prop)
-
ppBackground/src (modified) (1 prop)
-
ppBackground/src/ppBackgroundLoop.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100519
- Property svn:mergeinfo changed
/trunk merged: 28280-28298,28300-28302,28305-28307
- Property svn:mergeinfo changed
-
branches/czw_branch/20100519/ppBackground
-
Property svn:ignore
set to
configure
Makefile.in
ignore
config.log
depcomp
config.status
config.guess
ltmain.sh
config.sub
autom4te.cache
libtool
missing
Makefile
aclocal.m4
install-sh
-
Property svn:ignore
set to
-
branches/czw_branch/20100519/ppBackground/src
-
Property svn:ignore
set to
ppBackground
Makefile.in
config.h
ppBackgroundVersionDefinitions.h
.deps
Makefile
ppBackgroundErrorCodes.c
ppBackgroundErrorCodes.h
stamp-h1
config.h.in
-
Property svn:ignore
set to
-
branches/czw_branch/20100519/ppBackground/src/ppBackgroundLoop.c
r28304 r28334 6 6 #include <pslib.h> 7 7 #include <psmodules.h> 8 #include <ppStats.h> 8 9 9 10 #include "ppBackground.h" … … 13 14 { 14 15 pmConfig *config = data->config; // Configuration data 15 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND. BACKGROUND", 0);16 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.IMAGE", 0); 16 17 pmFPAfile *patternFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.PATTERN", 0); // File with data 18 pmFPAfile *bgFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.BACKGROUND", 0); // File with bg 17 19 pmFPA *patternMosaic = pmFPAConstruct(file->camera, file->cameraName); // Mosaicked FPA for pattern 18 20 19 psImageMaskType maskBad = pmConfigMaskGet(" BLANK", config); // Mask value to set21 psImageMaskType maskBad = pmConfigMaskGet("DETECTOR", config); // Mask value to set 20 22 21 23 pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy … … 34 36 } 35 37 36 if (chip->cell ->n > 1) {38 if (chip->cells->n > 1) { 37 39 psError(PPBACKGROUND_ERR_CONFIG, true, 38 40 "Input image and background model should be chip-mosaicked"); … … 44 46 pmFPAfileActivate(config->files, true, "PPBACKGROUND.PATTERN"); 45 47 46 pmCell * cell; // Cell with pattern data48 pmCell *patternCell; // Cell with pattern data 47 49 while ((patternCell = pmFPAviewNextCell(view, patternFile->fpa, 1))) { 48 if (! cell->process || !cell->file_exists) {50 if (!patternCell->process || !patternCell->file_exists) { 49 51 continue; 50 52 } … … 68 70 // Get size of image from concepts 69 71 if (numCols == 0 || numRows == 0) { 70 numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE");71 numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE");72 numCols = psMetadataLookupS32(NULL, patternCell->concepts, "CELL.XSIZE"); 73 numRows = psMetadataLookupS32(NULL, patternCell->concepts, "CELL.YSIZE"); 72 74 } 73 75 // Get size of image from TRIMSEC 74 76 if (numCols == 0 || numRows == 0) { 75 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");77 psRegion *trimsec = psMetadataLookupPtr(NULL, patternCell->concepts, "CELL.TRIMSEC"); 76 78 numCols = trimsec->x1 - trimsec->x0; 77 79 numRows = trimsec->y1 - trimsec->y0; … … 84 86 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 85 87 psImageInit(readout->image, 0.0); 88 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 89 psImageInit(readout->mask, 0); 86 90 87 91 if (!pmPatternRowApply(readout, maskBad) || !pmPatternCellApply(readout, maskBad)) { … … 91 95 92 96 // Remove bias sections to avoid warnings 93 psMetadataItem *biassec = psMetadataLookup(pattern RO->parent->concepts, "CELL.BIASSEC");97 psMetadataItem *biassec = psMetadataLookup(patternCell->concepts, "CELL.BIASSEC"); 94 98 if (psListLength(biassec->data.V)) { 95 99 psFree(biassec->data.V); … … 114 118 } 115 119 116 pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern 117 if (!pmChipMosaic(mosaic, chip, true, maskBad)) { 118 psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction"); 119 return false; 120 if (data->patternName) { 121 pmChip *patternChip = pmFPAviewThisChip(view, patternFile->fpa); // Chip for pattern 122 pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern 123 if (!mosaic->hdu && !mosaic->parent->hdu) { 124 pmFPAAddSourceFromView(patternMosaic, view, file->format); 125 } 126 if (!pmChipMosaic(mosaic, patternChip, true, maskBad)) { 127 psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction"); 128 return false; 129 } 130 pmFPAfileActivate(config->files, true, NULL); 131 // pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN"); 120 132 } 121 pmFPAfileActivate(config->files, true, NULL);122 pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");123 133 } 124 134 135 pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern 136 pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model 137 if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config)) { 138 psError(psErrorCodeLast(), false, "Unable to replace background"); 139 return false; 140 } 141 pmChipFreeData(patternChip); 125 142 126 127 128 129 130 131 pmHDU *hdu = pmHDUGetLowest(file->fpa, chip, cell); // HDU for readout 132 if (!hdu) { 133 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU for data."); 134 return false; 135 } 136 if (!hdu->header) { 137 hdu->header = psMetadataAlloc(); 138 } 139 ppBackgroundVersionHeader(hdu->header); 140 141 142 143 144 145 146 143 pmHDU *hdu = pmHDUGetLowest(file->fpa, chip, NULL); // HDU for chip 144 if (!hdu) { 145 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU for data."); 146 return false; 147 } 148 if (!hdu->header) { 149 hdu->header = psMetadataAlloc(); 150 } 151 ppBackgroundVersionHeader(hdu->header); 147 152 148 153 // Chip … … 158 163 } 159 164 165 psFree(patternMosaic); 166 167 if (data->stats) { 168 psImageMaskType maskVal = 0; // Bits to mask 169 if (!pmConfigMaskSetBits(&maskVal, NULL, config)) { 170 psError(psErrorCodeLast(), false, "Unable to find bits to mask"); 171 return false; 172 } 173 ppStatsFPA(data->stats, file->fpa, view, maskVal, config); 174 } 175 176 psFree(view); 177 160 178 return true; 161 179 }
Note:
See TracChangeset
for help on using the changeset viewer.
