Changeset 1143 in Sophya for trunk/SophyaExt
- Timestamp:
- Aug 25, 2000, 5:52:48 PM (25 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 6 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 -
trunk/SophyaExt/FitsIOServer/fitsfile.h
r1136 r1143 58 58 opens a file 'flnm' 59 59 60 gets parameters in header (hdunum)60 gets parameters in extension-header (hdunum) 61 61 62 62 calls the method 'ReadFromFits' from the inherited object … … 125 125 static void printerror(int&) ; 126 126 static void printerror(int&,char* texte) ; 127 inline void InitNull() { cout << " init fitsfile " << endl;fptr_= NULL; hdutype_= 0; hdunum_ = 1;127 inline void InitNull() { fptr_= NULL; hdutype_= 0; hdunum_ = 1; 128 128 fits_status_ = 0;} 129 129 … … 150 150 // FitsInFile(char flnm[], int hdunum=0); 151 151 FitsInFile(char flnm[]); 152 ~FitsInFile() { cout << " destructeur FitsInFile " << endl; };152 ~FitsInFile() { ; }; 153 153 154 154 … … 170 170 */ 171 171 inline const DVList& DVListFromFits() const { return dvl_;} 172 173 /* get the keywords of primary header in a DVList */ 174 DVList DVListFromPrimaryHeader() const; 172 175 173 176 void moveToFollowingHeader(); … … 347 350 FitsOutFile(); 348 351 FitsOutFile(char flnm[], bool OldFile=false); 349 ~FitsOutFile() { cout << " destructeur FitsOutFile " << endl;};352 ~FitsOutFile() { ;}; 350 353 inline void InitNull() {imageOnPrimary_=false;} 351 354 … … 368 371 \param <naxisn> array containind sizes of the different dimensions 369 372 */ 370 void makeHeaderImageOnFits(char type, int nbdim, int* naxisn) ; 373 void makeHeaderImageOnFits(char type, int nbdim, int* naxisn, DVList &dvl) ; 374 371 375 372 376 /*! write double data from array 'map'on an IMAGE extension … … 391 395 392 396 /*! create an BINTABLE header on FITS file. 393 \param <fieldType> array containing characters denoting types of the different column (see method ColTypeFromFits) 397 \param <fieldType> array conta 398 ining characters denoting types of the different column (see method ColTypeFromFits) 394 399 \param <Noms> array of the names of columns 395 400 \param <nentries> number of data of each column … … 416 421 void putColToFits(int nocol, int nentries, char** donnees) const; 417 422 423 ///////////////////////////////////////////////////////////// 424 // methods for managing any type of FITS extension 425 //////////////////////////////////////////////////////// 426 427 428 /* put keywords from a DVList into the primary header of the fits-file */ 429 void DVListIntoPrimaryHeader(DVList& dvl) const; 430 431 432 418 433 private : 419 434 420 435 void writeSignatureOnFits() const; 421 436 void addKeywordsOfDVList(DVList& dvl) const; 422 437 423 438 bool imageOnPrimary_; -
trunk/SophyaExt/FitsIOServer/fitsntuple.cc
r1136 r1143 119 119 delete [] ColName; 120 120 121 r_4* ligne = new r_4[nbcols];121 float* ligne = new float[nbcols]; 122 122 123 123 int firstln, lastln; … … 136 136 { 137 137 is.GetBinTabLine(numLigne, ligne); 138 dobj_->Fill( ligne);138 dobj_->Fill((r_4*)ligne); 139 139 } 140 140 delete [] ligne; … … 161 161 // extension name 162 162 char* extname = "NTuple_Binary_tbl"; 163 dvl.Print();164 163 165 164 char** Noms = new char*[ncols]; -
trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc
r1136 r1143 78 78 } 79 79 80 DVList dvl ;80 DVList dvl( dobj_->Info() ); 81 81 82 82 SphereCoordSys* cs= dobj_->GetCoordSys(); … … 99 99 dvl.SetComment("LASTPIX", "Last pixel # (0 based)"); 100 100 dvl["Content"]= "SphereHEALPix"; 101 dvl["EXTNAME"]= "SIMULATION";102 dvl["COMMENT"]= "Sky Map Pixelisation Specific Keywords";103 101 104 102 // On ecrit les dataBlocks … … 106 104 Noms[0]= new char[15]; 107 105 strncpy(Noms[0],dvl.GetS("Content").c_str(),15); 108 char extname[15]; 109 strncpy(extname,dvl.GetS("EXTNAME").c_str(),15); 106 char extname[15] = "SIMULATION"; 110 107 111 108 char Type[2]; … … 198 195 // on effectue le decoupage en tranches 199 196 dobj_->SetThetaSlices(); 200 dobj_->Info()=is.DVListFromFits();197 dobj_->Info() = is.DVListFromFits(); 201 198 202 199 -
trunk/SophyaExt/FitsIOServer/fitstarray.cc
r1136 r1143 94 94 // On lit le tableau 95 95 is.GetSingleColumn( dobj_->Data(),dobj_->Size()); 96 dobj_->Info() = is.DVListFromFits(); 96 97 97 98 } … … 133 134 } 134 135 cout << " nombre total d'elements a copier " << nbels << endl; 135 os.makeHeaderImageOnFits(type, nbdim, naxisn );136 os.makeHeaderImageOnFits(type, nbdim, naxisn, dobj_->Info()); 136 137 if (!dobj_->IsPacked()) 137 138 { -
trunk/SophyaExt/FitsIOServer/fitsxntuple.cc
r1136 r1143 142 142 delete [] ColName; 143 143 144 r_8* dligne;145 r_4* fligne;146 int _4* iligne;144 double* dligne; 145 float* fligne; 146 int* iligne; 147 147 char** cligne; 148 148 149 if (DfitsCol.size()>0) dligne = new r_8[DfitsCol.size()];149 if (DfitsCol.size()>0) dligne = new double[DfitsCol.size()]; 150 150 else dligne=NULL; 151 if (FfitsCol.size()>0) fligne = new r_4[FfitsCol.size()];151 if (FfitsCol.size()>0) fligne = new float[FfitsCol.size()]; 152 152 else fligne=NULL; 153 if (IfitsCol.size()>0) iligne = new int _4[IfitsCol.size()];153 if (IfitsCol.size()>0) iligne = new int[IfitsCol.size()]; 154 154 else iligne=NULL; 155 155 if (SfitsCol.size()>0) … … 176 176 { 177 177 is.GetBinTabLine(numLigne, dligne, fligne, iligne, cligne ); 178 dobj_->Fill( dligne, fligne,iligne, cligne);178 dobj_->Fill((r_8*)dligne, (r_4*)fligne, (int_4*)iligne, cligne); 179 179 } 180 180 delete [] dligne; … … 202 202 // extension name 203 203 char* extname = "XNTuple_Binary_tbl"; 204 dvl.Print();205 204 char** Noms = new char*[ncols]; 206 205 int k;
Note:
See TracChangeset
for help on using the changeset viewer.