Changeset 23594 for branches/cnb_branches/cnb_branch_20090301/psModules
- Timestamp:
- Mar 29, 2009, 6:15:31 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 49 edited
-
. (modified) (1 prop)
-
psModules (modified) (1 prop)
-
psModules/src/astrom/pmAstrometryDistortion.c (modified) (3 diffs)
-
psModules/src/astrom/pmAstrometryDistortion.h (modified) (1 diff)
-
psModules/src/astrom/pmAstrometryVisual.c (modified) (1 diff)
-
psModules/src/astrom/pmAstrometryVisual.h (modified) (1 diff)
-
psModules/src/camera/pmFPARead.c (modified) (1 diff)
-
psModules/src/camera/pmFPAWrite.c (modified) (3 diffs)
-
psModules/src/camera/pmFPAfile.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAfile.h (modified) (1 diff)
-
psModules/src/camera/pmFPAfileDefine.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAfileDefine.h (modified) (1 diff)
-
psModules/src/camera/pmFPAfileFitsIO.c (modified) (1 diff)
-
psModules/src/camera/pmFPAfileIO.c (modified) (4 diffs)
-
psModules/src/camera/pmFPAfileIO.h (modified) (1 diff)
-
psModules/src/concepts/pmConceptsStandard.c (modified) (5 diffs)
-
psModules/src/concepts/pmConceptsWrite.c (modified) (14 diffs)
-
psModules/src/concepts/pmConceptsWrite.h (modified) (4 diffs)
-
psModules/src/config/pmConfig.c (modified) (1 diff)
-
psModules/src/config/pmConfigCamera.c (modified) (2 diffs)
-
psModules/src/config/pmConfigMask.c (modified) (1 diff)
-
psModules/src/config/pmConfigRun.c (modified) (4 diffs)
-
psModules/src/config/pmConfigRun.h (modified) (1 diff)
-
psModules/src/detrend/pmDetrendDB.h (modified) (1 diff)
-
psModules/src/detrend/pmDetrendThreads.h (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.c (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.h (modified) (1 diff)
-
psModules/src/extras/pmKapaPlots.c (modified) (1 diff)
-
psModules/src/extras/pmKapaPlots.h (modified) (2 diffs)
-
psModules/src/extras/psPipe.c (modified) (1 diff)
-
psModules/src/extras/psPipe.h (modified) (2 diffs)
-
psModules/src/imcombine/pmStack.c (modified) (16 diffs)
-
psModules/src/imcombine/pmStack.h (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionIO.c (modified) (3 diffs)
-
psModules/src/imcombine/pmSubtractionVisual.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionVisual.h (modified) (1 diff)
-
psModules/src/objects/pmDetections.c (modified) (1 diff)
-
psModules/src/objects/pmDetections.h (modified) (1 diff)
-
psModules/src/objects/pmMoments.c (modified) (1 diff)
-
psModules/src/objects/pmMoments.h (modified) (1 diff)
-
psModules/src/objects/pmPSF.c (modified) (1 diff)
-
psModules/src/objects/pmPSF.h (modified) (1 diff)
-
psModules/src/objects/pmSource.h (modified) (1 diff)
-
psModules/src/objects/pmSourceExtendedPars.c (modified) (6 diffs)
-
psModules/src/objects/pmSourceExtendedPars.h (modified) (1 diff)
-
psModules/src/objects/pmSourceFitSet.c (modified) (3 diffs)
-
psModules/src/objects/pmSourceFitSet.h (modified) (3 diffs)
-
psModules/src/objects/pmSourcePlots.c (modified) (1 diff)
-
psModules/src/objects/pmSourcePlots.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
branches/cnb_branches/cnb_branch_20090301/psModules
- Property svn:mergeinfo changed
/trunk/psModules merged: 23354,23358,23370,23374,23378,23404-23405,23428,23432,23447,23450-23452,23476,23487,23498,23535,23574,23576-23577,23587
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryDistortion.c
r21183 r23594 40 40 } 41 41 42 pmAstromGradient *pmAstromGradientAlloc ( )42 pmAstromGradient *pmAstromGradientAlloc (void) 43 43 { 44 44 … … 126 126 grad = pmAstromGradientAlloc (); 127 127 128 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 7);128 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 7); 129 129 130 130 // fit the collection of positions and offsets with a local 1st order gradient … … 138 138 grad->dTPdM.x = local->coeff[0][1]; 139 139 140 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 0);140 // XXX psTraceSetLevel("psLib.math.psVectorClipFitPolynomial2D", 0); 141 141 142 142 // fit the collection of positions and offsets with a local 1st order gradient -
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryDistortion.h
r12486 r23594 27 27 pmAstromGradient; 28 28 29 pmAstromGradient *pmAstromGradientAlloc ( );29 pmAstromGradient *pmAstromGradientAlloc (void); 30 30 31 31 /* The following function determines the position residual, in the tangent -
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryVisual.c
r23351 r23594 47 47 /* Initialization Routines */ 48 48 49 bool pmAstromVisualClose( )49 bool pmAstromVisualClose(void) 50 50 { 51 51 if(kapa != -1) -
branches/cnb_branches/cnb_branch_20090301/psModules/src/astrom/pmAstrometryVisual.h
r23351 r23594 26 26 /** Close plotting windows at the end of a run 27 27 * @return true for success */ 28 bool pmAstromVisualClose( );28 bool pmAstromVisualClose(void); 29 29 30 30 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPARead.c
r22699 r23594 554 554 } 555 555 psFree(header); 556 bad = pmConfigMaskGet("BAD", config); 556 bad = pmConfigMaskGet("LOW", config); 557 if (!bad) { 558 // XXX look up old name for compatability 559 bad = pmConfigMaskGet("BAD", config); 560 } 557 561 break; 558 562 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAWrite.c
r23351 r23594 172 172 173 173 if (writeBlank || writeImage) { 174 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 175 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; 176 if (!pmConceptsWriteCell(cell, source, true, config)) { 174 if (!pmConceptsWriteCell(cell, true, config)) { 177 175 psError(PS_ERR_IO, false, "Unable to write concepts for cell."); 178 176 return false; … … 225 223 226 224 if (writeBlank || writeImage) { 227 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 228 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; 229 if (!pmConceptsWriteChip(chip, source, true, true, config)) { 225 if (!pmConceptsWriteChip(chip, true, true, config)) { 230 226 psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n"); 231 227 return false; … … 294 290 295 291 if (writeBlank || writeImage) { 296 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 297 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; 298 if (!pmConceptsWriteFPA(fpa, source, true, config)) { 292 if (!pmConceptsWriteFPA(fpa, true, config)) { 299 293 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n"); 300 294 return false; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfile.c
r23351 r23594 20 20 #include "pmConceptsCopy.h" 21 21 22 static int fileNum = 0; // Number of file 23 22 24 static void pmFPAfileFree(pmFPAfile *file) 23 25 { … … 56 58 } 57 59 58 pmFPAfile *pmFPAfileAlloc( )60 pmFPAfile *pmFPAfileAlloc(void) 59 61 { 60 62 pmFPAfile *file = psAlloc(sizeof(pmFPAfile)); … … 100 102 101 103 file->save = false; 104 105 file->index = fileNum++; 102 106 103 107 file->imageId = 0; … … 350 354 psStringSubstitute(&newRule, name, "{OUTPUT}"); 351 355 } 356 } 357 358 if (strstr(newRule, "{FILE.INDEX}")) { 359 // Number of the file in list 360 psString num = NULL; // Number to use 361 psStringAppend(&num, "%d", file->index); 362 psStringSubstitute(&newRule, num, "{FILE.INDEX}"); 363 psFree(num); 352 364 } 353 365 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfile.h
r23351 r23594 109 109 psString formatName; // name of the camera format 110 110 111 int index; // Index of file 112 111 113 psS64 imageId, sourceId; // Image and source identifiers 112 114 } pmFPAfile; 113 115 114 116 // allocate an empty pmFPAfile structure 115 pmFPAfile *pmFPAfileAlloc ();117 pmFPAfile *pmFPAfileAlloc(void); 116 118 117 119 // select the readout from the named pmFPAfile; if the named file does not exist, -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileDefine.c
r23351 r23594 382 382 383 383 // place the resulting file in the config system 384 psMetadataAddPtr(config->files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "Output file", file); 384 psMetadataAddPtr(config->files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, 385 "Output file", file); 385 386 psFree(file); // we free this copy of file, but 'files' still has a copy 386 387 return file; // the returned value is a view into the version on 'files' … … 719 720 } 720 721 721 pmFPAfile *pmFPAfileDefineFromRun(bool *success, pm Config *config, const char *filename)722 pmFPAfile *pmFPAfileDefineFromRun(bool *success, pmFPAfile *bind, pmConfig *config, const char *filename) 722 723 { 723 724 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 732 733 } 733 734 734 pmFPAfile *file = fpaFileDefineFromArray(config, NULL, filename, filenames); // File of interest735 pmFPAfile *file = fpaFileDefineFromArray(config, bind, filename, filenames); // File of interest 735 736 psFree(filenames); 736 737 … … 742 743 } 743 744 745 psArray *pmFPAfileDefineMultipleFromRun(bool *success, psArray *bind, pmConfig *config, const char *filename) 746 { 747 PS_ASSERT_PTR_NON_NULL(config, NULL); 748 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 749 750 if (success) { 751 *success = false; 752 } 753 754 psArray *files = pmConfigRunFileGet(config, filename); // Filenames used, to return 755 if (!files || files->n == 0) { 756 if (success) { 757 *success = true; 758 } 759 return NULL; 760 } 761 if (bind && files->n != bind->n) { 762 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 763 "Length of filenames (%ld) and bind files (%ld) does not match.", 764 files->n, bind->n); 765 psFree(files); 766 return NULL; 767 } 768 769 psArray *dummy = psArrayAlloc(1); // Dummy array of single filename 770 for (int i = 0; i < files->n; i++) { 771 psFree(dummy->data[0]); 772 dummy->data[0] = files->data[i]; 773 pmFPAfile *bindFile = bind ? bind->data[i] : NULL; // File to which to bind 774 files->data[i] = psMemIncrRefCounter(fpaFileDefineFromArray(config, bindFile, filename, dummy)); 775 if (!files->data[i]) { 776 psError(PS_ERR_UNKNOWN, false, "Unable to define file %s %d", filename, i); 777 psFree(dummy); 778 psFree(files); 779 return NULL; 780 } 781 } 782 psFree(dummy); 783 784 if (success) { 785 *success = true; 786 } 787 788 return files; 789 } 744 790 745 791 // define the named pmFPAfile from the camera->config -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileDefine.h
r23351 r23594 67 67 pmFPAfile *pmFPAfileDefineFromRun( 68 68 bool *found, ///< Found files? 69 pmFPAfile *bind, ///< File to which to bind, or NULL 69 70 pmConfig *config, ///< Configuration 70 71 const char *filename ///< Name of file 71 72 ); 72 73 74 /// Define multiple files based on the filenames in the RUN metadata in the configuration 75 /// 76 /// An array of the files defined is returned 77 psArray *pmFPAfileDefineMultipleFromRun( 78 bool *found, ///< Found files? 79 psArray *bind, ///< Files to which to bind, or NULL 80 pmConfig *config, ///< Configuration 81 const char *filename ///< Name of file 82 ); 73 83 74 84 // look for the given argname on the argument list. find the give filename from the file rules -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileFitsIO.c
r22699 r23594 183 183 } 184 184 185 pmConceptSource sources = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS |186 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; // Concept sources to write187 185 if (cell) { 188 if (!pmConceptsWriteCell(cell, sources,true, config)) {186 if (!pmConceptsWriteCell(cell, true, config)) { 189 187 psError(PS_ERR_IO, false, "Unable to write concepts for cell.\n"); 190 188 return false; 191 189 } 192 190 } else if (chip) { 193 if (!pmConceptsWriteChip(chip, sources,true, true, config)) {191 if (!pmConceptsWriteChip(chip, true, true, config)) { 194 192 psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n"); 195 193 return false; 196 194 } 197 } else if (!pmConceptsWriteFPA(fpa, sources,true, config)) {195 } else if (!pmConceptsWriteFPA(fpa, true, config)) { 198 196 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n"); 199 197 return false; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileIO.c
r23351 r23594 166 166 } 167 167 168 if (!pmConfigRunFileAdd (config, file)) {168 if (!pmConfigRunFileAddRead(config, file)) { 169 169 psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information"); 170 170 return false; … … 421 421 } 422 422 423 if (!pmConfigRunFileAdd (config, file)) {423 if (!pmConfigRunFileAddWrite(config, file)) { 424 424 psError(PS_ERR_UNKNOWN, false, "Unable to add file to run-time information"); 425 425 return false; … … 635 635 } 636 636 637 psString pmFPAfileName(const pmFPAfile *file, const pmFPAview *view, pmConfig *config) 638 { 639 PS_ASSERT_PTR_NON_NULL(file, NULL); 640 PS_ASSERT_PTR_NON_NULL(view, NULL); 641 PS_ASSERT_PTR_NON_NULL(config, NULL); 642 643 psString filename = pmFPAfileNameFromRule(file->filerule, file, view); // Filename, based on rule 644 if (!filename) { 645 psError(PS_ERR_IO, true, "Cannot determine file name from rule"); 646 return false; 647 } 648 649 // indirect filenames: these come from a list on the command line or elsewhere 650 if (!strcasecmp(filename, "@FILES")) { 651 psString filesrc = pmFPAfileNameFromRule(file->filesrc, file, view); // Source of file name 652 if (!filesrc) { 653 psError(PS_ERR_IO, false, "error converting filesrc to name %s", file->filesrc); 654 return false; 655 } 656 psFree(filename); 657 filename = psMemIncrRefCounter(psMetadataLookupStr(NULL, file->names, filesrc)); 658 if (!filename) { 659 psError(PS_ERR_IO, false, "filename lookup error (@FILES) for %s : %s", file->filesrc, filesrc); 660 psFree(filesrc); 661 return false; 662 } 663 psFree(filesrc); 664 } 665 666 // get name from detrend database 667 // file->detrend->detID contains the desired -det_id detID -iteration iter string 668 if (!strcasecmp(filename, "@DETDB")) { 669 if (!file->detrend) { 670 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find information about selected detrend."); 671 return false; 672 } 673 psMetadata *menu = psMetadataLookupMetadata(NULL, file->camera, "CLASSID"); // Menu of class IDs 674 if (!menu) { 675 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 676 return false; 677 } 678 const char *rule = psMetadataLookupStr(NULL, menu, file->detrend->level); // Rule for class_id 679 if (!rule || strlen(rule) == 0) { 680 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", 681 file->detrend->level); 682 return false; 683 } 684 psString classId = pmFPAfileNameFromRule(rule, file, view); // The class identifier, for pmDetrendFile 685 if (!classId) { 686 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule); 687 return false; 688 } 689 690 psTrace("psModules.camera", 6, "looking for detrend (%s, %s)\n", file->detrend->detID, classId); 691 psFree(filename); 692 filename = pmDetrendFile(file->detrend->detID, classId, config); 693 if (!filename) { 694 psError(PS_ERR_IO, false, "failed to find a valid detrend image for detID %s : classID %s", 695 file->detrend->detID, classId); 696 psFree(classId); 697 return false; 698 } 699 700 psTrace("psModules.camera", 6, "got detrend file %s", filename); 701 psFree(classId); 702 } 703 704 return filename; 705 } 706 637 707 // open file (if not already opened). 638 708 // this function is only called only within pmFPAfileRead or pmFPAfileWrite. … … 672 742 673 743 // determine the file name, free a name allocated earlier 674 psFree (file->filename); 675 file->filename = pmFPAfileNameFromRule (file->filerule, file, view); 676 if (file->filename == NULL) { 677 psError(PS_ERR_IO, true, "Filename is NULL"); 678 return false; 679 } 680 681 // indirect filenames: these come from a list on the command line or elsewhere 682 if (!strcasecmp (file->filename, "@FILES")) { 683 char *filesrc = pmFPAfileNameFromRule (file->filesrc, file, view); 684 if (filesrc == NULL) { 685 psError(PS_ERR_IO, false, "error converting filesrc to name %s\n", file->filesrc); 686 return false; 687 } 688 689 psFree (file->filename); 690 file->filename = psMetadataLookupStr (&status, file->names, filesrc); 691 692 if (file->filename == NULL) { 693 psError(PS_ERR_IO, true, "filename lookup error (@FILES) for %s : %s\n", file->filesrc, filesrc); 694 psFree (filesrc); 695 return false; 696 } 697 // psMetadataLookupStr just returns a view, file->filename must be protected 698 psMemIncrRefCounter (file->filename); 699 psFree (filesrc); 700 } 701 702 // get name from detrend database 703 // file->detrend->detID contains the desired -det_id detID -iteration iter string 704 if (!strcasecmp (file->filename, "@DETDB")) { 705 if (!file->detrend) { 706 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find information about selected detrend."); 707 return false; 708 } 709 710 psString classId = NULL; // The class identifier, to pass to pmDetrendFile 711 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "CLASSID"); // Menu of class IDs 712 if (!status || !menu) { 713 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 714 return false; 715 } 716 const char *rule = psMetadataLookupStr(&status, menu, file->detrend->level); // Rule for class_id 717 if (!status || !rule || strlen(rule) == 0) { 718 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", file->detrend->level); 719 return false; 720 } 721 classId = pmFPAfileNameFromRule(rule, file, view); 722 if (!classId) { 723 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule); 724 return false; 725 } 726 psTrace ("psModules.camera", 6, "looking for detrend (%s, %s)\n", file->detrend->detID, classId); 727 psFree (file->filename); 728 729 file->filename = pmDetrendFile(file->detrend->detID, classId, config); 730 if (file->filename == NULL) { 731 psError(PS_ERR_IO, false, "failed to find a valid detrend image for detID %s : classID %s\n", file->detrend->detID, classId); 732 psFree (classId); 733 return false; 734 } 735 736 psTrace ("psModules.camera", 6, "got detrend file %s\n", file->filename); 737 psFree (classId); 744 psFree(file->filename); 745 file->filename = pmFPAfileName(file, view, config); 746 if (!file->filename) { 747 psError(PS_ERR_IO, true, "Unable to determine filename"); 748 return false; 738 749 } 739 750 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/camera/pmFPAfileIO.h
r18364 r23594 15 15 /// @addtogroup Camera Camera Layout 16 16 /// @{ 17 18 // Determine appropriate file name 19 psString pmFPAfileName(const pmFPAfile *file, const pmFPAview *view, pmConfig *config); 17 20 18 21 // open the real file corresponding to the given pmFPAfile appropriate to the current view -
branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsStandard.c
r23351 r23594 606 606 } 607 607 608 // Get the current value of a concept 609 static psMetadataItem *conceptGet(const pmFPA *fpa, // FPA of interest 610 const pmChip *chip, // Chip of interest, or NULL 611 const pmCell *cell, // Cell of interest, or NULL 612 const char *name // Concept name 613 ) 614 { 615 psMetadataItem *item = NULL; // Item with time system 616 if (cell) { 617 item = psMetadataLookup(cell->concepts, name); 618 } 619 if (!item && chip) { 620 item = psMetadataLookup(chip->concepts, name); 621 } 622 if (!item && fpa) { 623 item = psMetadataLookup(fpa->concepts, name); 624 } 625 if (!item) { 626 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find %s in concepts", name); 627 return NULL; 628 } 629 return item; 630 } 631 632 // Determine the corresponding TIMESYS for one of the TIME concepts 633 static psTimeType conceptGetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME") 634 const pmFPA *fpa, // FPA of interest 635 const pmChip *chip, // Chip of interest, or NULL 636 const pmCell *cell // Cell of interest, or NULL 637 ) 638 { 639 assert(name); 640 641 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS" 642 psStringSubstitute(×ysName, "TIMESYS", "TIME"); 643 psMetadataItem *item = conceptGet(fpa, chip, cell, timesysName); // Time system 644 psFree(timesysName); 645 646 if (!item || item->type != PS_TYPE_S32) { 647 psWarning("Unable to find %s --- assuming UTC", timesysName); 648 return PS_TIME_UTC; 649 } 650 return item->data.S32; 651 } 652 653 // Set the corresponding TIMESYS for one of the TIME concepts 654 static bool conceptSetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME") 655 const pmFPA *fpa, // FPA of interest 656 const pmChip *chip, // Chip of interest, or NULL 657 const pmCell *cell, // Cell of interest, or NULL 658 psTimeType timeSys // The time system value 659 ) 660 { 661 assert(name); 662 663 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS" 664 psStringSubstitute(×ysName, "TIMESYS", "TIME"); 665 psMetadataItem *item = conceptGet(fpa, chip, cell, timesysName); // Time system 666 psFree(timesysName); 667 668 if (!item) { 669 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find %s in concepts when setting %s\n", 670 timesysName, name); 671 return false; 672 } 673 674 if (item->data.S32 != -1 && item->data.S32 != timeSys) { 675 psWarning("Time system is set to %x; but should be %x", item->data.S32, timeSys); 676 } 677 678 item->data.S32 = timeSys; 679 680 return true; 681 } 608 682 609 683 psMetadataItem *p_pmConceptParse_TIMESYS(const psMetadataItem *concept, … … 622 696 if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) { 623 697 // XXX is this too low verbosity? 624 ps LogMsg ("psModules.concepts", PS_LOG_DETAIL, "Can't interpret %s --- assuming UTC.\n", pattern->name);698 psWarning("Can't interpret %s --- assuming UTC.", pattern->name); 625 699 } else if (strcasecmp(sys, "TAI") == 0) { 626 700 timeSys = PS_TIME_TAI; … … 633 707 } else { 634 708 // XXX is this too low verbosity? 635 psLogMsg ("psModules.concepts", PS_LOG_DETAIL, "Can't interpret %s --- assuming UTC.\n", pattern->name); 709 psWarning("Can't interpret %s --- assuming UTC.", pattern->name); 710 } 711 712 psMetadataItem *old = conceptGet(fpa, chip, cell, pattern->name); // Old value 713 if (old && old->data.S32 != -1 && old->data.S32 != timeSys) { 714 psWarning("%s is already set (%x) and not consistent with new value (%x)", 715 pattern->name, old->data.S32, timeSys); 636 716 } 637 717 … … 639 719 } 640 720 641 // Determine the corresponding TIMESYS for one of the TIME concepts 642 static psTimeType conceptGetTimesysForTime(const char *name, // Concept name ("CELL.TIME" or "FPA.TIME") 643 const pmFPA *fpa, // FPA of interest 644 const pmChip *chip, // Chip of interest, or NULL 645 const pmCell *cell // Cell of interest, or NULL 646 ) 647 { 648 assert(name); 649 650 psString timesysName = psStringCopy(name); // e.g., "CELL.TIME" --> "CELL.TIMESYS" 651 psStringSubstitute(×ysName, "TIMESYS", "TIME"); 652 bool mdok = false; // Result of MD lookup 653 psTimeType timeSys = 0xFFFFFFFF; // The time system 654 if (cell) { 655 timeSys = psMetadataLookupS32(&mdok, cell->concepts, timesysName); 656 } 657 if (!mdok && chip) { 658 timeSys = psMetadataLookupS32(&mdok, chip->concepts, timesysName); 659 } 660 if (!mdok && fpa) { 661 timeSys = psMetadataLookupS32(&mdok, fpa->concepts, timesysName); 662 } 663 if (!mdok || (timeSys == 0xFFFFFFFF)) { 664 psWarning("Unable to find %s in concepts when parsing %s --- assuming UTC.\n", 665 timesysName, name); 666 timeSys = PS_TIME_UTC; 667 } 668 psFree(timesysName); 669 670 return timeSys; 671 } 721 672 722 673 723 psMetadataItem *p_pmConceptParse_TIME(const psMetadataItem *concept, … … 896 946 } 897 947 898 time->type = timeSys; 948 if (jdTime || mjdTime) { 949 conceptSetTimesysForTime(pattern->name, fpa, chip, cell, PS_TIME_TAI); 950 } else { 951 time->type = timeSys; 952 } 899 953 900 954 psMetadataItem *item = psMetadataItemAllocPtr(pattern->name, PS_DATA_TIME, pattern->comment, time); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsWrite.c
r22699 r23594 62 62 while ((cItem = psListGetAndIncrement(cIter))) { 63 63 if (cItem->type != PS_DATA_STRING) { 64 psWarning("psMetadataItem from list is of type %x instead of " 65 "%x (PS_DATA_STRING) --- can't interpret.\n", cItem->type, PS_DATA_STRING); 64 psWarning("psMetadataItem from list is of type %x instead of %x (PS_DATA_STRING) --- can't interpret.\n", cItem->type, PS_DATA_STRING); 66 65 psFree(cIter); 67 66 psFree(sIter); … … 183 182 } 184 183 default: 185 psWarning("Type of %s is not suitable for a FITS header --- not added.\n",184 psWarning("Type of %s is not suitable for a FITS header --- not added.\n", 186 185 item->name); 187 186 return false; … … 226 225 } 227 226 227 // Return the camera format appropriate for a focal plane hierarchy 228 static psMetadata *conceptsCameraFormat(const pmFPA *fpa, const pmChip *chip, const pmCell *cell) 229 { 230 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 231 if (!hdu) { 232 return NULL; 233 } 234 return hdu->format; 235 } 236 237 // Return the DATABASE metadata from the format 238 static psMetadata *conceptsDatabase(const psMetadata *format) 239 { 240 bool mdok; // Status of MD lookup 241 return psMetadataLookupMetadata(&mdok, format, "DEFAULTS"); 242 } 243 244 // Return the TRANSLATION metadata from the format 245 static psMetadata *conceptsTranslation(const psMetadata *format) 246 { 247 bool mdok; // Status of MD lookup 248 return psMetadataLookupMetadata(&mdok, format, "TRANSLATION"); 249 } 250 251 // Return the DEFAULTS metadata from the format 252 static psMetadata *conceptsDefaults(const psMetadata *format) 253 { 254 bool mdok; // Status of MD lookup 255 return psMetadataLookupMetadata(&mdok, format, "DEFAULTS"); 256 } 257 228 258 229 259 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 231 261 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 232 262 233 bool p_pmConceptsWriteToCells(const psMetadata *specs, const pmCell *cell, const psMetadata *concepts) 234 { 235 PS_ASSERT_PTR_NON_NULL(specs, false); 236 PS_ASSERT_PTR_NON_NULL(concepts, false); 263 bool p_pmConceptWriteToCells(const pmCell *cell, const pmConceptSpec *spec, 264 const psMetadataItem *conceptItem, const psMetadata *format) 265 { 237 266 if (!cell) { 238 267 return false; … … 242 271 } 243 272 244 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 273 if (!format) { 274 format = conceptsCameraFormat(NULL, NULL, cell); 275 if (!format) { 276 return false; 277 } 278 } 279 280 psMetadataItem *cameraItem = psMetadataLookup(cell->config, conceptItem->name); // Version in the config 281 if (!cameraItem) { 282 return false; 283 } 284 285 psString nameSource = NULL; // String with the concept name and ".SOURCE" added 286 psStringAppend(&nameSource, "%s.SOURCE", conceptItem->name); 287 bool mdok = true; // Status of MD lookup 288 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source 289 if (mdok && strlen(source) > 0) { 290 psTrace("psModules.concepts", 8, "%s is %s\n", nameSource, source); 291 if (strcasecmp(source, "HEADER") == 0) { 292 if (cameraItem->type != PS_DATA_STRING) { 293 psWarning("Concept %s is specified by header, but is not of type STR --- ignored.", 294 conceptItem->name); 295 psFree(nameSource); 296 return false; 297 } 298 299 // Formatted version 300 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 301 format, NULL, NULL, cell); 302 if (!formatted) { 303 psFree(nameSource); 304 return true; 305 } 306 307 psTrace("psModules.concepts", 8, "Writing %s to header %s\n", 308 conceptItem->name, cameraItem->data.str); 309 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // Header data unit 310 if (!hdu) { 311 psError(PS_ERR_UNEXPECTED_NULL, false, 312 "Unable to find HDU to write concept %s", conceptItem->name); 313 return false; 314 } 315 writeHeader(hdu, cameraItem->data.V, formatted); 316 psFree(formatted); 317 } else if (strcasecmp(source, "VALUE") == 0) { 318 // Formatted version 319 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 320 format, NULL, NULL, cell); 321 if (!formatted) { 322 psFree(nameSource); 323 return true; 324 } 325 326 psTrace("psModules.concepts", 8, "Checking %s against camera format.\n", conceptItem->name); 327 if (!compareConcepts(formatted, cameraItem)) { 328 psWarning("Concept %s is specified by value in the camera format, but the values don't match", 329 conceptItem->name); 330 } 331 psFree(formatted); 332 } else { 333 psWarning("Concept source %s isn't HEADER or VALUE --- can't write", nameSource); 334 } 335 } else { 336 // Assume it's specified by value 337 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 338 format, NULL, NULL, cell); 339 if (!formatted) { 340 psFree(nameSource); 341 return true; 342 } 343 344 if (!compareConcepts(formatted, cameraItem)) { 345 psWarning("Concept %s is specified by value in the camera format, but the values don't match.", 346 conceptItem->name); 347 } 348 psFree(formatted); 349 } 350 psFree(nameSource); 351 352 return true; 353 } 354 355 bool p_pmConceptWriteToDefaults(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 356 const pmConceptSpec *spec, const psMetadataItem *conceptItem, 357 const psMetadata *format, const psMetadata *defaults) 358 { 359 if (!format) { 360 format = conceptsCameraFormat(fpa, chip, cell); 361 if (!format) { 362 return false; 363 } 364 } 365 if (!defaults) { 366 defaults = conceptsDefaults(format); 367 if (!defaults) { 368 return false; 369 } 370 } 371 372 psMetadataItem *defaultItem = p_pmConceptsReadSingleFromDefaults(conceptItem->name, defaults, 373 fpa, chip, cell); 374 if (!defaultItem) { 375 return false; 376 } 377 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS, 378 format, fpa, chip, cell); 379 if (!formatted) { 380 return true; 381 } 382 383 if (strcmp(defaultItem->name, conceptItem->name) != 0) { 384 // Correct the name to match the concept name 385 defaultItem = psMetadataItemCopy(defaultItem); 386 psFree(defaultItem->name); 387 defaultItem->name = psStringCopy(conceptItem->name); 388 } else { 389 psMemIncrRefCounter(defaultItem); 390 } 391 392 if (!compareConcepts(formatted, defaultItem)) { 393 psWarning("Concept %s is specified by the DEFAULTS in the camera format, but the values don't match.", 394 conceptItem->name); 395 } 396 psFree(defaultItem); 397 psFree(formatted); 398 399 return true; 400 } 401 402 403 bool p_pmConceptWriteToHeader(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 404 const pmConceptSpec *spec, const psMetadataItem *conceptItem, 405 const psMetadata *format, const psMetadata *translation) 406 { 407 if (!format) { 408 format = conceptsCameraFormat(fpa, chip, cell); 409 if (!format) { 410 return false; 411 } 412 } 413 if (!translation) { 414 translation = conceptsTranslation(format); 415 if (!translation) { 416 return false; 417 } 418 } 419 420 psMetadataItem *headerItem = psMetadataLookup(translation, conceptItem->name); // How to format for header 421 if (!headerItem) { 422 return false; 423 } 424 if (headerItem->type == PS_DATA_METADATA) { 425 // This is a menu 426 psTrace("psModules.concepts", 5, "%s is of type METADATA.\n", conceptItem->name); 427 headerItem = p_pmConceptsDepend(conceptItem->name, headerItem->data.md, translation, fpa, chip, cell); 428 if (!headerItem) { 429 return false; 430 } 431 } 432 if (headerItem->type != PS_DATA_STRING) { 433 psWarning("TRANSLATION keyword for concept %s isn't of type STR --- ignored.", conceptItem->name); 434 return false; 435 } 436 psTrace("psModules.concepts", 3, "Writing %s to header %s\n", conceptItem->name, headerItem->data.str); 437 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 438 format, fpa, chip, cell); 439 if (!formatted) { 440 // Found it, but it doesn't need to be written 441 return true; 442 } 443 444 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // HDU to which to write 245 445 if (!hdu) { 246 return false; 247 } 248 psMetadata *cameraFormat = hdu->format; // The camera format 249 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 250 psMetadataItem *specItem = NULL; // Item from the specs metadata 251 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 252 pmConceptSpec *spec = specItem->data.V; // The specification 253 psString name = specItem->name; // The concept name 254 psMetadataItem *cameraItem = psMetadataLookup(cell->config, name); // The concept from the camera, 255 // or NULL 256 if (cameraItem) { 257 // Grab the concept 258 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The concept 259 260 psString nameSource = NULL; // String with the concept name and ".SOURCE" added 261 psStringAppend(&nameSource, "%s.SOURCE", name); 262 bool mdok = true; // Status of MD lookup 263 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source 264 if (mdok && strlen(source) > 0) { 265 psTrace("psModules.concepts", 8, "%s is %s\n", nameSource, source); 266 if (strcasecmp(source, "HEADER") == 0) { 267 if (cameraItem->type != PS_DATA_STRING) { 268 psWarning("Concept %s is specified by header, but is not " 269 "of type STR --- ignored.\n", conceptItem->name); 270 continue; 271 } 272 273 // Formatted version 274 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 275 cameraFormat, NULL, NULL, cell); 276 if (!formatted) { 277 continue; 278 } 279 280 psTrace("psModules.concepts", 8, "Writing %s to header %s\n", name, cameraItem->data.str); 281 writeHeader(hdu, cameraItem->data.V, formatted); 282 psFree(formatted); 283 } else if (strcasecmp(source, "VALUE") == 0) { 284 // Formatted version 285 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 286 cameraFormat, NULL, NULL, cell); 287 if (!formatted) { 288 continue; 289 } 290 291 psTrace("psModules.concepts", 8, "Checking %s against camera format.\n", name); 292 if (! compareConcepts(formatted, cameraItem)) { 293 psWarning("Concept %s is specified by value in the camera " 294 "format, but the values don't match.\n", name); 295 } 296 psFree(formatted); 297 } else { 298 psWarning("Concept source %s isn't HEADER or VALUE --- can't " 299 "write\n", nameSource); 300 } 301 } else { 302 // Assume it's specified by value 303 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 304 cameraFormat, NULL, NULL, cell); 305 if (!formatted) { 306 continue; 307 } 308 309 if (! compareConcepts(formatted, cameraItem)) { 310 psWarning("Concept %s is specified by value in the camera " 311 "format, but the values don't match.\n", name); 312 } 313 psFree(formatted); 314 } 315 psFree(nameSource); 316 } 317 318 } 319 psFree(specsIter); 446 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find HDU to write concept %s", conceptItem->name); 447 return false; 448 } 449 writeHeader(hdu, headerItem->data.V, formatted); 450 psFree(formatted); 451 320 452 return true; 321 453 } 322 454 323 bool p_pmConceptsWriteToDefaults(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip, 324 const pmCell *cell, const psMetadata *concepts) 325 { 326 PS_ASSERT_PTR_NON_NULL(specs, false); 327 PS_ASSERT_PTR_NON_NULL(concepts, false); 328 329 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 330 if (!hdu) { 331 return false; 332 } 333 psMetadata *cameraFormat = hdu->format; // The camera format 334 bool mdok = true; // Status of MD lookup 335 psMetadata *defaults = psMetadataLookupMetadata(&mdok, cameraFormat, "DEFAULTS"); // The DEFAULTS spec 336 if (!mdok || !defaults) { 337 return false; 338 } 339 340 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 341 psMetadataItem *specItem = NULL; // Item from the specs metadata 342 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 343 pmConceptSpec *spec = specItem->data.V; // The specification 344 psString name = specItem->name; // The concept name 345 346 psMetadataItem *defaultItem = p_pmConceptsReadSingleFromDefaults(name, defaults, fpa, chip, cell); 347 if (!defaultItem) { 348 continue; 349 } 350 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 351 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS, 352 cameraFormat, fpa, chip, cell); 353 if (!formatted) { 354 continue; 355 } 356 357 if (strcmp(defaultItem->name, name) != 0) { 358 // Correct the name to match the concept name 359 defaultItem = psMetadataItemCopy(defaultItem); 360 psFree(defaultItem->name); 361 defaultItem->name = psStringCopy(name); 362 } else { 363 psMemIncrRefCounter(defaultItem); 364 } 365 366 if (!compareConcepts(formatted, defaultItem)) { 367 psWarning("Concept %s is specified by the DEFAULTS in the camera " 368 "format, but the values don't match.\n", name); 369 } 370 psFree(defaultItem); 371 psFree(formatted); 372 } 373 psFree(specsIter); 455 bool p_pmConceptWriteToDatabase(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 456 pmConfig *config, const pmConceptSpec *spec, 457 const psMetadataItem *conceptItem, const psMetadata *format, 458 const psMetadata *database) 459 { 460 PS_ASSERT_PTR_NON_NULL(config, false); 461 462 #ifndef HAVE_PSDB 463 return false; 464 #else 465 466 if (!format) { 467 format = conceptsCameraFormat(fpa, chip, cell); 468 if (!format) { 469 return false; 470 } 471 } 472 if (!database) { 473 database = conceptsDatabase(format); 474 if (!database) { 475 return false; 476 } 477 } 478 479 psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(conceptItem->name, database, config, 480 fpa, chip, cell); // Database version 481 if (!dbItem) { 482 return false; 483 } 484 485 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE, 486 format, fpa, chip, cell); 487 if (!formatted) { 488 return false; 489 } 490 491 if (strcmp(dbItem->name, conceptItem->name) != 0) { 492 // Correct the name to match the concept name 493 dbItem = psMetadataItemCopy(dbItem); 494 psFree(dbItem->name); 495 dbItem->name = psStringCopy(conceptItem->name); 496 } else { 497 psMemIncrRefCounter(dbItem); 498 } 499 500 if (!compareConcepts(formatted, dbItem)) { 501 psWarning("Concept %s is specified by the DATABASE in the camera " 502 "format, but the values don't match.\n", conceptItem->name); 503 } 504 psFree(dbItem); 505 psFree(formatted); 506 374 507 return true; 375 } 376 377 378 bool p_pmConceptsWriteToHeader(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip, 379 const pmCell *cell, const psMetadata *concepts) 380 { 381 PS_ASSERT_PTR_NON_NULL(specs, false); 382 PS_ASSERT_PTR_NON_NULL(concepts, false); 383 384 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 385 if (!hdu) { 386 return false; 387 } 388 psMetadata *cameraFormat = hdu->format; // The camera format 389 bool mdok = true; // Status of MD lookup 390 psMetadata *translation = psMetadataLookupMetadata(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec 391 if (!mdok || !translation) { 392 return false; 393 } 394 395 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 396 psMetadataItem *specItem = NULL; // Item from the specs metadata 397 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 398 pmConceptSpec *spec = specItem->data.V; // The specification 399 psString name = specItem->name; // The concept name 400 psMetadataItem *headerItem = psMetadataLookup(translation, name); // The item from the TRANSLATION 401 if (!headerItem) { 402 continue; 403 } 404 if (headerItem->type == PS_DATA_METADATA) { 405 // This is a menu 406 psTrace("psModules.concepts", 5, "%s is of type METADATA.\n", name); 407 headerItem = p_pmConceptsDepend(name, headerItem->data.md, translation, fpa, chip, cell); 408 if (!headerItem) { 409 continue; 410 } 411 } 412 if (headerItem->type != PS_DATA_STRING) { 413 psWarning("TRANSLATION keyword for concept %s isn't of type STR --- ignored.", name); 414 continue; 415 } 416 psTrace("psModules.concepts", 3, "Writing %s to header %s\n", name, headerItem->data.str); 417 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 418 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 419 cameraFormat, fpa, chip, cell); 420 if (!formatted) { 421 continue; 422 } 423 writeHeader(hdu, headerItem->data.V, formatted); 424 psFree(formatted); 425 } 426 psFree(specsIter); 508 #endif 509 } 510 511 512 bool pmConceptWriteSingle(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 513 pmConfig *config, const psMetadataItem *conceptItem) 514 { 515 pmConceptsInit(); 516 517 psMetadata *format = conceptsCameraFormat(fpa, chip, cell); // Camera format 518 if (!format) { 519 psError(PS_ERR_UNKNOWN, false, "Unable to retrieve camera format."); 520 return false; 521 } 522 523 const char *name = conceptItem->name; // Name of concept 524 525 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications for FPA 526 bool mdok; // Status of MD lookup 527 pmConceptSpec *spec = psMetadataLookupPtr(&mdok, conceptsFPA, name); // Concept specification of interest 528 if (!spec) { 529 psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications for Chip 530 spec = psMetadataLookupPtr(&mdok, conceptsChip, name); 531 if (!spec) { 532 psMetadata *conceptsCell = pmConceptsSpecs(PM_FPA_LEVEL_CELL); // Concept specifications for Cell 533 spec = psMetadataLookupPtr(&mdok, conceptsCell, name); 534 if (!spec) { 535 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find specification for concept %s", name); 536 return false; 537 } 538 } 539 } 540 541 if (!p_pmConceptWriteToCells(cell, spec, conceptItem, format) && 542 !p_pmConceptWriteToDefaults(fpa, chip, cell, spec, conceptItem, format, NULL) && 543 !p_pmConceptWriteToHeader(fpa, chip, cell, spec, conceptItem, format, NULL) && 544 !p_pmConceptWriteToDatabase(fpa, chip, cell, config, spec, conceptItem, format, NULL)) { 545 return false; 546 } 427 547 return true; 428 548 } 429 430 // XXX Warning: This code has not been tested at all431 bool p_pmConceptsWriteToDatabase(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip,432 const pmCell *cell, pmConfig *config, const psMetadata *concepts)433 {434 PS_ASSERT_PTR_NON_NULL(specs, false);435 PS_ASSERT_PTR_NON_NULL(concepts, false);436 PS_ASSERT_PTR_NON_NULL(config, false);437 438 #ifndef HAVE_PSDB439 return false;440 #else441 442 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level443 if (!hdu) {444 return false;445 }446 psMetadata *cameraFormat = hdu->format; // The camera format447 bool mdok = true; // Status of MD lookup448 psMetadata *database = psMetadataLookupMetadata(&mdok, cameraFormat, "DATABASE"); // The DATABASE spec449 if (!mdok || !database) {450 return false;451 }452 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator453 psMetadataItem *specItem = NULL; // Item from the specs metadata454 while ((specItem = psMetadataGetAndIncrement(specsIter))) {455 pmConceptSpec *spec = specItem->data.V; // The specification456 psString name = specItem->name; // The concept name457 458 psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(name, database, config, fpa, chip, cell);459 if (!dbItem) {460 continue;461 }462 463 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts464 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE,465 cameraFormat, fpa, chip, cell);466 if (!formatted) {467 continue;468 }469 470 if (strcmp(dbItem->name, name) != 0) {471 // Correct the name to match the concept name472 dbItem = psMetadataItemCopy(dbItem);473 psFree(dbItem->name);474 dbItem->name = psStringCopy(name);475 } else {476 psMemIncrRefCounter(dbItem);477 }478 479 if (!compareConcepts(formatted, dbItem)) {480 psWarning("Concept %s is specified by the DATABASE in the camera "481 "format, but the values don't match.\n", name);482 }483 psFree(dbItem);484 psFree(formatted);485 }486 psFree(specsIter);487 return true;488 #endif489 }490 491 492 493 549 494 550 … … 498 554 const pmChip *chip, // The chip 499 555 const pmCell *cell, // The cell 500 pmConceptSource source, // The source of the concepts to write501 556 pmConfig *config, // Configuration 502 557 psMetadata *concepts // The concepts to write out … … 508 563 pmConceptsInit(); 509 564 510 psTrace("psModules.concepts", 3, "Writing concepts (%p %p %p): %d\n", fpa, chip, cell, source); 511 512 if (source & PM_CONCEPT_SOURCE_CELLS) { 513 p_pmConceptsWriteToCells(*specs, cell, concepts); 514 } 515 if (source & PM_CONCEPT_SOURCE_DEFAULTS) { 516 p_pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts); 517 } 518 if (source & (PM_CONCEPT_SOURCE_PHU | PM_CONCEPT_SOURCE_HEADER)) { 519 p_pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts); 520 } 521 if (source & PM_CONCEPT_SOURCE_DATABASE) { 522 p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, config, concepts); 523 } 565 psTrace("psModules.concepts", 3, "Writing concepts (%p %p %p)\n", fpa, chip, cell); 566 567 psMetadata *format = conceptsCameraFormat(fpa, chip, cell); // Camera format 568 if (!format) { 569 psError(PS_ERR_UNKNOWN, false, "Unable to retrieve camera format."); 570 return false; 571 } 572 573 psMetadata *defaults = conceptsDefaults(format); // DEFAULTS configuration 574 psMetadata *translation = conceptsTranslation(format); // TRANSLATION configuration 575 psMetadata *database = conceptsDatabase(format); // DATABASE configuration 576 577 psMetadataIterator *iter = psMetadataIteratorAlloc(*specs, PS_LIST_HEAD, NULL); // Iterator 578 psMetadataItem *item = NULL; // Item from the specs metadata 579 while ((item = psMetadataGetAndIncrement(iter))) { 580 pmConceptSpec *spec = item->data.V; // The specification 581 psString name = item->name; // The concept name 582 583 psMetadataItem *concept = psMetadataLookup(concepts, name); // Concept to write 584 585 if (!p_pmConceptWriteToCells(cell, spec, concept, format) && 586 !p_pmConceptWriteToDefaults(fpa, chip, cell, spec, concept, format, defaults) && 587 !p_pmConceptWriteToHeader(fpa, chip, cell, spec, concept, format, translation) && 588 !p_pmConceptWriteToDatabase(fpa, chip, cell, config, spec, concept, format, database)) { 589 psTrace("psModules.concepts", 1, "Unable to write concept %s to any output", name); 590 } 591 } 592 psFree(iter); 524 593 525 594 return true; … … 527 596 528 597 529 bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source,bool propagateDown, pmConfig *config)598 bool pmConceptsWriteFPA(const pmFPA *fpa, bool propagateDown, pmConfig *config) 530 599 { 531 600 PS_ASSERT_PTR_NON_NULL(fpa, false); 532 601 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 533 602 psTrace("psModules.concepts", 5, "Writing FPA concepts: %p %p\n", conceptsFPA, fpa->concepts); 534 bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source,config, fpa->concepts);603 bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, config, fpa->concepts); 535 604 if (propagateDown) { 536 605 psArray *chips = fpa->chips; // Array of chips … … 538 607 pmChip *chip = chips->data[i]; // Chip of interest 539 608 if (chip && !chip->hdu) { 540 success &= pmConceptsWriteChip(chip, source,false, true, config);609 success &= pmConceptsWriteChip(chip, false, true, config); 541 610 } 542 611 } … … 546 615 547 616 548 bool pmConceptsWriteChip(const pmChip *chip, pmConceptSource source, bool propagateUp, 549 bool propagateDown, pmConfig *config) 617 bool pmConceptsWriteChip(const pmChip *chip, bool propagateUp, bool propagateDown, pmConfig *config) 550 618 { 551 619 PS_ASSERT_PTR_NON_NULL(chip, false); … … 553 621 psTrace("psModules.concepts", 5, "Writing chip concepts: %p %p\n", conceptsChip, chip->concepts); 554 622 pmFPA *fpa = chip->parent; // FPA to which the chip belongs 555 bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source,config, chip->concepts);623 bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, config, chip->concepts); 556 624 if (propagateUp && !fpa->hdu) { 557 625 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 558 success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source,config, fpa->concepts);626 success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, config, fpa->concepts); 559 627 } 560 628 if (propagateDown) { … … 563 631 pmCell *cell = cells->data[i]; // Cell of interest 564 632 if (cell && !cell->hdu) { 565 success &= pmConceptsWriteCell(cell, source,false, config);633 success &= pmConceptsWriteCell(cell, false, config); 566 634 } 567 635 } … … 571 639 572 640 573 bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source,bool propagateUp, pmConfig *config)641 bool pmConceptsWriteCell(const pmCell *cell, bool propagateUp, pmConfig *config) 574 642 { 575 643 PS_ASSERT_PTR_NON_NULL(cell, false); … … 579 647 pmFPA *fpa = chip->parent; // FPA to which the chip belongs 580 648 581 bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source,config, cell->concepts);649 bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, config, cell->concepts); 582 650 if (propagateUp) { 583 651 if (!chip->hdu) { 584 652 psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications 585 success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source,config, chip->concepts);653 success &= conceptsWrite(&conceptsChip, fpa, chip, cell, config, chip->concepts); 586 654 if (!fpa->hdu) { 587 655 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 588 success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source,config, fpa->concepts);656 success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, config, fpa->concepts); 589 657 } 590 658 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/concepts/pmConceptsWrite.h
r22699 r23594 20 20 /// @{ 21 21 22 /// "Write" concept sto (actually, check against) the camera format file's CELLS.22 /// "Write" concept to (actually, check against) the camera format file's CELLS. 23 23 /// 24 24 /// Examines the CELLS metadata in the camera format file for the current type of cell, and checks that the 25 /// concept s as defined there match the ones defined in the cell. A warning is produced if the concepts do25 /// concept as defined there match the ones defined in the cell. A warning is produced if the concept does 26 26 /// not match. 27 bool p_pmConceptsWriteToCells(const psMetadata *specs, ///< The concept specifications 27 bool p_pmConceptWriteToCells(const pmCell *cell, ///< The cell 28 const pmConceptSpec *spec, ///< Concept specification 29 const psMetadataItem *conceptItem, ///< Concept to write 30 const psMetadata *format ///< Camera format, or NULL 31 ); 32 33 /// "Write" concept to (actually, check against) the camera format file's DEFAULTS. 34 /// 35 /// Examines the DEFAULTS metadata in the camera format file, and checks that the concept as defined there 36 /// match the one defined in the cell. A warning is produced if the concept does not match. 37 bool p_pmConceptWriteToDefaults(const pmFPA *fpa, ///< The FPA 38 const pmChip *chip, ///< The chip 39 const pmCell *cell, ///< The cell 40 const pmConceptSpec *spec, ///< Concept specification 41 const psMetadataItem *conceptItem, ///< Concept to write 42 const psMetadata *format, ///< Camera format, or NULL 43 const psMetadata *defaults ///< DEFAULTS configuration, or NULL 44 ); 45 46 /// "Write" concept to (actually, add to, pending a later write) the FITS header. 47 /// 48 /// Examines the FITS header TRANSLATION metadata in the camera format file, and writes concept to the 49 /// appropriate FITS header(s) in the HDU, in preparation for a future write of the HDU. 50 bool p_pmConceptWriteToHeader(const pmFPA *fpa, ///< The FPA 51 const pmChip *chip, ///< The chip 28 52 const pmCell *cell, ///< The cell 29 const psMetadata *concepts ///< The concepts 30 ); 53 const pmConceptSpec *spec, ///< Concept specification 54 const psMetadataItem *conceptItem, ///< Concept to write 55 const psMetadata *format, ///< Camera format, or NULL 56 const psMetadata *translation ///< TRANSLATION configuration, or NULL 57 ); 31 58 32 /// "Write" concepts to (actually, check against) the camera format file's DEFAULTS.59 /// Write concept to the database. 33 60 /// 34 /// Examines the DEFAULTS metadata in the camera format file, and checks that the concepts as defined there 35 /// match the ones defined in the cell. A warning is produced if the concepts do not match. 36 bool p_pmConceptsWriteToDefaults(const psMetadata *specs, ///< The concept specifications 37 const pmFPA *fpa, ///< The FPA 38 const pmChip *chip, ///< The chip 39 const pmCell *cell, ///< The cell 40 const psMetadata *concepts ///< The concepts 61 /// Examines the DATABASE metadata in the camera format file, and writes (actually, check against) 62 /// concept to the database. 63 bool p_pmConceptWriteToDatabase(const pmFPA *fpa, ///< The FPA 64 const pmChip *chip, ///< The chip 65 const pmCell *cell, ///< The cell 66 pmConfig *config, ///< Configuration 67 const pmConceptSpec *spec, ///< Concept specification 68 const psMetadataItem *conceptItem, ///< Concept to write 69 const psMetadata *format, ///< Camera format, or NULL 70 const psMetadata *database ///< DATABASE configuration, or NULL 41 71 ); 42 72 43 /// "Write" concepts to (actually, add to, pending a later write) the FITS header.44 ///45 /// Examines the FITS header TRANSLATION metadata in the camera format file, and writes concepts to the46 /// appropriate FITS headers in the HDU, in preparation for a future write of the HDU.47 bool p_pmConceptsWriteToHeader(const psMetadata *specs, ///< The concept specifications48 const pmFPA *fpa, ///< The FPA49 const pmChip *chip, ///< The chip50 const pmCell *cell, ///< The cell51 const psMetadata *concepts ///< The concepts52 );53 73 54 /// Write concepts to the database. 55 /// 56 /// Examines the DATABASE metadata in the camera format file, and writes concepts to the database. 57 /// Warning: This function has not been tested; use at your own risk. 58 bool p_pmConceptsWriteToDatabase(const psMetadata *specs, ///< The concept specifications 59 const pmFPA *fpa, ///< The FPA 60 const pmChip *chip, ///< The chip 61 const pmCell *cell, ///< The cell 62 pmConfig *config,///< Configuration 63 const psMetadata *concepts ///< The concepts 64 ); 74 bool pmConceptWriteSingle(const pmFPA *fpa, ///< The FPA 75 const pmChip *chip, ///< The chip 76 const pmCell *cell, ///< The cell 77 pmConfig *config, ///< Configuration 78 const psMetadataItem *concept ///< Concept to write 79 ); 65 80 66 81 … … 70 85 /// written for all lower levels by iterating over the components. 71 86 bool pmConceptsWriteFPA(const pmFPA *fpa, ///< FPA for which to write concepts 72 pmConceptSource source, ///< Source for concepts73 87 bool propagateDown, ///< Propagate to lower levels? 74 88 pmConfig *config ///< Configuration … … 80 94 /// written for the FPA, and the cell level by iterating over the components. 81 95 bool pmConceptsWriteChip(const pmChip *chip, ///< Chip for which to write concepts 82 pmConceptSource source, ///< Source for concepts83 96 bool propagateUp,///< Propagate to higher levels? 84 97 bool propagateDown, ///< Propagate to lower levels? … … 92 105 /// only the parent of this cell). 93 106 bool pmConceptsWriteCell(const pmCell *cell, ///< FPA for which to write concepts 94 pmConceptSource source, ///< Source for concepts95 107 bool propagateUp, ///< Propagate to higher levels? 96 108 pmConfig *config ///< Configuration -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfig.c
r23351 r23594 806 806 pmConfigLoadRecipeOptions(argc, argv, config, "-Df"); 807 807 pmConfigLoadRecipeOptions(argc, argv, config, "-Db"); 808 809 if (!pmConfigReadRecipes(config, PM_RECIPE_SOURCE_CL)) { 810 psError(PS_ERR_IO, false, "Failed to read recipes from command-line"); 811 psFree(config); 812 return NULL; 813 } 808 814 809 815 // Look for command-line options for files to replace -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigCamera.c
r23351 r23594 159 159 // Don't update these skycell concepts; last one MUST be 0 (i.e., NULL). 160 160 const static char *skycellConceptsCell[] = { "CELL.BIASSEC", "CELL.TRIMSEC", "CELL.READDIR", "CELL.XPARITY", 161 "CELL.YPARITY", "CELL.X0", "CELL.Y0", 0 };161 "CELL.YPARITY", "CELL.X0", "CELL.Y0", "CELL.TIMESYS", 0 }; 162 162 const static char *skycellConceptsChip[] = { "CHIP.XPARITY", "CHIP.YPARITY", 0 }; 163 const static char *skycellConceptsFPA[] = { 0};163 const static char *skycellConceptsFPA[] = { "FPA.TIMESYS" }; 164 164 165 165 // What do we call the skycell concept in the FITS header? … … 332 332 psMetadataAddS32(defaults, PS_LIST_TAIL, "CHIP.X0", 0, NULL, 0); 333 333 psMetadataAddS32(defaults, PS_LIST_TAIL, "CELL.READDIR", 0, "Read direction (rows)", 1); 334 psMetadataAddStr(defaults, PS_LIST_TAIL, "CELL.TIMESYS", 0, "Time system", "TAI"); 335 psMetadataAddStr(defaults, PS_LIST_TAIL, "FPA.TIMESYS", 0, "Time system", "TAI"); 334 336 335 337 psMetadataAddMetadata(format, PS_LIST_TAIL, "DEFAULTS", 0, "Default values for concepts", defaults); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigMask.c
r21386 r23594 10 10 11 11 static pmConfigMaskInfo masks[] = { 12 { "DETECTOR", NULL, 0x00, true }, // Something is wrong with the detector 13 { "DARK", "DETECTOR", 0x00, true }, // Pixel doesn't dark-subtract properly 14 { "FLAT", "DETECTOR", 0x01, true }, // Pixel doesn't flat-field properly 15 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 16 { "RANGE", NULL, 0x00, true }, // Pixel is out-of-range of linearity 17 { "SAT", "RANGE", 0x01, true }, // Pixel is saturated 18 { "BAD", "RANGE", 0x01, true }, // Pixel is low 19 { "BAD.WARP", NULL, 0x01, true }, // Pixel is bad after convolution with a bad pixel 20 { "CR", NULL, 0x00, true }, // Pixel contains a cosmic ray 21 { "GHOST", NULL, 0x00, true }, // Pixel contains an optical ghost 22 { "POOR.WARP", NULL, 0x00, false }, // Pixel is poor after convolution with a bad pixel 23 // "LOW" Pixel is low 24 // "CONV" Pixel is bad after convolution with a bad pixel 12 // Features of the detector 13 { "DETECTOR", NULL, 0x01, true }, // Something is wrong with the detector 14 { "FLAT", "DETECTOR", 0x01, true }, // Pixel doesn't flat-field properly 15 { "DARK", "DETECTOR", 0x01, true }, // Pixel doesn't dark-subtract properly 16 { "BLANK", "DETECTOR", 0x01, true }, // Pixel doesn't contain valid data 17 { "CTE", "DETECTOR", 0x01, true }, // Pixel has poor CTE 18 // Invalid signal ranges 19 { "SAT", NULL, 0x02, true }, // Pixel is saturated or non-linear 20 { "LOW", "SAT", 0x02, true }, // Pixel is low 21 { "SUSPECT", NULL, 0x04, false }, // Pixel is suspected of being bad 22 // Non-astronomical structures 23 { "CR", NULL, 0x08, true }, // Pixel contains a cosmic ray 24 { "SPIKE", NULL, 0x08, true }, // Pixel contains a diffraction spike 25 { "GHOST", NULL, 0x08, true }, // Pixel contains an optical ghost 26 { "STREAK", NULL, 0x08, true }, // Pixel contains streak data 27 { "STARCORE", NULL, 0x08, true }, // Pixel contains a bright star core 28 // Effects of convolution and interpolation 29 { "CONV.BAD", NULL, 0x02, true }, // Pixel is bad after convolution with a bad pixel 30 { "CONV.POOR", NULL, 0x04, false }, // Pixel is poor after convolution with a bad pixel 25 31 }; 26 32 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRun.c
r23351 r23594 39 39 } 40 40 41 42 bool pmConfigRunFileAdd(pmConfig *config, const pmFPAfile *file) 41 // Add a file to a nominated metadata in the RUN information 42 static bool configRunFileAdd(pmConfig *config, // Configuration 43 const pmFPAfile *file, // File to add 44 const char *target // Name of metadata to which to add 45 ) 43 46 { 44 47 PS_ASSERT_PTR_NON_NULL(config, false); … … 47 50 psMetadata *run = configRun(config);// RUN information 48 51 psAssert(run, "Require run-time information"); 49 psMetadata *files = configElement(run, "FILES", "Filerules used during execution");52 psMetadata *files = configElement(run, target, "Filerules used during execution"); 50 53 psAssert(files, "Require list of files"); 51 54 … … 71 74 } 72 75 73 psArray *pmConfigRunFileGet(pmConfig *config, const char *name)76 bool pmConfigRunFileAddRead(pmConfig *config, const pmFPAfile *file) 74 77 { 75 78 PS_ASSERT_PTR_NON_NULL(config, false); 76 PS_ASSERT_ STRING_NON_EMPTY(name, false);79 PS_ASSERT_PTR_NON_NULL(file, false); 77 80 81 return configRunFileAdd(config, file, "FILES.INPUT"); 82 } 83 84 bool pmConfigRunFileAddWrite(pmConfig *config, const pmFPAfile *file) 85 { 86 PS_ASSERT_PTR_NON_NULL(config, false); 87 PS_ASSERT_PTR_NON_NULL(file, false); 88 89 return configRunFileAdd(config, file, "FILES.OUTPUT"); 90 } 91 92 // Get an array of filenames from the nominated RUN information 93 static psArray *configRunFileGet(pmConfig *config, // Configuration 94 const char *name, // Name of file 95 const char *source // Source metadata for file 96 ) 97 { 78 98 psMetadata *run = configRun(config);// RUN information 79 99 psAssert(run, "Require run-time information"); 80 psMetadata *files = configElement(run, "FILES", "Filerules used during execution");100 psMetadata *files = configElement(run, source, "Filerules used during execution"); 81 101 psAssert(files, "Require list of files"); 102 103 if (psListLength(files->list) == 0) { 104 // Can't find anything 105 return NULL; 106 } 82 107 83 108 psList *list = psListAlloc(NULL); // List of file names … … 104 129 105 130 return array; 131 } 132 133 134 psArray *pmConfigRunFileGet(pmConfig *config, const char *name) 135 { 136 PS_ASSERT_PTR_NON_NULL(config, false); 137 PS_ASSERT_STRING_NON_EMPTY(name, false); 138 139 // Try the input and output, in turn 140 psArray *files = configRunFileGet(config, name, "FILES.INPUT"); // Files from RUN metadata 141 if (!files) { 142 configRunFileGet(config, name, "FILES.OUTPUT"); 143 } 144 145 return files; 106 146 } 107 147 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRun.h
r23351 r23594 6 6 #include <pmFPAfile.h> 7 7 8 /// Add a file to the list of files used in the run-time information 9 bool pmConfigRunFileAdd( 8 /// Add a file to the list of files read in the run-time information 9 bool pmConfigRunFileAddRead( 10 pmConfig *config, ///< Configuration 11 const pmFPAfile *file ///< File to add 12 ); 13 14 /// Add a file to the list of files written in the run-time information 15 bool pmConfigRunFileAddWrite( 10 16 pmConfig *config, ///< Configuration 11 17 const pmFPAfile *file ///< File to add -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmDetrendDB.h
r23351 r23594 63 63 64 64 pmDetrendSelectOptions *pmDetrendSelectOptionsAlloc(const char *camera, psTime time, pmDetrendType type); 65 pmDetrendSelectResults *pmDetrendSelectResultsAlloc( );65 pmDetrendSelectResults *pmDetrendSelectResultsAlloc(void); 66 66 pmDetrendSelectResults *pmDetrendSelect (const pmDetrendSelectOptions *options, const pmConfig *config); 67 67 char *pmDetrendFile (const char *detID, const char *classID, const pmConfig *config); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmDetrendThreads.h
r18893 r23594 18 18 19 19 /// get the requested number of scan rows per thread 20 int pmDetrendGetScanRows ();20 int pmDetrendGetScanRows(void); 21 21 22 22 /// @} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmShutterCorrection.c
r23351 r23594 71 71 } 72 72 73 pmShutterCorrection *pmShutterCorrectionAlloc( )73 pmShutterCorrection *pmShutterCorrectionAlloc(void) 74 74 { 75 75 pmShutterCorrection *corr = (pmShutterCorrection*)psAlloc(sizeof(pmShutterCorrection)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/detrend/pmShutterCorrection.h
r21509 r23594 69 69 70 70 /// Allocator for shutter correction parameters 71 pmShutterCorrection *pmShutterCorrectionAlloc( );71 pmShutterCorrection *pmShutterCorrectionAlloc(void); 72 72 73 73 /// Guess a shutter correction, based on plot of counts vs exposure time -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/pmKapaPlots.c
r13896 r23594 47 47 } 48 48 49 bool pmKapaClose ( )49 bool pmKapaClose (void) 50 50 { 51 51 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/pmKapaPlots.h
r12696 r23594 1 1 /* @file pmKapaPlots.h 2 * @brief functions to make plots with the external program 'kapa' 2 * @brief functions to make plots with the external program 'kapa' 3 3 * 4 4 * @author EAM, IfA … … 17 17 // move to psLib or psModules 18 18 int pmKapaOpen (bool showWindow); 19 bool pmKapaClose ();19 bool pmKapaClose(void); 20 20 bool pmKapaPlotVectorPair (psVector *xVec, psVector *yVec); 21 21 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/psPipe.c
r12888 r23594 35 35 } 36 36 37 psPipe *psPipeAlloc ( )37 psPipe *psPipeAlloc (void) 38 38 { 39 39 psPipe *pipe = (psPipe *)psAlloc(sizeof(psPipe)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/extras/psPipe.h
r11253 r23594 1 1 /* @file psPipe.h 2 * @brief 3-stream pipe 2 * @brief 3-stream pipe 3 3 * 4 4 * @author EAM, IfA … … 26 26 27 27 // psPipe functions 28 psPipe *psPipeAlloc ( );28 psPipe *psPipeAlloc (void); 29 29 psPipe *psPipeOpen (char *command); 30 30 int psPipeClose (psPipe *pipe); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmStack.c
r23351 r23594 46 46 psVector *weights; // Pixel weightings 47 47 psVector *sources; // Pixel sources (which image did they come from?) 48 psVector *limits; // Rejection limits 48 49 psVector *sort; // Buffer for sorting (to get a robust estimator of the standard dev) 49 50 } combineBuffer; … … 56 57 psFree(buffer->weights); 57 58 psFree(buffer->sources); 59 psFree(buffer->limits); 58 60 psFree(buffer->sort); 59 61 return; … … 71 73 buffer->weights = psVectorAlloc(numImages, PS_TYPE_F32); 72 74 buffer->sources = psVectorAlloc(numImages, PS_TYPE_U16); 75 buffer->limits = psVectorAlloc(numImages, PS_TYPE_F32); 73 76 buffer->sort = psVectorAlloc(numImages, PS_TYPE_F32); 74 77 return buffer; … … 319 322 bool useVariance, // Use variance for rejection when combining? 320 323 bool safe, // Combine safely? 324 bool rejectInspect, // Reject values marked for inspection from combination? 321 325 combineBuffer *buffer // Buffer for combination; to avoid multiple allocations 322 326 ) … … 336 340 psVector *pixelWeights = buffer->weights; // Image weights for the pixel of interest 337 341 psVector *pixelSources = buffer->sources; // Sources for the pixel of interest 342 psVector *pixelLimits = buffer->limits; // Limits for the pixel of interest 338 343 psVector *sort = buffer->sort; // Sort buffer 339 344 … … 375 380 pixelWeights->n = num; 376 381 pixelSources->n = num; 382 pixelLimits->n = num; 377 383 378 384 #ifdef TESTING … … 389 395 // Default option is that the pixel is bad 390 396 float imageValue = NAN, varianceValue = NAN; // Value for combined image and variance map 391 psImageMaskType maskValue = bad; // Value for combined mask397 psImageMaskType maskValue = bad; // Value for combined mask 392 398 switch (num) { 393 399 case 0: … … 449 455 if (PS_SQR(diff) > PS_SQR(rej) * sigma2) { 450 456 // Not consistent: mark both for inspection 451 combineInspect(inputs, x, y, pixelSources->data.U16[0]); 452 combineInspect(inputs, x, y, pixelSources->data.U16[1]); 457 if (rejectInspect) { 458 imageValue = NAN; 459 varianceValue = NAN; 460 maskValue = bad; 461 } else { 462 combineInspect(inputs, x, y, pixelSources->data.U16[0]); 463 combineInspect(inputs, x, y, pixelSources->data.U16[1]); 464 } 453 465 #ifdef TESTING 454 466 if (x == TEST_X && y == TEST_Y) { … … 501 513 #endif 502 514 503 pixel Variances->data.F32[i] = rej2 * (pixelVariances->data.F32[i] + sysVar);515 pixelLimits->data.F32[i] = rej2 * (pixelVariances->data.F32[i] + sysVar); 504 516 } 505 517 } … … 541 553 #define MASK_PIXEL_FOR_INSPECTION() \ 542 554 pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; \ 543 combineInspect(inputs, x, y, pixelSources->data.U16[j]); \ 555 if (!rejectInspect) { \ 556 combineInspect(inputs, x, y, pixelSources->data.U16[j]); \ 557 } \ 544 558 numClipped++; \ 545 559 totalClipped++; … … 553 567 // Comparing squares --- cheaper than lots of sqrts 554 568 // pixelVariances includes the rejection limit, from above 555 if (PS_SQR(diff) > pixel Variances->data.F32[j]) {569 if (PS_SQR(diff) > pixelLimits->data.F32[j]) { 556 570 MASK_PIXEL_FOR_INSPECTION(); 557 571 #ifdef TESTING 558 572 if (x == TEST_X && y == TEST_Y) { 559 573 fprintf(stderr, "Rejecting input %d based on variance: %f > %f\n", 560 j, diff, sqrtf(pixel Variances->data.F32[j]));574 j, diff, sqrtf(pixelLimits->data.F32[j])); 561 575 } 562 576 #endif … … 573 587 } 574 588 } 589 590 if (rejectInspect && totalClipped > 0) { 591 // Get rid of the masked values 592 // The alternative to this is to make combinationMeanVariance() accept a mask 593 int good = 0; // Index of good value 594 for (int i = 0; i < num; i++) { 595 if (pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 596 continue; 597 } 598 if (i != good) { 599 pixelData->data.F32[good] = pixelData->data.F32[i]; 600 pixelVariances->data.F32[good] = pixelVariances->data.F32[i]; 601 pixelWeights->data.F32[good] = pixelWeights->data.F32[i]; 602 pixelData->data.F32[good] = pixelData->data.F32[i]; 603 } 604 good++; 605 } 606 pixelData->n = good; 607 pixelVariances->n = good; 608 pixelWeights->n = good; 609 if (combinationMeanVariance(&mean, &var, pixelData, pixelVariances, pixelWeights)) { 610 imageValue = mean; 611 varianceValue = var; 612 maskValue = 0; 613 } else { 614 imageValue = NAN; 615 varianceValue = NAN; 616 maskValue = bad; 617 } 618 } 619 575 620 break; 576 621 } … … 734 779 bool pmStackCombine(pmReadout *combined, psArray *input, psImageMaskType maskVal, psImageMaskType bad, 735 780 int kernelSize, int numIter, float rej, float sys, float discard, 736 bool entire, bool useVariance, bool safe )781 bool entire, bool useVariance, bool safe, bool rejectInspect) 737 782 { 738 783 PS_ASSERT_PTR_NON_NULL(combined, false); … … 838 883 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, 839 884 addVariance, reject, x, y, maskVal, bad, numIter, rej, sys, discard, 840 useVariance, safe, buffer);885 useVariance, safe, rejectInspect, buffer); 841 886 } 842 887 } … … 853 898 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, 854 899 addVariance, reject, x, y, maskVal, bad, numIter, rej, sys, discard, 855 useVariance, safe, buffer);900 useVariance, safe, rejectInspect, buffer); 856 901 } 857 902 } … … 881 926 combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, 882 927 addVariance, NULL, x, y, maskVal, bad, numIter, rej, sys, discard, 883 useVariance, safe, buffer);928 useVariance, safe, rejectInspect, buffer); 884 929 } 885 930 } -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmStack.h
r21476 r23594 52 52 bool entire, ///< Combine entire image even if rejection lists provided? 53 53 bool useVariance, ///< Use variance values for rejection? 54 bool safe ///< Play safe with small numbers of input pixels (mask if N <= 2)? 54 bool safe, ///< Play safe with small numbers of input pixels (mask if N <= 2)? 55 bool rejectInspect ///< Reject pixels instead of marking them for inspection? 55 56 ); 56 57 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionIO.c
r23351 r23594 4 4 5 5 #include "pmHDU.h" 6 #include "pmHDUUtils.h" 6 7 #include "pmFPA.h" 7 8 #include "pmFPAview.h" … … 143 144 psMetadata *header = psMetadataAlloc(); // Header for FITS file 144 145 146 pmCell *cell = ro->parent; // Cell of interest 147 if (cell) { 148 pmChip *chip = cell->parent; // Chip of interest 149 pmFPA *fpa = chip->parent; // FPA of interest 150 pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell); // HDU for readout 151 if (hdu) { 152 header = psMetadataCopy(header, hdu->header); 153 } 154 } 155 145 156 // CVS tags, used to identify the version of this file (in case incompatibilities are introduced) 146 157 psString cvsFile = psStringCopy("$RCSfile: pmSubtractionIO.c,v $"); … … 533 544 return true; 534 545 } 535 if (file->fileLevel != PM_FPA_LEVEL_FPA) {536 return true;537 }538 if (file->fpa->chips->n == 1) {539 return true;540 }541 546 542 547 // find the FPA phu -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionVisual.c
r23351 r23594 44 44 45 45 /** destroy windows at the end of a run*/ 46 bool pmSubtractionVisualClose( )46 bool pmSubtractionVisualClose(void) 47 47 { 48 48 if(kapa != -1) … … 256 256 257 257 #else 258 bool pmSubtractionVisualClose( ) {return true;}258 bool pmSubtractionVisualClose(void) {return true;} 259 259 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels) {return true;} 260 260 bool pmSubtractionVisualPlotStamps(pmSubtractionStampList *stamps, pmReadout *ro) {return true;} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/imcombine/pmSubtractionVisual.h
r23351 r23594 2 2 #define PM_SUBTRACTION_VISUAL_H 3 3 4 bool pmSubtractionVisualClose( );4 bool pmSubtractionVisualClose(void); 5 5 bool pmSubtractionVisualPlotConvKernels(psImage *convKernels); 6 6 bool pmSubtractionVisualPlotStamps(pmSubtractionStampList *stamps, pmReadout *ro); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmDetections.c
r18828 r23594 30 30 31 31 // generate a pmDetections container with empty (allocated) footprints and peaks containers 32 pmDetections *pmDetectionsAlloc( ) {32 pmDetections *pmDetectionsAlloc(void) { 33 33 34 34 pmDetections *detections = (pmDetections *)psAlloc(sizeof(pmDetections)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmDetections.h
r18828 r23594 20 20 */ 21 21 typedef struct { 22 psArray *footprints; // collection of footprints in the image23 psArray *peaks; // collection of all peaks contained by the footprints24 psArray *oldPeaks; // collection of all peaks previously found22 psArray *footprints; // collection of footprints in the image 23 psArray *peaks; // collection of all peaks contained by the footprints 24 psArray *oldPeaks; // collection of all peaks previously found 25 25 int last; 26 26 } pmDetections; 27 27 28 pmDetections *pmDetectionsAlloc ( );28 pmDetections *pmDetectionsAlloc (void); 29 29 30 30 /// @} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmMoments.c
r23351 r23594 25 25 to zero. 26 26 *****************************************************************************/ 27 pmMoments *pmMomentsAlloc( )27 pmMoments *pmMomentsAlloc(void) 28 28 { 29 29 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmMoments.h
r19879 r23594 53 53 * 54 54 */ 55 pmMoments *pmMomentsAlloc( );55 pmMoments *pmMomentsAlloc(void); 56 56 57 57 /// @} -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmPSF.c
r20937 r23594 54 54 } 55 55 56 pmPSFOptions *pmPSFOptionsAlloc ( ) {56 pmPSFOptions *pmPSFOptionsAlloc (void) { 57 57 58 58 pmPSFOptions *options = (pmPSFOptions *) psAlloc(sizeof(pmPSFOptions)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmPSF.h
r21183 r23594 96 96 pmPSF *pmPSFAlloc (const pmPSFOptions *options); 97 97 bool psMemCheckPSF(psPtr ptr); 98 pmPSFOptions *pmPSFOptionsAlloc( );98 pmPSFOptions *pmPSFOptionsAlloc(void); 99 99 bool psMemCheckPSFOptions(psPtr ptr); 100 100 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSource.h
r23351 r23594 105 105 * 106 106 */ 107 pmSource *pmSourceAlloc( );107 pmSource *pmSourceAlloc(void); 108 108 109 109 /** pmSourceCopy() -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceExtendedPars.c
r21363 r23594 46 46 } 47 47 48 pmSourceExtendedPars *pmSourceExtendedParsAlloc ( ) {48 pmSourceExtendedPars *pmSourceExtendedParsAlloc (void) { 49 49 pmSourceExtendedPars *pars = (pmSourceExtendedPars *) psAlloc(sizeof(pmSourceExtendedPars)); 50 50 psMemSetDeallocator(pars, (psFreeFunc) pmSourceExtendedParsFree); … … 75 75 } 76 76 77 pmSourceRadialProfile *pmSourceRadialProfileAlloc ( ) {77 pmSourceRadialProfile *pmSourceRadialProfileAlloc (void) { 78 78 79 79 pmSourceRadialProfile *profile = (pmSourceRadialProfile *) psAlloc(sizeof(pmSourceRadialProfile)); … … 99 99 } 100 100 101 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc ( ) {101 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc (void) { 102 102 103 103 pmSourceIsophotalValues *isophot = (pmSourceIsophotalValues *) psAlloc(sizeof(pmSourceIsophotalValues)); … … 125 125 } 126 126 127 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc ( ) {127 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc (void) { 128 128 129 129 pmSourcePetrosianValues *petrosian = (pmSourcePetrosianValues *) psAlloc(sizeof(pmSourcePetrosianValues)); … … 150 150 } 151 151 152 pmSourceKronValues *pmSourceKronValuesAlloc ( ) {152 pmSourceKronValues *pmSourceKronValuesAlloc (void) { 153 153 154 154 pmSourceKronValues *kron = (pmSourceKronValues *) psAlloc(sizeof(pmSourceKronValues)); … … 181 181 } 182 182 183 pmSourceAnnuli *pmSourceAnnuliAlloc ( ) {183 pmSourceAnnuli *pmSourceAnnuliAlloc (void) { 184 184 185 185 pmSourceAnnuli *annuli = (pmSourceAnnuli *) psAlloc(sizeof(pmSourceAnnuli)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceExtendedPars.h
r21363 r23594 55 55 } pmSourceExtendedPars; 56 56 57 pmSourceExtendedPars *pmSourceExtendedParsAlloc ();57 pmSourceExtendedPars *pmSourceExtendedParsAlloc(void); 58 58 bool psMemCheckSourceExtendedPars(psPtr ptr); 59 pmSourceRadialProfile *pmSourceRadialProfileAlloc ();59 pmSourceRadialProfile *pmSourceRadialProfileAlloc(void); 60 60 bool psMemCheckSourceRadialProfile(psPtr ptr); 61 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc ();61 pmSourceIsophotalValues *pmSourceIsophotalValuesAlloc(void); 62 62 bool psMemCheckSourceIsophotalValues(psPtr ptr); 63 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc ();63 pmSourcePetrosianValues *pmSourcePetrosianValuesAlloc(void); 64 64 bool psMemCheckSourcePetrosianValues(psPtr ptr); 65 pmSourceKronValues *pmSourceKronValuesAlloc ();65 pmSourceKronValues *pmSourceKronValuesAlloc(void); 66 66 bool psMemCheckSourceKronValues(psPtr ptr); 67 pmSourceAnnuli *pmSourceAnnuliAlloc ();67 pmSourceAnnuli *pmSourceAnnuliAlloc(void); 68 68 bool psMemCheckSourceAnnuli(psPtr ptr); 69 69 -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceFitSet.c
r23351 r23594 67 67 } 68 68 69 void pmSourceFitSetDone ( ) {69 void pmSourceFitSetDone (void) { 70 70 psFree (fitSets); 71 71 } … … 150 150 } 151 151 152 pmSourceFitSetData *pmSourceFitSetDataGet ( ) {152 pmSourceFitSetData *pmSourceFitSetDataGet (void) { 153 153 154 154 psAssert (fitSets, "pmSourceFitSetInit not called"); … … 172 172 } 173 173 174 void pmSourceFitSetDataClear ( ) {174 void pmSourceFitSetDataClear (void) { 175 175 176 176 int i; -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourceFitSet.h
r21183 r23594 24 24 // use this function to init the fit sets based on the number of threads 25 25 bool pmSourceFitSetInit (int nThreads); 26 void pmSourceFitSetDone ( );26 void pmSourceFitSetDone (void); 27 27 28 28 // initialize data for a group of object models … … 32 32 // functions for selecting the FitSet corresponding to the current thread 33 33 pmSourceFitSetData *pmSourceFitSetDataSet (psArray *modelSet); 34 pmSourceFitSetData *pmSourceFitSetDataGet ( );35 void pmSourceFitSetDataClear ( );34 pmSourceFitSetData *pmSourceFitSetDataGet (void); 35 void pmSourceFitSetDataClear (void); 36 36 37 37 // function used to set limits for a group of models … … 54 54 */ 55 55 bool pmSourceFitSet( 56 pmSource *source, ///< The input pmSource57 psArray *modelSet, ///< model to be fitted58 pmSourceFitMode mode, ///< define parameters to be fitted59 psImageMaskType maskVal ///< Vale to mask56 pmSource *source, ///< The input pmSource 57 psArray *modelSet, ///< model to be fitted 58 pmSourceFitMode mode, ///< define parameters to be fitted 59 psImageMaskType maskVal ///< Vale to mask 60 60 61 61 ); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourcePlots.c
r19849 r23594 139 139 } 140 140 141 pmSourcePlotLayout *pmSourcePlotLayoutAlloc( )141 pmSourcePlotLayout *pmSourcePlotLayoutAlloc(void) 142 142 { 143 143 pmSourcePlotLayout *layout = (pmSourcePlotLayout *)psAlloc(sizeof(pmSourcePlotLayout)); -
branches/cnb_branches/cnb_branch_20090301/psModules/src/objects/pmSourcePlots.h
r15562 r23594 29 29 // typedef bool (*pmSourcePlotFunction)(pmConfig *config, pmFPAview *view, pmSourcePlotLayout *layout); 30 30 31 pmSourcePlotLayout *pmSourcePlotLayoutAlloc( );31 pmSourcePlotLayout *pmSourcePlotLayoutAlloc(void); 32 32 bool psMemCheckSourcePlotLayout(psPtr ptr); 33 33
Note:
See TracChangeset
for help on using the changeset viewer.
