IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 19, 2006, 11:47:06 PM (21 years ago)
Author:
Paul Price
Message:

Readouts now contain a subimage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_rel9_p0/psModules/src/astrom/pmFPA.c

    r6062 r6080  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-01-20 02:36:41 $
     14*  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-01-20 09:47:06 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include <string.h>
    2424#include <math.h>
     25#include <assert.h>
    2526#include "pslib.h"
    2627
    2728#include "pmFPA.h"
    2829#include "pmConcepts.h"
     30#include "pmMaskBadPixels.h"
    2931
    3032/******************************************************************************
     
    163165    tmpReadout->mask = NULL;
    164166    tmpReadout->weight = NULL;
     167    tmpReadout->bias = psListAlloc(NULL);
    165168    tmpReadout->analysis = psMetadataAlloc();
    166169    tmpReadout->parent = cell;
     
    390393}
    391394
     395bool pmChipSelectCell(pmChip *chip,
     396                      int cellNum
     397                     )
     398{
     399    assert(chip);
     400
     401    psArray *cells = chip->cells;       // Component cells
     402    if (!cells || cellNum > cells->n) {
     403        return false;
     404    }
     405
     406    for (int i = 0; i < cells->n; i++) {
     407        pmCell *cell = cells->data[i];
     408        if (!cell) {
     409            continue;
     410        }
     411        cell->process = (i == cellNum);
     412    }
     413
     414    return true;
     415}
    392416
    393417/*****************************************************************************
     
    437461}
    438462
     463int pmChipExcludeCell(pmChip *chip,
     464                      int cellNum
     465                     )
     466{
     467    assert(chip);
     468
     469    psArray *cells = chip->cells;       // The component cells
     470    if (!cells || cellNum > cells->n) {
     471        return 0;
     472    }
     473
     474    int numCells = 0;                   // Number of cells to be processed
     475    for (int i = 0; i < cells->n; i++) {
     476        pmCell *cell = cells->data[i];
     477        if (!cell) {
     478            continue;
     479        }
     480        if (i == cellNum) {
     481            cell->process = false;
     482        } else {
     483            numCells++;
     484        }
     485    }
     486
     487    return numCells;
     488}
     489
    439490
    440491bool pmCellSetWeights(pmCell *cell // Cell for which to set weights
     
    444495    float readnoise = psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE"); // Cell read noise
    445496    psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // Trim section
     497    float saturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION"); // Saturation level
     498    float bad = psMetadataLookupF32(NULL, cell->concepts, "CELL.BAD"); // Bad level
    446499
    447500    p_pmHDU *hdu = cell->hdu;           // The data unit, containing the weight and mask originals
     
    478531            psImage *image = pixels->data[i];
    479532            masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
    480             psImageInit(masks->data[i], 0);
    481533        }
    482534        hdu->masks = masks;
     
    489541
    490542        if (! readout->weight) {
    491             readout->weight = weights->data[i];
     543            readout->weight = psImageSubset(weights->data[i], *trimsec);
    492544        }
    493545        if (! readout->mask) {
    494             readout->mask = masks->data[i];
    495         }
    496 
    497         // Mask is already set to 0
     546            readout->mask = psImageSubset(masks->data[i], *trimsec);
     547        }
     548
     549        // Set up the mask
     550        psImage *image = readout->image;// Pixels
     551        psImage *mask = readout->mask;  // Mask image
     552        for (int i = 0; i < image->numRows; i++) {
     553            for (int j = 0; j < image->numCols; j++) {
     554                if (image->data.F32[i][j] > saturation) {
     555                    mask->data.F32[i][j] = PM_MASK_SAT;
     556                }
     557                if (image->data.F32[i][j] < bad) {
     558                    mask->data.F32[i][j] = PM_MASK_BAD;
     559                }
     560            }
     561        }
    498562
    499563        // Set weight image to the variance = g*f + rn^2
    500         psImage *image = psImageSubset(readout->image, *trimsec); // The pixels
    501         psImage *weight = psImageSubset(readout->weight, *trimsec); // The weight map
    502         psBinaryOp(weight, image, "*", psScalarAlloc(gain, PS_TYPE_F32));
    503         psBinaryOp(weight, weight, "+", psScalarAlloc(readnoise*readnoise, PS_TYPE_F32));
     564        psBinaryOp(readout->weight, image, "*", psScalarAlloc(gain, PS_TYPE_F32));
     565        psBinaryOp(readout->weight, readout->weight, "+", psScalarAlloc(readnoise*readnoise, PS_TYPE_F32));
    504566    }
    505567
Note: See TracChangeset for help on using the changeset viewer.