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:
1 deleted
12 edited
1 copied

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/configure.ac

    r28304 r28334  
    2020PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0])
    2121PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0])
    22 PKG_CHECK_MODULES([PSPHOT], [psphot >= 1.0.0])
     22PKG_CHECK_MODULES([PPSTATS], [ppStats >= 1.0.0])
     23PKG_CHECK_MODULES([PSPHOT], [psphot])
     24
     25AC_PATH_PROG([ERRORCODES], [psParseErrorCodes], [missing])
     26if test "$ERRORCODES" = "missing" ; then
     27  AC_MSG_ERROR([psParseErrorCodes is required])
     28fi
    2329
    2430dnl Set CFLAGS for build
  • 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/Makefile.am

    r28304 r28334  
    22
    33if HAVE_SVNVERSION
    4 PPVIZPATTERN_VERSION=`$(SVNVERSION) ..`
     4PPBACKGROUND_VERSION=`$(SVNVERSION) ..`
    55else
    6 PPVIZPATTERN_VERSION="UNKNOWN"
     6PPBACKGROUND_VERSION="UNKNOWN"
    77endif
    88
    99if HAVE_SVN
    10 PPVIZPATTERN_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
    11 PPVIZPATTERN_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
     10PPBACKGROUND_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
     11PPBACKGROUND_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
    1212else
    13 PPVIZPATTERN_BRANCH="UNKNOWN"
    14 PPVIZPATTERN_SOURCE="UNKNOWN"
     13PPBACKGROUND_BRANCH="UNKNOWN"
     14PPBACKGROUND_SOURCE="UNKNOWN"
    1515endif
    1616
     
    1919ppBackgroundVersionDefinitions.h: ppBackgroundVersionDefinitions.h.in FORCE
    2020        -$(RM) ppBackgroundVersionDefinitions.h
    21         $(SED) -e "s|@PPVIZPATTERN_VERSION@|\"$(PPVIZPATTERN_VERSION)\"|" -e "s|@PPVIZPATTERN_BRANCH@|\"$(PPVIZPATTERN_BRANCH)\"|" -e "s|@PPVIZPATTERN_SOURCE@|\"$(PPVIZPATTERN_SOURCE)\"|" ppBackgroundVersionDefinitions.h.in > ppBackgroundVersionDefinitions.h
     21        $(SED) -e "s|@PPBACKGROUND_VERSION@|\"$(PPBACKGROUND_VERSION)\"|" -e "s|@PPBACKGROUND_BRANCH@|\"$(PPBACKGROUND_BRANCH)\"|" -e "s|@PPBACKGROUND_SOURCE@|\"$(PPBACKGROUND_SOURCE)\"|" ppBackgroundVersionDefinitions.h.in > ppBackgroundVersionDefinitions.h
    2222FORCE: ;
    2323
     
    2525
    2626
    27 ppBackground_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPBACKGROUND_CFLAGS)
    28 ppBackground_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PSPHOT_LIBS)   $(PPBACKGROUND_LIBS)
     27ppBackground_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPBACKGROUND_CFLAGS)
     28ppBackground_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPBACKGROUND_LIBS)
    2929
    3030ppBackground_SOURCES =          \
     
    3535        ppBackgroundLoop.c      \
    3636        ppBackgroundVersion.c   \
    37         ppBackgroundModel.c     \
    38         ppBackgroundErrorCodes.c
     37        ppBackgroundRestore.c   \
     38        ppBackgroundErrorCodes.c        \
     39        ppBackgroundExit.c
    3940
    4041noinst_HEADERS = \
  • branches/czw_branch/20100519/ppBackground/src/ppBackground.c

    r28304 r28334  
    66#include <pslib.h>
    77#include <psmodules.h>
     8#include <psphot.h>
    89
    910#include "ppBackground.h"
     
    1213{
    1314    ppBackgroundVersionPrint();
     15
     16    pmErrorRegister();
     17    psphotErrorRegister();
     18    ppBackgroundErrorRegister();
    1419
    1520    ppBackgroundData *data = ppBackgroundDataInit(&argc, argv);
     
    4651        }
    4752        data->statsFile = NULL;
    48         pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);
    4953        exitValue = ppBackgroundExitCode(exitValue);
    5054    }
  • branches/czw_branch/20100519/ppBackground/src/ppBackground.h

    r28304 r28334  
    55#include <psmodules.h>
    66
    7 #include <ppBackgroundErrorCodes.h>
     7#include "ppBackgroundErrorCodes.h"
    88
    99#define PPBACKGROUND_RECIPE "PPBACKGROUND"      // Recipe name
     
    3737    );
    3838
     39/// Restore the background to an image
     40bool ppBackgroundRestore(
     41    pmChip *chip,                       // Chip to correct
     42    const pmChip *background,           // Chip with background model
     43    const pmChip *pattern,              // Chip with pattern
     44    const pmFPAview *view,              // View to data
     45    pmConfig *config                    // Configuration
     46    );
     47
    3948/// Determine exit code
    4049psExit ppBackgroundExitCode(
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundArguments.c

    r28304 r28334  
    4545    assert(data->config);
    4646
    47     psMetadata *arguments = psMetadataAlloc(); // Command-line arguments
     47    psMetadata *arguments = data->config->arguments;
    4848    psMetadataAddStr(arguments, PS_LIST_TAIL, "-pattern", 0, "Filename of pattern correction", NULL);
    4949    psMetadataAddStr(arguments, PS_LIST_TAIL, "-background", 0, "Filename of background model", NULL);
    50     psMetadataAddStr(arguments, PS_LIST_TAIL, "-image", 0, "Filename of image", NULL);
     50    psMetadataAddStr(arguments, PS_LIST_TAIL, "-image", 0, "Filename of image (required)", NULL);
    5151    psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask", 0, "Filename of mask", NULL);
     52    psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Output statistics file", NULL);
     53    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dumpconfig", 0, "Output configuration file", NULL);
    5254    if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) {
    5355        usage(argv[0], arguments, data);
     
    5961    data->maskName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-mask"));
    6062    data->outRoot = psStringCopy(argv[1]);
    61     psMetadataAddStr(data->config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Output root name", data->outRoot);
     63    psMetadataAddStr(arguments, PS_LIST_TAIL, "OUTPUT", 0, "Output root name", data->outRoot);
    6264
    6365    psTrace("ppBackground", 1, "Done reading command-line arguments\n");
    64     psFree(arguments);
    6566
    6667    if (!data->patternName && !data->backgroundName) {
     
    6869        return false;
    6970    }
     71    if (!data->imageName) {
     72        psError(PPBACKGROUND_ERR_CONFIG, true, "Must specify -image");
     73        return false;
     74    }
    7075
    7176    PS_ASSERT_STRING_NON_EMPTY(data->outRoot, false);
     77
     78    const char *statsName = psMetadataLookupStr(NULL, arguments, "-stats");
     79    if (statsName) {
     80        data->statsFile = fopen(statsName, "w");
     81        if (!data->statsFile) {
     82            psError(PPBACKGROUND_ERR_IO, true, "Unable to open statistics file %s", statsName);
     83            return false;
     84        }
     85        data->stats = psMetadataAlloc();
     86        pmConfigRunFilenameAddWrite(data->config, "STATS", statsName);
     87    }
    7288
    7389    return true;
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundCamera.c

    r28304 r28334  
    3232    bool status;                        // Status of file definition
    3333
    34     fileArguments("PATTERN", data->patternName, "Input pattern", data->config);
    35     pmFPAfile *pattern = pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.PATTERN",
    36                                                  "PATTERN"); // File
    37     if (!status) {
    38         psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.PATTERN");
    39         return false;
     34    if (data->patternName) {
     35        fileArguments("PATTERN", data->patternName, "Input pattern", data->config);
     36        pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.PATTERN", "PATTERN"); // File
     37        if (!status) {
     38            psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.PATTERN");
     39            return false;
     40        }
    4041    }
    4142
    42     fileArguments("BACKGROUND", data->backgroundName, "Input background model", data->config);
    43     pmFPAfile *background = pmFPAfileBindFromArgs(&status, data->config, "PPBACKGROUND.BACKGROUND",
    44                                                   "BACKGROUND"); // File
    45     if (!status) {
    46         psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.BACKGROUND");
    47         return false;
     43    if (data->backgroundName) {
     44        fileArguments("BACKGROUND", data->backgroundName, "Input background model", data->config);
     45        pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.BACKGROUND", "BACKGROUND"); // File
     46        if (!status) {
     47            psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.BACKGROUND");
     48            return false;
     49        }
    4850    }
    4951
    50     fileArguments("IMAGE", data->backgroundName, "Input uncorrected image", data->config);
    51     pmFPAfile *image = pmFPAfileBindFromArgs(&status, background, data->config, "PPBACKGROUND.IMAGE",
    52                                              "IMAGE"); // File
    53     if (!status) {
     52    fileArguments("IMAGE", data->imageName, "Input uncorrected image", data->config);
     53    pmFPAfile *image = pmFPAfileDefineFromArgs(&status, data->config, "PPBACKGROUND.IMAGE",
     54                                               "IMAGE"); // File
     55    if (!status || !image) {
    5456        psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.IMAGE");
    5557        return false;
    5658    }
    5759
    58     fileArguments("MASK", data->backgroundName, "Input uncorrected mask", data->config);
    59     pmFPAfile *mask = pmFPAfileBindFromArgs(&status, image, data->config, "PPBACKGROUND.MASK",
    60                                               "MASK"); // File
     60    fileArguments("MASK", data->maskName, "Input uncorrected mask", data->config);
     61    pmFPAfileBindFromArgs(&status, image, data->config, "PPBACKGROUND.MASK", "MASK"); // File
    6162    if (!status) {
    6263        psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.MASK");
     
    6465    }
    6566
    66     pmFPAfile *output = pmFPAfileDefineOutput(data->config, file->fpa, "PPBACKGROUND.OUTPUT");
     67    pmFPAfile *output = pmFPAfileDefineOutput(data->config, image->fpa, "PPBACKGROUND.OUTPUT");
    6768    if (!output) {
    6869        psError(psErrorCodeLast(), false, "Unable to define output.");
     
    7071    }
    7172    output->save = true;
     73
     74    pmFPAfile *outMask = pmFPAfileDefineOutput(data->config, output->fpa, "PPBACKGROUND.OUTPUT.MASK");
     75    if (!outMask) {
     76        psError(psErrorCodeLast(), false, "Unable to define output.");
     77        return false;
     78    }
     79    outMask->save = true;
    7280
    7381#if 0
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundExit.c

    r28304 r28334  
    1313    if (errorCode != PS_ERR_NONE) {
    1414        pmFPAfileFreeSetStrict(false);
    15         psErrorStackPrint(stderr, "Error in subtraction:");
     15        psErrorStackPrint(stderr, "Error in background restoration:");
    1616        switch (errorCode) {
    1717          case PS_ERR_UNKNOWN:
  • 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}
  • branches/czw_branch/20100519/ppBackground/src/ppBackgroundVersionDefinitions.h.in

    r28304 r28334  
    1 #ifndef PPVIZPATTERN_VERSION_DEFINITIONS_H
    2 #define PPVIZPATTERN_VERSION_DEFINITIONS_H
     1#ifndef PPBACKGROUND_VERSION_DEFINITIONS_H
     2#define PPBACKGROUND_VERSION_DEFINITIONS_H
    33
    4 #define PPVIZPATTERN_VERSION @PPVIZPATTERN_VERSION@ // SVN version
    5 #define PPVIZPATTERN_BRANCH  @PPVIZPATTERN_BRANCH@  // SVN branch
    6 #define PPVIZPATTERN_SOURCE  @PPVIZPATTERN_SOURCE@  // SVN source
     4#define PPBACKGROUND_VERSION @PPBACKGROUND_VERSION@ // SVN version
     5#define PPBACKGROUND_BRANCH  @PPBACKGROUND_BRANCH@  // SVN branch
     6#define PPBACKGROUND_SOURCE  @PPBACKGROUND_SOURCE@  // SVN source
    77
    88#endif
Note: See TracChangeset for help on using the changeset viewer.