Changeset 11801
- Timestamp:
- Feb 14, 2007, 2:51:20 PM (19 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 6 edited
-
pmFPAConstruct.c (modified) (6 diffs)
-
pmFPAConstruct.h (modified) (2 diffs)
-
pmFPAfileDefine.c (modified) (2 diffs)
-
pmFPAfileFitsIO.c (modified) (2 diffs)
-
pmFPAfileIO.c (modified) (5 diffs)
-
pmFPAfileIO.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAConstruct.c
r11792 r11801 469 469 // It returns a view corresponding to the PHU 470 470 static pmFPAview *addSource(pmFPA *fpa, // The FPA 471 const char *fpaname, // The desired FPA name 471 472 const pmFPAview *phuView, // The view corresponding to the PHU, or NULL 472 473 const psMetadata *header, // The PHU header, or NULL … … 479 480 assert(format); 480 481 481 bool mdok = true; // Status from metadata lookups 482 bool mdok; // Status of MD lookup 483 484 // If FPA.NAME is already defined, new name must match it; otherwise, warn the user that something 485 // potentially bad is happening. 486 if (fpaname && install) { 487 const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.NAME"); // Current name 488 if (mdok && currentName && strlen(currentName) > 0 && strcmp(currentName, fpaname) != 0) { 489 psLogMsg(__func__, PS_LOG_WARN, "FPA.NAME for new source (%s) doesn't match FPA.NAME for current " 490 "fpa (%s).\n", fpaname, currentName); 491 } 492 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", PS_META_REPLACE, "Name of FPA", fpaname); 493 } else if (!psMetadataLookup(fpa->concepts, "FPA.NAME")) { 494 // Make sure there is an FPA.NAME 495 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", 0, "Name of FPA", "UNKNOWN"); 496 } 497 482 498 psMetadata *fileInfo = psMetadataLookupMetadata(&mdok, format, "FILE"); // The file information 483 499 if (!mdok || !fileInfo) { … … 759 775 760 776 761 bool pmFPAAddSourceFromView(pmFPA *fpa, const pmFPAview *phuView, const psMetadata *format) 777 bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaname, const pmFPAview *phuView, 778 const psMetadata *format) 762 779 { 763 780 PS_ASSERT_PTR_NON_NULL(fpa, false); … … 765 782 PS_ASSERT_PTR_NON_NULL(format, false); 766 783 767 pmFPAview *view = addSource(fpa, phuView, NULL, format, true);784 pmFPAview *view = addSource(fpa, fpaname, phuView, NULL, format, true); 768 785 bool status = (view != NULL); 769 786 psFree(view); … … 785 802 786 803 // Check the name of the FPA 787 psString newFPAname = phuNameFromHeader("FPA.NAME", fileInfo, phu); // New name for the FPA 788 if (!newFPAname) { 789 psError(PS_ERR_IO, true, "Unable to determine FPA.NAME : check for FPA.NAME in FILE in FORMAT"); 790 return NULL; 791 } 792 793 // If FPAname already defined, new name must match it; otherwise, warn the user that something potentially 794 // bad is happening. 795 const char *currentFPAname = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.NAME"); // Current name 796 if (mdok && currentFPAname && strlen(currentFPAname) > 0 && strcmp(currentFPAname, newFPAname) != 0) { 797 psLogMsg(__func__, PS_LOG_WARN, "FPA.NAME for new source (%s) doesn't match FPA.NAME for current " 798 "fpa (%s).\n", newFPAname, currentFPAname); 799 } 800 psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", PS_META_REPLACE, "Name of FPA", newFPAname); 801 psFree(newFPAname); // Drop reference 802 803 return addSource(fpa, NULL, phu, format, true); 804 psString fpaname = phuNameFromHeader("FPA.NAME", fileInfo, phu); // New name for the FPA 805 if (!fpaname || strlen(fpaname) == 0) { 806 psError(PS_ERR_IO, true, "Unable to determine FPA.NAME: check for FPA.NAME in FILE in camera format"); 807 return NULL; 808 } 809 810 pmFPAview *view = addSource(fpa, fpaname, NULL, phu, format, true); // View of PHU, to return 811 psFree(fpaname); 812 813 return view; 804 814 } 805 815 … … 811 821 PS_ASSERT_PTR_NON_NULL(format, NULL); 812 822 813 return addSource(fpa, NULL, phu, format, false);823 return addSource(fpa, NULL, NULL, phu, format, false); 814 824 } 815 825 -
trunk/psModules/src/camera/pmFPAConstruct.h
r11255 r11801 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-24 03:11:19$6 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-02-15 00:51:20 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 33 33 /// configuration is required in order to describe how the FPA is laid out in terms of disk files. 34 34 bool pmFPAAddSourceFromView(pmFPA *fpa, ///< The FPA 35 const char *fpaname, ///< FPA.NAME for the source 35 36 const pmFPAview *phuView, ///< The view, corresponding to the PHU 36 37 const psMetadata *format ///< Format of file -
trunk/psModules/src/camera/pmFPAfileDefine.c
r11687 r11801 180 180 } 181 181 182 file->camera = psMemIncrRefCounter(config->camera); 182 psMetadata *camera; // Camera to use 183 if (fpa && fpa->camera) { 184 camera = (psMetadata*)fpa->camera; // Casting away const, so I can put it in the file 185 } else { 186 camera = config->camera; 187 } 188 file->camera = psMemIncrRefCounter(camera); 189 190 // select the format list from the selected camera 183 191 const char *formatName = psMetadataLookupStr (&status, data, "FILE.FORMAT"); 184 psMetadata *format = NULL; // Camera format to use 185 if (formatName && strcasecmp(formatName, "NONE") != 0) { 186 // select the format list from the selected camera 187 psMetadata *formats = psMetadataLookupMetadata(&status, file->camera, "FORMATS"); // List of formats 188 189 // select the desired format 190 format = psMetadataLookupMetadata(&status, formats, formatName); 191 if (!format) { 192 psError(PS_ERR_IO, false, "format %s for %s not defined", formatName, name); 193 psFree(file); 194 return NULL; 195 } 196 file->format = psMemIncrRefCounter(format); 197 #if 0 198 199 file->src = psMemIncrRefCounter(fpa); 200 file->fpa = pmFPAConstruct(file->camera); 201 #endif 202 203 } else { 192 if (!formatName) { 193 formatName = config->formatName; 194 } 195 psMetadata *formats = psMetadataLookupMetadata(&status, file->camera, "FORMATS"); // List of formats 196 psMetadata *format = psMetadataLookupMetadata(&status, formats, formatName); // Camera format to use 197 if (!format) { 198 // Try to get by with the default 204 199 format = config->format; 205 #if 0 206 207 file->fpa = psMemIncrRefCounter(fpa); 208 #endif 209 210 } 211 #if 1 200 } 201 file->format = psMemIncrRefCounter(format); 202 212 203 file->fpa = psMemIncrRefCounter(fpa); 213 #endif214 215 204 216 205 file->fileLevel = pmFPAPHULevel(format); … … 925 914 file->xBin = xBin; 926 915 file->yBin = yBin; 927 psFree (file->format);928 file->format = psMemIncrRefCounter(format);929 930 916 psFree (fpa); 931 917 return file; -
trunk/psModules/src/camera/pmFPAfileFitsIO.c
r11793 r11801 23 23 PS_ASSERT_PTR_NON_NULL(view, NULL); 24 24 25 if ( file->camera == config->camera || // Need to mosaic, not copy25 if (//file->camera == config->camera || // Need to mosaic, not copy 26 26 !file->format) { // Working with the same output format as input format 27 27 return psMemIncrRefCounter(file->fpa); … … 50 50 } 51 51 52 if (!pmFPAAddSourceFromView(fpa, phuView, file->format)) { 52 pmFPA *nameSource = file->src; // Source of FPA.NAME 53 if (!nameSource) { 54 nameSource = file->fpa; 55 } 56 bool mdok; // Status of MD lookup 57 const char *fpaname = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA 58 59 if (!pmFPAAddSourceFromView(fpa, fpaname, phuView, file->format)) { 53 60 psError(PS_ERR_UNKNOWN, false, "Unable to insert HDU into FPA for writing.\n"); 54 61 psFree(fpa); -
trunk/psModules/src/camera/pmFPAfileIO.c
r11793 r11801 107 107 } 108 108 } 109 #if 0 110 // This should be done by pmFPAfileBlank 109 111 if (file->mode == PM_FPA_MODE_WRITE) { 110 112 // Want to write out any potential blank … … 132 134 psFree(fpa); 133 135 } 134 136 #endif 135 137 return true; 136 138 … … 475 477 } 476 478 479 bool pmFPAfileBlank(pmFPAfile *file, const pmFPAview *view, pmConfig *config) 480 { 481 PS_ASSERT_PTR_NON_NULL(file, false); 482 PS_ASSERT_PTR_NON_NULL(view, false); 483 484 if (file->state & PM_FPA_STATE_INACTIVE) { 485 psTrace("psModules.camera", 6, "skip blank for %s, files is inactive", file->name); 486 return true; 487 } 488 489 if (file->mode != PM_FPA_MODE_WRITE) { 490 psTrace("psModules.camera", 6, "skip blank for %s, mode is not WRITE", file->name); 491 return true; 492 } 493 494 // an internal file should not be returned to here 495 if (file->mode == PM_FPA_MODE_INTERNAL) { 496 psError(PS_ERR_IO, true, "File is mode PM_FPA_MODE_INTERNAL"); 497 return false; 498 } 499 500 if (!file->save) { 501 psTrace("psModules.camera", 6, "skip blank for %s, save is FALSE", file->name); 502 return true; 503 } 504 505 // get the current level 506 pmFPALevel level = pmFPAviewLevel (view); 507 508 if (level != file->fileLevel) { 509 psTrace("psModules.camera", 6, "skip blank for %s, level is %s", file->name, 510 pmFPALevelToName(file->freeLevel)); 511 return true; 512 } 513 514 // do we need to open this file? 515 if (!pmFPAfileOpen (file, view, config)) { 516 psError(PS_ERR_IO, false, "failed to open %s", file->filename); 517 return false; 518 } 519 520 switch (file->type) { 521 case PM_FPA_FILE_IMAGE: 522 case PM_FPA_FILE_MASK: 523 case PM_FPA_FILE_WEIGHT: 524 case PM_FPA_FILE_FRINGE: 525 if (file->mode == PM_FPA_MODE_WRITE) { 526 // Want to write out any potential blank 527 pmFPA *fpa = pmFPAfileSuitableFPA(file, view, config); // FPA, ensuring it's ready to write a blank 528 529 switch (file->fileLevel) { 530 case PM_FPA_LEVEL_FPA: 531 pmFPAWrite(fpa, file->fits, NULL, true, false); 532 break; 533 case PM_FPA_LEVEL_CHIP: { 534 pmChip *chip = pmFPAviewThisChip(view, fpa); 535 pmChipWrite(chip, file->fits, NULL, true, false); 536 break; 537 } 538 case PM_FPA_LEVEL_CELL: { 539 pmCell *cell = pmFPAviewThisCell(view, fpa); 540 pmCellWrite(cell, file->fits, NULL, true); 541 break; 542 } 543 default: 544 psAbort("fileLevel not correctly set"); 545 break; 546 } 547 548 psFree(fpa); 549 } 550 case PM_FPA_FILE_SX: 551 case PM_FPA_FILE_RAW: 552 case PM_FPA_FILE_OBJ: 553 case PM_FPA_FILE_CMP: 554 case PM_FPA_FILE_CMF: 555 case PM_FPA_FILE_PSF: 556 case PM_FPA_FILE_JPEG: 557 case PM_FPA_FILE_MANAPLOT: 558 case PM_FPA_FILE_KAPA: 559 break; 560 default: 561 fprintf (stderr, "warning: type mismatch\n"); 562 return false; 563 } 564 return true; 565 } 566 567 477 568 bool pmFPAfileWrite(pmFPAfile *file, const pmFPAview *view, pmConfig *config) 478 569 { … … 630 721 case PM_FPA_FILE_WEIGHT: 631 722 case PM_FPA_FILE_FRINGE: { 632 // create FPA structure component based on view 633 // XXX drop this ifdef'ed out code?? 634 #if 0 635 psMetadata *format = file->format; // Camera format configuration 636 if (!format) { 637 // It's likely a mosaic, for which we don't yet know the appropriate format 638 const psMetadata *camera = file->fpa->camera; // Camera configuration 639 psMetadata *formats = psMetadataLookupMetadata(NULL, camera, "FORMATS"); // The FORMATS 640 if (!formats) { 641 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find FORMATS in camera configuration.\n"); 642 return false; 643 } 644 format = psMetadataLookupMetadata(NULL, formats, config->formatName); 645 if (!format) { 646 psError(PS_ERR_UNEXPECTED_NULL, false, 647 "Unable to find format %s in camera configuration.\n", config->formatName); 648 return false; 649 } 650 file->format = psMemIncrRefCounter(format); 651 } 652 #endif 653 pmFPAAddSourceFromView (file->fpa, view, file->format); 654 psTrace ("pmFPAfile", 5, "created fpa data elements for %s (fpa: %p)\n", file->name, file->fpa); 655 break; 723 // create FPA structure component based on view 724 psMetadata *format = file->format; // Camera format configuration 725 if (!format) { 726 format = config->format; 727 } 728 729 pmFPA *nameSource = file->src; // Source of FPA.NAME 730 if (!nameSource) { 731 nameSource = file->fpa; 732 } 733 bool mdok; // Status of MD lookup 734 const char *fpaname = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA 735 736 pmFPAAddSourceFromView(file->fpa, fpaname, view, format); 737 psTrace ("pmFPAfile", 5, "created fpa data elements for %s (fpa: %p)\n", file->name, file->fpa); 738 break; 656 739 } 657 740 case PM_FPA_FILE_HEADER: … … 807 890 goto failure; 808 891 } 892 if (!pmFPAfileBlank(file, view, config)) { 893 psError(PS_ERR_IO, false, "failed BLANK in FPA_BEFORE block for %s", file->name); 894 goto failure; 895 } 809 896 break; 810 897 case PM_FPA_AFTER: -
trunk/psModules/src/camera/pmFPAfileIO.h
r11253 r11801 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-24 02:54:14$6 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-02-15 00:51:20 $ 8 8 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii 9 9 */ … … 21 21 bool pmFPAfileRead (pmFPAfile *file, const pmFPAview *view, pmConfig *config); 22 22 23 bool pmFPAfileCreate (pmFPAfile *file, const pmFPAview *view, pmConfig *config);23 bool pmFPAfileCreate (pmFPAfile *file, const pmFPAview *view, const pmConfig *config); 24 24 25 25 // write to the real file corresponding to the given pmFPAfile for the current view
Note:
See TracChangeset
for help on using the changeset viewer.
