Changeset 1143 in Sophya for trunk/SophyaExt/FitsIOServer/fitsfile.cc
- Timestamp:
- Aug 25, 2000, 5:52:48 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsfile.cc
r1136 r1143 40 40 FitsFile::~FitsFile() 41 41 { 42 cout << " destructeur FitsFile " << endl;43 42 int status = 0; 44 43 if( fptr_ != NULL) … … 106 105 void FitsInFile::InitNull() 107 106 { 108 cout << " init FitsInFile " << endl;109 107 bitpix_ = 0; 110 108 naxis_ = 0; … … 215 213 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status); 216 214 if( status ) printerror( status ); 217 // cout << " dimension lue " << naxis << endl;218 215 // read the NAXISn keywords to get image size 219 216 long* naxes = new long[naxis] ; … … 232 229 233 230 234 //void FitsInFile::ReadFInit(char flnm[],int hdunum)235 231 void FitsInFile::ReadFInit(int hdunum) 236 232 { 237 //InitNull();233 InitNull(); 238 234 // int status = 0; 239 235 … … 275 271 } 276 272 273 DVList FitsInFile::DVListFromPrimaryHeader() const 274 { 275 int status; 276 DVList dvl; 277 KeywordsIntoDVList(fptr_, dvl, 1); 278 int hdutype = 0; 279 if (hdunum_ > 0) fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status); 280 return dvl; 281 } 277 282 278 283 … … 281 286 int status = 0; 282 287 int hdutype; 288 InitNull(); 283 289 fits_movrel_hdu(fptr_, 1,&hdutype,&status); 284 290 if( status ) printerror( status," lecture du header suivant" ); … … 484 490 void FitsInFile::GetBinTabFCol(int* valeurs,int nentries, int NoCol) const 485 491 { 486 cout <<" entree GetBinTabFCol " << endl;487 492 int status= 0; 488 493 int DTYPE; … … 735 740 char card[FLEN_CARD]; 736 741 char *comkey = "COMMENT"; 742 char comment[FLEN_COMMENT]; 737 743 738 744 // shift with the number of mandatory keywords 739 int num= 8; 740 745 // int num= 8; 746 int num= 0; 747 // primary header 748 if (hdunum == 1) 749 { 750 // read NAXIS 751 int naxis=0; 752 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status); 753 // number of mandatory keywords 754 num = naxis+3; 755 } 756 // extensions 757 else 758 { 759 if (hdutype == IMAGE_HDU) 760 { 761 // read NAXIS 762 int naxis=0; 763 fits_read_key(fileptr,TINT,"NAXIS",&naxis,NULL,&status); 764 // number of mandatory keywords 765 num = naxis+5; 766 } 767 else 768 if(hdutype == ASCII_TBL || hdutype == BINARY_TBL) 769 { 770 // number of mandatory keywords 771 num = 8; 772 } 773 } 741 774 int j; 742 775 for(j = num+1; j <= nkeys; j++) … … 760 793 { 761 794 case 'C': 762 dvl[keyname]= strval; 795 fits_read_key(fileptr,TSTRING,keyname,strval,comment,&status); 796 dvl[keyname]= strval; 797 dvl.SetComment(keyname, comment); 763 798 break; 764 799 case 'I': 765 800 int ival; 766 fits_read_key(fileptr,TINT,keyname,&ival, NULL,&status);801 fits_read_key(fileptr,TINT,keyname,&ival,comment,&status); 767 802 dvl[keyname]= (int_4) ival; // Portage mac DY 803 dvl.SetComment(keyname, comment); 768 804 break; 769 805 case 'L': 770 806 int ilog; 771 if(strncmp(strval,"T",1) == 0) ilog= 1; 772 else ilog= 0; 807 fits_read_key(fileptr,TLOGICAL,keyname,&ilog,comment,&status); 773 808 dvl[keyname]= (int_4) ilog; 809 dvl.SetComment(keyname, comment); 774 810 break; 775 811 case 'F': 776 812 double dval; 777 fits_read_key(fileptr,TDOUBLE,keyname,&dval, NULL,&status);813 fits_read_key(fileptr,TDOUBLE,keyname,&dval,comment,&status); 778 814 dvl[keyname]= dval; 815 dvl.SetComment(keyname, comment); 779 816 break; 780 817 } … … 817 854 818 855 819 void FitsOutFile::makeHeaderImageOnFits(char type, int nbdim, int* naxisn )856 void FitsOutFile::makeHeaderImageOnFits(char type, int nbdim, int* naxisn, DVList &dvl) 820 857 { 821 858 int status = 0; … … 824 861 if (hdunum_ == 1) 825 862 { 826 if (imageOnPrimary_ == false) fits_create_img(fptr_,FLOAT_IMG,0,naxes,&status); 863 if (imageOnPrimary_ == false) 864 { 865 fits_create_img(fptr_,FLOAT_IMG,0,naxes,&status); 866 writeSignatureOnFits(); } 827 867 else hdunum_--; 828 868 } … … 844 884 845 885 hdunum_++; 886 887 // write supplementary keywords 888 // dvl.Print(); 889 addKeywordsOfDVList(dvl); 890 846 891 delete [] naxes; 847 892 if( status ) printerror( status, "erreur creation HDU IMAGE" ); … … 854 899 fits_write_img(fptr_,TDOUBLE,1,npix,map,&status); 855 900 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 856 writeSignatureOnFits();901 // writeSignatureOnFits(); 857 902 } 858 903 … … 863 908 fits_write_img(fptr_,TFLOAT,1,npix, map,&status); 864 909 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 865 writeSignatureOnFits();910 // writeSignatureOnFits(); 866 911 867 912 } … … 873 918 fits_write_img(fptr_,TINT,1,npix,map,&status); 874 919 if( status ) printerror( status, "erreur ecriture putImageToFits" ); 875 writeSignatureOnFits();920 // writeSignatureOnFits(); 876 921 } 877 922 … … 954 999 // 955 1000 // write supplementary keywords 956 // 957 // get names and values from the join DVList object 958 // dvl.Print(); 959 fits_write_comment(fptr_,"--------------------------------------", &status); 960 DVList::ValList::const_iterator it; 961 for(it = dvl.Begin(); it != dvl.End(); it++) 962 { 963 char keytype= (*it).second.elval.typ; 964 char keyname[10]; 965 strncpy(keyname,(*it).first.substr(0,64).c_str(),10); 966 char comment[FLEN_COMMENT]; 967 switch (keytype) 968 { 969 case 'I' : 970 { 971 int ival=(*it).second.elval.iv; 972 strncpy(comment,(*it).second.elcomm.c_str(),FLEN_COMMENT ); 973 fits_write_key(fptr_,TINT,keyname,&ival,comment,&status); 974 break; 975 } 976 case 'D' : 977 { 978 double dval=(*it).second.elval.dv; 979 strncpy(comment,(*it).second.elcomm.c_str(),FLEN_COMMENT ); 980 fits_write_key(fptr_,TDOUBLE,keyname,&dval,comment,&status); 981 break; 982 } 983 case 'S' : 984 { 985 char strval[128]; 986 strncpy(strval,(*it).second.elval.strv->c_str(),127); 987 strncpy(comment,(*it).second.elcomm.c_str(),FLEN_COMMENT ); 988 fits_write_key(fptr_,TSTRING,keyname,&strval,comment,&status); 989 break; 990 } 991 } 992 if( status ) printerror( status,"fitsfile: probleme ecriture mot-cle du dvlist" ); 993 } 994 fits_write_comment(fptr_,"--------------------------------------", &status); 1001 addKeywordsOfDVList(dvl); 995 1002 996 1003 } … … 1097 1104 } 1098 1105 1106 void FitsOutFile::DVListIntoPrimaryHeader(DVList& dvl) const 1107 { 1108 int status = 0; 1109 int hdutype; 1110 fits_movabs_hdu(fptr_,1,&hdutype,&status); 1111 addKeywordsOfDVList(dvl); 1112 fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status); 1113 } 1114 1099 1115 1100 1116 void FitsOutFile::writeSignatureOnFits() const … … 1110 1126 fits_write_key(fptr_, TSTRING, keyname, &strval, comment, &status); 1111 1127 if( status ) printerror( status ); 1112 1128 fits_write_date(fptr_, &status); 1113 1129 fits_write_comment(fptr_,"..............................................", &status); 1114 1130 fits_write_comment(fptr_, " SOPHYA package - FITSIOSever ", &status); … … 1120 1136 1121 1137 1122 1123 1124 1138 void FitsOutFile::addKeywordsOfDVList(DVList& dvl) const 1139 { 1140 int status = 0; 1141 fits_write_comment(fptr_,"---------- keywords from SOPHYA ---------", &status); 1142 if (hdunum_ == 1) writeSignatureOnFits(); 1143 DVList::ValList::const_iterator it; 1144 for(it = dvl.Begin(); it != dvl.End(); it++) 1145 { 1146 char keytype= (*it).second.elval.typ; 1147 char keyname[10]; 1148 strncpy(keyname,(*it).first.substr(0,64).c_str(),10); 1149 char comment[FLEN_COMMENT]; 1150 char strval[FLEN_VALUE]= ""; 1151 char *comkey = "COMMENT"; 1152 fits_read_keyword(fptr_, keyname, strval, NULL, &status); 1153 if (status != 0 || strncmp(keyname,comkey,LEN_KEYWORD-1) == 0 ) 1154 { 1155 status = 0; 1156 switch (keytype) 1157 { 1158 case 'I' : 1159 { 1160 int ival=(*it).second.elval.iv; 1161 strncpy(comment,(*it).second.elcomm.c_str(),FLEN_COMMENT ); 1162 fits_write_key(fptr_,TINT,keyname,&ival,comment,&status); 1163 break; 1164 } 1165 case 'D' : 1166 { 1167 double dval=(*it).second.elval.dv; 1168 strncpy(comment,(*it).second.elcomm.c_str(),FLEN_COMMENT ); 1169 fits_write_key(fptr_,TDOUBLE,keyname,&dval,comment,&status); 1170 break; 1171 } 1172 case 'S' : 1173 { 1174 char strval[128]; 1175 strncpy(strval,(*it).second.elval.strv->c_str(),127); 1176 strncpy(comment,(*it).second.elcomm.c_str(),FLEN_COMMENT ); 1177 fits_write_key(fptr_,TSTRING,keyname,&strval,comment,&status); 1178 break; 1179 } 1180 } 1181 } 1182 if( status ) printerror( status,"fitsfile: probleme ecriture mot-cle du dvlist" ); 1183 } 1184 fits_write_comment(fptr_,"--------------------------------------", &status); 1185 } 1186 1187 1188
Note:
See TracChangeset
for help on using the changeset viewer.