IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 15, 2008, 5:51:49 PM (18 years ago)
Author:
eugene
Message:

extensive fixes to make these two programs actually work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dvoTools/src/dvoApplyCorrReadout.c

    r11862 r20180  
    55#include "dvoApplyCorr.h"
    66
    7 // this function is operating on each readout, assuming there is a correspondence between
    8 // readouts in the input (raw) flat-field image and the correction frame.  this is not really
    9 // true
     7// this function is operating on each cell (well, readout) of the flat to be corrected.  The
     8// input chip is supplied, but may be in a different format (eg, chip-mosaic vs single cell)
    109
    11 bool dvoApplyCorrReadout (pmConfig *config, pmFPAview *view, char *inName, char *corrName) {
     10bool dvoApplyCorrReadout (pmCell *inCell, pmChip *corrChip) {
    1211   
     12    // XXX for now, let's just assume the input is per-cell, and the correction is per-chip
     13    // Also, let's assume they are both binned 1x1
     14
    1315    bool status;
    1416
    15     pmFPAfile *inFile = psMetadataLookupPtr (&status, config->files, inName);
    16     pmFPAfile *corrFile = psMetadataLookupPtr (&status, config->files, corrName);
    17     assert (inFile);
    18     assert (corrFile);
     17    pmCell *corrCell = corrChip->cells->data[0];
     18    pmReadout *corrRO = corrCell->readouts->data[0];
     19    psImage *corrImage = corrRO->image;
    1920
    20     pmReadout *inData = pmFPAviewThisReadout (view, inFile->fpa);
    21     pmReadout *corrData = pmFPAviewThisReadout (view, corrFile->fpa);
    22     assert (inData);
    23     assert (corrData);
     21    pmReadout *inRO = inCell->readouts->data[0];
     22    psImage *inImage = inRO->image;
    2423
    25     // dimensions of input image:
    26     assert (inData->image->numCols == corrData->image->numCols);
    27     assert (inData->image->numRows == corrData->image->numRows);
     24    int x0 = psMetadataLookupS32(&status, inCell->concepts, "CELL.X0"); // Position of (0,0) on chip
     25    if (!status) {
     26        psError(PS_ERR_UNKNOWN, true, "CELL.X0 hasn't been set for cell.\n");
     27        return false;
     28    }
     29    int y0 = psMetadataLookupS32(&status, inCell->concepts, "CELL.Y0"); // Position of (0,0) on chip
     30    if (!status) {
     31        psError(PS_ERR_UNKNOWN, true, "CELL.Y0 hasn't been set for cell.\n");
     32        return false;
     33    }
    2834
    29     // NOTE : the output pmFPA points at the same pixels as the input pmFPA
     35    int xParity = psMetadataLookupS32(&status, inCell->concepts, "CELL.XPARITY"); // Parity in x
     36    if (!status) {
     37        psError(PS_ERR_UNKNOWN, true, "CELL.XPARITY hasn't been set for cell.\n");
     38        return false;
     39    }
     40    int yParity = psMetadataLookupS32(&status, inCell->concepts, "CELL.YPARITY"); // Parity in y
     41    if (!status) {
     42        psError(PS_ERR_UNKNOWN, true, "CELL.YPARITY hasn't been set for cell.\n");
     43        return false;
     44    }
    3045
    31     // the corr image is a multiplicative factor
    32     for (int j = 0; j < inData->image->numRows; j++) {
    33         for (int i = 0; i < inData->image->numCols; i++) {
    34             inData->image->data.F32[j][i] *= corrData->image->data.F32[j][i];
     46    // The corr image is a multiplicative factor.  Need to convert the input flat pixel
     47    // coordinates to the correction cell/pixel coords.
     48    for (int j = 0; j < inImage->numRows; j++) {
     49        int jC = (yParity < 0) ? y0 + j*yParity : y0 + j*yParity + 1;
     50        for (int i = 0; i < inImage->numCols; i++) {
     51            int iC = (xParity < 0) ? x0 + i*xParity : x0 + i*xParity + 1;
     52            inImage->data.F32[j][i] *= corrImage->data.F32[jC][iC];
    3553        }
    3654    }
    37 
    38     // psFits *fits = psFitsOpen ("tmp.fits", "w");
    39     // psFitsWriteImage (fits, NULL, inData->image, 0, NULL);
    40     // psFitsClose (fits);
    41     // exit (0);
    42 
    4355    return true;
    4456}
Note: See TracChangeset for help on using the changeset viewer.