Changeset 3128 in Sophya for trunk/SophyaExt
- Timestamp:
- Jan 11, 2007, 7:07:52 PM (19 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fabtcolread.cc
r3114 r3128 209 209 int sta=0; long val=0; 210 210 if(fits_read_key(fitsptr,TLONG,keyname,&val,NULL,&sta)) 211 printerror(sta); 212 return val; 213 } 214 215 /*! 216 Read a fitsheader key into long 217 \param fitsptr : cfitio pointer to Fits file 218 \param keyname : name of the key 219 \return value into long long 220 */ 221 LONGLONG FitsOpenFile::ReadKeyLL(fitsfile *fitsptr,char *keyname) 222 { 223 if(keyname==NULL || fitsptr==NULL) return 0; 224 int sta=0; LONGLONG val=0; 225 if(fits_read_key(fitsptr,TLONGLONG,keyname,&val,NULL,&sta)) 211 226 printerror(sta); 212 227 return val; … … 267 282 fbt.Print(3); 268 283 // Read element by element 269 for( longi=0;i<fbt.GetNbLine();i++) {284 for(LONGLONG i=0;i<fbt.GetNbLine();i++) { 270 285 double x = fbt.Read(i); 271 286 double y = fbt2.Read(i); … … 274 289 // Read into a vector 275 290 TVector<double> data; 276 longn = fbt.Read(32,50,data);291 LONGLONG n = fbt.Read(32,50,data); 277 292 cout<<"Number of values read: "<<n<<endl; 278 293 data.ReSize(100); … … 402 417 403 418 // Get number of rows 404 if(fits_get_num_rows (GetFitsPtr(),&NBline,&sta)) {419 if(fits_get_num_rowsll(GetFitsPtr(),&NBline,&sta)) { 405 420 FitsOpenFile::printerror(sta); 406 421 throw NotAvailableOperation("FitsABTColRd::Init: Error getting number of rows\n"); … … 425 440 426 441 // Get column type 427 if(fits_get_coltype (GetFitsPtr(),ColNum+1,&ColTypeCode,NULL,NULL,&sta)) {442 if(fits_get_coltypell(GetFitsPtr(),ColNum+1,&ColTypeCode,NULL,NULL,&sta)) { 428 443 FitsOpenFile::printerror(sta); 429 444 throw ParmError("FitsABTColRd::Init: Error getting column type\n"); … … 436 451 // Get column name back, tunit, tform 437 452 char tunit[64], tform[64], tdisp[64]; 438 longrepeat=0; double tscale=1., tzero=0.;453 LONGLONG repeat=0; double tscale=1., tzero=0.; 439 454 int rc=0; 440 455 if(HDUType()==BINARY_TBL) { 441 fits_get_bcolparms (GetFitsPtr(),ColNum+1,labelcol,tunit,tform456 fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform 442 457 ,&repeat,&tscale,&tzero,NULL,tdisp,&sta); 443 458 } else { 444 fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeat,tunit,tform 459 long repeatlng; 460 fits_get_acolparms(GetFitsPtr(),ColNum+1,labelcol,&repeatlng,tunit,tform 445 461 ,&tscale,&tzero,NULL,tdisp,&sta); 462 repeat = repeatlng; 446 463 } 447 464 if(rc) { … … 525 542 { 526 543 return FitsOpenFile::ReadKeyL(GetFitsPtr(),keyname); 544 } 545 546 /*! 547 Read a fitsheader key into long long 548 \param keyname : name of the key 549 \return value into long long 550 */ 551 LONGLONG FitsABTColRd::ReadKeyLL(char *keyname) 552 { 553 return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname); 527 554 } 528 555 … … 549 576 \endverbatim 550 577 */ 551 double FitsABTColRd::Read( longn,bool usebuffer)578 double FitsABTColRd::Read(LONGLONG n,bool usebuffer) 552 579 // Attention: n=nline [0,NBline[, cfistio veut [1,NBline] 553 580 // Attention: colnum [0,NBcol[ , cfistio veut [1,NBcol] … … 581 608 if(n<LineDeb || n>LineFin) { 582 609 NFitsRead++; 583 longrow1,row2,nrow;610 LONGLONG row1,row2,nrow; 584 611 if(BuffSens>0) { // Cas remplissage forward 585 612 row1 = n+1; … … 640 667 \endverbatim 641 668 */ 642 long FitsABTColRd::Read(long n1,longn2,TVector<double>& data)669 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<double>& data) 643 670 { 644 671 if(n1<0 || n1>=NBline) … … 649 676 if(n2>=NBline) n2 = NBline-1; 650 677 651 sa_size_tnread = n2-n1+1;678 LONGLONG nread = n2-n1+1; 652 679 if(data.Size()<nread) data.SetSize(nread); 653 680 654 //for( longi=n1;i<=n2;i++) data(i-n1) = Read(i);681 //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i); 655 682 int sta=0; 656 683 fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta); … … 664 691 665 692 /*! idem before but for TVector of float */ 666 long FitsABTColRd::Read(long n1,longn2,TVector<float>& data)693 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<float>& data) 667 694 { 668 695 if(n1<0 || n1>=NBline) … … 673 700 if(n2>=NBline) n2 = NBline-1; 674 701 675 sa_size_tnread = n2-n1+1;702 LONGLONG nread = n2-n1+1; 676 703 if(data.Size()<nread) data.SetSize(nread); 677 704 678 //for( longi=n1;i<=n2;i++) data(i-n1) = Read(i);705 //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i); 679 706 int sta=0; 680 707 fits_read_col(GetFitsPtr(),TFLOAT,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta); … … 688 715 689 716 /*! idem before but for TVector of unsigned short */ 690 long FitsABTColRd::Read(long n1,longn2,TVector<uint_2>& data)717 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data) 691 718 { 692 719 if(n1<0 || n1>=NBline) … … 697 724 if(n2>=NBline) n2 = NBline-1; 698 725 699 sa_size_tnread = n2-n1+1;726 LONGLONG nread = n2-n1+1; 700 727 if(data.Size()<nread) data.SetSize(nread); 701 728 … … 711 738 712 739 /*! idem before but for TVector of int_4 */ 713 long FitsABTColRd::Read(long n1,longn2,TVector<int_4>& data)740 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data) 714 741 { 715 742 if(n1<0 || n1>=NBline) … … 720 747 if(n2>=NBline) n2 = NBline-1; 721 748 722 sa_size_tnread = n2-n1+1;749 LONGLONG nread = n2-n1+1; 723 750 if(data.Size()<nread) data.SetSize(nread); 724 751 725 //for( longi=n1;i<=n2;i++) data(i-n1) = Read(i);752 //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i); 726 753 int sta=0; 727 754 int T = (sizeof(long)==4) ? TLONG: TINT; … … 736 763 737 764 /*! idem before but for TVector of int_8 */ 738 long FitsABTColRd::Read(long n1,longn2,TVector<int_8>& data)765 LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_8>& data) 739 766 { 740 767 #ifdef TLONGLONG … … 746 773 if(n2>=NBline) n2 = NBline-1; 747 774 748 sa_size_tnread = n2-n1+1;775 LONGLONG nread = n2-n1+1; 749 776 if(data.Size()<nread) data.SetSize(nread); 750 777 … … 773 800 \return <0 means not found 774 801 */ 775 long FitsABTColRd::FirstRow(double val1,double val2,longrowstart)776 { 777 longrow = -1;802 LONGLONG FitsABTColRd::FirstRow(double val1,double val2,LONGLONG rowstart) 803 { 804 LONGLONG row = -1; 778 805 if(NBline==0) return row; 779 806 // Change buffer for efficiency … … 782 809 if(rowstart<0) rowstart = 0; 783 810 if(rowstart>=NBline) rowstart = NBline-1; 784 for( longi=rowstart;i<NBline;i++) {811 for(LONGLONG i=rowstart;i<NBline;i++) { 785 812 double val = Read(i); 786 813 if(val<val1 || val>val2) continue; … … 802 829 \endverbatim 803 830 */ 804 long FitsABTColRd::LastRow(double val1,double val2,longrowstart)805 { 806 longrow = -1;831 LONGLONG FitsABTColRd::LastRow(double val1,double val2,LONGLONG rowstart) 832 { 833 LONGLONG row = -1; 807 834 if(NBline==0) return row; 808 835 // Change buffer for efficiency … … 810 837 if(bsens>=0) {ChangeBuffer(BuffLen,-1); bchange=true;} 811 838 if(rowstart<0 || rowstart>=NBline) rowstart = NBline-1; 812 for( longi=rowstart;i>=0;i--) {839 for(LONGLONG i=rowstart;i>=0;i--) { 813 840 double val = Read(i); 814 841 if(val<val1 || val>val2) continue; … … 853 880 fbt.Print(3); 854 881 // Read element by element 855 for( longi=0;i<fbt.GetNbLine();i++) {882 for(LONGLONG i=0;i<fbt.GetNbLine();i++) { 856 883 double x = fbt.Read(i); 857 884 if(i%lpmod==0) cout<<i<<": "<<x<<endl; … … 859 886 // Read into a vector 860 887 TVector<double> data; 861 longn = fbt.Read(32,50,data);888 LONGLONG n = fbt.Read(32,50,data); 862 889 cout<<"Number of values read: "<<n<<endl; 863 890 data.ReSize(100); … … 1027 1054 // Get NAXIS 1 et 2 1028 1055 int nfound=0; 1029 if(fits_read_keys_lng(GetFitsPtr(),"NAXIS",1,2,Naxis,&nfound,&sta)) { 1056 // car fits_read_keys_lnglng n'est pas prototype dans longnam.h 1057 if(ffgknjj(GetFitsPtr(),"NAXIS",1,2,Naxis,&nfound,&sta)) { 1030 1058 FitsOpenFile::printerror(sta); 1031 1059 throw RangeCheckError("FitsImg2DRd::Init: Error reading NAXIS cards\n"); … … 1065 1093 { 1066 1094 return FitsOpenFile::ReadKeyL(GetFitsPtr(),keyname); 1095 } 1096 1097 /*! 1098 Read a fitsheader key into long long 1099 \param keyname : name of the key 1100 \return value into long long 1101 */ 1102 LONGLONG FitsImg2DRd::ReadKeyLL(char *keyname) 1103 { 1104 return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname); 1067 1105 } 1068 1106 … … 1088 1126 \warning TMatrix data(Naxis2,Naxis1) 1089 1127 */ 1090 size_tFitsImg2DRd::Read(TMatrix<uint_2>& data)1128 LONGLONG FitsImg2DRd::Read(TMatrix<uint_2>& data) 1091 1129 { 1092 1130 int sta=0; … … 1094 1132 data.ReSize(Naxis[1],Naxis[0]); 1095 1133 1096 for( intj=0;j<Naxis[1];j++) {1097 longdeb = j*Naxis[0]+1, nel = Naxis[0];1134 for(LONGLONG j=0;j<Naxis[1];j++) { 1135 LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0]; 1098 1136 fits_read_img(GetFitsPtr(),TUSHORT,deb,nel,&NulVal,arr,NULL,&sta); 1099 1137 if(sta) { … … 1102 1140 NotAvailableOperation("FitsImg2DRd::Read(TMatrix<uint_2>): Error Reading Fits file\n"); 1103 1141 } 1104 for( inti=0;i<Naxis[0];i++) data(j,i) = arr[i];1142 for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i]; 1105 1143 } 1106 1144 … … 1110 1148 1111 1149 /*! Read image into a TMatrix<int_4> */ 1112 size_tFitsImg2DRd::Read(TMatrix<int_4>& data)1150 LONGLONG FitsImg2DRd::Read(TMatrix<int_4>& data) 1113 1151 { 1114 1152 int sta=0; … … 1117 1155 int T = (sizeof(long)==4) ? TLONG: TINT; 1118 1156 1119 for( intj=0;j<Naxis[1];j++) {1120 longdeb = j*Naxis[0]+1, nel = Naxis[0];1157 for(LONGLONG j=0;j<Naxis[1];j++) { 1158 LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0]; 1121 1159 fits_read_img(GetFitsPtr(),T,deb,nel,&NulVal,arr,NULL,&sta); 1122 1160 if(sta) { … … 1125 1163 NotAvailableOperation("FitsImg2DRd::Read(TMatrix<int_4>): Error Reading Fits file\n"); 1126 1164 } 1127 for( inti=0;i<Naxis[0];i++) data(j,i) = arr[i];1165 for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i]; 1128 1166 } 1129 1167 … … 1133 1171 1134 1172 /*! Read image into a TMatrix<int_8> */ 1135 size_tFitsImg2DRd::Read(TMatrix<int_8>& data)1173 LONGLONG FitsImg2DRd::Read(TMatrix<int_8>& data) 1136 1174 { 1137 1175 int sta=0; … … 1139 1177 data.ReSize(Naxis[1],Naxis[0]); 1140 1178 1141 for( intj=0;j<Naxis[1];j++) {1142 longdeb = j*Naxis[0]+1, nel = Naxis[0];1179 for(LONGLONG j=0;j<Naxis[1];j++) { 1180 LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0]; 1143 1181 fits_read_img(GetFitsPtr(),TLONGLONG,deb,nel,&NulVal,arr,NULL,&sta); 1144 1182 if(sta) { … … 1147 1185 NotAvailableOperation("FitsImg2DRd::Read(TMatrix<int_8>): Error Reading Fits file\n"); 1148 1186 } 1149 for( inti=0;i<Naxis[0];i++) data(j,i) = arr[i];1187 for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i]; 1150 1188 } 1151 1189 … … 1155 1193 1156 1194 /*! Read image into a TMatrix<float> */ 1157 size_tFitsImg2DRd::Read(TMatrix<float>& data)1195 LONGLONG FitsImg2DRd::Read(TMatrix<float>& data) 1158 1196 { 1159 1197 int sta=0; … … 1161 1199 data.ReSize(Naxis[1],Naxis[0]); 1162 1200 1163 for( intj=0;j<Naxis[1];j++) {1164 longdeb = j*Naxis[0]+1, nel = Naxis[0];1201 for(LONGLONG j=0;j<Naxis[1];j++) { 1202 LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0]; 1165 1203 fits_read_img(GetFitsPtr(),TFLOAT,deb,nel,&NulVal,arr,NULL,&sta); 1166 1204 if(sta) { … … 1169 1207 NotAvailableOperation("FitsImg2DRd::Read(TMatrix<float>): Error Reading Fits file\n"); 1170 1208 } 1171 for( inti=0;i<Naxis[0];i++) data(j,i) = arr[i];1209 for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i]; 1172 1210 } 1173 1211 … … 1177 1215 1178 1216 /*! Read image into a TMatrix<double> */ 1179 size_tFitsImg2DRd::Read(TMatrix<double>& data)1217 LONGLONG FitsImg2DRd::Read(TMatrix<double>& data) 1180 1218 { 1181 1219 int sta=0; … … 1183 1221 data.ReSize(Naxis[1],Naxis[0]); 1184 1222 1185 for( intj=0;j<Naxis[1];j++) {1186 longdeb = j*Naxis[0]+1, nel = Naxis[0];1223 for(LONGLONG j=0;j<Naxis[1];j++) { 1224 LONGLONG deb = j*Naxis[0]+1, nel = Naxis[0]; 1187 1225 fits_read_img(GetFitsPtr(),TDOUBLE,deb,nel,&NulVal,arr,NULL,&sta); 1188 1226 if(sta) { … … 1191 1229 NotAvailableOperation("FitsImg2DRd::Read(TMatrix<double>): Error Reading Fits file\n"); 1192 1230 } 1193 for( inti=0;i<Naxis[0];i++) data(j,i) = arr[i];1231 for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i]; 1194 1232 } 1195 1233 … … 1343 1381 // Get NAXIS 1, 2 et 3 1344 1382 int nfound=0; 1345 if(fits_read_keys_lng(GetFitsPtr(),"NAXIS",1,3,Naxis,&nfound,&sta)) { 1383 // car fits_read_keys_lnglng n'est pas prototype dans longnam.h 1384 if(ffgknjj(GetFitsPtr(),"NAXIS",1,3,Naxis,&nfound,&sta)) { 1346 1385 FitsOpenFile::printerror(sta); 1347 1386 throw RangeCheckError("FitsImg3DRd::Init: Error reading NAXIS cards\n"); … … 1384 1423 1385 1424 /*! 1425 Read a fitsheader key into long long 1426 \param keyname : name of the key 1427 \return value into long long 1428 */ 1429 LONGLONG FitsImg3DRd::ReadKeyLL(char *keyname) 1430 { 1431 return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname); 1432 } 1433 1434 /*! 1386 1435 Read a fitsheader key into string 1387 1436 \param keyname : name of the key … … 1401 1450 Read 3D image into a TArray<uint_2> 1402 1451 */ 1403 size_tFitsImg3DRd::Read(TArray<uint_2>& data)1452 LONGLONG FitsImg3DRd::Read(TArray<uint_2>& data) 1404 1453 { 1405 1454 int sta=0; … … 1407 1456 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim); 1408 1457 1409 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1410 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];1458 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1459 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; 1411 1460 fits_read_img(GetFitsPtr(),TUSHORT,deb,nel,&NulVal,arr,NULL,&sta); 1412 1461 if(sta) { … … 1415 1464 NotAvailableOperation("FitsImg3DRd::Read(TArray<uint_2>): Error Reading Fits file\n"); 1416 1465 } 1417 for( inti=0;i<Naxis[0];i++) data(i,j,k) = arr[i];1466 for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i]; 1418 1467 } 1419 1468 … … 1423 1472 1424 1473 /*! Read 3D image into a TArray<int_4> */ 1425 size_tFitsImg3DRd::Read(TArray<int_4>& data)1474 LONGLONG FitsImg3DRd::Read(TArray<int_4>& data) 1426 1475 { 1427 1476 int sta=0; … … 1430 1479 int T = (sizeof(long)==4) ? TLONG: TINT; 1431 1480 1432 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1433 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];1481 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1482 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; 1434 1483 fits_read_img(GetFitsPtr(),T,deb,nel,&NulVal,arr,NULL,&sta); 1435 1484 if(sta) { … … 1438 1487 NotAvailableOperation("FitsImg3DRd::Read(TArray<int_4>): Error Reading Fits file\n"); 1439 1488 } 1440 for( inti=0;i<Naxis[0];i++) data(i,j,k) = arr[i];1489 for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i]; 1441 1490 } 1442 1491 … … 1446 1495 1447 1496 /*! Read 3D image into a TArray<int_8> */ 1448 size_tFitsImg3DRd::Read(TArray<int_8>& data)1497 LONGLONG FitsImg3DRd::Read(TArray<int_8>& data) 1449 1498 { 1450 1499 int sta=0; … … 1452 1501 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim); 1453 1502 1454 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1455 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];1503 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1504 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; 1456 1505 fits_read_img(GetFitsPtr(),TLONGLONG,deb,nel,&NulVal,arr,NULL,&sta); 1457 1506 if(sta) { … … 1460 1509 NotAvailableOperation("FitsImg3DRd::Read(TArray<int_8>): Error Reading Fits file\n"); 1461 1510 } 1462 for( inti=0;i<Naxis[0];i++) data(i,j,k) = arr[i];1511 for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i]; 1463 1512 } 1464 1513 … … 1468 1517 1469 1518 /*! Read 3D image into a TArray<float> */ 1470 size_tFitsImg3DRd::Read(TArray<float>& data)1519 LONGLONG FitsImg3DRd::Read(TArray<float>& data) 1471 1520 { 1472 1521 int sta=0; … … 1474 1523 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim); 1475 1524 1476 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1477 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];1525 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1526 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; 1478 1527 fits_read_img(GetFitsPtr(),TFLOAT,deb,nel,&NulVal,arr,NULL,&sta); 1479 1528 if(sta) { … … 1482 1531 NotAvailableOperation("FitsImg3DRd::Read(TArray<float>): Error Reading Fits file\n"); 1483 1532 } 1484 for( inti=0;i<Naxis[0];i++) data(i,j,k) = arr[i];1533 for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i]; 1485 1534 } 1486 1535 … … 1490 1539 1491 1540 /*! Read 3D image into a TArray<double> */ 1492 size_tFitsImg3DRd::Read(TArray<double>& data)1541 LONGLONG FitsImg3DRd::Read(TArray<double>& data) 1493 1542 { 1494 1543 int sta=0; … … 1496 1545 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim); 1497 1546 1498 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1499 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0];1547 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1548 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; 1500 1549 fits_read_img(GetFitsPtr(),TDOUBLE,deb,nel,&NulVal,arr,NULL,&sta); 1501 1550 if(sta) { … … 1504 1553 NotAvailableOperation("FitsImg3DRd::Read(TArray<double>): Error Reading Fits file\n"); 1505 1554 } 1506 for( inti=0;i<Naxis[0];i++) data(i,j,k) = arr[i];1555 for(LONGLONG i=0;i<Naxis[0];i++) data(i,j,k) = arr[i]; 1507 1556 } 1508 1557 -
trunk/SophyaExt/FitsIOServer/fabtcolread.h
r3114 r3128 43 43 void Print(void); 44 44 45 static double ReadKey(fitsfile *fitsptr,char *keyname); 46 static long ReadKeyL(fitsfile *fitsptr,char *keyname); 47 static string ReadKeyS(fitsfile *fitsptr,char *keyname); 45 static double ReadKey(fitsfile *fitsptr,char *keyname); 46 static long ReadKeyL(fitsfile *fitsptr,char *keyname); 47 static LONGLONG ReadKeyLL(fitsfile *fitsptr,char *keyname); 48 static string ReadKeyS(fitsfile *fitsptr,char *keyname); 48 49 static void printerror(int sta); 49 50 … … 72 73 void ChangeBuffer(long blen=100,long bsens=1); 73 74 74 double ReadKey(char *keyname); 75 long ReadKeyL(char *keyname); 76 string ReadKeyS(char *keyname); 77 78 double Read(long n,bool usebuffer=true); 79 80 long Read(long n1,long n2,TVector<uint_2>& data); 81 long Read(long n1,long n2,TVector<int_4>& data); 82 long Read(long n1,long n2,TVector<int_8>& data); 83 long Read(long n1,long n2,TVector<float>& data); 84 long Read(long n1,long n2,TVector<double>& data); 75 double ReadKey(char *keyname); 76 long ReadKeyL(char *keyname); 77 LONGLONG ReadKeyLL(char *keyname); 78 string ReadKeyS(char *keyname); 79 80 double Read(LONGLONG n,bool usebuffer=true); 81 82 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data); 83 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data); 84 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<int_8>& data); 85 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<float>& data); 86 LONGLONG Read(LONGLONG n1,LONGLONG n2,TVector<double>& data); 85 87 86 88 //! return the value of the first row … … 91 93 {return Read(NBline-1,usebuffer);} 92 94 93 long FirstRow(double val1,double val2,longrowstart=-1);94 long LastRow(double val1,double val2,longrowstart=-1);95 LONGLONG FirstRow(double val1,double val2,LONGLONG rowstart=-1); 96 LONGLONG LastRow(double val1,double val2,LONGLONG rowstart=-1); 95 97 96 98 //! Set debug level … … 115 117 {if(FitsOF) return FitsOF->HDUType(); else return 0;} 116 118 //! Get the number of rows in the FITS HDU to be read 117 inline longGetNbLine(void) const {return NBline;}119 inline LONGLONG GetNbLine(void) const {return NBline;} 118 120 //! Get the number of columns in the FITS HDU to be read 119 121 inline int GetNbCol(void) const {return NBcol;} … … 148 150 string ColLabel,ColTUnit,ColTForm; 149 151 int ColNum,ColTypeCode,NBcol; 150 longNBline;152 LONGLONG NBline; 151 153 152 154 double NulVal; … … 154 156 long BuffLen, BuffSens; 155 157 156 unsigned longNFitsRead;158 LONGLONG NFitsRead; 157 159 FitsOpenFile* FitsOF; 158 longLineDeb, LineFin;160 LONGLONG LineDeb, LineFin; 159 161 double *Buffer; 160 162 long NBuffer; … … 188 190 virtual ~FitsImg2DRd(); 189 191 190 double ReadKey(char *keyname); 191 long ReadKeyL(char *keyname); 192 string ReadKeyS(char *keyname); 193 194 size_t Read(TMatrix<uint_2>& data); 195 size_t Read(TMatrix<int_4>& data); 196 size_t Read(TMatrix<int_8>& data); 197 size_t Read(TMatrix<float>& data); 198 size_t Read(TMatrix<double>& data); 192 double ReadKey(char *keyname); 193 long ReadKeyL(char *keyname); 194 LONGLONG ReadKeyLL(char *keyname); 195 string ReadKeyS(char *keyname); 196 197 LONGLONG Read(TMatrix<uint_2>& data); 198 LONGLONG Read(TMatrix<int_4>& data); 199 LONGLONG Read(TMatrix<int_8>& data); 200 LONGLONG Read(TMatrix<float>& data); 201 LONGLONG Read(TMatrix<double>& data); 199 202 200 203 //! Set debug level … … 216 219 {if(FitsOF) return FitsOF->HDUType(); else return 0;} 217 220 //! Get NAXIS1 218 inline longNaxis1(void) const {return Naxis[0];}221 inline LONGLONG Naxis1(void) const {return Naxis[0];} 219 222 //! Get NAXIS2 220 inline longNaxis2(void) const {return Naxis[1];}223 inline LONGLONG Naxis2(void) const {return Naxis[1];} 221 224 222 225 protected: 223 226 void Init(FitsOpenFile* fof,int ihdu,int lp); 224 227 225 longNaxis[2];228 LONGLONG Naxis[2]; 226 229 double NulVal; 227 230 unsigned short DbgLevel; … … 251 254 virtual ~FitsImg3DRd(); 252 255 253 double ReadKey(char *keyname); 254 long ReadKeyL(char *keyname); 255 string ReadKeyS(char *keyname); 256 257 size_t Read(TArray<uint_2>& data); 258 size_t Read(TArray<int_4>& data); 259 size_t Read(TArray<int_8>& data); 260 size_t Read(TArray<float>& data); 261 size_t Read(TArray<double>& data); 256 double ReadKey(char *keyname); 257 long ReadKeyL(char *keyname); 258 LONGLONG ReadKeyLL(char *keyname); 259 string ReadKeyS(char *keyname); 260 261 LONGLONG Read(TArray<uint_2>& data); 262 LONGLONG Read(TArray<int_4>& data); 263 LONGLONG Read(TArray<int_8>& data); 264 LONGLONG Read(TArray<float>& data); 265 LONGLONG Read(TArray<double>& data); 262 266 263 267 //! Set debug level … … 279 283 {if(FitsOF) return FitsOF->HDUType(); else return 0;} 280 284 //! Get NAXIS1 281 inline longNaxis1(void) const {return Naxis[0];}285 inline LONGLONG Naxis1(void) const {return Naxis[0];} 282 286 //! Get NAXIS2 283 inline longNaxis2(void) const {return Naxis[1];}287 inline LONGLONG Naxis2(void) const {return Naxis[1];} 284 288 //! Get NAXIS3 285 inline longNaxis3(void) const {return Naxis[2];}289 inline LONGLONG Naxis3(void) const {return Naxis[2];} 286 290 287 291 protected: 288 292 void Init(FitsOpenFile* fof,int ihdu,int lp); 289 293 290 longNaxis[3];294 LONGLONG Naxis[3]; 291 295 double NulVal; 292 296 unsigned short DbgLevel; -
trunk/SophyaExt/FitsIOServer/fabtwriter.cc
r3114 r3128 53 53 DoubleKey.resize(0); 54 54 LongKey.resize(0); 55 LongLongKey.resize(0); 55 56 StringKey.resize(0); 56 57 … … 78 79 79 80 // create d'un Primary HDU 80 // longnaxes[1] = {0};81 //if(fits_create_img (FitsPtr,BYTE_IMG,0,naxes,&sta)) {81 //LONGLONG naxes[1] = {0}; 82 //if(fits_create_imgll(FitsPtr,BYTE_IMG,0,naxes,&sta)) { 82 83 // printerror(sta); 83 84 // throw NullPtrError("FitsWriter::cr_or_upd_fits: Error creating Primary extension\n"); … … 125 126 } 126 127 128 /*! Write a long long value into Fits Header */ 129 void FitsWriter::WriteKey(const char *keyname,LONGLONG val,char* comment) 130 { 131 if(keyname==NULL || strlen(keyname)<=0) return; 132 KeyLongLong k; 133 k.keyname=keyname; 134 k.val=val; 135 if(comment) k.comment=comment; else k.comment=""; 136 LongLongKey.push_back(k); 137 } 138 127 139 /*! Write a string value into Fits Header */ 128 140 void FitsWriter::WriteKey(const char *keyname,string val,char* comment) … … 142 154 int sta=0; 143 155 if(DoubleKey.size()>0) 144 for(unsigned inti=0;i<DoubleKey.size();i++) {156 for(unsigned long i=0;i<DoubleKey.size();i++) { 145 157 char* key = const_cast<char*>(DoubleKey[i].keyname.c_str()); 146 158 char* com = const_cast<char*>(DoubleKey[i].comment.c_str()); … … 150 162 } 151 163 if(LongKey.size()>0) 152 for(unsigned inti=0;i<LongKey.size();i++) {164 for(unsigned long i=0;i<LongKey.size();i++) { 153 165 char* key = const_cast<char*>(LongKey[i].keyname.c_str()); 154 166 char* com = const_cast<char*>(LongKey[i].comment.c_str()); … … 157 169 printerror(sta); 158 170 } 171 if(LongLongKey.size()>0) 172 for(unsigned long i=0;i<LongLongKey.size();i++) { 173 char* key = const_cast<char*>(LongLongKey[i].keyname.c_str()); 174 char* com = const_cast<char*>(LongLongKey[i].comment.c_str()); 175 LONGLONG val = LongLongKey[i].val; 176 if(fits_update_key(FitsPtr,TLONGLONG,key,&val,com,&sta)) 177 printerror(sta); 178 } 159 179 if(StringKey.size()>0) 160 for(unsigned inti=0;i<StringKey.size();i++) {180 for(unsigned long i=0;i<StringKey.size();i++) { 161 181 char* key = const_cast<char*>(StringKey[i].keyname.c_str()); 162 182 char* com = const_cast<char*>(StringKey[i].comment.c_str()); … … 167 187 DoubleKey.resize(0); 168 188 LongKey.resize(0); 189 LongLongKey.resize(0); 169 190 StringKey.resize(0); 170 191 } 171 192 172 void FitsWriter::printerrorwrite(const char* type,int col, longrow,int sta)193 void FitsWriter::printerrorwrite(const char* type,int col,LONGLONG row,int sta) 173 194 { 174 195 if(sta==NUM_OVERFLOW) {NOverFlow++; return;} … … 176 197 char str[256]; 177 198 sprintf(str,"FitsWriter::Write_%s: Error Writing Fits c=%d r=%ld sta=%d" 178 ,type,col, row,sta);199 ,type,col,(long)row,sta); 179 200 throw NotAvailableOperation(str); 180 201 } … … 208 229 int c5 = fbtw.AddCol("vard","","arcmin",TDOUBLE); // col=4 209 230 fbtw.SetDebug(3); 210 for( longi=0;i<1000;i++) {231 for(LONGLONG i=0;i<1000;i++) { 211 232 double x = i; 212 233 fbtw.Write(c1,i,1000.*x); // if overflow, managed by cfitsio … … 228 249 TVector<float> dataf(100); 229 250 TVector<int_4> datal(100); 230 for( longi=0;i<9990;i+=100) {231 longi2=i+100-1; if(i2>=9990) i2=9990-1;232 for( longj=0;j<100;j++) datad(i) = ...;233 for( longj=0;j<100;j++) dataf(i) = ...;234 for( longj=0;j<100;j++) datal(i) = ...;251 for(LONGLONG i=0;i<9990;i+=100) { 252 LONGLONG i2=i+100-1; if(i2>=9990) i2=9990-1; 253 for(LONGLONG j=0;j<100;j++) datad(i) = ...; 254 for(LONGLONG j=0;j<100;j++) dataf(i) = ...; 255 for(LONGLONG j=0;j<100;j++) datal(i) = ...; 235 256 fbtw.Write(1,i,datal); 236 257 fbtw.Write(2,i,dataf); … … 251 272 cout<<"Writing Keys"<<endl; 252 273 fbtw.WriteKey("MYKEYL",(long)123456789,"my LONG key"); 274 fbtw.WriteKey("MYKEYLL",(LONGLONG)123456789,"my LONGLONG key"); 253 275 fbtw.WriteKey("MYKEYD",1.9999999,"my DOUBLE key"); 254 276 fbtw.WriteKey("MYKEYC","how are you ?","my CHAR* key"); … … 265 287 cout<<"Writing Keys"<<endl; 266 288 fbtw2.WriteKey("MYKEYL",(long)-123456789,"my new LONG key"); 289 fbtw2.WriteKey("MYKEYLL",(LONGLONG)-123456789,"my new LONGLONG key"); 267 290 fbtw2.WriteKey("MYKEYD",-1.9999999,"my new clef DOUBLE key"); 268 291 fbtw2.WriteKey("MYKEYC","how are you NOW ?","my new CHAR* key"); … … 275 298 276 299 cout<<">>>>> Write into the 2 tables simultaneously"<<endl; 277 for( inti=0;i<NNN;i++) {300 for(LONGLONG i=0;i<NNN;i++) { 278 301 fbtw.Write(i1,i,i+1.); 279 302 fbtw.Write(i2,i,i+11.); … … 462 485 throw ParmError("FitsABTWriter::createtbl: Zero column asked !\n"); 463 486 464 longnrows = 0;487 LONGLONG nrows = 0; 465 488 char *extname = NULL; 466 489 char **ttype = (char **) malloc(tfields*sizeof(char *)); … … 472 495 strcpy(extname,ExtName.c_str()); 473 496 } 474 int i; 475 for(i=0;i<tfields;i++) { 497 for(int i=0;i<tfields;i++) { 476 498 ttype[i] = (char *) malloc((strlen(Label[i].c_str())+1)*sizeof(char)); 477 499 strcpy(ttype[i],Label[i].c_str()); … … 491 513 // menage 492 514 if(extname) delete [] extname; 493 for(i =0;i<tfields;i++) {515 for(int i=0;i<tfields;i++) { 494 516 if(ttype[i]) delete [] ttype[i]; 495 517 if(tform[i]) delete [] tform[i]; … … 525 547 526 548 /*! Write signed char (1 Byte) data to FITS file (see below) */ 527 void FitsABTWriter::Write(int col, longrow,int_1 val)549 void FitsABTWriter::Write(int col,LONGLONG row,int_1 val) 528 550 { 529 551 #ifdef TSBYTE … … 538 560 539 561 /*! Write unsigned char (1 Byte) data to FITS file (see below) */ 540 void FitsABTWriter::Write(int col, longrow,uint_1 val)562 void FitsABTWriter::Write(int col,LONGLONG row,uint_1 val) 541 563 { 542 564 if(FirstTime) createtbl(); … … 547 569 548 570 /*! Write short (2 Bytes) data to FITS file (see below) */ 549 void FitsABTWriter::Write(int col, longrow,int_2 val)571 void FitsABTWriter::Write(int col,LONGLONG row,int_2 val) 550 572 { 551 573 if(FirstTime) createtbl(); … … 556 578 557 579 /*! Write unsigned short (2 Bytes) data to FITS file (see below) */ 558 void FitsABTWriter::Write(int col, longrow,uint_2 val)580 void FitsABTWriter::Write(int col,LONGLONG row,uint_2 val) 559 581 { 560 582 if(FirstTime) createtbl(); … … 565 587 566 588 /*! Write long (4 Bytes) data to FITS file (see below) */ 567 void FitsABTWriter::Write(int col, longrow,int_4 val)589 void FitsABTWriter::Write(int col,LONGLONG row,int_4 val) 568 590 { 569 591 if(FirstTime) createtbl(); … … 576 598 577 599 /*! Write unsigned long (4 Bytes) data to FITS file (see below) */ 578 void FitsABTWriter::Write(int col, longrow,uint_4 val)600 void FitsABTWriter::Write(int col,LONGLONG row,uint_4 val) 579 601 { 580 602 if(FirstTime) createtbl(); … … 587 609 588 610 /*! Write long long (8 Bytes) data to FITS file (see below) */ 589 void FitsABTWriter::Write(int col, longrow,int_8 val)611 void FitsABTWriter::Write(int col,LONGLONG row,int_8 val) 590 612 { 591 613 #ifdef TLONGLONG … … 600 622 601 623 /*! Write float data to FITS file (see below) */ 602 void FitsABTWriter::Write(int col, longrow,float val)624 void FitsABTWriter::Write(int col,LONGLONG row,float val) 603 625 { 604 626 if(FirstTime) createtbl(); … … 609 631 610 632 /*! Write double data to FITS file (see below) */ 611 void FitsABTWriter::Write(int col, longrow,double val)633 void FitsABTWriter::Write(int col,LONGLONG row,double val) 612 634 { 613 635 if(FirstTime) createtbl(); … … 628 650 629 651 /*! Write a vector of unsigned short (2 Bytes) data to FITS file (see below) */ 630 long FitsABTWriter::Write(int col,longrow,TVector<uint_2>& val)631 { 632 if(FirstTime) createtbl(); 633 longnel = val.Size();652 LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<uint_2>& val) 653 { 654 if(FirstTime) createtbl(); 655 LONGLONG nel = val.Size(); 634 656 int sta=0; 635 657 if(fits_write_col(FitsPtr,TUSHORT,col+1,row+1,1,nel,val.Data(),&sta)) … … 639 661 640 662 /*! Write a vector of long (4 Bytes) data to FITS file (see below) */ 641 long FitsABTWriter::Write(int col,longrow,TVector<int_4>& val)642 { 643 if(FirstTime) createtbl(); 644 longnel = val.Size();663 LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<int_4>& val) 664 { 665 if(FirstTime) createtbl(); 666 LONGLONG nel = val.Size(); 645 667 int sta=0; 646 668 // Bug ou inconsistence cfitsio sur machine ou long=8Bytes ? … … 652 674 653 675 /*! Write a vector of long long (8 Bytes) data to FITS file (see below) */ 654 long FitsABTWriter::Write(int col,longrow,TVector<int_8>& val)676 LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<int_8>& val) 655 677 { 656 678 #ifdef TLONGLONG 657 679 if(FirstTime) createtbl(); 658 longnel = val.Size();680 LONGLONG nel = val.Size(); 659 681 int sta=0; 660 682 if(fits_write_col(FitsPtr,TLONGLONG,col+1,row+1,1,nel,val.Data(),&sta)) … … 667 689 668 690 /*! Write a vector of float data to FITS file (see below) */ 669 long FitsABTWriter::Write(int col,longrow,TVector<float>& val)670 { 671 if(FirstTime) createtbl(); 672 longnel = val.Size();691 LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<float>& val) 692 { 693 if(FirstTime) createtbl(); 694 LONGLONG nel = val.Size(); 673 695 int sta=0; 674 696 if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,nel,val.Data(),&sta)) … … 678 700 679 701 /*! Write a vector of double data to FITS file (see below) */ 680 long FitsABTWriter::Write(int col,longrow,TVector<double>& val)681 { 682 if(FirstTime) createtbl(); 683 longnel = val.Size();702 LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<double>& val) 703 { 704 if(FirstTime) createtbl(); 705 LONGLONG nel = val.Size(); 684 706 int sta=0; 685 707 if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,nel,val.Data(),&sta)) … … 785 807 786 808 int sta=0; 787 if(fits_create_img (FitsPtr,BitPix,2,Naxis,&sta)) {809 if(fits_create_imgll(FitsPtr,BitPix,2,Naxis,&sta)) { 788 810 printerror(sta); 789 811 throw NullPtrError("FitsImg2DWriter::createimg: Error creating image extension\n"); … … 802 824 uint_2* arr = new uint_2[Naxis[0]]; 803 825 804 for( intl=0;l<Naxis[1];l++) {805 for( intc=0;c<Naxis[0];c++) arr[c] = data(l,c);806 longdeb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;826 for(LONGLONG l=0;l<Naxis[1];l++) { 827 for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c); 828 LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0; 807 829 fits_write_img(FitsPtr,TUSHORT,deb,nel,arr,&sta); 808 830 if(sta) { … … 823 845 int_4* arr = new int_4[Naxis[0]]; 824 846 825 for( intl=0;l<Naxis[1];l++) {826 for( intc=0;c<Naxis[0];c++) arr[c] = data(l,c);827 longdeb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;847 for(LONGLONG l=0;l<Naxis[1];l++) { 848 for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c); 849 LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0; 828 850 fits_write_img(FitsPtr,T,deb,nel,arr,&sta); 829 851 if(sta) { … … 843 865 float* arr = new float[Naxis[0]]; 844 866 845 for( intl=0;l<Naxis[1];l++) {846 for( intc=0;c<Naxis[0];c++) arr[c] = data(l,c);847 longdeb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;867 for(LONGLONG l=0;l<Naxis[1];l++) { 868 for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c); 869 LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0; 848 870 fits_write_img(FitsPtr,TFLOAT,deb,nel,arr,&sta); 849 871 if(sta) { … … 863 885 double* arr = new double[Naxis[0]]; 864 886 865 for( intl=0;l<Naxis[1];l++) {866 for( intc=0;c<Naxis[0];c++) arr[c] = data(l,c);867 longdeb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0;887 for(LONGLONG l=0;l<Naxis[1];l++) { 888 for(LONGLONG c=0;c<Naxis[0];c++) arr[c] = data(l,c); 889 LONGLONG deb = l*Naxis[0]+1, nel = Naxis[0]; int sta=0; 868 890 fits_write_img(FitsPtr,TDOUBLE,deb,nel,arr,&sta); 869 891 if(sta) { … … 972 994 973 995 int sta=0; 974 if(fits_create_img (FitsPtr,BitPix,3,Naxis,&sta)) {996 if(fits_create_imgll(FitsPtr,BitPix,3,Naxis,&sta)) { 975 997 printerror(sta); 976 998 throw NullPtrError("FitsImg3DWriter::createimg: Error creating 3D image extension\n"); … … 991 1013 uint_2* arr = new uint_2[Naxis[0]]; 992 1014 993 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {994 for( inti=0;i<Naxis[0];i++) arr[i] = data(i,j,k);995 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;1015 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1016 for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k); 1017 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0; 996 1018 fits_write_img(FitsPtr,TUSHORT,deb,nel,arr,&sta); 997 1019 if(sta) { … … 1015 1037 int_4* arr = new int_4[Naxis[0]]; 1016 1038 1017 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1018 for( inti=0;i<Naxis[0];i++) arr[i] = data(i,j,k);1019 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;1039 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1040 for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k); 1041 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0; 1020 1042 fits_write_img(FitsPtr,T,deb,nel,arr,&sta); 1021 1043 if(sta) { … … 1038 1060 float* arr = new float[Naxis[0]]; 1039 1061 1040 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1041 for( inti=0;i<Naxis[0];i++) arr[i] = data(i,j,k);1042 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;1062 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1063 for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k); 1064 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0; 1043 1065 fits_write_img(FitsPtr,TFLOAT,deb,nel,arr,&sta); 1044 1066 if(sta) { … … 1061 1083 double* arr = new double[Naxis[0]]; 1062 1084 1063 for( int k=0;k<Naxis[2];k++) for(intj=0;j<Naxis[1];j++) {1064 for( inti=0;i<Naxis[0];i++) arr[i] = data(i,j,k);1065 longdeb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0;1085 for(LONGLONG k=0;k<Naxis[2];k++) for(LONGLONG j=0;j<Naxis[1];j++) { 1086 for(LONGLONG i=0;i<Naxis[0];i++) arr[i] = data(i,j,k); 1087 LONGLONG deb = Naxis[0]*(j+Naxis[1]*k)+1, nel = Naxis[0]; int sta=0; 1066 1088 fits_write_img(FitsPtr,TDOUBLE,deb,nel,arr,&sta); 1067 1089 if(sta) { -
trunk/SophyaExt/FitsIOServer/fabtwriter.h
r3114 r3128 34 34 //! Write a long value in Fits header. 35 35 void WriteKey(const char *keyname,long val,char* comment=NULL); 36 //! Write a long long value in Fits header. 37 void WriteKey(const char *keyname,LONGLONG val,char* comment=NULL); 36 38 //! Write a string value in Fits header. 37 39 void WriteKey(const char *keyname,string val,char* comment=NULL); … … 43 45 44 46 //! Return the number of overflows managed by cfitsio 45 inline unsigned longGetNOverFlow(void) {return NOverFlow;}47 inline LONGLONG GetNOverFlow(void) {return NOverFlow;} 46 48 47 49 //! Return the c-fitsio file pointer 48 50 inline fitsfile * GetFitsPtr() { return FitsPtr; } 49 51 protected: 50 struct KeyDouble {string keyname; double val; string comment;}; 51 struct KeyLong {string keyname; long val; string comment;}; 52 struct KeyString {string keyname; string val; string comment;}; 52 struct KeyDouble {string keyname; double val; string comment;}; 53 struct KeyLong {string keyname; long val; string comment;}; 54 struct KeyLongLong {string keyname; LONGLONG val; string comment;}; 55 struct KeyString {string keyname; string val; string comment;}; 53 56 54 57 void cr_or_upd_fits(const char *cfname,bool update,int lp); 55 58 56 59 void writekeys(void); 57 void printerrorwrite(const char* type,int col, longrow,int sta);60 void printerrorwrite(const char* type,int col,LONGLONG row,int sta); 58 61 void printerror(int sta) const; 59 62 … … 63 66 unsigned short DbgLevel; 64 67 fitsfile *FitsPtr; 65 unsigned longNOverFlow;68 LONGLONG NOverFlow; 66 69 67 vector<struct KeyDouble> DoubleKey; 68 vector<struct KeyLong> LongKey; 69 vector<struct KeyString> StringKey; 70 vector<struct KeyDouble> DoubleKey; 71 vector<struct KeyLong> LongKey; 72 vector<struct KeyLongLong> LongLongKey; 73 vector<struct KeyString> StringKey; 70 74 }; 71 75 … … 95 99 {return addcol(label,tform,tunit,datatype);} 96 100 97 void Write(int col, longrow,int_1 val);98 void Write(int col, longrow,uint_1 val);99 void Write(int col, longrow,int_2 val);100 void Write(int col, longrow,uint_2 val);101 void Write(int col, longrow,int_4 val);102 void Write(int col, longrow,uint_4 val);103 void Write(int col, longrow,int_8 val);104 void Write(int col, longrow,float val);105 void Write(int col, longrow,double val);106 long Write(int col,longrow,TVector<uint_2>& val);107 long Write(int col,longrow,TVector<int_4>& val);108 long Write(int col,longrow,TVector<int_8>& val);109 long Write(int col,longrow,TVector<float>& val);110 long Write(int col,longrow,TVector<double>& val);101 void Write(int col,LONGLONG row,int_1 val); 102 void Write(int col,LONGLONG row,uint_1 val); 103 void Write(int col,LONGLONG row,int_2 val); 104 void Write(int col,LONGLONG row,uint_2 val); 105 void Write(int col,LONGLONG row,int_4 val); 106 void Write(int col,LONGLONG row,uint_4 val); 107 void Write(int col,LONGLONG row,int_8 val); 108 void Write(int col,LONGLONG row,float val); 109 void Write(int col,LONGLONG row,double val); 110 LONGLONG Write(int col,LONGLONG row,TVector<uint_2>& val); 111 LONGLONG Write(int col,LONGLONG row,TVector<int_4>& val); 112 LONGLONG Write(int col,LONGLONG row,TVector<int_8>& val); 113 LONGLONG Write(int col,LONGLONG row,TVector<float>& val); 114 LONGLONG Write(int col,LONGLONG row,TVector<double>& val); 111 115 112 116 //! Return the number of created columns … … 153 157 154 158 int BitPix; 155 longNaxis[2];159 LONGLONG Naxis[2]; 156 160 bool FirstTime; 157 161 }; … … 182 186 183 187 int BitPix; 184 longNaxis[3];188 LONGLONG Naxis[3]; 185 189 bool FirstTime; 186 190 }; -
trunk/SophyaExt/FitsIOServer/fboloread.cc
r2615 r3128 28 28 29 29 cout<<"Reading element by elements"<<endl; 30 for( longi=0; i<fbr.GetNbLine(); i++) {30 for(LONGLONG i=0; i<fbr.GetNbLine(); i++) { 31 31 double a = fbr.GetAlpha(i); 32 32 double d = fbr.GetDelta(i); … … 43 43 TVector<float> Vc1; 44 44 TVector<int_4> Vs; 45 for( longi=0, istep=1000; i<fbr.GetNbLine(); i+=istep) {46 longi2=i+istep-1; if(i2>=fbr.GetNbLine()) i2=fbr.GetNbLine()-1;45 for(LONGLONG i=0, istep=1000; i<fbr.GetNbLine(); i+=istep) { 46 LONGLONG i2=i+istep-1; if(i2>=fbr.GetNbLine()) i2=fbr.GetNbLine()-1; 47 47 fbr.GetSNum(i,i2,Vs); 48 48 fbr.GetBolo(i,i2,Vb); … … 148 148 149 149 // Set the number of rows as the smallest of for connected columns 150 longnrows = mFABT[col]->GetNbLine();150 LONGLONG nrows = mFABT[col]->GetNbLine(); 151 151 if(NBline==0) NBline = nrows; 152 152 else if(nrows<NBline) NBline = nrows; … … 222 222 for(col=0; col<(int)mFABT.size(); col++) { 223 223 if(mFABT[col]==NULL) continue; 224 longnbl = mFABT[col]->GetNbLine();224 LONGLONG nbl = mFABT[col]->GetNbLine(); 225 225 if(nbl==0) continue; 226 226 if(NBline==0 || nbl<NBline) NBline = nbl; -
trunk/SophyaExt/FitsIOServer/fboloread.h
r2322 r3128 44 44 45 45 //! return Alpha value for row "n" into double 46 inline double GetAlpha( longn,bool usebuffer=true)46 inline double GetAlpha(LONGLONG n,bool usebuffer=true) 47 47 {return GetCol(ColAlpha,n,usebuffer);} 48 48 //! return Delta value for row "n" into double 49 inline double GetDelta( longn,bool usebuffer=true)49 inline double GetDelta(LONGLONG n,bool usebuffer=true) 50 50 {return GetCol(ColDelta,n,usebuffer);} 51 51 //! return Bolo value for row "n" into double 52 inline double GetBolo( longn,bool usebuffer=true)52 inline double GetBolo(LONGLONG n,bool usebuffer=true) 53 53 {return GetCol(ColBolo,n,usebuffer);} 54 54 //! return Flag value for row "n" into double 55 inline double GetFlag( longn,bool usebuffer=true)55 inline double GetFlag(LONGLONG n,bool usebuffer=true) 56 56 {if(!IsFlag()) return 0.; return GetCol(ColFlag,n,usebuffer);} 57 57 //! return SNum value for row "n" into double 58 inline double GetSNum( longn,bool usebuffer=true)58 inline double GetSNum(LONGLONG n,bool usebuffer=true) 59 59 {return GetCol(ColSNum,n,usebuffer);} 60 60 //! return column "col" value for row "n" into double 61 inline double GetCol(int col, longn,bool usebuffer=true) {61 inline double GetCol(int col,LONGLONG n,bool usebuffer=true) { 62 62 if(col<0 || col>=(int)mFABT.size()) 63 63 throw ParmError("FitsBoloRead::GetCol: bad column number\n"); … … 68 68 69 69 //! return Alpha values for rows [n1,n2] into TVector 70 inline long GetAlpha(long n1,longn2,TVector<double>& data)70 inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<double>& data) 71 71 {return GetCol(ColAlpha,n1,n2,data);} 72 inline long GetAlpha(long n1,longn2,TVector<float>& data)72 inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<float>& data) 73 73 {return GetCol(ColAlpha,n1,n2,data);} 74 inline long GetAlpha(long n1,longn2,TVector<int_4>& data)74 inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<int_4>& data) 75 75 {return GetCol(ColAlpha,n1,n2,data);} 76 76 77 77 //! return Delta values for rows [n1,n2] into TVector 78 inline long GetDelta(long n1,longn2,TVector<double>& data)78 inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<double>& data) 79 79 {return GetCol(ColDelta,n1,n2,data);} 80 inline long GetDelta(long n1,longn2,TVector<float>& data)80 inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<float>& data) 81 81 {return GetCol(ColDelta,n1,n2,data);} 82 inline long GetDelta(long n1,longn2,TVector<int_4>& data)82 inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<int_4>& data) 83 83 {return GetCol(ColDelta,n1,n2,data);} 84 84 85 85 //! return Bolo values for rows [n1,n2] into TVector 86 inline long GetBolo(long n1,longn2,TVector<double>& data)86 inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<double>& data) 87 87 {return GetCol(ColBolo,n1,n2,data);} 88 inline long GetBolo(long n1,longn2,TVector<float>& data)88 inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<float>& data) 89 89 {return GetCol(ColBolo,n1,n2,data);} 90 inline long GetBolo(long n1,longn2,TVector<int_4>& data)90 inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<int_4>& data) 91 91 {return GetCol(ColBolo,n1,n2,data);} 92 92 93 93 //! return Flag values for rows [n1,n2] into TVector 94 inline long GetFlag(long n1,longn2,TVector<double>& data)94 inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<double>& data) 95 95 {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);} 96 inline long GetFlag(long n1,longn2,TVector<float>& data)96 inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<float>& data) 97 97 {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);} 98 inline long GetFlag(long n1,longn2,TVector<int_4>& data)98 inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<int_4>& data) 99 99 {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);} 100 100 101 101 //! return Sample Number values for rows [n1,n2] into TVector 102 inline long GetSNum(long n1,longn2,TVector<double>& data)102 inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<double>& data) 103 103 {return GetCol(ColSNum,n1,n2,data);} 104 inline long GetSNum(long n1,longn2,TVector<float>& data)104 inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<float>& data) 105 105 {return GetCol(ColSNum,n1,n2,data);} 106 inline long GetSNum(long n1,longn2,TVector<int_4>& data)106 inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<int_4>& data) 107 107 {return GetCol(ColSNum,n1,n2,data);} 108 108 109 109 //! return column "col" values for rows [n1,n2] into TVector 110 inline long GetCol(int col,long n1,longn2,TVector<double>& data) {110 inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<double>& data) { 111 111 if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0; 112 112 return mFABT[col]->Read(n1,n2,data); 113 113 } 114 inline long GetCol(int col,long n1,longn2,TVector<float>& data) {114 inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<float>& data) { 115 115 if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0; 116 116 return mFABT[col]->Read(n1,n2,data); 117 117 } 118 inline long GetCol(int col,long n1,longn2,TVector<int_4>& data) {118 inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<int_4>& data) { 119 119 if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0; 120 120 return mFABT[col]->Read(n1,n2,data); … … 144 144 void SetNbLine(int col=-1); 145 145 //! Get the number of rows to be read 146 inline longGetNbLine(void) const {return NBline;}146 inline LONGLONG GetNbLine(void) const {return NBline;} 147 147 //! Get the number of columns in the FITS HDU to be read 148 148 inline int GetNbCol(void) const {return mFABT.size();} … … 175 175 void Gess_If_Not_Define(int col); 176 176 177 longNBline;177 LONGLONG NBline; 178 178 unsigned short DbgLevel; 179 179 long BuffLen, BuffSens;
Note:
See TracChangeset
for help on using the changeset viewer.