Changeset 23352 for branches/cnb_branches/cnb_branch_20090301/ppImage
- Timestamp:
- Mar 17, 2009, 12:08:50 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 1 deleted
- 13 edited
-
. (modified) (1 prop)
-
ppImage (modified) (1 prop)
-
ppImage/src/Makefile.am (modified) (1 diff)
-
ppImage/src/ppImage.c (modified) (1 diff)
-
ppImage/src/ppImage.h (modified) (2 diffs)
-
ppImage/src/ppImageArguments.c (modified) (5 diffs)
-
ppImage/src/ppImageDefineFile.c (modified) (1 diff)
-
ppImage/src/ppImageDetrendReadout.c (modified) (6 diffs)
-
ppImage/src/ppImageLoop.c (modified) (7 diffs)
-
ppImage/src/ppImageLoop_Threaded.c (deleted)
-
ppImage/src/ppImageOptions.c (modified) (2 diffs)
-
ppImage/src/ppImageParseCamera.c (modified) (15 diffs)
-
ppImage/src/ppImageReplaceBackground.c (modified) (1 diff)
-
ppImage/src/ppImageVersion.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk merged eligible /branches/eam_branches/eam_branch_20090303 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/ppImage
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/ppImage merged eligible /trunk/ppImage merged eligible /branches/cnb_branch_20090215/ppImage 21495-22685 /branches/eam_branches/eam_branch_20090303/ppImage 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/ppImage/src/Makefile.am
r20774 r23352 4 4 ppImage.h 5 5 6 ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 6 #PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 7 #PPIMAGE_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else 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 }'; fi` 8 #PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 9 10 # Force recompilation of ppImageVersion.c, since it gets the version information 11 # ppImageVersion.c: FORCE 12 # touch ppImageVersion.c 13 # FORCE: ; 14 15 ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPIMAGE_VERSION=$(SVN_VERSION) -DPPIMAGE_BRANCH=$(SVN_BRANCH) -DPPIMAGE_SOURCE=$(SVN_SOURCE) 7 16 ppImage_LDFLAGS = $(PPIMAGE_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 8 17 ppImage_SOURCES = \ -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImage.c
r19928 r23352 21 21 exit(PS_EXIT_CONFIG_ERROR); 22 22 } 23 24 ppImageVersionPrint(); 23 25 24 26 // define recipe options -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImage.h
r21364 r23352 86 86 int remnanceSize; // Size for remnance detection 87 87 float remnanceThresh; // Threshold for remnance detection 88 89 char *normClass; // class to use for per-class normalization 88 90 } ppImageOptions; 89 91 … … 208 210 psString ppImageVersion(void); 209 211 212 /// Return software source 213 psString ppImageSource(void); 214 210 215 /// Return long version information 211 216 psString ppImageVersionLong(void); 212 217 213 /// Update the metadata with version information for all dependencies 214 void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information 215 ); 218 /// Populate the header with version information for all dependencies 219 bool ppImageVersionHeader(psMetadata *metadata ///< Header to populate 220 ); 221 222 /// Print version information 223 void ppImageVersionPrint(void); 216 224 217 225 -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageArguments.c
r19943 r23352 14 14 fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n"); 15 15 fprintf(stderr, "\t-norm VALUE: Divide through by this value when done.\n"); 16 fprintf(stderr, "\t-normlist file.mdc: normalizations by class_id.\n"); 16 17 fprintf(stderr, "\n"); 17 18 fprintf(stderr, "Input options (single file / file list):\n"); … … 80 81 if ((argnum = psArgumentGet(argc, argv, "-visual"))) { 81 82 psArgumentRemove(argnum, &argc, argv); 82 psphotSetVisual(true);83 pmVisualSetVisual(true); 83 84 } 84 85 … … 86 87 if ((argnum = psArgumentGet(argc, argv, "-threads"))) { 87 88 psArgumentRemove(argnum, &argc, argv); 88 int nThreads = atoi(argv[argnum]);89 int nThreads = atoi(argv[argnum]); 89 90 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of warp threads", nThreads); 90 91 psArgumentRemove(argnum, &argc, argv); 91 92 92 // create the thread pool with number of desired threads, supplying our thread launcher function93 // XXX need to determine the number of threads from the config data94 psThreadPoolInit (nThreads);93 // create the thread pool with number of desired threads, supplying our thread launcher function 94 // XXX need to determine the number of threads from the config data 95 psThreadPoolInit (nThreads); 95 96 } 96 97 … … 107 108 108 109 // the input file is a required argument; if not found, we will exit 109 bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 110 if (!status) { 111 usage (); 112 } 110 pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 113 111 114 112 // if these command-line options are supplied, load the file name lists into config->arguments … … 128 126 } 129 127 130 // Optional normali sation factor128 // Optional normalization factor 131 129 if ((argnum = psArgumentGet(argc, argv, "-norm"))) { 132 130 psArgumentRemove(argnum, &argc, argv); 133 131 float norm = atof(argv[argnum]); 134 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALI SATION", 0,132 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALIZATION", 0, 135 133 "Normalisation to apply", norm); 134 psArgumentRemove(argnum, &argc, argv); 135 } 136 137 // Optional per-class normalization table 138 if ((argnum = psArgumentGet(argc, argv, "-normlist"))) { 139 psArgumentRemove(argnum, &argc, argv); 140 141 unsigned int nFail = 0; 142 psMetadata *normlist = psMetadataConfigRead (NULL, &nFail, argv[argnum], false); 143 // XXX allow this file to be in nebulous? 144 145 psMetadataAddMetadata(config->arguments, PS_LIST_TAIL, "NORMALIZATION.TABLE", 0, "Normalization to apply", normlist); 146 psFree (normlist); 136 147 psArgumentRemove(argnum, &argc, argv); 137 148 } -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageDefineFile.c
r13562 r23352 5 5 # include "ppImage.h" 6 6 7 bool ppImageDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType) { 7 bool ppImageDefineFile(pmConfig *config, pmFPA *input, char *filerule, char *argname, 8 pmFPAfileType fileType, pmDetrendType detrendType) 9 { 10 bool status; 11 pmFPAfile *file = NULL; // File to be defined 8 12 9 bool status; 10 pmFPAfile *file; 11 12 // look for the file on the argument list 13 file = pmFPAfileDefineFromArgs (&status, config, filerule, argname); 14 if (!status) { 15 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 16 return false; 13 if (!file) { 14 // look for the file on the RUN metadata 15 file = pmFPAfileDefineFromRun(&status, config, filerule); 16 if (!status) { 17 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 18 return false; 19 } 17 20 } 18 if (file) { 19 if (file->type != fileType) { 20 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 21 return false; 22 } 23 return true; 21 if (!file) { 22 // look for the file on the argument list 23 file = pmFPAfileDefineFromArgs(&status, config, filerule, argname); 24 if (!status) { 25 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 26 return false; 27 } 28 } 29 if (!file) { 30 // look for the file in the camera config table 31 file = pmFPAfileDefineFromConf(&status, config, filerule); 32 if (!status) { 33 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 34 return false; 35 } 36 } 37 if (!file) { 38 // look for the file to be loaded from the detrend database 39 file = pmFPAfileDefineFromDetDB(&status, config, filerule, input, detrendType); 40 if (!status) { 41 psError(PS_ERR_UNKNOWN, false, "failed to load file definition"); 42 return false; 43 } 24 44 } 25 45 26 // look for the file in the camera config table 27 file = pmFPAfileDefineFromConf (&status, config, filerule); 28 if (!status) { 29 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 30 return false; 31 } 32 if (file) { 33 if (file->type != fileType) { 34 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 35 return false; 36 } 37 return true; 46 if (!file) { 47 return false; 38 48 } 39 49 40 // look for the file to be loaded from the detrend database 41 file = pmFPAfileDefineFromDetDB (&status, config, filerule, input, detrendType); 42 if (!status) { 43 psError (PS_ERR_UNKNOWN, false, "failed to load file definition"); 44 return false; 50 if (file->type != fileType) { 51 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 52 return false; 45 53 } 46 if (file) { 47 if (file->type != fileType) { 48 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType)); 49 return false; 50 } 51 return true; 52 } 53 return false; 54 return true; 54 55 } 55 56 -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageDetrendReadout.c
r21364 r23352 54 54 if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) { 55 55 psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias."); 56 psFree(detview); 56 57 return false; 57 58 } … … 67 68 if (!pmDarkApply(input, dark, options->maskValue)) { 68 69 psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark."); 70 psFree(detview); 69 71 return false; 70 72 } … … 75 77 options->remnanceSize, options->remnanceThresh)) { 76 78 psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance."); 79 psFree(detview); 77 80 return false; 78 81 } … … 83 86 pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER"); 84 87 if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) { 88 psFree(detview); 85 89 return false; 86 90 } … … 91 95 pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT"); 92 96 if (!pmFlatField(input, flat, options->flatMask)) { 97 psFree(detview); 93 98 return false; 94 99 } 95 100 } 96 101 97 // Normali sation by a(known) constant102 // Normalization by a single (known) constant 98 103 bool mdok; // Status of MD lookup 99 float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALI SATION");104 float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALIZATION"); 100 105 if (mdok && isfinite(norm) && norm != 1.0) { 101 106 pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest … … 108 113 } 109 114 115 # if (1) 116 // Normalization by per-class values 117 psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE"); 118 if (normlist) { 119 pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT"); 120 121 // get the menu of class IDs 122 psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID"); 123 if (!menu) { 124 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 125 psFree(detview); 126 return false; 127 } 128 // get the rule for class_id for the desired class 129 const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass); 130 if (!rule) { 131 psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass); 132 psFree(detview); 133 return false; 134 } 135 // get the class_id from the rule 136 char *classID = pmFPAfileNameFromRule(rule, inputFile, view); 137 if (!classID) { 138 psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule); 139 psFree(detview); 140 return false; 141 } 142 143 // get normalization from the class_id 144 float norm = psMetadataLookupF32 (&mdok, normlist, classID); 145 146 pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest 147 psString comment = NULL; // Comment to add 148 psStringAppend(&comment, "Normalization: %f", norm); 149 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, ""); 150 psFree(comment); 151 152 // apply the normalization 153 psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32)); 154 155 psFree (classID); 156 } 157 # endif 158 110 159 if (options->doFringe) { 111 160 pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE"); 112 161 if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) { 162 psFree(detview); 113 163 return false; 114 164 } -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageLoop.c
r21183 r23352 25 25 } 26 26 27 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 28 if (dump_file) { 29 pmConfigCamerasCull(config, NULL); 30 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO"); 31 32 pmConfigDump(config, input->fpa, dump_file); 33 } 27 pmConfigCamerasCull(config, NULL); 28 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO,JPEG"); 34 29 35 30 pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest … … 63 58 64 59 // Put version information into the header 65 pmHDU *hdu = pmHDU FromCell(cell);60 pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell); 66 61 if (hdu && hdu != lastHDU) { 67 ppImageVersion Metadata(hdu->header);62 ppImageVersionHeader(hdu->header); 68 63 lastHDU = hdu; 69 64 } … … 96 91 } 97 92 98 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT99 if (!ppImageDetrendFree (config, view)) {100 ESCAPE("Unable to free detrend images");101 }93 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 94 if (!ppImageDetrendFree (config, view)) { 95 ESCAPE("Unable to free detrend images"); 96 } 102 97 } 103 98 … … 105 100 ppImageDetrendRecord(cell, config, options, view); 106 101 } 107 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT108 if (!ppImageDetrendFree (config, view)) {109 ESCAPE("Unable to free detrend images");110 }111 } 112 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT113 if (!ppImageDetrendFree (config, view)) {114 ESCAPE("Unable to free detrend images");115 }102 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 103 if (!ppImageDetrendFree (config, view)) { 104 ESCAPE("Unable to free detrend images"); 105 } 106 } 107 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 108 if (!ppImageDetrendFree (config, view)) { 109 ESCAPE("Unable to free detrend images"); 110 } 116 111 117 112 // Apply the fringe correction … … 121 116 } 122 117 } 123 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT124 if (!ppImageFringeFree (config, view)) {125 ESCAPE("Unable to free fringe images");126 }118 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT 119 if (!ppImageFringeFree (config, view)) { 120 ESCAPE("Unable to free fringe images"); 121 } 127 122 128 123 // measure various pixel-based statistics for this image … … 152 147 } 153 148 154 // these may be used by ppImageSubtractBackground.155 // if these are defined as internal files, drop them here156 status = true;157 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");158 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");159 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");160 if (!status) {161 psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");162 psFree (view);163 return false;164 }149 // these may be used by ppImageSubtractBackground. 150 // if these are defined as internal files, drop them here 151 status = true; 152 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL"); 153 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV"); 154 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND"); 155 if (!status) { 156 psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files"); 157 psFree (view); 158 return false; 159 } 165 160 166 161 // binning (used for display) must take place after the background is replaced, if desired … … 219 214 } 220 215 psFree(view); 216 217 // Dump configuration 218 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 219 if (dump_file) { 220 pmConfigDump(config, input->fpa, dump_file); 221 } 221 222 222 223 // Write out summary statistics -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageOptions.c
r21364 r23352 81 81 options->remnanceThresh = 25.0; // Threshold for remnance detection 82 82 83 // per-class normalization source 84 options->normClass = NULL; // per-class normalizations refer to this class 85 83 86 return options; 84 87 } … … 278 281 options->remnanceThresh = psMetadataLookupS32(NULL, recipe, "REMNANCE.THRESH"); 279 282 283 // per-class normalization source (just a reference; don't free) 284 options->normClass = psMetadataLookupStr(NULL, recipe, "NORM.CLASS"); 285 280 286 return options; 281 287 } -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageParseCamera.c
r21364 r23352 9 9 bool status = false; 10 10 11 // the input image defines the camera, and all recipes and options the follow 12 pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT"); 13 if (!status || !input) { 14 psError(PS_ERR_IO, false, "Failed to build FPA from PPIMAGE.INPUT"); 15 return NULL; 16 } 17 if (input->type != PM_FPA_FILE_IMAGE) { 18 psError(PS_ERR_IO, true, "PPIMAGE.INPUT is not of type IMAGE"); 19 return NULL; 20 } 21 22 // if MASK or VARIANCE was supplied on command line, bind files to 'input'. 23 // the mask and variance will be mosaicked with the image 24 pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.MASK", "PPIMAGE.INPUT.MASK"); 25 if (!status) { 26 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 27 return NULL; 28 } 29 if (inputMask) { 30 if (inputMask->type != PM_FPA_FILE_MASK) { 31 psError(PS_ERR_IO, true, "PPIMAGE.INPUT.MASK is not of type MASK"); 32 return NULL; 33 } 34 } 35 36 pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.VARIANCE", "PPIMAGE.INPUT.VARIANCE"); 37 if (!status) { 38 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 39 return NULL; 40 } 41 if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) { 42 psError(PS_ERR_IO, true, "PPIMAGE.INPUT.VARIANCE is not of type VARIANCE"); 43 return NULL; 44 } 11 if (!ppImageDefineFile(config, NULL, "PPIMAGE.INPUT", "INPUT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_NONE)) { 12 psError(PS_ERR_IO, false, "Can't find an input image source"); 13 return NULL; 14 } 15 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.INPUT"); // Input file 16 psAssert(input, "We just put it there!"); 45 17 46 18 // add recipe options supplied on command line 47 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, RECIPE_NAME);19 psMetadata *recipe = psMetadataLookupPtr(&status, config->recipes, RECIPE_NAME); 48 20 49 21 // parse the options from the metadata format to the ppImageOptions structure 50 ppImageOptions *options = ppImageOptionsParse (config);22 ppImageOptions *options = ppImageOptionsParse(config); 51 23 52 24 // the following are defined from the argument list, if given, … … 54 26 // not all input or output images are used in a given recipe 55 27 if (options->doBias) { 56 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.BIAS", "BIAS", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) { 57 psError (PS_ERR_IO, false, "Can't find a bias image source"); 58 psFree (options); 28 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.BIAS", "BIAS", 29 PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) { 30 psError(PS_ERR_IO, false, "Can't find a bias image source"); 31 psFree(options); 59 32 return NULL; 60 33 } 61 34 } 62 35 if (options->doDark) { 63 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) { 64 psError (PS_ERR_IO, false, "Can't find a dark image source"); 65 psFree (options); 36 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.DARK", "DARK", 37 PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) { 38 psError(PS_ERR_IO, false, "Can't find a dark image source"); 39 psFree(options); 66 40 return NULL; 67 41 } 68 42 } 69 43 if (options->doMask) { 70 71 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.MASK", "MASK", PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) { 72 psError (PS_ERR_IO, false, "Can't find a mask image source"); 73 psFree (options); 74 return NULL; 75 } 44 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.MASK", "MASK", 45 PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) { 46 psError(PS_ERR_IO, false, "Can't find a mask image source"); 47 psFree(options); 48 return NULL; 49 } 50 51 #if 0 52 // I think this is now done automatically in the pmFPAfileDefine and pmFPAfileIOChecks -- PAP. 53 76 54 // XXX have ppImageDefineFile return the pmFPAfile? 77 55 pmFPAfile *mask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.MASK"); 78 psAssert (mask, "mask not defined? not possible!");56 psAssert(mask, "Just defined the mask!"); 79 57 80 58 // Need to read the names of bit masks from the mask header and set them in the … … 84 62 // XXX need to load the mask bit names from one of the headers 85 63 // this grabs the first available hdu : no guarantee that it will be valid, though 86 pmHDU *hdu = pmHDUGetFirst (mask->fpa);64 pmHDU *hdu = pmHDUGetFirst(mask->fpa); 87 65 if (!hdu) { 88 66 psError(PS_ERR_IO, true, "no valid HDU for PPIMAGE.INPUT.MASK"); … … 90 68 } 91 69 // XXX is this consistent with the pmConfigMaskReadHeader call above? 92 if (!pmConfigMaskReadHeader (config, hdu->header)) {70 if (!pmConfigMaskReadHeader(config, hdu->header)) { 93 71 psError(PS_ERR_IO, false, "error in mask bits"); 94 72 return NULL; 95 73 } 96 74 } 75 #endif 97 76 } 98 77 if (options->doShutter) { 99 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) { 100 psError (PS_ERR_IO, false, "Can't find a shutter image source"); 101 psFree (options); 78 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER", 79 PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) { 80 psError(PS_ERR_IO, false, "Can't find a shutter image source"); 81 psFree(options); 102 82 return NULL; 103 83 } … … 105 85 106 86 if (options->doFlat) { 107 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FLAT", "FLAT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) { 108 psError (PS_ERR_IO, false, "Can't find a flat image source"); 109 psFree (options); 110 return NULL; 111 } 112 } 113 114 int nThreads = psMetadataLookupS32 (&status, config->arguments, "NTHREADS"); 87 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FLAT", "FLAT", 88 PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) { 89 psError(PS_ERR_IO, false, "Can't find a flat image source"); 90 psFree(options); 91 return NULL; 92 } 93 } 94 95 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); 115 96 if (nThreads > 0) { 116 int nScanRows = psMetadataLookupS32 (&status, recipe, "SCAN.ROWS");117 pmDetrendSetThreadTasks (nScanRows);97 int nScanRows = psMetadataLookupS32(&status, recipe, "SCAN.ROWS"); 98 pmDetrendSetThreadTasks(nScanRows); 118 99 } 119 100 … … 166 147 skip_fringe: 167 148 if (options->doFringe) { 168 if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FRINGE", "FRINGE", PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) { 149 if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FRINGE", "FRINGE", 150 PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) { 169 151 psError (PS_ERR_IO, false, "Can't find a fringe image source"); 170 152 return NULL; … … 283 265 // define associated psphot input/output files 284 266 if (!psphotDefineFiles (config, psphotInput)) { 285 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot"); 267 psError(PSPHOT_ERR_CONFIG, false, 268 "Trouble defining the additional input/output files for psphot"); 286 269 return false; 287 270 } … … 291 274 if (options->doAstromChip || options->doAstromMosaic) { 292 275 if (!options->doPhotom) { 293 psError (PSASTRO_ERR_CONFIG, false, "photometry mode is not selected; it is required for astrometry"); 276 psError(PSASTRO_ERR_CONFIG, false, 277 "Photometry mode is not selected; it is required for astrometry"); 294 278 return false; 295 279 } 296 280 297 pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");298 PS_ASSERT (psphotOutput, false);299 300 pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, NULL, "PSASTRO.INPUT");301 PS_ASSERT (psastroInput, false);281 pmFPAfile *psphotOutput = psMetadataLookupPtr(&status, config->files, "PSPHOT.OUTPUT"); 282 PS_ASSERT(psphotOutput, false); 283 284 pmFPAfile *psastroInput = pmFPAfileDefineInput(config, psphotOutput->fpa, NULL, "PSASTRO.INPUT"); 285 PS_ASSERT(psastroInput, false); 302 286 psastroInput->mode = PM_FPA_MODE_REFERENCE; 303 287 304 288 // define associated psphot input/output files 305 if (!psastroDefineFiles (config, psastroInput)) { 306 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psastro"); 289 if (!psastroDefineFiles(config, psastroInput)) { 290 psError(PSPHOT_ERR_CONFIG, false, 291 "Trouble defining the additional input/output files for psastro"); 307 292 return false; 308 293 } 309 294 310 295 // deactivate the psastro files, reactive when needed 311 pmFPAfileActivate (config->files, false, "PSASTRO.OUTPUT");296 pmFPAfileActivate(config->files, false, "PSASTRO.OUTPUT"); 312 297 } 313 298 … … 325 310 326 311 // outImage is used as a carrier: input to chipImage -> require the data to remain at the CHIP level 327 outImage->freeLevel = PS_MIN (outImage->freeLevel, PM_FPA_LEVEL_CHIP);312 outImage->freeLevel = PS_MIN(outImage->freeLevel, PM_FPA_LEVEL_CHIP); 328 313 outImage->dataLevel = outImage->freeLevel; 329 outImage->fileLevel = PS_MIN (outImage->fileLevel, outImage->dataLevel);314 outImage->fileLevel = PS_MIN(outImage->fileLevel, outImage->dataLevel); 330 315 331 316 // outMask and outVariance must be freed at the same level as outImage (all freed by pmFPAFreeData) … … 342 327 343 328 // the input data is the same as the outImage data : force the free levels to match 344 input->freeLevel = PS_MIN (outImage->freeLevel, input->freeLevel);329 input->freeLevel = PS_MIN(outImage->freeLevel, input->freeLevel); 345 330 346 331 // define the binned target files (which may just be carriers for some camera configurations) 347 pmFPAfile *bin1 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1"); 332 pmFPAfile *bin1 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin1, options->yBin1, 333 "PPIMAGE.BIN1"); 348 334 if (!bin1) { 349 335 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN1")); … … 357 343 } 358 344 359 pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2"); 345 pmFPAfile *bin2 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin2, options->yBin2, 346 "PPIMAGE.BIN2"); 360 347 if (!bin2) { 361 348 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN2")); … … 373 360 bin2->freeLevel = PM_FPA_LEVEL_FPA; 374 361 375 pmFPAfile *jpg1 = pmFPAfileDefineOutput (config, byFPA1->fpa, "PPIMAGE.JPEG1");362 pmFPAfile *jpg1 = pmFPAfileDefineOutput(config, byFPA1->fpa, "PPIMAGE.JPEG1"); 376 363 if (!jpg1) { 377 364 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG1")); … … 384 371 return NULL; 385 372 } 386 pmFPAfile *jpg2 = pmFPAfileDefineOutput (config, byFPA2->fpa, "PPIMAGE.JPEG2");373 pmFPAfile *jpg2 = pmFPAfileDefineOutput(config, byFPA2->fpa, "PPIMAGE.JPEG2"); 387 374 if (!jpg2) { 388 375 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG2")); … … 404 391 // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg) 405 392 char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS"); 406 psArray *chips = psStringSplitArray (chipLine, ",", false);393 psArray *chips = psStringSplitArray(chipLine, ",", false); 407 394 if (chips->n > 0) { 408 395 pmFPASelectChip (input->fpa, -1, true); // deselect all chips … … 454 441 if (psTraceGetLevel("ppImage.config") > 0) { 455 442 // Get a look inside all the files. 456 psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator443 psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); 457 444 psMetadataItem *item; // Item from iteration 458 445 fprintf(stderr, "Files:\n"); -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageReplaceBackground.c
r21183 r23352 101 101 } 102 102 } 103 psImageBinning *binning = psMetadataLookupPtr(&status, psphotRecipe, "PSPHOT.BACKGROUND.BINNING"); // Binning for model 103 psImageBinning *binning = psMetadataLookupPtr(&status, modelRO->analysis, 104 "PSPHOT.BACKGROUND.BINNING"); // Binning for model 104 105 if (!binning) { 105 106 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background binning"); -
branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageVersion.c
r14000 r23352 5 5 #include "ppImage.h" 6 6 7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name 7 #ifndef PPIMAGE_VERSION 8 #error "PPIMAGE_VERSION is not set" 9 #endif 10 #ifndef PPIMAGE_BRANCH 11 #error "PPIMAGE_BRANCH is not set" 12 #endif 13 #ifndef PPIMAGE_SOURCE 14 #error "PPIMAGE_SOURCE is not set" 15 #endif 16 17 #define xstr(s) str(s) 18 #define str(s) #s 8 19 9 20 psString ppImageVersion(void) 10 21 { 11 psString version = NULL; // Version, to return 12 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 13 return version; 22 char *value = NULL; 23 psStringAppend(&value, "%s@%s", xstr(PPIMAGE_BRANCH), xstr(PPIMAGE_VERSION)); 24 return value; 25 } 26 27 psString ppImageSource(void) 28 { 29 return psStringCopy (xstr(PPIMAGE_SOURCE)); 14 30 } 15 31 16 32 psString ppImageVersionLong(void) 17 33 { 18 psString version = ppImageVersion(); // Version, to return 19 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 20 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 21 psFree(tag); 34 psString version = ppImageVersion(); // Version, to return 35 psString source = ppImageSource(); // Source 36 37 psStringPrepend(&version, "ppImage "); 38 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 39 psFree(source); 40 41 #ifdef __OPTIMIZE__ 42 psStringAppend(&version, " optimised"); 43 #else 44 psStringAppend(&version, " unoptimised"); 45 #endif 46 22 47 return version; 48 }; 49 50 bool ppImageVersionHeader(psMetadata *header) 51 { 52 PS_ASSERT_METADATA_NON_NULL(header, false); 53 54 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 55 psString timeString = psTimeToISO(time); // The time in an ISO string 56 psFree(time); 57 psString history = NULL; // History string 58 psStringAppend(&history, "ppImage at %s", timeString); 59 psFree(timeString); 60 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 61 psFree(history); 62 63 psLibVersionHeader(header); 64 psModulesVersionHeader(header); 65 psphotVersionHeader(header); 66 psastroVersionHeader(header); 67 ppStatsVersionHeader(header); 68 69 psString version = ppImageVersion(); // ppImage software version 70 psString source = ppImageSource(); // ppImage software source 71 72 psStringPrepend(&version, "ppImage version: "); 73 psStringPrepend(&source, "ppImage source: "); 74 75 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 76 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 77 78 psFree(version); 79 psFree(source); 80 81 return true; 23 82 } 24 83 25 84 26 void ppImageVersion Metadata(psMetadata *metadata)85 void ppImageVersionPrint(void) 27 86 { 28 PS_ASSERT_METADATA_NON_NULL(metadata,); 87 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 88 psString timeString = psTimeToISO(time); // The time in an ISO string 89 psFree(time); 90 psLogMsg("ppImage", PS_LOG_INFO, "ppImage at %s", timeString); 91 psFree(timeString); 29 92 30 93 psString pslib = psLibVersionLong();// psLib version … … 35 98 psString ppImage = ppImageVersionLong(); // ppImage version 36 99 37 ps Time *time = psTimeGetNow(PS_TIME_TAI); // The time now38 ps String timeString = psTimeToISO(time); // The time in an ISO string39 ps Free(time);40 ps String head = NULL; // Head string41 ps StringAppend(&head, "ppImage processing at %s. Component information:", timeString);42 ps Free(timeString);100 psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib); 101 psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules); 102 psLogMsg("ppImage", PS_LOG_INFO, "%s", psphot); 103 psLogMsg("ppImage", PS_LOG_INFO, "%s", psastro); 104 psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats); 105 psLogMsg("ppImage", PS_LOG_INFO, "%s", ppImage); 43 106 44 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");45 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");46 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");47 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psphot, "");48 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psastro, "");49 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");50 psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppImage, "");51 52 psFree(head);53 107 psFree(pslib); 54 108 psFree(psmodules);
Note:
See TracChangeset
for help on using the changeset viewer.
