Changeset 12824
- Timestamp:
- Apr 12, 2007, 11:50:07 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageParseCamera.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageParseCamera.c
r12820 r12824 5 5 # include "ppImage.h" 6 6 7 ppImageOptions *ppImageParseCamera (pmConfig *config) {8 7 ppImageOptions *ppImageParseCamera(pmConfig *config) 8 { 9 9 bool status = false; 10 10 … … 15 15 return NULL; 16 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 } 17 21 18 22 // if MASK or WEIGHT was supplied on command line, bind files to 'input' 19 23 // the mask and weight will be mosaicked with the image 20 pmFPAfileBindFromArgs (NULL, input, config, "PPIMAGE.INPUT.MASK", "MASK"); 21 pmFPAfileBindFromArgs (NULL, input, config, "PPIMAGE.INPUT.WEIGHT", "WEIGHT"); 24 pmFPAfile *inputMask = pmFPAfileBindFromArgs(NULL, input, config, "PPIMAGE.INPUT.MASK", "INPUT.MASK"); 25 if (inputMask && inputMask->type != PM_FPA_FILE_MASK) { 26 psError(PS_ERR_IO, true, "PPIMAGE.INPUT.MASK is not of type MASK"); 27 return NULL; 28 } 29 30 pmFPAfile *inputWeight = pmFPAfileBindFromArgs(NULL, input, config, "PPIMAGE.INPUT.WEIGHT", "INPUT.WEIGHT"); 31 if (inputWeight && inputWeight->type != PM_FPA_FILE_WEIGHT) { 32 psError(PS_ERR_IO, true, "PPIMAGE.INPUT.WEIGHT is not of type WEIGHT"); 33 return NULL; 34 } 22 35 23 36 // add recipe options supplied on command line … … 35 48 pmFPAfileDefineFromConf (&status, config, "PPIMAGE.BIAS"); 36 49 pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.BIAS", input->fpa, PM_DETREND_TYPE_BIAS); 37 if (!status) { 38 psError (PS_ERR_IO, false, "can't find a bias image source"); 50 pmFPAfile *bias = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.BIAS"); 51 if (!status || !bias) { 52 psError (PS_ERR_IO, false, "Can't find a bias image source"); 53 psFree(options); 54 return NULL; 55 } 56 if (bias->type != PM_FPA_FILE_IMAGE) { 57 psError(PS_ERR_IO, true, "PPIMAGE.BIAS is not of type IMAGE"); 58 psFree(options); 39 59 return NULL; 40 60 } … … 45 65 pmFPAfileDefineFromConf (&status, config, "PPIMAGE.DARK"); 46 66 pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.DARK", input->fpa, PM_DETREND_TYPE_DARK); 47 if (!status) { 48 psError (PS_ERR_IO, false, "can't find a dark image source"); 67 pmFPAfile *dark = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.DARK"); 68 if (!status || !dark) { 69 psError (PS_ERR_IO, false, "Can't find a dark image source"); 70 psFree(options); 71 return NULL; 72 } 73 if (dark->type != PM_FPA_FILE_IMAGE) { 74 psError(PS_ERR_IO, true, "PPIMAGE.DARK is not of type IMAGE"); 75 psFree(options); 49 76 return NULL; 50 77 } … … 55 82 pmFPAfileDefineFromConf (&status, config, "PPIMAGE.MASK"); 56 83 pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.MASK", input->fpa, PM_DETREND_TYPE_MASK); 57 if (!status) { 58 psError (PS_ERR_IO, false, "can't find a mask image source"); 84 pmFPAfile *mask = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.MASK"); 85 if (!status || !mask) { 86 psError (PS_ERR_IO, false, "Can't find a mask image source"); 87 psFree(options); 88 return NULL; 89 } 90 if (mask->type != PM_FPA_FILE_MASK) { 91 psError(PS_ERR_IO, true, "PPIMAGE.MASK is not of type MASK"); 92 psFree(options); 59 93 return NULL; 60 94 } … … 65 99 pmFPAfileDefineFromConf (&status, config, "PPIMAGE.SHUTTER"); 66 100 pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.SHUTTER", input->fpa, PM_DETREND_TYPE_SHUTTER); 67 if (!status) { 68 psError (PS_ERR_IO, false, "can't find a shutter image source"); 101 pmFPAfile *shutter = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.SHUTTER"); 102 if (!status || !shutter) { 103 psError (PS_ERR_IO, false, "Can't find a shutter image source"); 104 psFree(options); 105 return NULL; 106 } 107 if (shutter->type != PM_FPA_FILE_IMAGE) { 108 psError(PS_ERR_IO, true, "PPIMAGE.SHUTTER is not of type IMAGE"); 109 psFree(options); 69 110 return NULL; 70 111 } … … 81 122 psErrorClear(); 82 123 pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.FLAT", input->fpa, PM_DETREND_TYPE_FLAT); 83 if (!status) { 84 psError (PS_ERR_IO, false, "can't find a flat image source"); 124 pmFPAfile *flat = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.FLAT"); 125 if (!status || !flat) { 126 psError (PS_ERR_IO, false, "Can't find a flat image source"); 127 psFree(options); 128 return NULL; 129 } 130 if (flat->type != PM_FPA_FILE_IMAGE) { 131 psError(PS_ERR_IO, true, "PPIMAGE.FLAT is not of type IMAGE"); 132 psFree(options); 85 133 return NULL; 86 134 } … … 95 143 if (!status || !filter || strlen(filter) == 0) { 96 144 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FPA.FILTER.\n"); 145 psFree(options); 97 146 return NULL; 98 147 } … … 114 163 filters = psMemIncrRefCounter(mdi->data.list); 115 164 } else { 116 psAbort("invalid type for FRINGE.FILTERS"); 165 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 166 "FRINGE.FILTERS in recipe %s is not of type METADATA", RECIPE_NAME); 167 psFree(options); 168 return NULL; 117 169 } 118 170 … … 135 187 pmFPAfileDefineFromConf (&status, config, "PPIMAGE.FRINGE"); 136 188 pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.FRINGE", input->fpa, PM_DETREND_TYPE_FRINGE_IMAGE); 137 if (!status) { 138 psError (PS_ERR_IO, false, "can't find a fringe image source"); 189 pmFPAfile *fringe = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.FRINGE"); 190 if (!status || !fringe) { 191 psError (PS_ERR_IO, false, "Can't find a fringe image source"); 192 psFree(options); 193 return NULL; 194 } 195 if (fringe->type != PM_FPA_FILE_FRINGE) { 196 psError(PS_ERR_IO, true, "PPIMAGE.FRINGE is not of type FRINGE"); 197 psFree(options); 139 198 return NULL; 140 199 } … … 148 207 return NULL; 149 208 } 209 if (output->type != PM_FPA_FILE_IMAGE) { 210 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT is not of type IMAGE"); 211 psFree(options); 212 return NULL; 213 } 150 214 pmFPAfile *outMask = pmFPAfileDefineOutput(config, input->fpa, "PPIMAGE.OUTPUT.MASK"); 151 215 if (!outMask) { … … 154 218 return NULL; 155 219 } 220 if (outMask->type != PM_FPA_FILE_MASK) { 221 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.MASK is not of type MASK"); 222 psFree(options); 223 return NULL; 224 } 156 225 pmFPAfile *outWeight = pmFPAfileDefineOutput(config, input->fpa, "PPIMAGE.OUTPUT.WEIGHT"); 157 226 if (!outWeight) { … … 160 229 return NULL; 161 230 } 231 if (outWeight->type != PM_FPA_FILE_WEIGHT) { 232 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.WEIGHT is not of type WEIGHT"); 233 psFree(options); 234 return NULL; 235 } 236 162 237 // XXX should these be bound explicitly to the output->fpa rather than the input->fpa? 163 238 pmFPAfile *byChip = pmFPAfileDefineChipMosaic(config, input->fpa, "PPIMAGE.OUTPUT.CHIP"); … … 167 242 return NULL; 168 243 } 244 if (byChip->type != PM_FPA_FILE_IMAGE) { 245 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.CHIP is not of type IMAGE"); 246 psFree(options); 247 return NULL; 248 } 169 249 pmFPAfile *byFPA1 = pmFPAfileDefineFPAMosaic(config, input->fpa, "PPIMAGE.OUTPUT.FPA1"); 170 250 if (!byFPA1) { … … 173 253 return NULL; 174 254 } 255 if (byFPA1->type != PM_FPA_FILE_IMAGE) { 256 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.FPA1 is not of type IMAGE"); 257 psFree(options); 258 return NULL; 259 } 175 260 pmFPAfile *byFPA2 = pmFPAfileDefineFPAMosaic(config, input->fpa, "PPIMAGE.OUTPUT.FPA2"); 176 261 if (!byFPA2) { … … 179 264 return NULL; 180 265 } 266 if (byFPA2->type != PM_FPA_FILE_IMAGE) { 267 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.FPA2 is not of type IMAGE"); 268 psFree(options); 269 return NULL; 270 } 181 271 182 272 // For photometry, we operate on the chip-mosaicked image 183 273 // we create a copy of the mosaicked image for psphot so we can write out a clean image 184 274 if (options->doPhotom) { 185 pmFPAfile *psphotInput = pmFPAfileDefineFromFPA (config, byChip->fpa, 1, 1, "PSPHOT.INPUT");186 PS_ASSERT (psphotInput, false);187 188 // this file is just used as a carrier; 189 // actual output files (eg, PSPHOT.RESID) are defined below190 psphotInput->save = false; 191 192 // define associated psphot input/output files193 if (!psphotDefineFiles (config, psphotInput)) {194 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot");195 return false;196 }275 pmFPAfile *psphotInput = pmFPAfileDefineFromFPA (config, byChip->fpa, 1, 1, "PSPHOT.INPUT"); 276 PS_ASSERT (psphotInput, false); 277 278 // this file is just used as a carrier; 279 // actual output files (eg, PSPHOT.RESID) are defined below 280 psphotInput->save = false; 281 282 // define associated psphot input/output files 283 if (!psphotDefineFiles (config, psphotInput)) { 284 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot"); 285 return false; 286 } 197 287 } 198 288 199 289 // For photometry, we operate on the chip-mosaicked image 200 290 if (options->doAstromChip || options->doAstromMosaic) { 201 if (!options->doPhotom) {202 psError (PSASTRO_ERR_CONFIG, false, "photometry mode is not selected; it is required for astrometry");203 return false;204 }205 206 pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");207 PS_ASSERT (psphotOutput, false);208 209 pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, "PSASTRO.INPUT");210 PS_ASSERT (psastroInput, false);211 psastroInput->mode = PM_FPA_MODE_REFERENCE;212 213 // define associated psphot input/output files214 if (!psastroDefineFiles (config, psastroInput)) {215 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psastro");216 return false;217 }291 if (!options->doPhotom) { 292 psError (PSASTRO_ERR_CONFIG, false, "photometry mode is not selected; it is required for astrometry"); 293 return false; 294 } 295 296 pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT"); 297 PS_ASSERT (psphotOutput, false); 298 299 pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, "PSASTRO.INPUT"); 300 PS_ASSERT (psastroInput, false); 301 psastroInput->mode = PM_FPA_MODE_REFERENCE; 302 303 // define associated psphot input/output files 304 if (!psastroDefineFiles (config, psastroInput)) { 305 psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psastro"); 306 return false; 307 } 218 308 } 219 309 … … 234 324 return NULL; 235 325 } 326 if (bin1->type != PM_FPA_FILE_IMAGE) { 327 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.BIN1 is not of type IMAGE"); 328 psFree(options); 329 return NULL; 330 } 236 331 237 332 pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, byChip->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2"); … … 241 336 return NULL; 242 337 } 338 if (bin2->type != PM_FPA_FILE_IMAGE) { 339 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.BIN2 is not of type IMAGE"); 340 psFree(options); 341 return NULL; 342 } 243 343 244 344 // bin1 and bin2 are used as carriers: input for byFPA1, byFPA2 … … 252 352 return NULL; 253 353 } 354 if (jpg1->type != PM_FPA_FILE_JPEG) { 355 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.JPEG1 is not of type JPEG"); 356 psFree(options); 357 return NULL; 358 } 254 359 pmFPAfile *jpg2 = pmFPAfileDefineOutput (config, byFPA2->fpa, "PPIMAGE.JPEG2"); 255 360 if (!jpg2) { 256 361 psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG2")); 362 psFree(options); 363 return NULL; 364 } 365 if (jpg2->type != PM_FPA_FILE_JPEG) { 366 psError(PS_ERR_IO, true, "PPIMAGE.OUTPUT.JPEG2 is not of type JPEG"); 257 367 psFree(options); 258 368 return NULL; … … 274 384 if (! pmFPASelectChip(input->fpa, chipNum, false)) { 275 385 psError(PS_ERR_IO, false, "Chip number %d doesn't exist in camera.\n", chipNum); 386 psFree(options); 276 387 return false; 277 388 } … … 293 404 294 405 if (psTraceGetLevel("ppImage.config") > 0) { 295 // Get a look inside all the files.296 psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator297 psMetadataItem *item; // Item from iteration298 fprintf(stderr, "Files:\n");299 while ((item = psMetadataGetAndIncrement(filesIter))) {300 pmFPAfile *file = item->data.V; // File of interest301 fprintf(stderr, "%s: %p %p %p (%p) %p\n", file->name,302 file->src, file->fpa,303 file->camera, file->fpa->camera, file->format);304 }305 psFree(filesIter);406 // Get a look inside all the files. 407 psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator 408 psMetadataItem *item; // Item from iteration 409 fprintf(stderr, "Files:\n"); 410 while ((item = psMetadataGetAndIncrement(filesIter))) { 411 pmFPAfile *file = item->data.V; // File of interest 412 fprintf(stderr, "%s: %p %p %p (%p) %p\n", file->name, 413 file->src, file->fpa, 414 file->camera, file->fpa->camera, file->format); 415 } 416 psFree(filesIter); 306 417 } 307 418
Note:
See TracChangeset
for help on using the changeset viewer.
