IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12988


Ignore:
Timestamp:
Apr 24, 2007, 11:17:19 AM (19 years ago)
Author:
Paul Price
Message:

Changing pmShutterCorrectionMeasure to act on a readout, rather than return an image, so that it can update the 'concepts' as well.

Location:
trunk/psModules/src/detrend
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r12696 r12988  
    1212#include "pmHDUUtils.h"
    1313#include "psVectorBracket.h"
     14#include "pmConceptsAverage.h"
     15
    1416#include "pmShutterCorrection.h"
    1517
     
    347349#define MEASURE_SAMPLES 4
    348350
    349 psImage *pmShutterCorrectionMeasure(const psArray *readouts, int size, psStatsOptions meanStat,
    350                                     psStatsOptions stdevStat, int nIter, float rej, psMaskType maskVal)
     351bool pmShutterCorrectionMeasure(pmReadout *output, const psArray *readouts, int size, psStatsOptions meanStat,
     352                                psStatsOptions stdevStat, int nIter, float rej, psMaskType maskVal)
    351353{
    352354    PS_ASSERT_ARRAY_NON_NULL(readouts, NULL);
     
    591593
    592594    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);
    596598    }
    597599    psFree(pattern);
    598600
    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;
    600619
    601620
     
    611630    psFree(samplesMean);
    612631    psFree(samplesStdev);
    613     return NULL;
     632    return false;
    614633}
    615634
  • trunk/psModules/src/detrend/pmShutterCorrection.h

    r12696 r12988  
    55 * @author Paul Price, IfA
    66 *
    7  * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-03-30 21:12:56 $
     7 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-04-24 21:17:19 $
    99 * Copyright 2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    2929 *  Choose a reference location in the image (eg, the detector center) and
    3030 *  divide by the value of that region (ie, mean or median):
    31  * 
     31 *
    3232 *  s(t,x,y) = S(t,x,y) / S(t,0,0)
    3333 *  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))
    3434 *  s(t,x,y) = f(x,y) (T_o + dT(x,y)) / f(0,0) (T_o + dT(0,0))
    35  * 
     35 *
    3636 *  we can absorb the term f(0,0) into f(x,y) as we have no motivation for the
    3737 *  scale of f(x,y).  For any single pixel, over the set of exposures, we thus
    3838 *  need to solve for dT(x,y), dT(0,0), and f'(x,y) in the equation:
    3939 *  s(t,x,y) = f'(x,y) (T_o + dT(x,y)) / (T_o + dT(0,0))
    40  * 
     40 *
    4141 *  we avoid directly fitting these values as the process would be a non-linear
    4242 *  least-squares problem for every pixel in the image, and thus very time
     
    4848 *  points covering a reasonable dynamic range, we can solve for these three
    4949 *  values by interpolation and/or extrapolation.
    50  * 
     50 *
    5151 *  To take the strategy one step further, we could use the above recipe to
    5252 *  obtain a guess for the three parameters and then apply non-linear fitting to
     
    111111/// measuring the reference time offset using the full non-linear fit for a small number of representative
    112112/// 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                                    );
     113bool 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    );
    121122
    122123/// Apply a shutter correction
Note: See TracChangeset for help on using the changeset viewer.