Changeset 28334 for branches/czw_branch/20100519/ppBackground
- Timestamp:
- Jun 15, 2010, 11:22:56 AM (16 years ago)
- Location:
- branches/czw_branch/20100519
- Files:
-
- 1 deleted
- 12 edited
- 1 copied
-
. (modified) (1 prop)
-
ppBackground (modified) (1 prop)
-
ppBackground/configure.ac (modified) (1 diff)
-
ppBackground/src (modified) (1 prop)
-
ppBackground/src/Makefile.am (modified) (4 diffs)
-
ppBackground/src/ppBackground.c (modified) (3 diffs)
-
ppBackground/src/ppBackground.h (modified) (2 diffs)
-
ppBackground/src/ppBackgroundArguments.c (modified) (3 diffs)
-
ppBackground/src/ppBackgroundCamera.c (modified) (3 diffs)
-
ppBackground/src/ppBackgroundExit.c (modified) (1 diff)
-
ppBackground/src/ppBackgroundLoop.c (modified) (9 diffs)
-
ppBackground/src/ppBackgroundModel.c (deleted)
-
ppBackground/src/ppBackgroundRestore.c (copied) (copied from trunk/ppBackground/src/ppBackgroundRestore.c )
-
ppBackground/src/ppBackgroundVersionDefinitions.h.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100519
- Property svn:mergeinfo changed
/trunk merged: 28280-28298,28300-28302,28305-28307
- Property svn:mergeinfo changed
-
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
-
Property svn:ignore
set to
-
branches/czw_branch/20100519/ppBackground/configure.ac
r28304 r28334 20 20 PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0]) 21 21 PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0]) 22 PKG_CHECK_MODULES([PSPHOT], [psphot >= 1.0.0]) 22 PKG_CHECK_MODULES([PPSTATS], [ppStats >= 1.0.0]) 23 PKG_CHECK_MODULES([PSPHOT], [psphot]) 24 25 AC_PATH_PROG([ERRORCODES], [psParseErrorCodes], [missing]) 26 if test "$ERRORCODES" = "missing" ; then 27 AC_MSG_ERROR([psParseErrorCodes is required]) 28 fi 23 29 24 30 dnl 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
-
Property svn:ignore
set to
-
branches/czw_branch/20100519/ppBackground/src/Makefile.am
r28304 r28334 2 2 3 3 if HAVE_SVNVERSION 4 PP VIZPATTERN_VERSION=`$(SVNVERSION) ..`4 PPBACKGROUND_VERSION=`$(SVNVERSION) ..` 5 5 else 6 PP VIZPATTERN_VERSION="UNKNOWN"6 PPBACKGROUND_VERSION="UNKNOWN" 7 7 endif 8 8 9 9 if HAVE_SVN 10 PP VIZPATTERN_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 PP VIZPATTERN_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`10 PPBACKGROUND_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 PPBACKGROUND_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'` 12 12 else 13 PP VIZPATTERN_BRANCH="UNKNOWN"14 PP VIZPATTERN_SOURCE="UNKNOWN"13 PPBACKGROUND_BRANCH="UNKNOWN" 14 PPBACKGROUND_SOURCE="UNKNOWN" 15 15 endif 16 16 … … 19 19 ppBackgroundVersionDefinitions.h: ppBackgroundVersionDefinitions.h.in FORCE 20 20 -$(RM) ppBackgroundVersionDefinitions.h 21 $(SED) -e "s|@PP VIZPATTERN_VERSION@|\"$(PPVIZPATTERN_VERSION)\"|" -e "s|@PPVIZPATTERN_BRANCH@|\"$(PPVIZPATTERN_BRANCH)\"|" -e "s|@PPVIZPATTERN_SOURCE@|\"$(PPVIZPATTERN_SOURCE)\"|" ppBackgroundVersionDefinitions.h.in > ppBackgroundVersionDefinitions.h21 $(SED) -e "s|@PPBACKGROUND_VERSION@|\"$(PPBACKGROUND_VERSION)\"|" -e "s|@PPBACKGROUND_BRANCH@|\"$(PPBACKGROUND_BRANCH)\"|" -e "s|@PPBACKGROUND_SOURCE@|\"$(PPBACKGROUND_SOURCE)\"|" ppBackgroundVersionDefinitions.h.in > ppBackgroundVersionDefinitions.h 22 22 FORCE: ; 23 23 … … 25 25 26 26 27 ppBackground_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(P SPHOT_CFLAGS) $(PPBACKGROUND_CFLAGS)28 ppBackground_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(P SPHOT_LIBS) $(PPBACKGROUND_LIBS)27 ppBackground_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPBACKGROUND_CFLAGS) 28 ppBackground_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PPBACKGROUND_LIBS) 29 29 30 30 ppBackground_SOURCES = \ … … 35 35 ppBackgroundLoop.c \ 36 36 ppBackgroundVersion.c \ 37 ppBackgroundModel.c \ 38 ppBackgroundErrorCodes.c 37 ppBackgroundRestore.c \ 38 ppBackgroundErrorCodes.c \ 39 ppBackgroundExit.c 39 40 40 41 noinst_HEADERS = \ -
branches/czw_branch/20100519/ppBackground/src/ppBackground.c
r28304 r28334 6 6 #include <pslib.h> 7 7 #include <psmodules.h> 8 #include <psphot.h> 8 9 9 10 #include "ppBackground.h" … … 12 13 { 13 14 ppBackgroundVersionPrint(); 15 16 pmErrorRegister(); 17 psphotErrorRegister(); 18 ppBackgroundErrorRegister(); 14 19 15 20 ppBackgroundData *data = ppBackgroundDataInit(&argc, argv); … … 46 51 } 47 52 data->statsFile = NULL; 48 pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);49 53 exitValue = ppBackgroundExitCode(exitValue); 50 54 } -
branches/czw_branch/20100519/ppBackground/src/ppBackground.h
r28304 r28334 5 5 #include <psmodules.h> 6 6 7 #include <ppBackgroundErrorCodes.h>7 #include "ppBackgroundErrorCodes.h" 8 8 9 9 #define PPBACKGROUND_RECIPE "PPBACKGROUND" // Recipe name … … 37 37 ); 38 38 39 /// Restore the background to an image 40 bool 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 39 48 /// Determine exit code 40 49 psExit ppBackgroundExitCode( -
branches/czw_branch/20100519/ppBackground/src/ppBackgroundArguments.c
r28304 r28334 45 45 assert(data->config); 46 46 47 psMetadata *arguments = psMetadataAlloc(); // Command-line arguments47 psMetadata *arguments = data->config->arguments; 48 48 psMetadataAddStr(arguments, PS_LIST_TAIL, "-pattern", 0, "Filename of pattern correction", NULL); 49 49 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); 51 51 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); 52 54 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) { 53 55 usage(argv[0], arguments, data); … … 59 61 data->maskName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-mask")); 60 62 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); 62 64 63 65 psTrace("ppBackground", 1, "Done reading command-line arguments\n"); 64 psFree(arguments);65 66 66 67 if (!data->patternName && !data->backgroundName) { … … 68 69 return false; 69 70 } 71 if (!data->imageName) { 72 psError(PPBACKGROUND_ERR_CONFIG, true, "Must specify -image"); 73 return false; 74 } 70 75 71 76 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 } 72 88 73 89 return true; -
branches/czw_branch/20100519/ppBackground/src/ppBackgroundCamera.c
r28304 r28334 32 32 bool status; // Status of file definition 33 33 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 } 40 41 } 41 42 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 } 48 50 } 49 51 50 fileArguments("IMAGE", data-> backgroundName, "Input uncorrected image", data->config);51 pmFPAfile *image = pmFPAfile BindFromArgs(&status, background, data->config, "PPBACKGROUND.IMAGE",52 "IMAGE"); // File53 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) { 54 56 psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.IMAGE"); 55 57 return false; 56 58 } 57 59 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 61 62 if (!status) { 62 63 psError(psErrorCodeLast(), false, "Failed to build file from PPBACKGROUND.MASK"); … … 64 65 } 65 66 66 pmFPAfile *output = pmFPAfileDefineOutput(data->config, file->fpa, "PPBACKGROUND.OUTPUT");67 pmFPAfile *output = pmFPAfileDefineOutput(data->config, image->fpa, "PPBACKGROUND.OUTPUT"); 67 68 if (!output) { 68 69 psError(psErrorCodeLast(), false, "Unable to define output."); … … 70 71 } 71 72 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; 72 80 73 81 #if 0 -
branches/czw_branch/20100519/ppBackground/src/ppBackgroundExit.c
r28304 r28334 13 13 if (errorCode != PS_ERR_NONE) { 14 14 pmFPAfileFreeSetStrict(false); 15 psErrorStackPrint(stderr, "Error in subtraction:");15 psErrorStackPrint(stderr, "Error in background restoration:"); 16 16 switch (errorCode) { 17 17 case PS_ERR_UNKNOWN: -
branches/czw_branch/20100519/ppBackground/src/ppBackgroundLoop.c
r28304 r28334 6 6 #include <pslib.h> 7 7 #include <psmodules.h> 8 #include <ppStats.h> 8 9 9 10 #include "ppBackground.h" … … 13 14 { 14 15 pmConfig *config = data->config; // Configuration data 15 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND. BACKGROUND", 0);16 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.IMAGE", 0); 16 17 pmFPAfile *patternFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.PATTERN", 0); // File with data 18 pmFPAfile *bgFile = pmFPAfileSelectSingle(config->files, "PPBACKGROUND.BACKGROUND", 0); // File with bg 17 19 pmFPA *patternMosaic = pmFPAConstruct(file->camera, file->cameraName); // Mosaicked FPA for pattern 18 20 19 psImageMaskType maskBad = pmConfigMaskGet(" BLANK", config); // Mask value to set21 psImageMaskType maskBad = pmConfigMaskGet("DETECTOR", config); // Mask value to set 20 22 21 23 pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy … … 34 36 } 35 37 36 if (chip->cell ->n > 1) {38 if (chip->cells->n > 1) { 37 39 psError(PPBACKGROUND_ERR_CONFIG, true, 38 40 "Input image and background model should be chip-mosaicked"); … … 44 46 pmFPAfileActivate(config->files, true, "PPBACKGROUND.PATTERN"); 45 47 46 pmCell * cell; // Cell with pattern data48 pmCell *patternCell; // Cell with pattern data 47 49 while ((patternCell = pmFPAviewNextCell(view, patternFile->fpa, 1))) { 48 if (! cell->process || !cell->file_exists) {50 if (!patternCell->process || !patternCell->file_exists) { 49 51 continue; 50 52 } … … 68 70 // Get size of image from concepts 69 71 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"); 72 74 } 73 75 // Get size of image from TRIMSEC 74 76 if (numCols == 0 || numRows == 0) { 75 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");77 psRegion *trimsec = psMetadataLookupPtr(NULL, patternCell->concepts, "CELL.TRIMSEC"); 76 78 numCols = trimsec->x1 - trimsec->x0; 77 79 numRows = trimsec->y1 - trimsec->y0; … … 84 86 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 85 87 psImageInit(readout->image, 0.0); 88 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 89 psImageInit(readout->mask, 0); 86 90 87 91 if (!pmPatternRowApply(readout, maskBad) || !pmPatternCellApply(readout, maskBad)) { … … 91 95 92 96 // Remove bias sections to avoid warnings 93 psMetadataItem *biassec = psMetadataLookup(pattern RO->parent->concepts, "CELL.BIASSEC");97 psMetadataItem *biassec = psMetadataLookup(patternCell->concepts, "CELL.BIASSEC"); 94 98 if (psListLength(biassec->data.V)) { 95 99 psFree(biassec->data.V); … … 114 118 } 115 119 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"); 120 132 } 121 pmFPAfileActivate(config->files, true, NULL);122 pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");123 133 } 124 134 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); 125 142 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); 147 152 148 153 // Chip … … 158 163 } 159 164 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 160 178 return true; 161 179 } -
branches/czw_branch/20100519/ppBackground/src/ppBackgroundVersionDefinitions.h.in
r28304 r28334 1 #ifndef PP VIZPATTERN_VERSION_DEFINITIONS_H2 #define PP VIZPATTERN_VERSION_DEFINITIONS_H1 #ifndef PPBACKGROUND_VERSION_DEFINITIONS_H 2 #define PPBACKGROUND_VERSION_DEFINITIONS_H 3 3 4 #define PP VIZPATTERN_VERSION @PPVIZPATTERN_VERSION@ // SVN version5 #define PP VIZPATTERN_BRANCH @PPVIZPATTERN_BRANCH@ // SVN branch6 #define PP VIZPATTERN_SOURCE @PPVIZPATTERN_SOURCE@ // SVN source4 #define PPBACKGROUND_VERSION @PPBACKGROUND_VERSION@ // SVN version 5 #define PPBACKGROUND_BRANCH @PPBACKGROUND_BRANCH@ // SVN branch 6 #define PPBACKGROUND_SOURCE @PPBACKGROUND_SOURCE@ // SVN source 7 7 8 8 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
