Changeset 23268 for trunk/ppImage/src
- Timestamp:
- Mar 11, 2009, 10:54:22 AM (17 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 3 edited
-
ppImageArguments.c (modified) (2 diffs)
-
ppImageDefineFile.c (modified) (1 diff)
-
ppImageParseCamera.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageArguments.c
r23242 r23268 108 108 109 109 // the input file is a required argument; if not found, we will exit 110 bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 111 if (!status) { 112 usage (); 113 } 110 pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 114 111 115 112 // if these command-line options are supplied, load the file name lists into config->arguments … … 142 139 psArgumentRemove(argnum, &argc, argv); 143 140 144 unsigned int nFail = 0;145 psMetadata *normlist = psMetadataConfigRead (NULL, &nFail, argv[argnum], false);146 // XXX allow this file to be in nebulous?141 unsigned int nFail = 0; 142 psMetadata *normlist = psMetadataConfigRead (NULL, &nFail, argv[argnum], false); 143 // XXX allow this file to be in nebulous? 147 144 148 145 psMetadataAddMetadata(config->arguments, PS_LIST_TAIL, "NORMALIZATION.TABLE", 0, "Normalization to apply", normlist); 149 psFree (normlist);146 psFree (normlist); 150 147 psArgumentRemove(argnum, &argc, argv); 151 148 } -
trunk/ppImage/src/ppImageDefineFile.c
r13562 r23268 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 -
trunk/ppImage/src/ppImageParseCamera.c
r21364 r23268 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");
Note:
See TracChangeset
for help on using the changeset viewer.
