- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ppSub/src
- Property svn:ignore
-
old new 13 13 ppSubErrorCodes.c 14 14 ppSubVersionDefinitions.h 15 ppSubConvolve
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/ppSub/src/ppSubCamera.c
r24261 r27840 23 23 24 24 // Define an input file 25 static pmFPAfile *defineInputFile(pmConfig *config,// Configuration 25 static pmFPAfile *defineInputFile(bool *success, 26 pmConfig *config,// Configuration 26 27 pmFPAfile *bind, // File to which to bind, or NULL 27 28 char *filerule, // Name of file rule … … 32 33 bool status; 33 34 34 // look for the file on the RUN metadata 35 pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return 35 *success = false; 36 37 pmFPAfile *file = NULL; 38 39 // look for the file on the argument list 40 if (bind) { 41 file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname); 42 } else { 43 file = pmFPAfileDefineFromArgs(&status, config, filerule, argname); 44 } 45 36 46 if (!status) { 37 psError( PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);38 return NULL;47 psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule); 48 return false; 39 49 } 40 50 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 } 51 // look for the file on the RUN metadata 52 file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return 47 53 if (!status) { 48 psError( PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);49 return false;54 psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule); 55 return NULL; 50 56 } 51 57 } 52 58 53 59 if (!file) { 60 // no file defined 61 *success = true; 54 62 return NULL; 55 63 } 56 64 57 65 if (file->type != fileType) { 58 psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 59 return NULL; 60 } 61 66 psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 67 return NULL; 68 } 69 70 *success = true; 62 71 return file; 63 72 } … … 75 84 pmFPAfileDefineOutput(config, template->fpa, filerule); 76 85 if (!file) { 77 psError( PS_ERR_IO, false, _("Unable to generate output file from %s"), filerule);86 psError(psErrorCodeLast(), false, _("Unable to generate output file from %s"), filerule); 78 87 return NULL; 79 88 } 80 89 if (file->type != fileType) { 81 psError(P S_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));90 psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 82 91 return NULL; 83 92 } … … 92 101 pmFPAfile *bind, // File to which to bind, or NULL 93 102 char *filerule, // Name of file rule 103 const char *argname, // Argument name for file 94 104 pmFPAfileType fileType // Type of file 95 105 ) … … 98 108 99 109 // look for the file on the RUN metadata 100 pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return110 pmFPAfile *file = pmFPAfileDefineFromRun(&status, NULL, config, filerule); // File to return 101 111 if (!status) { 102 psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule); 112 psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule); 113 return NULL; 114 } 115 file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname); 116 if (!status) { 117 psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule); 103 118 return NULL; 104 119 } … … 112 127 file = pmFPAfileDefineOutput(config, bind ? bind->fpa : NULL, filerule); 113 128 if (!status) { 114 psError( PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);129 psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule); 115 130 return false; 116 131 } … … 126 141 127 142 if (file->type != fileType) { 128 psError(P S_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));143 psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType)); 129 144 return NULL; 130 145 } … … 136 151 bool ppSubCamera(ppSubData *data) 137 152 { 153 bool success = true; 154 138 155 psAssert(data, "Require processing data"); 139 156 pmConfig *config = data->config; … … 141 158 142 159 // Input image 143 pmFPAfile *input = defineInputFile(config, NULL, "PPSUB.INPUT", "INPUT", PM_FPA_FILE_IMAGE); 144 if (!input) { 145 psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT"); 146 return false; 147 } 148 defineInputFile(config, input, "PPSUB.INPUT.MASK", "INPUT.MASK", PM_FPA_FILE_MASK); 149 pmFPAfile *inVar = defineInputFile(config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE", 150 PM_FPA_FILE_VARIANCE); 151 defineInputFile(config, NULL, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF); 160 pmFPAfile *input = defineInputFile(&success, config, NULL, "PPSUB.INPUT", "INPUT", PM_FPA_FILE_IMAGE); 161 if (!success) { 162 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT"); 163 return false; 164 } 165 166 defineInputFile(&success, config, input, "PPSUB.INPUT.MASK", "INPUT.MASK", PM_FPA_FILE_MASK); 167 if (!success) { 168 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.MASK"); 169 return false; 170 } 171 172 pmFPAfile *inVar = defineInputFile(&success, config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE", PM_FPA_FILE_VARIANCE); 173 if (!success) { 174 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.VARIANCE"); 175 return false; 176 } 177 178 defineInputFile(&success, config, NULL, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF); 179 if (!success) { 180 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.SOURCES"); 181 return false; 182 } 152 183 153 184 // Reference image 154 pmFPAfile *ref = defineInputFile(config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE); 155 if (!ref) { 156 psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF"); 157 return false; 158 } 159 defineInputFile(config, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK); 160 pmFPAfile *refVar = defineInputFile(config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", 161 PM_FPA_FILE_VARIANCE); 162 defineInputFile(config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF); 163 185 pmFPAfile *ref = defineInputFile(&success, config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE); 186 if (!success) { 187 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF"); 188 return false; 189 } 190 191 defineInputFile(&success, config, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK); 192 if (!success) { 193 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.MASK"); 194 return false; 195 } 196 197 pmFPAfile *refVar = defineInputFile(&success, config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", PM_FPA_FILE_VARIANCE); 198 if (!success) { 199 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.VARIANCE"); 200 return false; 201 } 202 203 defineInputFile(&success, config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF); 204 if (!success) { 205 psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES"); 206 return false; 207 } 164 208 165 209 // Now that the camera has been determined, we can read the recipe 166 210 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim 167 211 if (!recipe) { 168 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);212 psError(PPSUB_ERR_CONFIG, false, "Unable to find recipe %s", PPSUB_RECIPE); 169 213 return false; 170 214 } … … 180 224 data->inverse = psMetadataLookupBool(NULL, recipe, "INVERSE"); 181 225 data->photometry = psMetadataLookupBool(NULL, recipe, "PHOTOMETRY"); 182 183 bool mdok; // Status of MD lookup184 bool saveConv = psMetadataLookupBool(&mdok, recipe, "SAVE.CONVOLVED"); // Save convolved images?185 226 186 227 // Convolved input image … … 189 230 PM_FPA_FILE_MASK); 190 231 if (!inConvImage || !inConvMask) { 191 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 192 return false; 193 } 194 if (saveConv) { 195 inConvImage->save = true; 196 inConvMask->save = true; 197 } 232 psError(psErrorCodeLast(), false, "Unable to define output files"); 233 return false; 234 } 235 inConvImage->save = data->saveInConv; 236 inConvMask->save = data->saveInConv; 198 237 if (inVar) { 199 238 pmFPAfile *inConvVar = defineOutputFile(config, inConvImage, false, "PPSUB.INPUT.CONV.VARIANCE", 200 239 PM_FPA_FILE_VARIANCE); 201 240 if (!inConvVar) { 202 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 203 return false; 204 } 205 if (saveConv) { 206 inConvVar->save = true; 207 } 241 psError(psErrorCodeLast(), false, "Unable to define output files"); 242 return false; 243 } 244 inConvVar->save = data->saveInConv; 208 245 } 209 246 … … 213 250 PM_FPA_FILE_MASK); 214 251 if (!refConvImage || !refConvMask) { 215 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 216 return false; 217 } 218 if (saveConv) { 219 refConvImage->save = true; 220 refConvMask->save = true; 221 } 252 psError(psErrorCodeLast(), false, "Unable to define output files"); 253 return false; 254 } 255 refConvImage->save = data->saveRefConv; 256 refConvMask->save = data->saveRefConv; 222 257 if (refVar) { 223 258 pmFPAfile *refConvVar = defineOutputFile(config, refConvImage, false, "PPSUB.REF.CONV.VARIANCE", 224 259 PM_FPA_FILE_VARIANCE); 225 260 if (!refConvVar) { 226 psError(PS_ERR_UNKNOWN, false, "Unable to define output files"); 227 return false; 228 } 229 if (saveConv) { 230 refConvVar->save = true; 231 } 261 psError(psErrorCodeLast(), false, "Unable to define output files"); 262 return false; 263 } 264 refConvVar->save = data->saveRefConv; 232 265 } 233 266 … … 236 269 pmFPAfile *outMask = defineOutputFile(config, output, false, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK); 237 270 if (!output || !outMask) { 238 psError( PS_ERR_UNKNOWN, false, "Unable to define output files");271 psError(psErrorCodeLast(), false, "Unable to define output files"); 239 272 return false; 240 273 } … … 245 278 PM_FPA_FILE_VARIANCE); 246 279 if (!outVar) { 247 psError( PS_ERR_UNKNOWN, false, "Unable to define output files");280 psError(psErrorCodeLast(), false, "Unable to define output files"); 248 281 return false; 249 282 } … … 258 291 PM_FPA_FILE_MASK); 259 292 if (!inverse || !invMask) { 260 psError( PS_ERR_UNKNOWN, false, "Unable to define output files");293 psError(psErrorCodeLast(), false, "Unable to define output files"); 261 294 return false; 262 295 } … … 267 300 PM_FPA_FILE_VARIANCE); 268 301 if (!invVar) { 269 psError( PS_ERR_UNKNOWN, false, "Unable to define output files");302 psError(psErrorCodeLast(), false, "Unable to define output files"); 270 303 return false; 271 304 } … … 278 311 pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG1"); 279 312 if (!jpeg1) { 280 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG1"));313 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG1")); 281 314 return false; 282 315 } 283 316 if (jpeg1->type != PM_FPA_FILE_JPEG) { 284 psError( PS_ERR_IO, true, "PPSUB.OUTPUT.JPEG1 is not of type JPEG");317 psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.JPEG1 is not of type JPEG"); 285 318 return false; 286 319 } … … 288 321 pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG2"); 289 322 if (!jpeg2) { 290 psError( PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG2"));323 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG2")); 291 324 return false; 292 325 } 293 326 if (jpeg2->type != PM_FPA_FILE_JPEG) { 294 psError( PS_ERR_IO, true, "PPSUB.OUTPUT.JPEG2 is not of type JPEG");327 psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.JPEG2 is not of type JPEG"); 295 328 return false; 296 329 } 297 330 jpeg2->save = true; 298 331 332 // Output residual JPEG 333 pmFPAfile *jpeg3 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.RESID.JPEG"); 334 if (!jpeg3) { 335 psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.RESID.JPEG")); 336 return false; 337 } 338 if (jpeg3->type != PM_FPA_FILE_JPEG) { 339 psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.RESID.JPEG is not of type JPEG"); 340 return false; 341 } 342 jpeg3->save = true; 343 299 344 // Output subtraction kernel 300 pmFPAfile *kernel = defineCalcFile(config, output, "PPSUB.OUTPUT.KERNELS", PM_FPA_FILE_SUBKERNEL); 345 pmFPAfile *kernel = defineCalcFile(config, output, "PPSUB.OUTPUT.KERNELS", "KERNEL", 346 PM_FPA_FILE_SUBKERNEL); 301 347 if (!kernel) { 302 348 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to define file PPSUB.OUTPUT.KERNELS"); … … 305 351 306 352 // psPhot input 307 if (data->photometry ) {353 if (data->photometry || 1) { 308 354 psphotModelClassInit(); // load implementation-specific models 309 355 310 356 pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT"); 311 357 if (!psphot) { 312 psError( PS_ERR_IO, false, "Failed to build FPA from PSPHOT.INPUT");358 psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.INPUT"); 313 359 return false; 314 360 } 315 361 if (psphot->type != PM_FPA_FILE_IMAGE) { 316 psError(PS_ERR_IO, true, "PSPHOT.INPUT is not of type IMAGE"); 317 return false; 318 } 362 psError(psErrorCodeLast(), true, "PSPHOT.INPUT is not of type IMAGE"); 363 return false; 364 } 365 // specify the number of psphot input images 366 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1); 319 367 pmFPAfileActivate(config->files, false, "PSPHOT.INPUT"); 320 368 321 // Internal -ishfile for getting the PSF from the minuend322 pmFPAfile *psf = pmFPAfileDefine OutputFromFile(config, psphot, "PSPHOT.PSF.LOAD");369 // Internal file for getting the PSF from the minuend 370 pmFPAfile *psf = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.PSF.LOAD"); 323 371 if (!psf) { 324 psError( PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD");372 psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.PSF.LOAD"); 325 373 return false; 326 374 } 327 375 if (psf->type != PM_FPA_FILE_PSF) { 328 psError( PS_ERR_IO, true, "PSPHOT.PSF.LOAD is not of type PSF");376 psError(psErrorCodeLast(), true, "PSPHOT.PSF.LOAD is not of type PSF"); 329 377 return false; 330 378 } … … 332 380 333 381 if (!psphotDefineFiles(config, psphot)) { 334 psError( PS_ERR_UNKNOWN, false, "Unable to set up psphot files.");382 psError(psErrorCodeLast(), false, "Unable to set up psphot files."); 335 383 return false; 336 384 } … … 343 391 PM_FPA_FILE_CMF); 344 392 if (!outSources) { 345 psError( PS_ERR_UNKNOWN, false, "Unable to set up output source file.");393 psError(psErrorCodeLast(), false, "Unable to set up output source file."); 346 394 return false; 347 395 } … … 352 400 PM_FPA_FILE_CMF); 353 401 if (!invSources) { 354 psError( PS_ERR_UNKNOWN, false, "Unable to set up inverse source file.");402 psError(psErrorCodeLast(), false, "Unable to set up inverse source file."); 355 403 return false; 356 404 }
Note:
See TracChangeset
for help on using the changeset viewer.
