Changeset 41894 for trunk/ppImage
- Timestamp:
- Nov 4, 2021, 6:07:14 PM (5 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 6 edited
-
Makefile.am (modified) (1 diff)
-
ppImage.h (modified) (2 diffs)
-
ppImageArguments.c (modified) (1 diff)
-
ppImageDetrendPattern.c (modified) (5 diffs)
-
ppImageParseCamera.c (modified) (2 diffs)
-
ppImageSetThreads.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/Makefile.am
r40453 r41894 42 42 ppImageDefineFile.c \ 43 43 ppImageSetMaskBits.c \ 44 ppImageSetThreads.c \ 44 45 ppImageBurntoolMask.c \ 45 46 ppImageParityFlip.c \ -
trunk/ppImage/src/ppImage.h
r41382 r41894 193 193 bool ppImageBurntoolApply(pmConfig *config, ppImageOptions *options, pmFPAview *view, pmReadout *readout); 194 194 195 bool ppImageDetrendPatternApply(pmConfig *config, pmChip *chip, const pmFPAview *inputView, const ppImageOptions *options); 195 bool ppImageDetrendPatternApply(pmConfig *config, pmChip *chip, const pmFPAview *inputView, ppImageOptions *options); 196 bool ppImageDetrendPatternApplyCell (pmConfig *config, pmFPA *fpa, pmChip *chip, pmCell *cell, pmFPAview *view, ppImageOptions *options); 196 197 197 198 // Do background continuity step … … 326 327 bool ppImageAuxiliaryMask(pmConfig *config, const pmFPAview *view, const ppImageOptions *options, psMetadata *stats); 327 328 329 bool ppImageSetThreads (void); 330 328 331 #endif -
trunk/ppImage/src/ppImageArguments.c
r35685 r41894 116 116 pmConfigFileSetsMD (config->arguments, &argc, argv, "FRINGE", "-fringe", "-fringelist"); 117 117 pmConfigFileSetsMD (config->arguments, &argc, argv, "LINEARITY", "-linearity", "-linearlist"); 118 pmConfigFileSetsMD (config->arguments, &argc, argv, "PATTERN.ROW.AMP", "-pattern-row-amplitude", "-not-defined"); 118 119 119 120 if ((argnum = psArgumentGet(argc, argv, "-burntool"))) { -
trunk/ppImage/src/ppImageDetrendPattern.c
r41265 r41894 14 14 15 15 bool ppImageDetrendPatternApply(pmConfig *config, pmChip *chip, const pmFPAview *inputView, 16 constppImageOptions *options)16 ppImageOptions *options) 17 17 { 18 18 pmCell *cell = NULL; … … 31 31 // CELLS in the format:CHIPS metadata table) 32 32 33 // New 2021 October : During ppImageParseCamera, we have loaded a file identified by 34 // PPIMAGE.PATTERN.ROW.AMP on config->files. This file contains a collection of FITS 35 // tables, one per chip. Each table lists the typical bias-drift amplitude for cell, 36 // measured from a collection of dark images. These values are passed (via 37 // cell->analysis) to pmPatternRow which choosed to apply the correction based on the 38 // ratio of the poisson noise due to the median background (+ read noise) and the 39 // typical amplitude. Tests show that if the amplitude / noise < 1/6, then the 40 // row-by-row variations are insignificant. 41 33 42 // We also check the chip header for the boolean 'PTRN_ROW' : if this is true, we have 34 43 // already applied this correct to this data, so we simply skip the correction for this … … 52 61 53 62 pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT"); 63 64 // grab the PATTERN.ROW.AMP file 65 pmFPAfile *PRAfile = psMetadataLookupPtr (NULL, config->files, "PPIMAGE.PATTERN.ROW.AMP"); 66 if (!PRAfile) { 67 psLogMsg("ppImage", PS_LOG_INFO, "Pattern Row Amplitude file not found, applying to all (with limits from ROW.SUBSET) "); 68 } 69 54 70 pmFPAview *view = pmFPAviewAlloc(0); // View for local processing 55 71 *view = *inputView; … … 75 91 } 76 92 93 // grab the corresponding cell 94 if (PRAfile) { 95 pmCell *PRAcell = pmFPAviewThisCell (view, PRAfile->fpa); 96 psAssert (PRAcell, "found Pattern Row Amplitude file, but not cell?"); 97 98 // find the nominal signal amplitude (check the ghost and/or crosstalk recipe file) 99 float amplitude = psMetadataLookupF32 (&status, PRAcell->analysis, "PTN.ROW.AMP"); 100 if (!status) amplitude = NAN; 101 102 // put the value on the science cell 103 psMetadataAddF32 (cell->analysis, PS_LIST_TAIL, "PTN.ROW.AMP", PS_META_REPLACE, "", amplitude); 104 } 105 77 106 bool doPattern = false; 78 107 if (!doPatternForView(&doPattern, config, chip, view, RECIPE_NAME, "PATTERN.ROW.SUBSET")) { 79 108 ESCAPE(false, "Unable to determine whether row pattern matching should be applied."); 80 109 } 81 //psWarning ("Row: %d\n", doPattern);82 110 if (!doPattern) continue; 83 111 84 // A very detailed log message. 85 const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); 86 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); 87 psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %s, %s\n", chipName, cellName); 88 89 // process each of the readouts 90 pmReadout *readout; // Readout from cell 91 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 92 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 93 ESCAPE(false, "load failure for Readout"); 94 } 95 if (!readout->data_exists) { 96 continue; 97 } 98 99 // Perform pattern correction 100 if (!pmPatternRow(readout, options->patternRowOrder, options->patternRowIter, 101 options->patternRowRej, options->patternRowThresh, options->patternRowMean, 102 options->patternRowStdev, options->maskValue, options->darkMask)) { 103 psFree(view); 104 return(false); 105 } 106 } 107 108 } 112 // switch to test threaded version 113 if (true) { 114 // I need to allocate a view here to be freed by the 115 // called function below. 116 pmFPAview *myView = pmFPAviewAlloc(0); // View for local processing 117 *myView = *view; 118 119 // allocate a job, construct the arguments for this job 120 psThreadJob *job = psThreadJobAlloc("PPIMAGE_PATTERN_ROW_CELL"); 121 psArrayAdd(job->args, 1, config); 122 psArrayAdd(job->args, 1, input->fpa); 123 psArrayAdd(job->args, 1, chip); 124 psArrayAdd(job->args, 1, cell); 125 psArrayAdd(job->args, 1, myView); 126 psArrayAdd(job->args, 1, options); 127 if (!psThreadJobAddPending(job)) { 128 return false; 129 } 130 } else { 131 // bump the counter since it must be freed by the function below. 132 psMemIncrRefCounter (view); // View for local processing 133 if (!ppImageDetrendPatternApplyCell (config, input->fpa, chip, cell, view, options)) { 134 return false; 135 } 136 } 137 138 } 139 140 // wait here for the threaded jobs to finish 141 // if no threads are allocated, this 142 if (!psThreadPoolWait(true, true)) { 143 psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction."); 144 return false; 145 } 146 109 147 psMetadataAddBool(hdu->header, PS_LIST_TAIL, "PTRN_ROW",PS_META_REPLACE,"PATTERN.ROW correction applied",true); 110 148 psFree(view); … … 266 304 return false; 267 305 } 306 307 // thread safety : 308 bool ppImageDetrendPatternApplyCell (pmConfig *config, pmFPA *fpa, pmChip *chip, pmCell *cell, pmFPAview *view, ppImageOptions *options) { 309 310 // process each of the readouts 311 pmReadout *readout; // Readout from cell 312 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 313 if (!readout->data_exists) { 314 continue; 315 } 316 317 // Perform pattern correction 318 if (!pmPatternRow(readout, options->patternRowOrder, options->patternRowIter, 319 options->patternRowRej, options->patternRowThresh, options->patternRowMean, 320 options->patternRowStdev, options->maskValue, options->darkMask)) { 321 psFree (view); 322 return false; 323 } 324 } 325 psFree (view); // supplied view must be freeable 326 return true; 327 } 328 -
trunk/ppImage/src/ppImageParseCamera.c
r36169 r41894 117 117 pmDetrendSetThreadTasks(nScanRows); 118 118 } 119 ppImageSetThreads (); // even if threading is off, we need to identify the ppImageDetrendPattern thread function 119 120 120 121 if (options->doPatternRow || options->doPatternCell) { … … 180 181 psError (PS_ERR_IO, false, "Can't find a fringe image source"); 181 182 return NULL; 183 } 184 } 185 186 if (options->doPatternRow) { 187 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.PATTERN.ROW.AMP", "PATTERN.ROW.AMP", 188 PM_FPA_FILE_PATTERN_ROW_AMP, PM_DETREND_TYPE_PATTERN_ROW_AMP)) { 189 psWarning ("Can't find a pattern row amplitude source, will apply to all cells or defined subset"); 190 // an empty or invalid file may have been generated -- we want to skip, not raise an error 191 pmFPAfile *PRAfile = psMetadataLookupPtr (NULL, config->files, "PPIMAGE.PATTERN.ROW.AMP"); 192 if (PRAfile) { 193 PRAfile->state |= PM_FPA_STATE_INACTIVE; 194 } 182 195 } 183 196 } -
trunk/ppImage/src/ppImageSetThreads.c
r18823 r41894 15 15 } 16 16 17 bool ppImage SetThreads () {17 bool ppImageThread_ppImageDetrendPatternApplyCell (psThreadJob *job) { 18 18 19 psThreadTask *task = NULL; 19 pmConfig *config = job->args->data[0]; 20 pmFPA *fpa = job->args->data[1]; 21 pmChip *chip = job->args->data[2]; 22 pmCell *cell = job->args->data[3]; 23 pmFPAview *view = job->args->data[4]; 24 ppImageOptions *options = job->args->data[5]; 20 25 21 task = psThreadTaskAlloc ("PPIMAGE_DETREND_READOUT", 3);22 task->function = &ppImageThread_ppImageDetrendReadout;23 psThreadTaskAdd (task); 26 bool status = ppImageDetrendPatternApplyCell (config, fpa, chip, cell, view, options); 27 return status; 28 } 24 29 30 bool ppImageSetThreads (void) { 31 32 # if (0) 33 // *** Detrend Readout (now unused : threading is done at the readout level in pmDetrend) 34 { 35 psThreadTask *task = psThreadTaskAlloc ("PPIMAGE_DETREND_READOUT", 3); 36 task->function = &ppImageThread_ppImageDetrendReadout; 37 psThreadTaskAdd (task); 38 } 39 # endif 40 41 // *** Detrend Pattern Row 42 { 43 psThreadTask *task = psThreadTaskAlloc("PPIMAGE_PATTERN_ROW_CELL", 6); 44 task->function = &ppImageThread_ppImageDetrendPatternApplyCell; 45 psThreadTaskAdd(task); 46 psFree(task); 47 } 25 48 return true; 26 49 }
Note:
See TracChangeset
for help on using the changeset viewer.
