Changeset 10966 for trunk/psModules/src/camera/pmFPAfileDefine.c
- Timestamp:
- Jan 8, 2007, 12:30:21 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileDefine.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileDefine.c
r10724 r10966 30 30 31 31 // define an input-type pmFPAfile, bind to the optional fpa if supplied 32 pmFPAfile *pmFPAfileDefineInput(pmConfig *config, pmFPA *fpa, c har *name)32 pmFPAfile *pmFPAfileDefineInput(pmConfig *config, pmFPA *fpa, const char *name) 33 33 { 34 34 PS_ASSERT_PTR_NON_NULL(config, NULL); 35 35 PS_ASSERT_PTR_NON_NULL(config->files, NULL); 36 36 PS_ASSERT_PTR_NON_NULL(config->camera, NULL); 37 PS_ASSERT_PTR_NON_NULL(name, NULL); 38 PS_ASSERT_INT_POSITIVE(strlen(name), NULL); 37 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 39 38 40 39 bool status; … … 50 49 // select the name from the FILERULES 51 50 // check for alias name (type == STR, name is aliased name) 52 c har *realname = psMetadataLookupStr (&status, filerules, name);51 const char *realname = psMetadataLookupStr (&status, filerules, name); 53 52 if (!realname || strlen(realname) == 0) { 54 53 realname = name; … … 107 106 108 107 // define a pmFPAfile, bind to the optional fpa if supplied 109 pmFPAfile *pmFPAfileDefineOutput(pmConfig *config, pmFPA *fpa, c har *name)108 pmFPAfile *pmFPAfileDefineOutput(pmConfig *config, pmFPA *fpa, const char *name) 110 109 { 111 110 PS_ASSERT_PTR_NON_NULL(config, NULL); 112 111 PS_ASSERT_PTR_NON_NULL(config->files, NULL); 113 112 PS_ASSERT_PTR_NON_NULL(config->camera, NULL); 114 PS_ASSERT_PTR_NON_NULL(name, NULL); 115 PS_ASSERT_INT_POSITIVE(strlen(name), NULL); 113 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 116 114 117 115 bool status; 118 char *type;119 116 120 117 // select the FILERULES from the camera config … … 127 124 // select the name from the FILERULES 128 125 // check for alias name (type == STR, name is aliased name) 129 c har *realname = psMetadataLookupStr (&status, filerules, name);126 const char *realname = psMetadataLookupStr (&status, filerules, name); 130 127 if (!realname || strlen(realname) == 0) { 131 128 realname = name; … … 148 145 file->extxtra = psMemIncrRefCounter(psMetadataLookupStr (&status, data, "EXTNAME.XTRA")); 149 146 150 type = psMetadataLookupStr (&status, data, "FILE.TYPE");147 const char *type = psMetadataLookupStr (&status, data, "FILE.TYPE"); 151 148 file->type = pmFPAfileTypeFromString(type); 152 149 if (file->type == PM_FPA_FILE_NONE) { … … 188 185 } 189 186 187 #if 0 190 188 // for WRITE type of data, the output format needs to be determined 191 189 // this is only needed if the output file is not identical in structure to the input? … … 231 229 psFree (words); 232 230 } 231 #endif 233 232 234 233 // add argument-supplied OUTPUT name to this file … … 248 247 // save the pmFPAfile on config->files 249 248 // return the pmFPAfile (a view to the one saved on config->files) 250 pmFPAfile *pmFPAfileDefineFromArgs (bool *found, pmConfig *config, c har *filename,char *argname)249 pmFPAfile *pmFPAfileDefineFromArgs (bool *found, pmConfig *config, const char *filename, const char *argname) 251 250 { 252 251 PS_ASSERT_PTR_NON_NULL(config, NULL); 253 PS_ASSERT_PTR_NON_NULL(filename, NULL); 254 PS_ASSERT_INT_POSITIVE(strlen(filename), NULL); 255 PS_ASSERT_PTR_NON_NULL(argname, NULL); 256 PS_ASSERT_INT_POSITIVE(strlen(argname), NULL); 252 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 253 PS_ASSERT_STRING_NON_EMPTY(argname, NULL); 257 254 258 255 bool status; … … 269 266 psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname); 270 267 if (!status) { 271 psTrace("psModules.camera", 5, "Failed to find %s in argument list", argname); 268 // psTrace("psModules.camera", 5, "Failed to find %s in argument list", argname); 269 psError(PS_ERR_UNEXPECTED_NULL, false, "Failed to find %s in argument list", argname); 272 270 return NULL; 273 271 } … … 296 294 return NULL; 297 295 } 298 psFitsClose (fits);296 psFitsClose(fits); 299 297 300 298 // determine the current format from the header … … 417 415 // save the pmFPAfiles on config->files 418 416 // return the pmFPAfiles (a view to the one saved on config->files) 419 pmFPAfile *pmFPAfileDefineSingleFromArgs (bool *found, pmConfig *config, char *filename, char *argname, int entry) 417 pmFPAfile *pmFPAfileDefineSingleFromArgs (bool *found, pmConfig *config, const char *filename, 418 const char *argname, int entry) 420 419 { 421 420 PS_ASSERT_PTR_NON_NULL(config, NULL); 422 PS_ASSERT_PTR_NON_NULL(filename, NULL); 423 PS_ASSERT_INT_POSITIVE(strlen(filename), NULL); 424 PS_ASSERT_PTR_NON_NULL(argname, NULL); 425 PS_ASSERT_INT_POSITIVE(strlen(argname), NULL); 421 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 422 PS_ASSERT_STRING_NON_EMPTY(argname, NULL); 426 423 427 424 bool status; … … 533 530 // define the named pmFPAfile from the camera->config 534 531 // only valid for pmFPAfile->mode = READ 535 pmFPAfile *pmFPAfileDefineFromConf (bool *found, pmConfig *config, c har *filename)532 pmFPAfile *pmFPAfileDefineFromConf (bool *found, pmConfig *config, const char *filename) 536 533 { 537 534 PS_ASSERT_PTR_NON_NULL(config, false); 538 PS_ASSERT_PTR_NON_NULL(filename, false); 539 PS_ASSERT_INT_POSITIVE(strlen(filename), false); 535 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 540 536 541 537 if (*found) { … … 603 599 // save the pmFPAfile on config->files 604 600 // return the pmFPAfile (a view to the one saved on config->files) 605 pmFPAfile *pmFPAfileDefineFromDetDB (bool *found, pmConfig *config, char *filename, pmFPA *input, pmDetrendType type) 601 pmFPAfile *pmFPAfileDefineFromDetDB (bool *found, pmConfig *config, const char *filename, 602 pmFPA *input, pmDetrendType type) 606 603 { 607 604 PS_ASSERT_PTR_NON_NULL(input, NULL); … … 609 606 PS_ASSERT_PTR_NON_NULL(config->camera, NULL); 610 607 PS_ASSERT_PTR_NON_NULL(config->files, NULL); 611 PS_ASSERT_ PTR_NON_NULL(filename, NULL);608 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 612 609 613 610 pmFPA *fpa = NULL; … … 681 678 // create a new output pmFPAfile based on an existing FPA 682 679 // only valid for pmFPAfile->mode == WRITE (or internal?) 683 pmFPAfile *pmFPAfileDefineFromFPA (pmConfig *config, pmFPA *src, int xBin, int yBin, c har *filename)680 pmFPAfile *pmFPAfileDefineFromFPA (pmConfig *config, pmFPA *src, int xBin, int yBin, const char *filename) 684 681 { 685 682 PS_ASSERT_PTR_NON_NULL(config, false); 686 683 PS_ASSERT_PTR_NON_NULL(src, false); 687 PS_ASSERT_PTR_NON_NULL(filename, false); 688 PS_ASSERT_INT_POSITIVE(strlen(filename), false); 689 690 pmFPA *fpa = pmFPAConstruct (src->camera); 684 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 685 686 // Need to look up the format 687 bool mdok; // Status of MD lookup 688 psMetadata *formats = psMetadataLookupMetadata(&mdok, src->camera, "FORMATS"); // The FORMATS 689 if (!mdok || !formats) { 690 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n", 691 config->cameraName); 692 return NULL; 693 } 694 psMetadata *format = psMetadataLookupMetadata(&mdok, formats, config->formatName); // The format 695 if (!mdok || !format) { 696 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find camera format %s within camera %s.\n", 697 config->formatName, config->cameraName); 698 return NULL; 699 } 700 701 pmFPA *fpa = pmFPAConstruct(src->camera); 691 702 pmFPAfile *file = pmFPAfileDefineOutput (config, fpa, filename); 692 703 if (!file) { … … 697 708 file->xBin = xBin; 698 709 file->yBin = yBin; 710 file->format = psMemIncrRefCounter(format); 699 711 700 712 psFree (fpa); … … 704 716 // create a new output pmFPAfile based on an existing FPA 705 717 // only valid for pmFPAfile->mode == WRITE (or internal?) 706 pmFPAfile *pmFPAfileDefineNewCamera (pmConfig *config, c har *filename)718 pmFPAfile *pmFPAfileDefineNewCamera (pmConfig *config, const char *filename) 707 719 { 708 720 PS_ASSERT_PTR_NON_NULL(config, false); 709 PS_ASSERT_PTR_NON_NULL(filename, false); 710 PS_ASSERT_INT_POSITIVE(strlen(filename), false); 721 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 711 722 712 723 pmFPAfile *file = pmFPAfileDefineOutput (config, NULL, filename); … … 724 735 } 725 736 737 pmFPAfile *pmFPAfileDefineChipMosaic(pmConfig *config, pmFPA *src, const char *filename) 738 { 739 PS_ASSERT_PTR_NON_NULL(config, NULL); 740 PS_ASSERT_PTR_NON_NULL(src, NULL); 741 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 742 PS_ASSERT_STRING_NON_EMPTY(config->cameraName, NULL); 743 PS_ASSERT_STRING_NON_EMPTY(config->formatName, NULL); 744 745 if (config->cameraName[0] == '_' && 746 strcmp(config->cameraName + strlen(config->cameraName) - 5, "-CHIP") == 0) { 747 // The input camera has already been mosaicked to this level 748 pmFPAfile *file = pmFPAfileDefineOutput(config, NULL, filename); 749 file->camera = psMemIncrRefCounter(config->camera); 750 file->format = psMemIncrRefCounter(config->format); 751 file->fpa = pmFPAConstruct(file->camera); 752 return file; 753 } 754 755 // Find the correct camera configuration 756 bool mdok; // Status of MD lookup 757 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->site, "CAMERAS"); // Camera configurations 758 if (!mdok || !cameras) { 759 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n"); 760 return NULL; 761 } 762 psString name = NULL; // Name of the new (automatically-generated) camera configuration 763 psStringAppend(&name, "_%s-CHIP", config->cameraName); 764 psMetadata *camera = psMetadataLookupMetadata(&mdok, cameras, name); // Camera configuration of interest 765 if (!mdok || !camera) { 766 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find automatically generated " 767 "camera configuration %s in site configuration.\n", name); 768 psFree(name); 769 return NULL; 770 } 771 psFree(name); 772 773 // Need to look up the format of the same name, but under the mosaic camera 774 psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // The FORMATS 775 if (!mdok || !formats) { 776 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n", 777 config->cameraName); 778 return NULL; 779 } 780 psMetadata *format = psMetadataLookupMetadata(&mdok, formats, config->formatName); // The format 781 if (!mdok || !format) { 782 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find camera format %s within camera %s.\n", 783 config->formatName, config->cameraName); 784 return NULL; 785 } 786 787 pmFPA *fpa = pmFPAConstruct(camera); 788 if (!fpa) { 789 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate mosaicked camera.\n"); 790 return NULL; 791 } 792 pmFPAfile *file = pmFPAfileDefineOutput(config, fpa, filename); 793 if (!file) { 794 psErrorStackPrint(stderr, "file %s not defined\n", filename); 795 return NULL; 796 } 797 file->src = src; // inherit output elements from this source pmFPA 798 file->mosaicLevel = PM_FPA_LEVEL_CHIP; // don't do any I/O on this at a lower level 799 file->format = psMemIncrRefCounter(format); 800 801 psFree(fpa); 802 803 return file; 804 } 805 806 pmFPAfile *pmFPAfileDefineFPAMosaic(pmConfig *config, pmFPA *src, const char *filename) 807 { 808 PS_ASSERT_PTR_NON_NULL(config, NULL); 809 PS_ASSERT_PTR_NON_NULL(src, NULL); 810 PS_ASSERT_STRING_NON_EMPTY(filename, NULL); 811 PS_ASSERT_STRING_NON_EMPTY(config->cameraName, NULL); 812 813 if (config->cameraName[0] == '_' && 814 strcmp(config->cameraName + strlen(config->cameraName) - 4 , "-FPA") == 0) { 815 // The input camera has already been mosaicked to this level 816 pmFPAfile *file = pmFPAfileDefineOutput(config, NULL, filename); 817 file->camera = psMemIncrRefCounter(config->camera); 818 file->format = psMemIncrRefCounter(config->format); 819 file->fpa = pmFPAConstruct(file->camera); 820 return file; 821 } 822 823 // Find the correct camera configuration 824 bool mdok; // Status of MD lookup 825 psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->site, "CAMERAS"); // Camera configurations 826 if (!mdok || !cameras) { 827 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the site configuration.\n"); 828 return NULL; 829 } 830 psString original; // Name of the original camera configuration 831 psString name = NULL; // Name of the new (automatically-generated) camera configuration 832 if (config->cameraName[0] == '_' && 833 strcmp(config->cameraName + strlen(config->cameraName) - 5 , "-CHIP") == 0) { 834 // It's a chip mosaic; we need to get the original name 835 original = psStringNCopy(config->cameraName + 1, strlen(config->cameraName) - 6); 836 } else { 837 original = psMemIncrRefCounter(config->cameraName); 838 } 839 psStringAppend(&name, "_%s-FPA", original); 840 psFree(original); 841 psMetadata *camera = psMetadataLookupMetadata(&mdok, cameras, name); // Camera configuration of interest 842 if (!mdok || !camera) { 843 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find automatically generated " 844 "camera configuration %s in site configuration.\n", name); 845 psFree(name); 846 return NULL; 847 } 848 psFree(name); 849 850 // Need to look up the format of the same name, but under the mosaic camera 851 psMetadata *formats = psMetadataLookupMetadata(&mdok, camera, "FORMATS"); // The FORMATS 852 if (!mdok || !formats) { 853 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find FORMATS in camera configuration %s.\n", 854 config->cameraName); 855 return NULL; 856 } 857 psMetadata *format = psMetadataLookupMetadata(&mdok, formats, config->formatName); // The format 858 if (!mdok || !format) { 859 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find camera format %s within camera %s.\n", 860 config->formatName, config->cameraName); 861 return NULL; 862 } 863 864 pmFPA *fpa = pmFPAConstruct(camera); 865 if (!fpa) { 866 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate mosaicked camera.\n"); 867 return NULL; 868 } 869 pmFPAfile *file = pmFPAfileDefineOutput(config, fpa, filename); 870 if (!file) { 871 psErrorStackPrint(stderr, "file %s not defined\n", filename); 872 return NULL; 873 } 874 file->src = src; // inherit output elements from this source pmFPA 875 file->mosaicLevel = PM_FPA_LEVEL_FPA; // don't do any I/O on this at a lower level 876 file->format = psMemIncrRefCounter(format); 877 878 psFree(fpa); 879 880 return file; 881 } 882 726 883 // create a file with the given name, assign it type "INTERNAL", and supply it with an image 727 884 // of the requested dimensions. (image only, mask and weight are ignored) 728 pmReadout *pmFPAfileDefineInternal (psMetadata *files, c har *name, int Nx, int Ny, int type)885 pmReadout *pmFPAfileDefineInternal (psMetadata *files, const char *name, int Nx, int Ny, int type) 729 886 { 730 887 PS_ASSERT_PTR_NON_NULL(files, false); 731 PS_ASSERT_PTR_NON_NULL(name, false); 732 PS_ASSERT_INT_POSITIVE(strlen(name), false); 888 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 733 889 734 890 pmReadout *readout = pmReadoutAlloc(NULL); … … 748 904 } 749 905 750 bool pmFPAfileDropInternal(psMetadata *files, c har *name)906 bool pmFPAfileDropInternal(psMetadata *files, const char *name) 751 907 { 752 908 PS_ASSERT_PTR_NON_NULL(files, false); 753 PS_ASSERT_PTR_NON_NULL(name, false); 754 PS_ASSERT_INT_POSITIVE(strlen(name), false); 909 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 755 910 756 911 bool status = false;
Note:
See TracChangeset
for help on using the changeset viewer.
