Changeset 2197 in Sophya for trunk/SophyaExt
- Timestamp:
- Sep 24, 2002, 4:03:36 PM (23 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/exclude
r1221 r2197 4 4 fitsbntbllinereader.travail.cc 5 5 fitsbntbllinereader.sv.cc 6 fitsspherethetaphi.cc -
trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.cc
r1359 r2197 16 16 } 17 17 18 FITS_BntblLineReader::FITS_BntblLineReader(c har inputfile[],int hdunum)18 FITS_BntblLineReader::FITS_BntblLineReader(const char inputfile[],int hdunum) 19 19 20 20 { … … 134 134 for (k=0; k<ic;k++) 135 135 { 136 types+=' I';136 types+='J'; 137 137 } 138 138 for (k=0; k<lc;k++) -
trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.h
r1359 r2197 19 19 public: 20 20 FITS_BntblLineReader(); 21 FITS_BntblLineReader(c har inputfile[],int hdunum=2);21 FITS_BntblLineReader(const char inputfile[],int hdunum=2); 22 22 ~FITS_BntblLineReader(); 23 23 -
trunk/SophyaExt/FitsIOServer/fitsfile.cc
r2129 r2197 26 26 if (dc >0) ddata_ = vector<double>(dc); 27 27 if (fc >0) fdata_ = vector<float>(fc); 28 if (ic >0) idata_ = vector<int>(fc); 29 if (cc >0) cdata_ = vector<string>(fc); 28 if (ic >0) idata_ = vector<int>(ic); 30 29 if (lc >0) ldata_ = vector<long>(lc); 31 30 if (bc >0) bdata_ = vector<unsigned char>(bc); 31 if (cc >0) cdata_ = vector<string>(cc); 32 32 } 33 33 … … 66 66 } 67 67 68 68 FitsFile::BufferLine::BufferLine(const vector<FitsFile::FitsDataType>& types) 69 { 70 71 72 int dc=0; 73 int fc=0; 74 int shc=0; 75 int ic=0; 76 int lc=0; 77 int cc=0; 78 int bc=0; 79 id_ = vector< pair<FitsFile::FitsDataType, int> >(types.size()); 80 for (int k= 0; k < types.size(); k++) 81 { 82 switch( types[k] ) 83 { 84 case FitsFile::FitsDataType_double : 85 { 86 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_double, dc); 87 dc++; 88 break; 89 } 90 case FitsFile::FitsDataType_float : 91 { 92 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_float, fc); 93 fc++; 94 break; 95 } 96 case FitsFile::FitsDataType_short : 97 { 98 id_[k] = pair<FitsFile::FitsDataType, int>(FitsDataType_short, shc); 99 shc++; 100 break; 101 } 102 case FitsFile::FitsDataType_int : 103 { 104 id_[k] = pair<FitsFile::FitsDataType, int>(FitsDataType_int, ic); 105 ic++; 106 break; 107 } 108 case FitsFile::FitsDataType_long : 109 { 110 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_long, lc); 111 lc++; 112 break; 113 } 114 case FitsFile::FitsDataType_byte : 115 { 116 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_byte, bc); 117 bc++; 118 break; 119 } 120 case FitsDataType_char : 121 { 122 id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_char, cc); 123 cc++; 124 break; 125 } 126 default: 127 { 128 throw PException(" FitsFile::getHeaderWithSophyaObject() : unsupported FITS data type"); 129 } 130 } 131 } 132 133 if (dc >0) ddata_ = vector<r_8>(dc); 134 if (fc >0) fdata_ = vector<r_4>(fc); 135 if (shc >0) shdata_ = vector<int_2>(shc); 136 if (ic >0) idata_ = vector<int_4>(ic); 137 if (lc >0) ldata_ = vector<int_8>(lc); 138 if (cc >0) cdata_ = vector<string>(cc); 139 if (bc >0) bdata_ = vector<unsigned char>(bc); 140 } 141 142 143 void FitsFile::BufferLine::Print() const 144 { 145 cout << " impression de la ligne: " << endl; 146 147 cout << " doubles : " << endl; 148 for (int k=0; k< ddata_.size(); k++) 149 { 150 cout << ddata_[k] << " " ; 151 } 152 cout << endl; 153 154 cout << " floats : " << endl; 155 for (int k=0; k< fdata_.size(); k++) 156 { 157 cout << fdata_[k] << " " ; 158 } 159 cout << endl; 160 161 cout << " entiers courts: " << endl; 162 for (int k=0; k< shdata_.size(); k++) 163 { 164 cout << shdata_[k] << " " ; 165 } 166 cout << endl; 167 cout << " entiers : " << endl; 168 for (int k=0; k< idata_.size(); k++) 169 { 170 cout << idata_[k] << " " ; 171 } 172 cout << endl; 173 174 cout << " entiers longs : " << endl; 175 for (int k=0; k< ldata_.size(); k++) 176 { 177 cout << ldata_[k] << " " ; 178 } 179 cout << endl; 180 181 cout << " chaines carac. : " << endl; 182 for (int k=0; k< cdata_.size(); k++) 183 { 184 cout << cdata_[k] << " " ; 185 } 186 cout << endl; 187 188 cout << " bytes : " << endl; 189 for (int k=0; k< bdata_.size(); k++) 190 { 191 cout << (char)bdata_[k] << " " ; 192 } 193 cout << endl; 194 195 196 } 69 197 70 198 /*! … … 601 729 // printerror( status,":FitsInFile::getHeader : erreur movabs"); 602 730 } 731 732 603 733 if(hdutype == IMAGE_HDU) 604 734 { … … 627 757 KeywordsIntoDVList(fptr_, dvl_, hdunum_); 628 758 } 759 760 } 761 if (hdutype_ == FitsExtensionType_BINARY_TBL || hdutype_ == FitsExtensionType_ASCII_TBL) 762 { 763 bfl_ = BufferLine(types_); 629 764 } 630 765 } … … 736 871 } 737 872 return taille_des_chaines_[index]; 873 } 874 875 const FitsFile::BufferLine& FitsInFile::GetBufferLine(long NoLine) 876 { 877 int status= 0; 878 int anynul; 879 double dnull= dnull_; 880 float fnull= fnull_; 881 int inull= inull_; 882 char* cnull= const_cast<char*>(cnull_.c_str()); 883 int ncol; 884 long nels=1; 885 double dval; 886 float fval; 887 int ival; 888 889 // pas d'entier de longueur superieure a 32 bits, pour cfitsio 890 int lval; 891 892 unsigned char usval; 893 int rang = 0; 894 int ccount = 0; 895 for (ncol=0; ncol<nbcols_; ncol++) 896 { 897 rang = bfl_.identificateur()[ncol].second; 898 // cout << " fitsfile : relecture col " << ncol << " type " << bfl_.identificateur()[ncol].first << " rang " << rang << endl; 899 switch (bfl_.identificateur()[ncol].first) 900 { 901 case FitsDataType_double : 902 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull, &dval,&anynul,&status); 903 bfl_.r_8Array(rang) = (r_8)dval; 904 break; 905 case FitsDataType_float : 906 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fval,&anynul,&status); 907 bfl_.r_4Array(rang) = (r_4)fval; 908 break; 909 case FitsDataType_short : 910 fits_read_col(fptr_,TSHORT,ncol+1,NoLine+1,1,1,&inull,&ival, &anynul,&status); 911 bfl_.int_2Array(rang) = (int_2)ival; 912 break; 913 case FitsDataType_int : 914 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ival, &anynul,&status); 915 bfl_.int_4Array(rang) = (int_4)ival; 916 break; 917 case FitsDataType_long : 918 fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&lval, &anynul,&status); 919 bfl_.int_8Array(rang) = (int_8)lval; 920 break; 921 case FitsDataType_byte : 922 fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull, &usval, &anynul,&status); 923 bfl_.u_charArray(rang) = usval; 924 break; 925 case FitsDataType_char : 926 char* chaine = new char[taille_des_chaines_[ccount++]]; 927 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status); 928 bfl_.stringArray(rang) = string(chaine); 929 break; 930 } 931 if (status) 932 { 933 ResetStatus(status); 934 break; 935 } 936 } 937 // cout << " fitsfile : ligne relue " << endl; 938 // bfl_.Print(); 939 return bfl_; 738 940 } 739 941 … … 778 980 break; 779 981 } 780 case FitsDataType_float : 781 fits_read_col(fptr_,TFLOAT,ncol+1,ligneALire,premierElement,1,&fnull,&fdata[fcount++],&anynul,&status); 782 break; 982 case FitsDataType_float : 983 { 984 fits_read_col(fptr_,TFLOAT,ncol+1,ligneALire,premierElement,1,&fnull,&fdata[fcount++],&anynul,&status); 985 break; 986 } 783 987 case FitsDataType_int : 784 fits_read_col(fptr_,TINT,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++], 988 { 989 fits_read_col(fptr_,TINT,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++], 785 990 &anynul,&status); 786 break; 991 break; 992 } 787 993 case FitsDataType_long : 788 fits_read_col(fptr_,TLONG,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++], &anynul,&status); 789 break; 994 { 995 fits_read_col(fptr_,TLONG,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++], &anynul,&status); 996 break; 997 } 790 998 case FitsDataType_byte : 791 999 { … … 793 1001 fits_read_col(fptr_,TBYTE,ncol+1,ligneALire,premierElement,1,&inull,&uschar, &anynul,&status); 794 1002 idata[icount++] = (int)uschar; 795 }796 break;1003 break; 1004 } 797 1005 case FitsDataType_char : 798 fits_read_col(fptr_,TSTRING,ncol+1,ligneALire,premierElement,1,cnull,&cdata[ccount++],&anynul,&status); 799 break; 1006 { 1007 fits_read_col(fptr_,TSTRING,ncol+1,ligneALire,premierElement,1,cnull,&cdata[ccount++],&anynul,&status); 1008 break; 1009 } 1010 default: 1011 { 1012 throw PException(" FitsInFile::GetBinTabLine : unsupported FITS data type"); 1013 } 800 1014 } 801 1015 if (status) … … 829 1043 { 830 1044 case FitsDataType_double : 831 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ligne.ddata_[dcount++],&anynul,&status); 832 break; 1045 { 1046 fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ligne.ddata_[dcount++],&anynul,&status); 1047 break; 1048 } 833 1049 case FitsDataType_float : 834 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&ligne.fdata_[fcount++],&anynul,&status); 835 break; 1050 { 1051 fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&ligne.fdata_[fcount++],&anynul,&status); 1052 break; 1053 } 836 1054 case FitsDataType_int : 837 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ligne.idata_[icount++], &anynul,&status); 838 break; 1055 { 1056 fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ligne.idata_[icount++], &anynul,&status); 1057 break; 1058 } 839 1059 case FitsDataType_long : 840 fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&ligne.ldata_[icount++], &anynul,&status); 841 break; 1060 { 1061 fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&ligne.ldata_[icount++], &anynul,&status); 1062 break; 1063 } 842 1064 case FitsDataType_byte : 843 fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull,&ligne.bdata_[icount++], &anynul,&status); 844 break; 1065 { 1066 fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull,&ligne.bdata_[icount++], &anynul,&status); 1067 break; 1068 } 845 1069 case FitsDataType_char : 846 char* chaine = new char[taille_des_chaines_[ccount]]; 847 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status); 848 ligne.cdata_[ccount++] = string(chaine); 849 break; 1070 { 1071 char* chaine = new char[taille_des_chaines_[ccount]]; 1072 fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status); 1073 ligne.cdata_[ccount++] = string(chaine); 1074 break; 1075 } 1076 default: 1077 { 1078 throw PException(" FitsInFile::GetBinTabLine : unsupported FITS data type"); 1079 } 850 1080 } 851 1081 if (status) … … 856 1086 } 857 1087 } 1088 1089 858 1090 859 1091 /*! \fn void SOPHYA::FitsInFile::GetBinTabLine(int NoLine, float* fdata) … … 945 1177 long repeat,width; 946 1178 fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status); 947 cout << " en lecture fits trouve le type " << DTYPE << endl;948 1179 if( DTYPE != TLONG && DTYPE != TINT) 949 1180 { … … 1137 1368 int rept=0; 1138 1369 if(hdutype == ASCII_TBL) 1139 {1140 for(ii = 0; ii < nbcols; ii++)1141 {1142 int DTYPE;1143 long width;1144 long repete = 0;1145 fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status);1146 if( status ) printerror( status,"erreur lecture type de colonne");1147 rept = repete;1148 noms.push_back(string(ttype[ii]));1149 switch (DTYPE)1150 {1151 case TDOUBLE :1152 types.push_back(FitsDataType_double);1153 break;1154 case TFLOAT :1155 types.push_back(FitsDataType_float);1156 break;1157 case TLONG :1158 types.push_back(FitsDataType_long);1159 break;1160 case TSHORT :1161 types.push_back(FitsDataType_int);1162 break;1163 case TSTRING :1164 types.push_back(FitsDataType_char);1165 taille_des_chaines.push_back(width);1166 rept/=width;1167 break;1168 default :1169 cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl;1170 throw IOExc("FitsFile::GetBinTabParameters, unsupported data type of field, for ASCII table");1171 }1172 repeat.push_back(rept);1173 }1174 }1175 else1176 1370 { 1177 1371 for(ii = 0; ii < nbcols; ii++) … … 1199 1393 break; 1200 1394 case TSHORT : 1395 types.push_back(FitsDataType_short); 1396 break; 1397 case TSTRING : 1398 types.push_back(FitsDataType_char); 1399 taille_des_chaines.push_back(width); 1400 rept/=width; 1401 break; 1402 default : 1403 cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl; 1404 throw IOExc("FitsFile::GetBinTabParameters, unsupported data type of field, for ASCII table"); 1405 } 1406 repeat.push_back(rept); 1407 } 1408 } 1409 else 1410 { 1411 for(ii = 0; ii < nbcols; ii++) 1412 { 1413 int DTYPE; 1414 long width; 1415 long repete = 0; 1416 fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status); 1417 if( status ) printerror( status,"erreur lecture type de colonne"); 1418 rept = repete; 1419 noms.push_back(string(ttype[ii])); 1420 switch (DTYPE) 1421 { 1422 case TDOUBLE : 1423 types.push_back(FitsDataType_double); 1424 break; 1425 case TFLOAT : 1426 types.push_back(FitsDataType_float); 1427 break; 1428 case TLONG : 1429 types.push_back(FitsDataType_long); 1430 break; 1431 case TINT : 1201 1432 types.push_back(FitsDataType_int); 1433 break; 1434 case TSHORT : 1435 types.push_back(FitsDataType_short); 1202 1436 break; 1203 1437 case TSTRING : … … 1718 1952 1719 1953 1720 // la logique voudrait qu'on distingue TLONG et TINT. Mais si j'ecris1721 // et relis immediatement quelque chose en TLONG l'experience montre 1722 // que ca foire. Donc, je fais tout en TINT, d'ailleurs cfitsio n'a pas 1723 // (apparemment) d'entiers de longueur superieure a 32 bits.1724 // En fait, je n'y comprend rien. A suivre (GLM). 1725 if (code == TINT || code == TLONG )1726 {1727 cout << " j'ecris des TINT" << endl;1954 1955 if (code == TINT || code == TLONG) 1956 { 1957 // cfitsio n'a que des entiers de longueur inferieure a 32 bits. 1958 // ici, a l'ecriture TLONG impliquerait que le tableau de donnees 1959 // soit un tableau int_8. Donc c'est toujours TINT qu;il faut mettre 1960 // De plus, j'ai l'impression que TINT va devenir obsolete dans cfitsio 1961 // (GLM) 1728 1962 fits_write_col(fptr_,TINT,nocol+1,1,1,nentries, donnees ,&status); 1729 }1730 else if (code == TSHORT)1731 {1732 cout << " j'ecris des TSHORT " << endl;1733 fits_write_col(fptr_,TSHORT,nocol+1,1,1,nentries, donnees ,&status);1734 1963 } 1735 1964 else … … 2211 2440 { 2212 2441 cout << "FitsKeyword : complex keyword value not supported" << endl;; 2442 break; 2213 2443 } 2214 2444 default : -
trunk/SophyaExt/FitsIOServer/fitsfile.h
r1978 r2197 17 17 18 18 struct BnTblLine; 19 class BufferLine; 19 20 class FitsFile; 20 21 class FitsInFile; … … 96 97 FitsDataType_ASCII, 97 98 FitsDataType_long, 98 FitsDataType_byte 99 FitsDataType_byte, 100 FitsDataType_short 99 101 }; 102 103 104 class BufferLine 105 106 { 107 public : 108 109 BufferLine() {;} 110 BufferLine(const vector<FitsFile::FitsDataType>& types); 111 inline const vector< pair<FitsFile::FitsDataType, int> >& identificateur() const {return id_;} 112 inline r_8& r_8Array(int k) { return ddata_[k];} 113 inline const r_8& r_8Array(int k) const { return ddata_[k];} 114 inline r_4& r_4Array(int k) { return fdata_[k];} 115 inline const r_4& r_4Array(int k) const { return fdata_[k];} 116 117 118 inline int_2& int_2Array(int k) { return shdata_[k];} 119 inline const int_2& int_2Array(int k) const { return shdata_[k];} 120 inline int_4& int_4Array(int k) { return idata_[k];} 121 inline const int_4& int_4Array(int k) const { return idata_[k];} 122 123 124 inline int_8& int_8Array(int k) { return ldata_[k];} 125 inline const int_8& int_8Array(int k) const { return ldata_[k];} 126 inline string& stringArray(int k) { return cdata_[k];} 127 inline const string& stringArray(int k) const { return cdata_[k];} 128 inline unsigned char& u_charArray(int k) { return bdata_[k];} 129 inline const unsigned char& u_charArray(int k) const { return bdata_[k];} 130 131 132 void Print() const; 133 134 135 private : 136 // la paire contient le type de la variable et le rang dans le tableau 137 // du type 138 vector< pair<FitsFile::FitsDataType, int> > id_; 139 vector<r_8> ddata_; 140 vector<r_4> fdata_; 141 vector<int_2> shdata_; 142 vector<int_4> idata_; 143 vector<int_8> ldata_; 144 vector<string> cdata_; 145 vector<unsigned char> bdata_; 146 }; 147 148 100 149 101 150 FitsFile() { InitNull(); }; … … 108 157 109 158 protected: 159 160 161 162 163 110 164 111 165 void ResetStatus(int& status) ; … … 130 184 bool imageOnPrimary_; 131 185 186 BufferLine bfl_; 187 188 132 189 }; 133 190 … … 214 271 string ColNameFromFits(int nocol) const; 215 272 int ColStringLengthFromFits(int nocol) const; 273 const BufferLine& GetBufferLine(long NoLine); 216 274 void GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char 217 275 ** cdata) ; … … 367 425 368 426 369 370 371 427 } // Fin du namespace 372 428 -
trunk/SophyaExt/FitsIOServer/fitslocalmap.cc
r2013 r2197 76 76 ownobj_= true; 77 77 } 78 int nbcols, nbentries; 79 nbcols = is.NbColsFromFits(); 80 if (nbcols != 1) 81 { 82 throw IOExc("le fichier fits n'est pas une LocalMap"); 83 } 78 int nbentries; 79 80 // lecture sur bin-table 81 // 82 // if (!is.IsFitsTable()) 83 // { 84 // throw PException("ReadFromFits: the fits file seems not to be a bintable"); 85 // } 86 // int nbcols; 87 // nbcols = is.NbColsFromFits(); 88 // if (nbcols != 1) 89 // { 90 // throw IOExc("le fichier fits n'est pas une LocalMap"); 91 // } 92 // nbentries = is.NentriesFromFits(0); 93 // 94 95 // lecture sur image fits 96 // 97 if (!is.IsFitsImage()) 98 { 99 throw PException("ReadFromFits: the fits file seems not to be an image"); 100 } 101 int dimension = is.nbDimOfImage(); 102 if (dimension != 2 ) 103 { 104 cout << " WARNING::ReadFromFits: the fits image seems not to be a matrix" << endl; 105 } 106 nbentries = is.nbOfImageData(); 107 // 108 84 109 DVList dvl=is.DVListFromFits(); 85 86 nbentries = is.NentriesFromFits(0); 110 87 111 int_4 nSzX = dvl.GetI("NSZX"); 88 112 int_4 nSzY = dvl.GetI("NSZY"); … … 93 117 } 94 118 dobj_->ReSize(nSzX, nSzY); 95 //int_4 localMappingDone = dvl.GetI("LCMP");96 //if (localMappingDone)97 //{119 int_4 localMappingDone = dvl.GetI("LCMP"); 120 if (localMappingDone) 121 { 98 122 int_4 x0 = dvl.GetI("X0"); 99 123 int_4 y0 = dvl.GetI("Y0"); … … 105 129 double angleY = dvl.GetD("ANGLEY"); 106 130 dobj_->SetSize(angleX, angleY); 107 //}131 } 108 132 // On lit les DataBlocks; 133 109 134 dobj_->DataBlock().ReSize(nPix); 110 135 is.GetSingleColumn(dobj_->DataBlock().Data(),nPix); … … 122 147 return; 123 148 } 124 125 DVList dvl( dobj_->Info() ); 126 dvl["NSZX"] = dobj_->Size_x(); 149 int nx, ny; 150 151 DVList dvl( dobj_->Info() ); 152 nx = dobj_->Size_x(); 153 dvl["NSZX"] = nx; 127 154 dvl.SetComment("NSZX", "number of pixels in x direction"); 128 dvl["NSZY"] = dobj_->Size_y(); 155 ny = dobj_->Size_y(); 156 dvl["NSZY"] = ny; 129 157 dvl.SetComment("NSZY", "number of pixels in y direction"); 130 158 dvl["NPIX"] = dobj_->NbPixels(); 131 159 dvl.SetComment("NPIX", "number of pixels in local map"); 132 160 133 //if(dobj_->LocalMap_isDone())134 //{135 //dvl["LCMP"] = (int_4) 1;136 //dvl.SetComment("LCMP", "local mapping 1= done, 0= not done");161 if(dobj_->LocalMap_isDone()) 162 { 163 dvl["LCMP"] = (int_4) 1; 164 dvl.SetComment("LCMP", "local mapping 1= done, 0= not done"); 137 165 int_4 x0 = 0; 138 166 int_4 y0 = 0; … … 159 187 dvl["ANGLEY"] = angleY; 160 188 dvl.SetComment("ANGLEY", "sphere angle covered by map y-extension "); 161 //}162 //else163 //{164 //dvl["LCMP"] = (int_4) 0;165 //}189 } 190 else 191 { 192 dvl["LCMP"] = (int_4) 0; 193 } 166 194 dvl["Content"]= "LocalMap"; 167 195 dvl.SetComment("Content", "name of SOPHYA object"); … … 171 199 string extname("SIMULATION"); 172 200 173 string Type; 174 if (typeid(T) == typeid(r_8) ) Type+='D'; 201 // sortie sur image fits 202 // 203 char type; 204 if ( typeid(T) == typeid(r_8) ) type='D'; 175 205 else 176 if ( typeid(T) == typeid(r_4) ) Type+='E';206 if ( typeid(T) == typeid(r_4) ) type='E'; 177 207 else 178 { 179 cout << " type de la LocalMap = " << typeid(T).name() << endl; 180 throw IOExc("FITS_LocalMap:: unknown type"); 181 } 182 vector<int> dummy; 183 os.makeHeaderBntblOnFits(Type, Noms, dobj_->NbPixels(), 1, &dvl, extname, dummy); 184 os.PutColToFits(0, dobj_->NbPixels(), dobj_->DataBlock().Data()); 208 if ( typeid(T) == typeid(int_4) ) type='J'; 209 else 210 { 211 cout << " type du tableau= " << typeid(T).name() << endl; 212 throw IOExc("FITS_LocalMap:: unknown type"); 213 } 214 int nbdim = 2; 215 int* naxisn = new int[nbdim]; 216 naxisn[0] = dobj_->Matrix().Size(0); 217 naxisn[1] = dobj_->Matrix().Size(1); 218 os.makeHeaderImageOnFits(type, nbdim, naxisn, &dvl); 219 os.PutImageToFits(nx*ny, dobj_->Matrix().Data()); 220 221 delete [] naxisn; 222 // 223 224 // sortie sur bin-table fits 225 // 226 // string Type; 227 // if (typeid(T) == typeid(r_8) ) Type+='D'; 228 // else 229 // if (typeid(T) == typeid(r_4) ) Type+='E'; 230 // else 231 // { 232 // cout << " type de la LocalMap = " << typeid(T).name() << endl; 233 // throw IOExc("FITS_LocalMap:: unknown type"); 234 // } 235 // vector<int> dummy; 236 // os.makeHeaderBntblOnFits(Type, Noms, dobj_->NbPixels(), 1, &dvl, extname, dummy); 237 // os.PutColToFits(0, dobj_->NbPixels(), dobj_->DataBlock().Data()); 238 // 185 239 186 240 } -
trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.cc
r2082 r2197 101 101 102 102 // On ecrit les dataBlocks 103 104 // the BINTABLE consits of 4 columns 105 // first column : pixels values (type : T ), length : number of pixels 106 // second column : number of pixels of each theta slice (type : integer) , 107 // length : number of theta-slices (parameter INDTHMAX above +1) 108 // third column : cumulated number of pixels until the beginning of each 109 // theta slice (type : integer) , same length as the previous one 110 // fourth column : theta values of each slice (type : double_) same length 111 // as the previous one. 103 112 vector<string> Noms(4); 104 113 Noms[0] = dvl.GetS("Content"); … … 187 196 // On lit les DataBlocks; 188 197 // 198 // the BINTABLE consits of 4 columns 199 // first column : pixels values (type : T ), length : number of pixels 200 // second column : number of pixels of each theta slice (type : integer) , 201 // length : number of theta-slices (parameter INDTHMAX above +1) 202 // third column : cumulated number of pixels until the beginning of each 203 // theta slice (type : integer) , same length as the previous one 204 // fourth column : theta values of each slice (type : double_) same length 205 // as the previous one. 206 189 207 dobj_->pixels_.ReSize(nPix); 190 208 is.GetBinTabFCol(dobj_->pixels_.Data(),nPix,0); … … 265 283 #pragma define_template FITS_SphereThetaPhi<r_8> 266 284 #pragma define_template FITS_SphereThetaPhi<r_4> 267 //#pragma define_template FITS_SphereThetaPhi<int_4>285 #pragma define_template FITS_SphereThetaPhi<int_4> 268 286 #endif 269 287 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) 270 288 template class FITS_SphereThetaPhi<r_8>; 271 289 template class FITS_SphereThetaPhi<r_4>; 272 //template class FITS_SphereThetaPhi<int_4>;290 template class FITS_SphereThetaPhi<int_4>; 273 291 #endif -
trunk/SophyaExt/FitsIOServer/fitstarray.cc
r1388 r2197 125 125 if ( typeid(T) == typeid(r_4) ) type='E'; 126 126 else 127 if ( typeid(T) == typeid(int_4) ) type=' I';127 if ( typeid(T) == typeid(int_4) ) type='J'; 128 128 else 129 129 { -
trunk/SophyaExt/FitsIOServer/fitsxntuple.cc
r1499 r2197 86 86 for (k=0; k<nbcols;k++) 87 87 { 88 88 89 FitsFile::FitsDataType ss= is.ColTypeFromFits(k); 89 if (ss == FitsFile::FitsDataType_double) DfitsCol.push_back(k); 90 else if (ss == FitsFile::FitsDataType_float) FfitsCol.push_back(k); 91 else if (ss == FitsFile::FitsDataType_int) IfitsCol.push_back(k); 92 else if (ss == FitsFile::FitsDataType_long) IfitsCol.push_back(k); 93 else if (ss == FitsFile::FitsDataType_byte) IfitsCol.push_back(k); 94 else if (ss == FitsFile::FitsDataType_char) SfitsCol.push_back(k); 95 else { 96 cout << " FITS_XNTuple: colonne fits " << k << " type= " << (int) ss << endl; 97 throw IOExc("type de champ inconnu"); 98 } 90 switch (ss) 91 { 92 case FitsFile::FitsDataType_double : 93 { 94 DfitsCol.push_back(k); 95 break; 96 } 97 case FitsFile::FitsDataType_float : 98 { 99 FfitsCol.push_back(k); 100 break; 101 } 102 case FitsFile::FitsDataType_int : 103 { 104 IfitsCol.push_back(k); 105 break; 106 } 107 case FitsFile::FitsDataType_long : 108 { 109 IfitsCol.push_back(k); 110 break; 111 } 112 case FitsFile::FitsDataType_byte : 113 { 114 IfitsCol.push_back(k); 115 break; 116 } 117 case FitsFile::FitsDataType_char : 118 { 119 SfitsCol.push_back(k); 120 break; 121 } 122 default : 123 { 124 cout << " FITS_XNTuple: colonne fits " << k << " type= " << (int) ss << endl; 125 throw IOExc("type de champ inconnu"); 126 } 127 } 99 128 } 100 129 char ** ColName = new char*[nbcols]; … … 143 172 if (ND != dobj_->NDVar() || NF != dobj_->NFVar() || NI != dobj_->NIVar() || NS != dobj_->NSVar()) 144 173 { 145 cout << " WARNING : FITS_XNTuple : XNTuple reconfigured " << endl;174 // cout << " WARNING : FITS_XNTuple : XNTuple reconfigured " << endl; 146 175 (*dobj_)= XNTuple(ND, NF, NI, NS,ColName); 147 176 } … … 155 184 delete [] ColName; 156 185 157 double* dligne;158 float* fligne;159 int * iligne;186 r_8* dligne; 187 r_4* fligne; 188 int_4* iligne; 160 189 char** cligne; 161 190 … … 188 217 for (numLigne=firstln; numLigne < lastln; numLigne++) 189 218 { 190 is.GetBinTabLine(numLigne, dligne, fligne, iligne, cligne ); 191 dobj_->Fill((r_8*)dligne, (r_4*)fligne, (int_4*)iligne, cligne); 219 const FitsFile::BufferLine& bfligne = is.GetBufferLine(numLigne); 220 int k; 221 int rang; 222 int dcount =0; 223 int fcount =0; 224 int icount =0; 225 int ccount = 0; 226 for (k=0; k<nbcols;k++) 227 { 228 rang = bfligne.identificateur()[k].second; 229 switch (bfligne.identificateur()[k].first) 230 { 231 case FitsFile::FitsDataType_double : 232 { 233 dligne[dcount++] = bfligne.r_8Array(rang); 234 break; 235 } 236 case FitsFile::FitsDataType_float : 237 { 238 fligne[fcount++] = bfligne.r_4Array(rang); 239 break; 240 } 241 case FitsFile::FitsDataType_short : 242 { 243 iligne[icount++] = bfligne.int_2Array(rang); 244 break; 245 } 246 case FitsFile::FitsDataType_int : 247 { 248 iligne[icount++] = bfligne.int_4Array(rang); 249 break; 250 } 251 case FitsFile::FitsDataType_long : 252 { 253 iligne[icount++] = (int_4)bfligne.int_8Array(rang); 254 break; 255 } 256 case FitsFile::FitsDataType_byte : 257 { 258 iligne[icount++] = (int_4)bfligne.u_charArray(rang); 259 break; 260 } 261 case FitsFile::FitsDataType_char : 262 { 263 strncpy( cligne[ccount++], bfligne.stringArray(rang).c_str(),bfligne.stringArray(rang).length()); 264 break; 265 } 266 267 default: 268 { 269 throw PException(" FITS_XNTuple::ReadFromFits : unsupported FITS data type"); 270 } 271 } 272 273 } 274 // is.GetBinTabLine(numLigne, dligne, fligne, iligne, cligne ); 275 // dobj_->Fill((r_8*)dligne, (r_4*)fligne, (int_4*)iligne, cligne); 276 dobj_->Fill(dligne, fligne, iligne, cligne); 192 277 } 193 278 delete [] dligne; … … 234 319 for (k=0; k<dobj_->NIVar();k++) 235 320 { 236 types+=' I';321 types+='J'; 237 322 } 238 323 for (k=0; k<dobj_->NSVar();k++) … … 277 362 { 278 363 for(int j = 0; j < nrows; j++) icolumn[j]= dobj_->GetIVal(j,compt); 364 cout << " fitsx.. va ecrire la colonne " << endl; 365 for(int j = 0; j < nrows; j++) cout << icolumn[j] << endl;; 366 279 367 os.PutColToFits(compt, nrows, icolumn); 280 368 compt++;
Note:
See TracChangeset
for help on using the changeset viewer.