Changeset 11182 for trunk/psModules/src/camera/pmFPAfileDefine.c
- Timestamp:
- Jan 19, 2007, 12:14:15 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileDefine.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileDefine.c
r11144 r11182 261 261 psMetadata *format = NULL; 262 262 263 if ( *found)263 if (found && *found) 264 264 return NULL; 265 265 … … 411 411 412 412 // search for argname on the config->argument list 413 // construct an FPA based on the files in this list (must represent a single FPA) 414 // built the association between the FPA elements (CHIP/CELL) and the files 415 // define the pmFPAfile filename and bind it to this FPA 416 // save the pmFPAfile on config->files 417 // return the pmFPAfile (a view to the one saved on config->files) 418 pmFPAfile *pmFPAfileBindFromArgs (bool *found, pmFPAfile *input, pmConfig *config, const char *filename, const char *argname) 419 { 420 PS_ASSERT_PTR_NON_NULL(input, NULL); 421 PS_ASSERT_PTR_NON_NULL(config, NULL); 422 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 423 PS_ASSERT_STRING_NON_EMPTY(argname, NULL); 424 425 bool status; 426 psFits *fits = NULL; 427 pmFPAfile *file = NULL; 428 psMetadata *phu = NULL; 429 psMetadata *format = NULL; 430 431 if (found && *found) 432 return NULL; 433 434 // we search the argument data for the named fileset (argname) 435 psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname); 436 if (!status) { 437 // this is not an error: this just means no matching argument was supplied 438 return NULL; 439 } 440 if (infiles->n < 1) { 441 psError(PS_ERR_IO, false, "Found n == %ld files in %s in arguments\n", infiles->n, argname); 442 return NULL; 443 } 444 445 // load the given filerule (from config->camera) and bind it to the fpa 446 // the returned file is just a view to the entry on config->files 447 file = pmFPAfileDefineInput (config, input->fpa, filename); 448 if (!file) { 449 psError(PS_ERR_IO, false, "file %s not defined\n", filename); 450 psFree(phu); 451 return NULL; 452 } 453 // XXX temporary hack : force PSF input onto filename 454 if (file->type == PM_FPA_FILE_PSF) { 455 file->filerule = psStringCopy (infiles->data[0]); 456 return file; 457 } 458 459 // set derived values 460 file->fileLevel = input->fileLevel; 461 file->format = psMemIncrRefCounter(input->format); 462 463 // defin the rule to identify these files in the file->names data 464 psFree (file->filerule); 465 psFree (file->filextra); 466 file->filerule = psStringCopy ("@FILES"); 467 file->filextra = psStringCopy ("{CHIP.NAME}.{CELL.NAME}"); 468 469 // examine the list of input files and validate their cameras 470 // associated each filename with an element of the FPA 471 // save the association on file->names 472 for (int i = 0; i < infiles->n; i++) { 473 psString realName = pmConfigConvertFilename (infiles->data[i], config); 474 if (!realName) { 475 psError(PS_ERR_IO, false, "Failed to convert file name %s", (char *) infiles->data[i]); 476 return NULL; 477 } 478 fits = psFitsOpen (realName, "r"); 479 if (!fits) { 480 psError(PS_ERR_IO, false, "Failed to open file %s\n", realName); 481 psFree (realName); 482 return NULL; 483 } 484 phu = psFitsReadHeader (NULL, fits); 485 if (!phu) { 486 psError(PS_ERR_IO, false, "Failed to read file header %s", realName); 487 psFree (realName); 488 psFitsClose (fits); 489 return NULL; 490 } 491 if (!pmConfigValidateCameraFormat (format, phu)) { 492 psError(PS_ERR_IO, false, "specified MASK %s does not match format of supplied INPUT\n", realName); 493 psFree (realName); 494 psFitsClose (fits); 495 return NULL; 496 } 497 psFree(realName); 498 psFitsClose (fits); 499 500 // set the view to the corresponding entry for this phu 501 // XXX this will override the fpa->header, which I don't want to do. 502 // XXX do I need to carry around the mask and weight headers??? 503 psAbort ("psModules", "pmFPAfileBindMaskFromArgs is not completed"); 504 pmFPAview *view = pmFPAAddSourceFromHeader (input->fpa, phu, format); 505 if (!view) { 506 psError(PS_ERR_IO, false, "Unable to determine source for %s", file->name); 507 psFree(phu); 508 psFree (format); 509 return NULL; 510 } 511 512 // associate the filename with the FPA element 513 char *name = pmFPAfileNameFromRule (file->filextra, file, view); 514 515 // save the name association in the pmFPAfile structure 516 psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]); 517 518 psFree (view); 519 psFree (name); 520 psFree (phu); 521 } 522 *found = true; 523 return file; 524 } 525 526 // search for argname on the config->argument list 413 527 // construct an FPA based on the files in this list (each represents the same FPA) 414 528 // built the association between the FPA elements (CHIP/CELL) and the files … … 430 544 psMetadata *format = NULL; 431 545 432 if ( *found)546 if (found && *found) 433 547 return NULL; 434 548 … … 536 650 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 537 651 538 if (*found) { 539 return NULL; 540 } 652 if (found && *found) 653 return NULL; 541 654 542 655 // a camera config is needed (as source of file rule) … … 613 726 pmFPAfile *file = NULL; 614 727 615 if ( *found)728 if (found && *found) 616 729 return NULL; 617 730
Note:
See TracChangeset
for help on using the changeset viewer.
