IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 15, 2010, 11:22:56 AM (16 years ago)
Author:
watersc1
Message:

association and jpegs look fine. random simtest errors are a bit worrying, though.

Location:
branches/czw_branch/20100519
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100519

  • branches/czw_branch/20100519/ppBackground

    • Property svn:ignore set to
      configure
      Makefile.in
      ignore
      config.log
      depcomp
      config.status
      config.guess
      ltmain.sh
      config.sub
      autom4te.cache
      libtool
      missing
      Makefile
      aclocal.m4
      install-sh
  • branches/czw_branch/20100519/ppBackground/src

    • Property svn:ignore set to
      ppBackground
      Makefile.in
      config.h
      ppBackgroundVersionDefinitions.h
      .deps
      Makefile
      ppBackgroundErrorCodes.c
      ppBackgroundErrorCodes.h
      stamp-h1
      config.h.in
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundLoop.c

    r28304 r28334  
    66#include <pslib.h>
    77#include <psmodules.h>
     8#include <ppStats.h>
    89
    910#include "ppBackground.h"
     
    1314{
    1415    pmConfig *config = data->config;                                        // Configuration data
    15     pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.BACKGROUND", 0);
     16    pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.IMAGE", 0);
    1617    pmFPAfile *patternFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.PATTERN", 0); // File with data
     18    pmFPAfile *bgFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.BACKGROUND", 0);   // File with bg
    1719    pmFPA *patternMosaic = pmFPAConstruct(file->camera, file->cameraName); // Mosaicked FPA for pattern
    1820
    19     psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Mask value to set
     21    psImageMaskType maskBad = pmConfigMaskGet("DETECTOR", config); // Mask value to set
    2022
    2123    pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy
     
    3436        }
    3537
    36         if (chip->cell->n > 1) {
     38        if (chip->cells->n > 1) {
    3739            psError(PPBACKGROUND_ERR_CONFIG, true,
    3840                    "Input image and background model should be chip-mosaicked");
     
    4446            pmFPAfileActivate(config->files, true, "PPBACKGROUND.PATTERN");
    4547
    46             pmCell *cell;               // Cell with pattern data
     48            pmCell *patternCell;               // Cell with pattern data
    4749            while ((patternCell = pmFPAviewNextCell(view, patternFile->fpa, 1))) {
    48                 if (!cell->process || !cell->file_exists) {
     50                if (!patternCell->process || !patternCell->file_exists) {
    4951                    continue;
    5052                }
     
    6870                    // Get size of image from concepts
    6971                    if (numCols == 0 || numRows == 0) {
    70                         numCols = psMetadataLookupS32(NULL, cell->concepts, "CELL.XSIZE");
    71                         numRows = psMetadataLookupS32(NULL, cell->concepts, "CELL.YSIZE");
     72                        numCols = psMetadataLookupS32(NULL, patternCell->concepts, "CELL.XSIZE");
     73                        numRows = psMetadataLookupS32(NULL, patternCell->concepts, "CELL.YSIZE");
    7274                    }
    7375                    // Get size of image from TRIMSEC
    7476                    if (numCols == 0 || numRows == 0) {
    75                         psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
     77                        psRegion *trimsec = psMetadataLookupPtr(NULL, patternCell->concepts, "CELL.TRIMSEC");
    7678                        numCols = trimsec->x1 - trimsec->x0;
    7779                        numRows = trimsec->y1 - trimsec->y0;
     
    8486                    readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    8587                    psImageInit(readout->image, 0.0);
     88                    readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
     89                    psImageInit(readout->mask, 0);
    8690
    8791                    if (!pmPatternRowApply(readout, maskBad) || !pmPatternCellApply(readout, maskBad)) {
     
    9195
    9296                    // Remove bias sections to avoid warnings
    93                     psMetadataItem *biassec = psMetadataLookup(patternRO->parent->concepts, "CELL.BIASSEC");
     97                    psMetadataItem *biassec = psMetadataLookup(patternCell->concepts, "CELL.BIASSEC");
    9498                    if (psListLength(biassec->data.V)) {
    9599                        psFree(biassec->data.V);
     
    114118            }
    115119
    116             pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern
    117             if (!pmChipMosaic(mosaic, chip, true, maskBad)) {
    118                 psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction");
    119                 return false;
     120            if (data->patternName) {
     121                pmChip *patternChip = pmFPAviewThisChip(view, patternFile->fpa); // Chip for pattern
     122                pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern
     123                if (!mosaic->hdu && !mosaic->parent->hdu) {
     124                    pmFPAAddSourceFromView(patternMosaic, view, file->format);
     125                }
     126                if (!pmChipMosaic(mosaic, patternChip, true, maskBad)) {
     127                    psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction");
     128                    return false;
     129                }
     130                pmFPAfileActivate(config->files, true, NULL);
     131            //            pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
    120132            }
    121             pmFPAfileActivate(config->files, true, NULL);
    122             pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
    123133        }
    124134
     135        pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern
     136        pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model
     137        if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config)) {
     138            psError(psErrorCodeLast(), false, "Unable to replace background");
     139            return false;
     140        }
     141        pmChipFreeData(patternChip);
    125142
    126 
    127 
    128 
    129 
    130 
    131                 pmHDU *hdu = pmHDUGetLowest(file->fpa, chip, cell); // HDU for readout
    132                 if (!hdu) {
    133                     psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU for data.");
    134                     return false;
    135                 }
    136                 if (!hdu->header) {
    137                     hdu->header = psMetadataAlloc();
    138                 }
    139                 ppBackgroundVersionHeader(hdu->header);
    140 
    141 
    142 
    143 
    144 
    145 
    146 
     143        pmHDU *hdu = pmHDUGetLowest(file->fpa, chip, NULL); // HDU for chip
     144        if (!hdu) {
     145            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU for data.");
     146            return false;
     147        }
     148        if (!hdu->header) {
     149            hdu->header = psMetadataAlloc();
     150        }
     151        ppBackgroundVersionHeader(hdu->header);
    147152
    148153        // Chip
     
    158163    }
    159164
     165    psFree(patternMosaic);
     166
     167    if (data->stats) {
     168        psImageMaskType maskVal = 0;    // Bits to mask
     169        if (!pmConfigMaskSetBits(&maskVal, NULL, config)) {
     170            psError(psErrorCodeLast(), false, "Unable to find bits to mask");
     171            return false;
     172        }
     173        ppStatsFPA(data->stats, file->fpa, view, maskVal, config);
     174    }
     175
     176    psFree(view);
     177
    160178    return true;
    161179}
Note: See TracChangeset for help on using the changeset viewer.