Changeset 23352 for branches/cnb_branches/cnb_branch_20090301/ppSub
- Timestamp:
- Mar 17, 2009, 12:08:50 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 15 edited
-
. (modified) (1 prop)
-
ppSub (modified) (1 prop)
-
ppSub/src/Makefile.am (modified) (1 diff)
-
ppSub/src/ppSub.c (modified) (2 diffs)
-
ppSub/src/ppSub.h (modified) (1 diff)
-
ppSub/src/ppSubArguments.c (modified) (10 diffs)
-
ppSub/src/ppSubBackground.c (modified) (1 diff)
-
ppSub/src/ppSubCamera.c (modified) (2 diffs)
-
ppSub/src/ppSubLoop.c (modified) (4 diffs)
-
ppSub/src/ppSubMakePSF.c (modified) (1 diff)
-
ppSub/src/ppSubMatchPSFs.c (modified) (3 diffs)
-
ppSub/src/ppSubReadoutUpdate.c (modified) (1 diff)
-
ppSub/src/ppSubVarianceFactors.c (modified) (1 diff)
-
ppSub/src/ppSubVersion.c (modified) (1 diff)
-
ppSub/test/fake.c (modified) (1 diff)
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/ppSub
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/ppSub merged eligible /trunk/ppSub merged eligible /branches/cnb_branch_20090215/ppSub 21495-22685 /branches/eam_branches/eam_branch_20090303/ppSub 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/ppSub/src/Makefile.am
r21257 r23352 1 1 bin_PROGRAMS = ppSub ppSubKernel 2 2 3 ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) 3 # PPSUB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PPSUB_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` 5 # PPSUB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of ppSubVersion.c, since it gets the version information 8 # ppSubVersion.c: FORCE 9 # touch ppSubVersion.c 10 # FORCE: ; 11 12 ppSub_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS) -DPPSUB_VERSION=$(SVN_VERSION) -DPPSUB_BRANCH=$(SVN_BRANCH) -DPPSUB_SOURCE=$(SVN_SOURCE) 4 13 ppSub_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PPSUB_LIBS) 5 14 -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSub.c
r21524 r23352 34 34 goto die; 35 35 } 36 37 ppSubVersionPrint(); 36 38 37 39 if (!pmModelClassInit()) { … … 75 77 psTimerStop(); 76 78 77 pm SubtractionVisualClose(); //close plot windows, if -visual is set79 pmVisualClose(); //close plot windows, if -visual is set 78 80 psFree(config); 79 81 pmModelClassCleanup(); -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSub.h
r21524 r23352 89 89 ); 90 90 91 /// Put the program version information into a metadata92 void ppSubVersionMetadata(psMetadata *metadata ///< Metadatato populate91 /// Put the program version information into a header 92 bool ppSubVersionHeader(psMetadata *header ///< Header to populate 93 93 ); 94 95 /// Print version information 96 void ppSubVersionPrint(void); 94 97 95 98 -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubArguments.c
r21524 r23352 29 29 { 30 30 fprintf(stderr, "\nPan-STARRS PSF-matched image subtraction\n\n"); 31 fprintf(stderr, "Usage: %s INPUT.fits REFERENCE.fitsOUTPUT_ROOT \n"32 "\t[-psf REFERENCE.psf.fits] [-sources REFERENCE.cmf]\n\n"31 fprintf(stderr, "Usage: %s OUTPUT_ROOT \n" 32 "\t[-psf REFERENCE.psf.fits]\n\n" 33 33 "This subtracts the convolved REFERENCE from the INPUT, by default.\n", 34 34 program); … … 191 191 bool ppSubArgumentsSetup(int argc, char *argv[], pmConfig *config) 192 192 { 193 int argnum; // Argument Number193 // int argnum; // Argument Number 194 194 assert(config); 195 195 … … 200 200 } 201 201 202 if ((argnum = psArgumentGet(argc, argv, "-psphot-visual"))) {203 psArgumentRemove(argnum, &argc, argv);204 psphotSetVisual(true);205 }206 207 pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL);208 202 209 203 psMetadata *arguments = config->arguments; // Command-line arguments 204 psMetadataAddStr(arguments, PS_LIST_TAIL, "-inimage", 0, "Input image", NULL); 210 205 psMetadataAddStr(arguments, PS_LIST_TAIL, "-inmask", 0, "Input mask image", NULL); 211 206 psMetadataAddStr(arguments, PS_LIST_TAIL, "-invariance", 0, "Input variance image", NULL); 207 psMetadataAddStr(arguments, PS_LIST_TAIL, "-insources", 0, "Input source list", NULL); 208 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refimage", 0, "Reference image", NULL); 212 209 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refmask", 0, "Reference mask image", NULL); 213 210 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refvariance", 0, "Reference variance image", NULL); 211 psMetadataAddStr(arguments, PS_LIST_TAIL, "-refsources", 0, "Reference source list", NULL); 212 psMetadataAddStr(arguments, PS_LIST_TAIL, "-kernel", 0, "Precalculated kernel to apply", NULL); 214 213 psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL); 215 214 psMetadataAddF32(arguments, PS_LIST_TAIL, "-region", 0, "Size of iso-kernel region", NAN); … … 228 227 psMetadataAddF32(arguments, PS_LIST_TAIL, "-spacing", 0, "Typical stamp spacing (pixels)", NAN); 229 228 psMetadataAddS32(arguments, PS_LIST_TAIL, "-footprint", 0, "Stamp footprint half-size (pixels)", -1); 229 psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-radius", 0, "Source matching radius (pixels)", NAN); 230 230 psMetadataAddS32(arguments, PS_LIST_TAIL, "-stride", 0, "Size of convolution patches (pixels)", -1); 231 231 psMetadataAddF32(arguments, PS_LIST_TAIL, "-threshold", 0, "Minimum threshold for stamps (ADU)", NAN); … … 256 256 psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "Show diagnostic plots", NULL); 257 257 258 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 4) {258 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) { 259 259 usage(argv[0], arguments, config); 260 260 } 261 261 262 fileList("INPUT", argv[1], "Name of the input image", config);263 fileList("REF", argv[2], "Name of the reference image", config);264 262 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[3]); 265 263 264 265 const char *inImage = psMetadataLookupStr(NULL, arguments, "-inimage"); // Name of input image 266 if (inImage && strlen(inImage) > 0) { 267 fileList("INPUT", inImage, "Name of the input image", config); 268 } 266 269 const char *inMask = psMetadataLookupStr(NULL, arguments, "-inmask"); // Name of input mask 267 270 if (inMask && strlen(inMask) > 0) { … … 272 275 fileList("INPUT.VARIANCE", inVariance, "Name of the input variance image", config); 273 276 } 274 277 const char *inSources = psMetadataLookupStr(NULL, arguments, "-insources"); // Name of input source list 278 if (inSources && strlen(inSources) > 0) { 279 fileList("INPUT.SOURCES", inSources, "Name of the input source list", config); 280 } 281 282 const char *refImage = psMetadataLookupStr(NULL, arguments, "-refimage"); // Name of reference image 283 if (refImage && strlen(refImage) > 0) { 284 fileList("INPUT", refImage, "Name of the reference image", config); 285 } 275 286 const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask 276 287 if (refMask && strlen(refMask) > 0) { … … 280 291 if (refVariance && strlen(refVariance) > 0) { 281 292 fileList("REF.VARIANCE", refVariance, "Name of the reference variance image", config); 293 } 294 const char *refSources = psMetadataLookupStr(NULL, arguments, "-refsources"); // Name of ref source list 295 if (refSources && strlen(refSources) > 0) { 296 fileList("REF.SOURCES", refSources, "Name of the reference source list", config); 297 } 298 299 const char *kernel = psMetadataLookupStr(NULL, arguments, "-kernel"); // Name of kernel 300 if (kernel && strlen(kernel) > 0) { 301 fileList("KERNEL", kernel, "Name of the kernel to apply", config); 282 302 } 283 303 … … 304 324 } 305 325 306 VALUE_ARG_RECIPE_FLOAT("-region", "REGION.SIZE", F32); 307 VALUE_ARG_RECIPE_INT("-size", "KERNEL.SIZE", S32, 0); 308 VALUE_ARG_RECIPE_INT("-order", "SPATIAL.ORDER", S32, -1); 309 VALUE_ARG_RECIPE_FLOAT("-spacing", "STAMP.SPACING", F32); 310 VALUE_ARG_RECIPE_INT("-rings-order", "RINGS.ORDER", S32, -1); 311 VALUE_ARG_RECIPE_INT("-inner", "INNER", S32, -1); 312 VALUE_ARG_RECIPE_INT("-spam-binning", "SPAM.BINNING", S32, 0); 313 VALUE_ARG_RECIPE_INT("-footprint", "STAMP.FOOTPRINT", S32, -1); 314 VALUE_ARG_RECIPE_INT("-stride", "STRIDE", S32, -1); 315 VALUE_ARG_RECIPE_FLOAT("-threshold", "STAMP.THRESHOLD", F32); 316 VALUE_ARG_RECIPE_INT("-iter", "ITER", S32, -1); 317 VALUE_ARG_RECIPE_FLOAT("-rej", "REJ", F32); 318 VALUE_ARG_RECIPE_FLOAT("-sys", "SYS", F32); 319 VALUE_ARG_RECIPE_FLOAT("-badfrac", "BADFRAC", F32); 320 VALUE_ARG_RECIPE_FLOAT("-penalty", "PENALTY", F32); 321 VALUE_ARG_RECIPE_FLOAT("-poor-frac", "POOR.FRACTION", F32); 322 VALUE_ARG_RECIPE_INT("-bin1", "BIN1", S32, 0); 323 VALUE_ARG_RECIPE_INT("-bin2", "BIN2", S32, 0); 326 VALUE_ARG_RECIPE_FLOAT("-region", "REGION.SIZE", F32); 327 VALUE_ARG_RECIPE_INT("-size", "KERNEL.SIZE", S32, 0); 328 VALUE_ARG_RECIPE_INT("-order", "SPATIAL.ORDER", S32, -1); 329 VALUE_ARG_RECIPE_FLOAT("-spacing", "STAMP.SPACING", F32); 330 VALUE_ARG_RECIPE_INT("-rings-order", "RINGS.ORDER", S32, -1); 331 VALUE_ARG_RECIPE_INT("-inner", "INNER", S32, -1); 332 VALUE_ARG_RECIPE_INT("-spam-binning", "SPAM.BINNING", S32, 0); 333 VALUE_ARG_RECIPE_INT("-footprint", "STAMP.FOOTPRINT", S32, -1); 334 VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS", F32); 335 VALUE_ARG_RECIPE_INT("-stride", "STRIDE", S32, -1); 336 VALUE_ARG_RECIPE_FLOAT("-threshold", "STAMP.THRESHOLD", F32); 337 VALUE_ARG_RECIPE_INT("-iter", "ITER", S32, -1); 338 VALUE_ARG_RECIPE_FLOAT("-rej", "REJ", F32); 339 VALUE_ARG_RECIPE_FLOAT("-sys", "SYS", F32); 340 VALUE_ARG_RECIPE_FLOAT("-badfrac", "BADFRAC", F32); 341 VALUE_ARG_RECIPE_FLOAT("-penalty", "PENALTY", F32); 342 VALUE_ARG_RECIPE_FLOAT("-poor-frac", "POOR.FRACTION", F32); 343 VALUE_ARG_RECIPE_INT("-bin1", "BIN1", S32, 0); 344 VALUE_ARG_RECIPE_INT("-bin2", "BIN2", S32, 0); 324 345 325 346 valueArgRecipeStr(arguments, recipe, "-mask-in", "MASK.IN", recipe); … … 360 381 361 382 if (psMetadataLookupBool(NULL, arguments, "-visual")) { 362 pm SubtractionSetVisual(true);383 pmVisualSetVisual(true); 363 384 } 364 385 … … 376 397 psTrace("ppSub", 1, "Done reading command-line arguments\n"); 377 398 378 // Dump configuration, now that's it's settled379 psBool status;380 psString dump_file = psMetadataLookupStr(&status, config->arguments, "-dumpconfig");381 if (dump_file) {382 pmConfigCamerasCull(config, NULL);383 pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS");384 385 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file386 pmConfigDump(config, input->fpa, dump_file);387 }388 389 399 // XXX move this to ppSubArguments 390 400 int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubBackground.c
r21524 r23352 53 53 } 54 54 } 55 psImageBinning *binning = psMetadataLookupPtr(&mdok, psphotRecipe,55 psImageBinning *binning = psMetadataLookupPtr(&mdok, modelRO->analysis, 56 56 "PSPHOT.BACKGROUND.BINNING"); // Binning for model 57 57 psImage *modelImage = modelRO->image; // Background model -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubCamera.c
r21524 r23352 22 22 #include "ppSub.h" 23 23 24 // Define an input file 25 static pmFPAfile *defineInputFile(pmConfig *config,// Configuration 26 pmFPAfile *bind, // File to which to bind, or NULL 27 char *filerule, // Name of file rule 28 char *argname, // Argument name 29 pmFPAfileType fileType // Type of file 30 ) 31 { 32 bool status; 33 34 // look for the file on the RUN metadata 35 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return 36 if (!status) { 37 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 38 return NULL; 39 } 40 if (!file) { 41 // look for the file on the argument list 42 if (bind) { 43 file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname); 44 } else { 45 file = pmFPAfileDefineFromArgs(&status, config, filerule, argname); 46 } 47 if (!status) { 48 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 49 return false; 50 } 51 } 52 53 if (!file) { 54 return NULL; 55 } 56 57 if (file->type != fileType) { 58 psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 59 return NULL; 60 } 61 62 return file; 63 } 64 65 // Define an output file 66 static pmFPAfile *defineOutputFile(pmConfig *config, // Configuration 67 pmFPAfile *template, // File to use as basis for definition 68 char *filerule, // Name of file rule 69 pmFPAfileType fileType // Type of file 70 ) 71 { 72 73 pmFPAfile *file = pmFPAfileDefineFromFile(config, template, 1, 1, filerule); 74 if (!file) { 75 psError(PS_ERR_IO, false, _("Unable to generate output file from %s"), filerule); 76 return NULL; 77 } 78 if (file->type != fileType) { 79 psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 80 return NULL; 81 } 82 83 return file; 84 } 85 86 87 // Define an output file that will be used in a calculation 88 // This means it might already be available in the RUN metadata 89 static pmFPAfile *defineCalcFile(pmConfig *config, // Configuration 90 pmFPAfile *bind, // File to which to bind, or NULL 91 char *filerule, // Name of file rule 92 pmFPAfileType fileType // Type of file 93 ) 94 { 95 bool status; 96 97 // look for the file on the RUN metadata 98 pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return 99 if (!status) { 100 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 101 return NULL; 102 } 103 if (file) { 104 // It's an input 105 file->save = false; 106 } 107 108 // define new version of file 109 if (!file) { 110 pmFPAfileDefineOutput(config, bind ? bind->fpa : NULL, filerule); 111 if (!status) { 112 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 113 return false; 114 } 115 if (file) { 116 // It's an output 117 file->save = true; 118 } 119 } 120 121 if (!file) { 122 return NULL; 123 } 124 125 if (file->type != fileType) { 126 psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 127 return NULL; 128 } 129 130 return file; 131 } 132 133 24 134 bool ppSubCamera(pmConfig *config) 25 135 { 26 bool status = false; // result from pmFPAfileDefine operations136 psAssert(config, "Require configuration"); 27 137 28 138 // Input image 29 pmFPAfile *input = pmFPAfileDefineFromArgs(&status, config, "PPSUB.INPUT", "INPUT");30 if (! status || !input) {139 pmFPAfile *input = defineInputFile(config, NULL, "PPSUB.INPUT", "INPUT", PM_FPA_FILE_IMAGE); 140 if (!input) { 31 141 psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT"); 32 142 return false; 33 143 } 34 if (input->type != PM_FPA_FILE_IMAGE) { 35 psError(PS_ERR_IO, true, "PPSUB.INPUT is not of type IMAGE"); 36 return false; 37 } 38 39 // Input mask 40 pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.MASK", "INPUT.MASK"); 41 if (!status) { 42 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.MASK"); 43 return NULL; 44 } 45 if (inputMask && inputMask->type != PM_FPA_FILE_MASK) { 46 psError(PS_ERR_IO, true, "PPSUB.INPUT.MASK is not of type MASK"); 47 return false; 48 } 49 50 // Input variance map 51 pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE"); 52 if (!status) { 53 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.INPUT.VARIANCE"); 54 return NULL; 55 } 56 if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) { 57 psError(PS_ERR_IO, true, "PPSUB.INPUT.VARIANCE is not of type VARIANCE"); 58 return false; 59 } 144 defineInputFile(config, input, "PPSUB.INPUT.MASK", "INPUT.MASK", PM_FPA_FILE_MASK); 145 pmFPAfile *inVar = defineInputFile(config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE", 146 PM_FPA_FILE_VARIANCE); 147 defineInputFile(config, input, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF); 60 148 61 149 // Reference image 62 status = false; 63 pmFPAfile *ref = pmFPAfileDefineFromArgs(&status, config, "PPSUB.REF", "REF"); 150 pmFPAfile *ref = defineInputFile(config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE); 64 151 if (!ref) { 65 152 psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF"); 66 153 return false; 67 154 } 68 if (ref->type != PM_FPA_FILE_IMAGE) { 69 psError(PS_ERR_IO, true, "PPSUB.REF is not of type IMAGE"); 70 return false; 71 } 72 73 // Reference mask 74 pmFPAfile *refMask = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.MASK", "REF.MASK"); 75 if (!status) { 76 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.MASK"); 77 return NULL; 78 } 79 if (refMask && refMask->type != PM_FPA_FILE_MASK) { 80 psError(PS_ERR_IO, true, "PPSUB.REF.MASK is not of type MASK"); 81 return false; 82 } 83 84 // Reference variance map 85 pmFPAfile *refVariance = pmFPAfileBindFromArgs(&status, ref, config, "PPSUB.REF.VARIANCE", "REF.VARIANCE"); 86 if (!status) { 87 psError (PS_ERR_UNKNOWN, false, "Failed to load file definition PPSUB.REF.VARIANCE"); 88 return NULL; 89 } 90 if (refVariance && refVariance->type != PM_FPA_FILE_VARIANCE) { 91 psError(PS_ERR_IO, true, "PPSUB.REF.VARIANCE is not of type VARIANCE"); 92 return false; 93 } 155 defineInputFile(config, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK); 156 pmFPAfile *refVar = defineInputFile(config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", 157 PM_FPA_FILE_VARIANCE); 158 defineInputFile(config, ref, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF); 159 94 160 95 161 // Output image 96 pmFPAfile *output = pmFPAfileDefineFromFile(config, input, 1, 1, "PPSUB.OUTPUT"); 97 if (!output) { 98 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT")); 99 return false; 100 } 101 if (output->type != PM_FPA_FILE_IMAGE) { 102 psError(PS_ERR_IO, true, "PPSUB.OUTPUT is not of type IMAGE"); 162 pmFPAfile *output = defineOutputFile(config, input, "PPSUB.OUTPUT", PM_FPA_FILE_IMAGE); 163 pmFPAfile *outMask = defineOutputFile(config, output, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK); 164 if (!output || !outMask) { 165 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 103 166 return false; 104 167 } 105 168 output->save = true; 106 107 // Output mask108 pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.MASK");109 if (!outMask) {110 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.MASK"));111 return false;112 }113 if (outMask->type != PM_FPA_FILE_MASK) {114 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.MASK is not of type MASK");115 return false;116 }117 169 outMask->save = true; 118 119 // Output variance 120 if (inputVariance && refVariance) { 121 pmFPAfile *outVariance = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.VARIANCE"); 122 if (!outVariance) { 123 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE")); 124 return false; 125 } 126 if (outVariance->type != PM_FPA_FILE_VARIANCE) { 127 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.VARIANCE is not of type VARIANCE"); 128 return false; 129 } 130 outVariance->save = true; 131 } 170 pmFPAfile *outVar = NULL; 171 if (inVar && refVar) { 172 outVar = defineOutputFile(config, output, "PPSUB.OUTPUT.VARIANCE", PM_FPA_FILE_VARIANCE); 173 if (!outVar) { 174 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 175 return false; 176 } 177 outVar->save = true; 178 } 179 132 180 133 181 // Convolved input image 134 pmFPAfile *inConv = pmFPAfileDefineFromFile(config, input, 1, 1, "PPSUB.INPUT.CONV"); 135 if (!inConv) { 136 psError(PS_ERR_IO, false, _("Unable to generate output file for PPSUB.INPUT.CONV")); 137 return false; 138 } 139 if (output->type != PM_FPA_FILE_IMAGE) { 140 psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV is not of type IMAGE"); 141 return false; 142 } 143 // XXX should be based on recipe : inConv->save = true; 144 145 // Convolved input mask 146 pmFPAfile *inConvMask = pmFPAfileDefineOutput(config, inConv->fpa, "PPSUB.INPUT.CONV.MASK"); 147 if (!inConvMask) { 148 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.INPUT.CONV.MASK")); 149 return false; 150 } 151 if (inConvMask->type != PM_FPA_FILE_MASK) { 152 psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV.MASK is not of type MASK"); 153 return false; 154 } 155 // XXX should be based on recipe : inConvMask->save = true; 156 157 // Convolved input variance 158 if (inputVariance) { 159 pmFPAfile *inConvVariance = pmFPAfileDefineOutput(config, inConv->fpa, "PPSUB.INPUT.CONV.VARIANCE"); 160 if (!inConvVariance) { 161 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE")); 162 return false; 163 } 164 if (inConvVariance->type != PM_FPA_FILE_VARIANCE) { 165 psError(PS_ERR_IO, true, "PPSUB.INPUT.CONV.VARIANCE is not of type VARIANCE"); 166 return false; 167 } 168 // XXX should be based on recipe : inConvVariance->save = true; 182 pmFPAfile *inConvImage = defineOutputFile(config, input, "PPSUB.INPUT.CONV", PM_FPA_FILE_IMAGE); 183 pmFPAfile *inConvMask = defineOutputFile(config, input, "PPSUB.INPUT.CONV.MASK", PM_FPA_FILE_MASK); 184 if (!inConvImage || !inConvMask) { 185 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 186 return false; 187 } 188 if (inVar) { 189 pmFPAfile *inConvVar = defineOutputFile(config, input, "PPSUB.INPUT.CONV.VARIANCE", 190 PM_FPA_FILE_VARIANCE); 191 if (!inConvVar) { 192 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 193 return false; 194 } 169 195 } 170 196 171 197 // Convolved ref image 172 pmFPAfile *refConv = pmFPAfileDefineFromFile(config, ref, 1, 1, "PPSUB.REF.CONV"); 173 if (!refConv) { 174 psError(PS_ERR_IO, false, _("Unable to generate output file for PPSUB.REF.CONV")); 175 return false; 176 } 177 if (output->type != PM_FPA_FILE_IMAGE) { 178 psError(PS_ERR_IO, true, "PPSUB.REF.CONV is not of type IMAGE"); 179 return false; 180 } 181 // XXX should be based on recipe : refConv->save = true; 182 183 // Convolved ref mask 184 pmFPAfile *refConvMask = pmFPAfileDefineOutput(config, refConv->fpa, "PPSUB.REF.CONV.MASK"); 185 if (!refConvMask) { 186 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.REF.CONV.MASK")); 187 return false; 188 } 189 if (refConvMask->type != PM_FPA_FILE_MASK) { 190 psError(PS_ERR_IO, true, "PPSUB.REF.CONV.MASK is not of type MASK"); 191 return false; 192 } 193 // XXX should be based on recipe : refConvMask->save = true; 194 195 // Convolved ref variance 196 if (refVariance) { 197 pmFPAfile *refConvVariance = pmFPAfileDefineOutput(config, refConv->fpa, "PPSUB.REF.CONV.VARIANCE"); 198 if (!refConvVariance) { 199 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.VARIANCE")); 200 return false; 201 } 202 if (refConvVariance->type != PM_FPA_FILE_VARIANCE) { 203 psError(PS_ERR_IO, true, "PPSUB.REF.CONV.VARIANCE is not of type VARIANCE"); 204 return false; 205 } 206 // XXX should be based on recipe : refConvVariance->save = true; 207 } 198 pmFPAfile *refConvImage = defineOutputFile(config, input, "PPSUB.REF.CONV", PM_FPA_FILE_IMAGE); 199 pmFPAfile *refConvMask = defineOutputFile(config, input, "PPSUB.REF.CONV.MASK", PM_FPA_FILE_MASK); 200 if (!refConvImage || !refConvMask) { 201 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 202 return false; 203 } 204 if (refVar) { 205 pmFPAfile *refConvVar = defineOutputFile(config, input, "PPSUB.REF.CONV.VARIANCE", 206 PM_FPA_FILE_VARIANCE); 207 if (!refConvVar) { 208 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 209 return false; 210 } 211 } 212 208 213 209 214 // Output JPEGs … … 230 235 231 236 // Output subtraction kernel 232 pmFPAfile *outKernels = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.KERNELS"); 233 if (!outKernels) { 234 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.KERNELS")); 235 return false; 236 } 237 if (outKernels->type != PM_FPA_FILE_SUBKERNEL) { 238 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.KERNELS is not of type SUBKERNEL"); 239 return false; 240 } 241 outKernels->save = true; 242 243 #if 0 244 if (!pmFPAAddSourceFromFormat(output->fpa, "Subtraction", output->format)) { 245 psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA."); 246 return false; 247 } 248 #endif 249 250 pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSUB.SOURCES", "PPSUB.SOURCES"); 251 if (!status) { 252 psError(PS_ERR_IO, false, "Failed to load file definition PPSUB.SOURCES"); 253 return false; 254 } 255 if (sources && sources->type != PM_FPA_FILE_CMF) { 256 psError(PS_ERR_IO, true, "PPSUB.SOURCES is not of type CMF"); 237 pmFPAfile *kernel = defineCalcFile(config, output, "PPSUB.OUTPUT.KERNELS", PM_FPA_FILE_SUBKERNEL); 238 if (!kernel) { 239 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to define file PPSUB.OUTPUT.KERNELS"); 257 240 return false; 258 241 } -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubLoop.c
r21524 r23352 23 23 bool ppSubLoop(pmConfig *config) 24 24 { 25 psAssert(config, "Require configuration."); 26 27 pmConfigCamerasCull(config, NULL); 28 pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS,JPEG"); 29 25 30 bool mdok; // Status of MD lookup 26 31 const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics … … 59 64 60 65 pmFPAview *view = pmFPAviewAlloc(0); // Pointer into FPA hierarchy 61 pmHDU *lastHDU = NULL; // Last HDU that was updated62 66 63 67 // Iterate over the FPA hierarchy … … 99 103 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 100 104 return false; 101 }102 103 // Put version information into the header104 pmHDU *hdu = pmHDUFromCell(inCell);105 if (hdu && hdu != lastHDU) {106 if (!hdu->header) {107 hdu->header = psMetadataAlloc();108 }109 ppSubVersionMetadata(hdu->header);110 lastHDU = hdu;111 105 } 112 106 … … 183 177 } 184 178 179 psString dump_file = psMetadataLookupStr(&mdok, config->arguments, "-dumpconfig"); 180 if (dump_file) { 181 182 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file 183 pmConfigDump(config, input->fpa, dump_file); 184 } 185 185 186 return true; 186 187 } -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubMakePSF.c
r21524 r23352 81 81 // Extract the loaded sources from the associated readout, and generate PSF 82 82 // Here, we assume the image is background-subtracted 83 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); 84 psArray *sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES"); 83 psArray *sources = psMetadataLookupPtr(&mdok, minuend->analysis, "PSPHOT.SOURCES"); 85 84 if (!psphotReadoutFindPSF(config, view, sources)) { 86 85 psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry on subtracted image."); -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubMatchPSFs.c
r21524 r23352 49 49 bool mdok; // Status of MD lookup 50 50 51 // Load pre-calculated kernel, if available 52 pmReadout *kernelRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNEL"); // RO with kernel 53 51 54 // Sources in image, used for stamps: these must be loaded from previous analysis stages 52 pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources 53 psArray *sources = NULL; // Sources in image; used for stamps 54 if (sourcesRO) { 55 sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES"); 55 psArray *inSources = psMetadataLookupPtr(&mdok, inRO->analysis, "PSPHOT.SOURCES"); // Input source list 56 psArray *refSources = psMetadataLookupPtr(&mdok, refRO->analysis, "PSPHOT.SOURCES"); // Ref source list 57 58 psArray *sources = NULL; // Merged list of sources 59 if (inSources && refSources) { 60 float radius = psMetadataLookupF32(NULL, recipe, "SOURCE.RADIUS"); // Matching radius 61 psArray *lists = psArrayAlloc(2); // Source lists 62 lists->data[0] = psMemIncrRefCounter(inSources); 63 lists->data[1] = psMemIncrRefCounter(refSources); 64 sources = pmSourceMatchMerge(lists, radius); 65 psFree(lists); 66 if (!sources) { 67 psError(PS_ERR_UNKNOWN, false, "Unable to merge source lists"); 68 return false; 69 } 70 } else if (inSources) { 71 sources = psMemIncrRefCounter(inSources); 72 } else if (refSources) { 73 sources = psMemIncrRefCounter(refSources); 56 74 } 75 76 psMetadataAddArray(inConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, 77 "Merged source list", sources); 78 psMetadataAddArray(refConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE, 79 "Merged source list", sources); 80 psFree(sources); // Drop reference 57 81 58 82 int footprint = psMetadataLookupS32(NULL, recipe, "STAMP.FOOTPRINT"); // Stamp half-size … … 113 137 114 138 // Match the PSFs 115 if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize, spacing, threshold, 116 sources, stampsName, type, size, order, widths, orders, inner, ringsOrder, 117 binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, sys, 118 maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode)) { 119 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 120 return false; 139 if (kernelRO) { 140 if (!pmSubtractionMatchPrecalc(inConv, refConv, inRO, refRO, kernelRO->analysis, 141 stride, sys, maskVal, maskBad, maskPoor, poorFrac, badFrac)) { 142 psError(PS_ERR_UNKNOWN, false, "Unable to convolve images."); 143 return false; 144 } 145 } else { 146 if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize, spacing, 147 threshold, sources, stampsName, type, size, order, widths, orders, inner, 148 ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter, 149 rej, sys, maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode)) { 150 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 151 return false; 152 } 121 153 } 122 154 … … 129 161 130 162 // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf) 131 163 #ifdef TESTING 132 164 psphotSaveImage (NULL, inRO->image, "inRO.fits"); 133 165 psphotSaveImage (NULL, refRO->image, "refRO.fits"); 134 166 psphotSaveImage (NULL, inConv->image, "inConv.fits"); 135 167 psphotSaveImage (NULL, refConv->image, "refConv.fits"); 168 #endif 136 169 137 170 return true; -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubReadoutUpdate.c
r21524 r23352 44 44 psMetadataAddStr(outHDU->header, PS_LIST_TAIL, "PPSUB.INPUT", 0, 45 45 "Subtraction input", inFile->filename); 46 ppSubVersionHeader(outHDU->header); 46 47 47 48 // Statistics on the matching -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubVarianceFactors.c
r21524 r23352 65 65 66 66 psStats *vfStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics 67 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator67 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 68 68 69 69 // mask these values when examining the background -
branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubVersion.c
r21524 r23352 19 19 #include <psmodules.h> 20 20 #include <ppStats.h> 21 #include <psphot.h> 21 22 22 23 #include "ppSub.h" 23 24 24 static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name 25 #ifndef PPSUB_VERSION 26 #error "PPSUB_VERSION is not set" 27 #endif 28 #ifndef PPSUB_BRANCH 29 #error "PPSUB_BRANCH is not set" 30 #endif 31 #ifndef PPSUB_SOURCE 32 #error "PPSUB_SOURCE is not set" 33 #endif 34 35 #define xstr(s) str(s) 36 #define str(s) #s 25 37 26 38 psString ppSubVersion(void) 27 39 { 28 psString version = NULL; // Version, to return 29 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 30 return version; 40 char *value = NULL; 41 psStringAppend(&value, "%s@%s", xstr(PPSUB_BRANCH), xstr(PPSUB_VERSION)); 42 return value; 43 } 44 45 psString ppSubSource(void) 46 { 47 return psStringCopy(xstr(PPSUB_SOURCE)); 31 48 } 32 49 33 50 psString ppSubVersionLong(void) 34 51 { 35 psString version = ppSubVersion(); // Version, to return 36 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 37 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 38 psFree(tag); 52 psString version = ppSubVersion(); // Version, to return 53 psString source = ppSubSource(); // Source 54 55 psStringPrepend(&version, "ppSub "); 56 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 57 psFree(source); 58 59 #ifdef __OPTIMIZE__ 60 psStringAppend(&version, " optimised"); 61 #else 62 psStringAppend(&version, " unoptimised"); 63 #endif 64 39 65 return version; 40 } 66 }; 41 67 42 68 43 void ppSubVersionMetadata(psMetadata *metadata)69 bool ppSubVersionHeader(psMetadata *header) 44 70 { 45 PS_ASSERT_METADATA_NON_NULL(metadata,); 46 47 psString pslib = psLibVersionLong();// psLib version 48 psString psmodules = psModulesVersionLong(); // psModules version 49 psString ppStats = ppStatsVersionLong(); // ppStats version 50 psString ppSub = ppSubVersionLong(); // ppSub version 71 PS_ASSERT_METADATA_NON_NULL(header, false); 51 72 52 73 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 53 74 psString timeString = psTimeToISO(time); // The time in an ISO string 54 75 psFree(time); 55 psString head = NULL; // Head string 56 psStringAppend(&head, "ppSub processing at %s. Component information:", timeString); 76 psString history = NULL; // History string 77 psStringAppend(&history, "ppSub at %s", timeString); 78 psFree(timeString); 79 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 80 psFree(history); 81 82 psLibVersionHeader(header); 83 psModulesVersionHeader(header); 84 psphotVersionHeader(header); 85 ppStatsVersionHeader(header); 86 87 psString version = ppSubVersion(); // Software version 88 psString source = ppSubSource(); // Software source 89 90 psStringPrepend(&version, "ppSub version: "); 91 psStringPrepend(&source, "ppSub source: "); 92 93 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 94 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 95 96 psFree(version); 97 psFree(source); 98 99 return true; 100 } 101 102 void ppSubVersionPrint(void) 103 { 104 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 105 psString timeString = psTimeToISO(time); // The time in an ISO string 106 psFree(time); 107 psLogMsg("ppSub", PS_LOG_INFO, "ppSub at %s", timeString); 57 108 psFree(timeString); 58 109 59 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");60 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");61 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");62 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");63 ps MetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppSub, "");110 psString pslib = psLibVersionLong();// psLib version 111 psString psmodules = psModulesVersionLong(); // psModules version 112 psString psphot = psphotVersionLong(); // psphot version 113 psString ppStats = ppStatsVersionLong(); // ppStats version 114 psString ppSub = ppSubVersionLong(); // ppSub version 64 115 65 psFree(head); 116 psLogMsg("ppSub", PS_LOG_INFO, "%s", pslib); 117 psLogMsg("ppSub", PS_LOG_INFO, "%s", psmodules); 118 psLogMsg("ppSub", PS_LOG_INFO, "%s", psphot); 119 psLogMsg("ppSub", PS_LOG_INFO, "%s", ppStats); 120 psLogMsg("ppSub", PS_LOG_INFO, "%s", ppSub); 121 66 122 psFree(pslib); 67 123 psFree(psmodules); 124 psFree(psphot); 68 125 psFree(ppStats); 69 126 psFree(ppSub); -
branches/cnb_branches/cnb_branch_20090301/ppSub/test/fake.c
r18591 r23352 89 89 int main(int argc, char *argv[]) 90 90 { 91 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0); // Random number generator91 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 92 92 93 93 // Images to generate
Note:
See TracChangeset
for help on using the changeset viewer.
