IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6080


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

Readouts now contain a subimage

Location:
branches/eam_rel9_p0/psModules/src
Files:
8 edited

Legend:

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

    r6062 r6080  
    3737    int yMin = INT_MAX;
    3838    int yMax = - INT_MAX;
     39    psElemType type = 0;
    3940    for (int i = 0; i < source->n; i++) {
    4041        psImage *image = source->data[i]; // The image of interest
     
    4344        }
    4445
    45         assert(image->type.type == PS_TYPE_F32); // Only implemented for F32 images so far.
     46        // Only implemented for F32 and U8 images so far.
     47        assert(image->type.type == PS_TYPE_F32 || image->type.type == PS_TYPE_U8);
     48        // All input types must be the same
     49        if (type == 0) {
     50            type = image->type.type;
     51        }
     52        assert(type == image->type.type);
    4653
    4754        // Size of cell in x and y
     
    7178
    7279    psTrace(__func__, 3, "Spliced image will be %dx%d\n", (int)xSize, (int)ySize);
    73     psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, PS_TYPE_F32); // The mosaic image
     80    psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, type); // The mosaic image
    7481    psImageInit(mosaic, 0.0);
    7582
     
    96103                    // In case the original image is binned but the mosaic is not, we need to fill in the
    97104                    // values in the mosaic.
    98                     for (int j = 0; j < yBinSource->data.S32[i]; j++) {
    99                         int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget);
    100                         for (int i = 0; i < xBinSource->data.S32[i]; i++) {
    101                             int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget);
    102 
    103                             mosaic->data.F32[yTarget][xTarget] += image->data.F32[y][x];
    104                         }
    105                     } // Iterating over mosaic image for binned input image
     105                    #define FILL_IN(TYPE)                                                                    \
     106                    for (int j = 0; j < yBinSource->data.S32[i]; j++) {                                      \
     107                        int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget);           \
     108                        for (int i = 0; i < xBinSource->data.S32[i]; i++) {                                  \
     109                            int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget);       \
     110                            mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x];                   \
     111                        }                                                                                    \
     112                    }
     113
     114                    switch (type) {
     115                    case PS_TYPE_F32:
     116                        FILL_IN(F32);
     117                        break;
     118                    case PS_TYPE_U8:
     119                        FILL_IN(U8);
     120                        break;
     121                    default:
     122                        psAbort(__func__, "Should never get here.\n");
     123                    }
     124
    106125                }
    107126            } // Iterating over input image
     
    158177        }
    159178
    160         // Trim the image to get rid of the overscan
    161         psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
    162         psTrace(__func__, 7, "Cell %d trimsec: [%.0f:%.0f,%.0f:%.0f]\n", i, trimsec->x0, trimsec->x1,
    163                 trimsec->y0, trimsec->y1);
    164179        psArray *readouts = cell->readouts; // The array of readouts
    165180        if (readouts->n > 1) {
     
    167182                     "be mosaicked.\n", i);
    168183        }
    169         psImage *image = ((pmReadout*)readouts->data[0])->image; // The image to put into the mosaic
    170         psImage *weight = ((pmReadout*)readouts->data[0])->weight;
    171         psImage *mask = ((pmReadout*)readouts->data[0])->weight;
    172         images->data[i] = psImageSubset(image, *trimsec); // Trimmed image
    173         weights->data[i] = weight ? psImageSubset(weight, *trimsec) : NULL;
    174         masks->data[i] = mask ? psImageSubset(mask, *trimsec) : NULL;
     184        pmReadout *readout = readouts->data[0]; // The only readout we'll bother with
     185
     186        // The images to put into the mosaic
     187        images->data[i]  = readout->image;
     188        weights->data[i] = readout->weight;
     189        masks->data[i]   = readout->mask;
    175190    }
    176191    // Mosaic the images together and we're done
  • branches/eam_rel9_p0/psModules/src/astrom/pmConcepts.c

    r6062 r6080  
    160160    while ((item = psMetadataGetAndIncrement(iter))) {
    161161        const char *name = item->name;  // Name of the concept
     162        if (!strcmp(name, "CELL.NAME") || !strcmp(name, "CHIP.NAME")) {
     163            // These concepts are not written out; they are set from things like the FITS extname
     164            continue;
     165        }
    162166        psMetadataItem *specItem = psMetadataLookup(*specs, name); // Specification for the concept
    163167        if (specItem) {
  • 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
  • branches/eam_rel9_p0/psModules/src/astrom/pmFPA.h

    r6062 r6080  
    77*  @author GLG, MHPCC
    88*
    9 *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2006-01-20 02:36:41 $
     9*  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2006-01-20 09:47:06 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    153153    psImage *mask;                      ///< Mask of input image
    154154    psImage *weight;                    ///< Weight of input image
     155    psList *bias;                       ///< Overscan images
    155156    psMetadata *analysis;               ///< Readout-level analysis metadata
    156157    pmCell *parent;                     ///< Parent cell
     
    261262);
    262263
     264bool pmChipSelectCell(pmChip *chip,
     265                      int cellNum
     266                     );
     267
    263268/**
    264269 *
     
    275280);
    276281
     282int pmChipExcludeCell(pmChip *chip,
     283                      int cellNum
     284                     );
    277285
    278286// Set the weights and masks within a cell, based on the gain and RN
  • branches/eam_rel9_p0/psModules/src/astrom/pmFPARead.c

    r6077 r6080  
    11#include <stdio.h>
    22#include <strings.h>
     3#include <assert.h>
    34#include "pslib.h"
    45
     
    105106{
    106107    psArray *images = hdu->images;      // Array of images (each of which is a readout)
    107     psArray *masks = hdu->masks;        // Array of masks (one for each readout)
     108
     109    psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
     110    psList *biassecs = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC");
     111
    108112    // Iterate over each of the image planes
    109113    for (int i = 0; i < images->n; i++) {
    110114        psImage *image = images->data[i]; // The i-th plane
    111         psImage *mask = NULL;           // The mask
    112         if (masks) {
    113             mask = masks->data[i];
    114         }
    115 
    116115        pmReadout *readout = pmReadoutAlloc(cell);
    117         readout->image = image;
    118         readout->mask = mask;
    119         psFree(readout);
     116
     117        readout->image = psImageSubset(image, *trimsec); // The image corresponding to the trim region
     118
     119        // Get the list of overscans
     120        psListIterator *iter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, false); // Iterator
     121        psRegion *biassec = NULL;       // A BIASSEC region from the list
     122        while ((biassec = psListGetAndIncrement(iter))) {
     123            psImage *overscan = psImageSubset(image, *biassec);
     124            psListAdd(readout->bias, PS_LIST_TAIL, overscan);
     125            psFree(overscan);
     126        }
     127        psFree(iter);
     128
     129        readout->mask = NULL;
     130        readout->weight = NULL;
     131
     132        psFree(readout);                // Drop reference
    120133    }
    121134
     
    164177        pmChip *chip = chips->data[i]; // The chip
    165178
    166         // Only read chips marked to "process"
    167         if (! chip->process) {
     179        // Only read chips marked to "read"
     180        if (! chip->process || chip->exists) {
    168181            psTrace(__func__, 2, "Ignoring chip %d...\n", i);
    169182            continue;
     
    187200            pmCell *cell = cells->data[j]; // The cell
    188201
    189             // Only read cells marked to "process"
    190             if (! cell->process) {
     202            // Only read cells marked to "read"
     203            if (! cell->process || cell->exists) {
    191204                psTrace(__func__, 3, "Ignoring chip %d...\n", i);
    192205                continue;
     
    400413    for (int chipNum = 0; chipNum < chips->n; chipNum++) {
    401414        pmChip *chip = chips->data[chipNum]; // The current chip of interest
    402         if (chip->process) {
     415        if (chip->process && !chip->exists) {
    403416            if (chip->hdu) {
    404417                hdu = chip->hdu;
     
    407420            for (int cellNum = 0; cellNum < cells->n; cellNum++) {
    408421                pmCell *cell = cells->data[cellNum]; // The current cell of interest
    409                 if (cell->process) {
     422                if (cell->process && !cell->exists) {
    410423                    if (cell->hdu) {
    411424                        hdu = cell->hdu;
     
    538551    for (int chipNum = 0; chipNum < chips->n; chipNum++) {
    539552        pmChip *chip = chips->data[chipNum]; // The current chip of interest
    540         if (chip->process) {
     553        if (chip->process && !chip->exists) {
    541554            if (chip->hdu) {
    542555                hdu = chip->hdu;
     
    545558            for (int cellNum = 0; cellNum < cells->n; cellNum++) {
    546559                pmCell *cell = cells->data[cellNum]; // The current cell of interest
    547                 if (cell->process) {
     560                if (cell->process && !cell->exists) {
    548561                    if (cell->hdu) {
    549562                        hdu = cell->hdu;
  • branches/eam_rel9_p0/psModules/src/detrend/pmFlatField.c

    r6076 r6080  
    2424 *  @author Ross Harman, MHPCC
    2525 *
    26  *  @version $Revision: 1.4.8.1.2.2 $ $Name: not supported by cvs2svn $
    27  *  @date $Date: 2006-01-20 06:01:02 $
     26 *  @version $Revision: 1.4.8.1.2.3 $ $Name: not supported by cvs2svn $
     27 *  @date $Date: 2006-01-20 09:47:06 $
    2828 *
    2929 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5353    psElemType flatType;
    5454    psElemType maskType;
    55     psImage *inImage = NULL;
    56     psImage *inMask = NULL;
    57     psImage *flatImage = NULL;
    58 
    5955
    6056    // Check for nulls
     
    6763    }
    6864
    69     // Get the TRIMSEC of each image
    70     {
    71         psRegion *trimsec = psMetadataLookupPtr(NULL, in->parent->concepts, "CELL.TRIMSEC");
    72         inImage = psImageSubset(in->image, *trimsec);
    73         trimsec = psMetadataLookupPtr(NULL, flat->parent->concepts, "CELL.TRIMSEC");
    74         flatImage = psImageSubset(flat->image, *trimsec);
    75     }
     65    psImage *inImage   = in->image;     // Input image
     66    psImage *inMask    = in->mask;      // Mask for input image
     67    psImage *flatImage = flat->image;   // Flat-field image
     68
     69    // Offsets on the chip
     70    int x0in = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.X0");
     71    int y0in = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.Y0");
     72    int x0flat = psMetadataLookupS32(NULL, flat->parent->concepts, "CELL.X0");
     73    int y0flat = psMetadataLookupS32(NULL, flat->parent->concepts, "CELL.Y0");
    7674
    7775    if (inImage == NULL) {
     
    8482        return false;
    8583    }
    86     inMask = in->mask;
    8784
    8885    // Check input image and its mask are not larger than flat image
     
    10299
    103100    // Determine total offset based on image offset with chip offset
    104     totOffCol = inImage->col0 + in->col0;
    105     totOffRow = inImage->row0 + in->row0;
     101    totOffCol = inImage->col0 + y0in - flatImage->col0 - y0flat;
     102    totOffRow = inImage->row0 + x0in - flatImage->row0 - x0flat;
    106103
    107104    // Check that offsets are within image limits
  • branches/eam_rel9_p0/psModules/src/detrend/pmMaskBadPixels.h

    r6062 r6080  
    2424 *  @author Ross Harman, MHPCC
    2525 *
    26  *  @version $Revision: 1.2.8.1.2.1 $ $Name: not supported by cvs2svn $
    27  *  @date $Date: 2006-01-20 02:38:28 $
     26 *  @version $Revision: 1.2.8.1.2.2 $ $Name: not supported by cvs2svn $
     27 *  @date $Date: 2006-01-20 09:47:06 $
    2828 *
    2929 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3838    PM_MASK_BADCOL  = 0x0002,   ///< The pixel is a bad column.
    3939    PM_MASK_SAT     = 0x0004,   ///< The pixel is saturated.
    40     PM_MASK_FLAT    = 0x0008    ///< The pixel is non-positive in the flat-field.
     40    PM_MASK_BAD     = 0x0008,   ///< The pixel is low
     41    PM_MASK_FLAT    = 0x0010    ///< The pixel is non-positive in the flat-field.
    4142} pmMaskValue;
    4243
  • branches/eam_rel9_p0/psModules/src/imsubtract/pmSubtractBias.c

    r6078 r6080  
    1111 *  @author GLG, MHPCC
    1212 *
    13  *  @version $Revision: 1.6.8.1.2.3 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2006-01-20 06:03:29 $
     13 *  @version $Revision: 1.6.8.1.2.4 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2006-01-20 09:47:06 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    102102    assert(sub);
    103103
    104     // Get the trim sections
    105     psRegion *inTrimsec = psMetadataLookupPtr(NULL, in->parent->concepts, "CELL.TRIMSEC");
    106     psRegion *subTrimsec = psMetadataLookupPtr(NULL, sub->parent->concepts, "CELL.TRIMSEC");
    107     psImage *inImage = psImageSubset(in->image, *inTrimsec); // The input image
    108     psImage *subImage = psImageSubset(sub->image, *subTrimsec); // The image to be subtracted
    109     psImage *inMask = in->mask ? psImageSubset(in->mask, *inTrimsec) : NULL; // The input mask
    110     psImage *subMask = sub->mask ? psImageSubset(sub->mask, *subTrimsec) : NULL; // The input mask
     104    psImage *inImage  = in->image;      // The input image
     105    psImage *inMask   = in->mask;       // The input mask
     106    psImage *subImage = sub->image;     // The image to be subtracted
     107    psImage *subMask  = sub->mask;      // The mask for the subtraction image
    111108
    112109    // Offsets of the cells
     
    425422    PS_ASSERT_READOUT_TYPE(in, PS_TYPE_F32, NULL);
    426423
    427     pmCell *cell = in->parent;      // The parent cell
    428     psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC"); // The trim region
    429     psImage *image = psImageSubset(in->image, *trimsec); // The image corresponding to the trim region
     424    psImage *image = in->image;         // The input image
    430425
    431426    // Overscan processing
     
    438433        }
    439434
    440         // Get the list of overscans
    441         psList *overscanRegions = psMetadataLookupPtr(NULL, cell->concepts, "CELL.BIASSEC");
    442         psList *overscans = psListAlloc(NULL); // List of the overscan images
    443         psListIterator *iter = psListIteratorAlloc(overscanRegions, PS_LIST_HEAD, false); // Iterator
    444         psRegion *biassec = NULL;       // A BIASSEC region from the list
    445         while ((biassec = psListGetAndIncrement(iter))) {
    446             psImage *overscan = psImageSubset(in->image, *biassec);
    447             psListAdd(overscans, PS_LIST_TAIL, overscan);
    448             psFree(overscan);
    449         }
    450         psFree(iter);
     435        psList *overscans = in->bias; // List of the overscan images
    451436
    452437        psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // A new psStats, to avoid clobbering original
     
    482467
    483468            // We do the regular overscan subtraction
    484             bool readRows = psMetadataLookupBool(NULL, cell->concepts, "CELL.READDIR"); // Read direction
     469
     470            bool readRows = psMetadataLookupBool(NULL, in->parent->concepts, "CELL.READDIR");// Read direction
    485471
    486472            if (readRows) {
Note: See TracChangeset for help on using the changeset viewer.