Changeset 12988
- Timestamp:
- Apr 24, 2007, 11:17:19 AM (19 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 2 edited
-
pmShutterCorrection.c (modified) (4 diffs)
-
pmShutterCorrection.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r12696 r12988 12 12 #include "pmHDUUtils.h" 13 13 #include "psVectorBracket.h" 14 #include "pmConceptsAverage.h" 15 14 16 #include "pmShutterCorrection.h" 15 17 … … 347 349 #define MEASURE_SAMPLES 4 348 350 349 psImage *pmShutterCorrectionMeasure(const psArray *readouts, int size, psStatsOptions meanStat,350 psStatsOptions stdevStat, int nIter, float rej, psMaskType maskVal)351 bool pmShutterCorrectionMeasure(pmReadout *output, const psArray *readouts, int size, psStatsOptions meanStat, 352 psStatsOptions stdevStat, int nIter, float rej, psMaskType maskVal) 351 353 { 352 354 PS_ASSERT_ARRAY_NON_NULL(readouts, NULL); … … 591 593 592 594 if (psTraceGetLevel("psModules.detrend") > 5) { 593 psFits *fits = psFitsOpen("pattern.fits", "w");594 psFitsWriteImage(fits, NULL, pattern, 0, NULL);595 psFitsClose(fits);595 psFits *fits = psFitsOpen("pattern.fits", "w"); 596 psFitsWriteImage(fits, NULL, pattern, 0, NULL); 597 psFitsClose(fits); 596 598 } 597 599 psFree(pattern); 598 600 599 return shutter; 601 output->image = shutter; 602 603 // Update the "concepts" 604 psList *inputCells = psListAlloc(NULL); // List of cells 605 for (long i = 0; i < readouts->n; i++) { 606 pmReadout *readout = readouts->data[i]; // Readout of interest 607 psListAdd(inputCells, PS_LIST_TAIL, readout->parent); 608 } 609 bool success = pmConceptsAverageCells(output->parent, inputCells, NULL, NULL, true); 610 psFree(inputCells); 611 612 // Correct the exposure times --- they don't make sense any more. 613 psMetadataItem *item = psMetadataLookup(output->parent->concepts, "CELL.EXPOSURE"); 614 item->data.F32 = NAN; 615 item = psMetadataLookup(output->parent->concepts, "CELL.DARKTIME"); 616 item->data.F32 = NAN; 617 618 return success; 600 619 601 620 … … 611 630 psFree(samplesMean); 612 631 psFree(samplesStdev); 613 return NULL;632 return false; 614 633 } 615 634 -
trunk/psModules/src/detrend/pmShutterCorrection.h
r12696 r12988 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 3-30 21:12:56$7 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-04-24 21:17:19 $ 9 9 * Copyright 2006 Institute for Astronomy, University of Hawaii 10 10 */ … … 29 29 * Choose a reference location in the image (eg, the detector center) and 30 30 * divide by the value of that region (ie, mean or median): 31 * 31 * 32 32 * s(t,x,y) = S(t,x,y) / S(t,0,0) 33 33 * s(t,x,y) = F_o(t) f(x,y) (T_o + dT(x,y)) / F_o(t) f(0,0) (T_o + dT(0,0)) 34 34 * s(t,x,y) = f(x,y) (T_o + dT(x,y)) / f(0,0) (T_o + dT(0,0)) 35 * 35 * 36 36 * we can absorb the term f(0,0) into f(x,y) as we have no motivation for the 37 37 * scale of f(x,y). For any single pixel, over the set of exposures, we thus 38 38 * need to solve for dT(x,y), dT(0,0), and f'(x,y) in the equation: 39 39 * s(t,x,y) = f'(x,y) (T_o + dT(x,y)) / (T_o + dT(0,0)) 40 * 40 * 41 41 * we avoid directly fitting these values as the process would be a non-linear 42 42 * least-squares problem for every pixel in the image, and thus very time … … 48 48 * points covering a reasonable dynamic range, we can solve for these three 49 49 * values by interpolation and/or extrapolation. 50 * 50 * 51 51 * To take the strategy one step further, we could use the above recipe to 52 52 * obtain a guess for the three parameters and then apply non-linear fitting to … … 111 111 /// measuring the reference time offset using the full non-linear fit for a small number of representative 112 112 /// regions (middle and corners), and then using that to perform a linear fit to each pixel. 113 psImage *pmShutterCorrectionMeasure(const psArray *readouts, ///< Array of readouts 114 int size, ///< Size of samples for statistics for non-linear fit 115 psStatsOptions meanStat, ///< Statistic to use for mean 116 psStatsOptions stdevStat, ///< Statistic to use for stdev 117 int nIter, ///< Number of iterations 118 float rej, ///< Rejection threshold (sigma) 119 psMaskType maskVal ///< Mask value 120 ); 113 bool pmShutterCorrectionMeasure(pmReadout *output, ///< Output readout 114 const psArray *readouts, ///< Array of readouts 115 int size, ///< Size of samples for statistics for non-linear fit 116 psStatsOptions meanStat, ///< Statistic to use for mean 117 psStatsOptions stdevStat, ///< Statistic to use for stdev 118 int nIter, ///< Number of iterations 119 float rej, ///< Rejection threshold (sigma) 120 psMaskType maskVal ///< Mask value 121 ); 121 122 122 123 /// Apply a shutter correction
Note:
See TracChangeset
for help on using the changeset viewer.
