Changeset 3128 in Sophya


Ignore:
Timestamp:
Jan 11, 2007, 7:07:52 PM (19 years ago)
Author:
cmv
Message:

gestion gros fichiers FITS dans fabtcolread et fabtwriter cmv 11/01/2007

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/fabtcolread.cc

    r3114 r3128  
    209209 int sta=0; long val=0;
    210210 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*/
     221LONGLONG 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))
    211226   printerror(sta);
    212227 return val;
     
    267282  fbt.Print(3);
    268283  // Read element by element
    269   for(long i=0;i<fbt.GetNbLine();i++) {
     284  for(LONGLONG i=0;i<fbt.GetNbLine();i++) {
    270285    double x = fbt.Read(i);
    271286    double y = fbt2.Read(i);
     
    274289  // Read into a vector
    275290  TVector<double> data;
    276   long n = fbt.Read(32,50,data);
     291  LONGLONG n = fbt.Read(32,50,data);
    277292    cout<<"Number of values read: "<<n<<endl;
    278293  data.ReSize(100);
     
    402417
    403418 // Get number of rows
    404  if(fits_get_num_rows(GetFitsPtr(),&NBline,&sta)) {
     419 if(fits_get_num_rowsll(GetFitsPtr(),&NBline,&sta)) {
    405420   FitsOpenFile::printerror(sta);
    406421   throw NotAvailableOperation("FitsABTColRd::Init: Error getting number of rows\n");
     
    425440
    426441 // 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)) {
    428443   FitsOpenFile::printerror(sta);
    429444   throw ParmError("FitsABTColRd::Init: Error getting column type\n");
     
    436451 // Get column name back, tunit, tform
    437452 char tunit[64], tform[64], tdisp[64];
    438  long repeat=0; double tscale=1., tzero=0.;
     453 LONGLONG repeat=0; double tscale=1., tzero=0.;
    439454 int rc=0;
    440455 if(HDUType()==BINARY_TBL) {
    441    fits_get_bcolparms(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
     456   fits_get_bcolparmsll(GetFitsPtr(),ColNum+1,labelcol,tunit,tform
    442457                     ,&repeat,&tscale,&tzero,NULL,tdisp,&sta);
    443458 } 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
    445461                     ,&tscale,&tzero,NULL,tdisp,&sta);
     462   repeat = repeatlng;
    446463 }
    447464 if(rc) {
     
    525542{
    526543 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*/
     551LONGLONG FitsABTColRd::ReadKeyLL(char *keyname)
     552{
     553 return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname);
    527554}
    528555
     
    549576  \endverbatim
    550577*/
    551 double FitsABTColRd::Read(long n,bool usebuffer)
     578double FitsABTColRd::Read(LONGLONG n,bool usebuffer)
    552579// Attention: n=nline [0,NBline[, cfistio veut [1,NBline]
    553580// Attention: colnum  [0,NBcol[ , cfistio veut [1,NBcol]
     
    581608 if(n<LineDeb || n>LineFin) {
    582609   NFitsRead++;
    583    long row1,row2,nrow;
     610   LONGLONG row1,row2,nrow;
    584611   if(BuffSens>0) { // Cas remplissage forward
    585612     row1 = n+1;
     
    640667  \endverbatim
    641668*/
    642 long FitsABTColRd::Read(long n1,long n2,TVector<double>& data)
     669LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<double>& data)
    643670{
    644671 if(n1<0 || n1>=NBline)
     
    649676 if(n2>=NBline) n2 = NBline-1;
    650677
    651  sa_size_t nread = n2-n1+1;
     678 LONGLONG nread = n2-n1+1;
    652679 if(data.Size()<nread) data.SetSize(nread);
    653680
    654  //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
     681 //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i);
    655682 int sta=0;
    656683 fits_read_col(GetFitsPtr(),TDOUBLE,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
     
    664691
    665692/*! idem before but for TVector of float */
    666 long FitsABTColRd::Read(long n1,long n2,TVector<float>& data)
     693LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<float>& data)
    667694{
    668695 if(n1<0 || n1>=NBline)
     
    673700 if(n2>=NBline) n2 = NBline-1;
    674701
    675  sa_size_t nread = n2-n1+1;
     702 LONGLONG nread = n2-n1+1;
    676703 if(data.Size()<nread) data.SetSize(nread);
    677704
    678  //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
     705 //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i);
    679706 int sta=0;
    680707 fits_read_col(GetFitsPtr(),TFLOAT,ColNum+1,n1+1,1,nread,NULL,data.Data(),NULL,&sta);
     
    688715
    689716/*! idem before but for TVector of unsigned short */
    690 long FitsABTColRd::Read(long n1,long n2,TVector<uint_2>& data)
     717LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<uint_2>& data)
    691718{
    692719 if(n1<0 || n1>=NBline)
     
    697724 if(n2>=NBline) n2 = NBline-1;
    698725
    699  sa_size_t nread = n2-n1+1;
     726 LONGLONG nread = n2-n1+1;
    700727 if(data.Size()<nread) data.SetSize(nread);
    701728
     
    711738
    712739/*! idem before but for TVector of int_4 */
    713 long FitsABTColRd::Read(long n1,long n2,TVector<int_4>& data)
     740LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
    714741{
    715742 if(n1<0 || n1>=NBline)
     
    720747 if(n2>=NBline) n2 = NBline-1;
    721748
    722  sa_size_t nread = n2-n1+1;
     749 LONGLONG nread = n2-n1+1;
    723750 if(data.Size()<nread) data.SetSize(nread);
    724751
    725  //for(long i=n1;i<=n2;i++) data(i-n1) = Read(i);
     752 //for(LONGLONG i=n1;i<=n2;i++) data(i-n1) = Read(i);
    726753 int sta=0;
    727754 int T = (sizeof(long)==4) ? TLONG: TINT;
     
    736763
    737764/*! idem before but for TVector of int_8 */
    738 long FitsABTColRd::Read(long n1,long n2,TVector<int_8>& data)
     765LONGLONG FitsABTColRd::Read(LONGLONG n1,LONGLONG n2,TVector<int_8>& data)
    739766{
    740767#ifdef TLONGLONG
     
    746773 if(n2>=NBline) n2 = NBline-1;
    747774
    748  sa_size_t nread = n2-n1+1;
     775 LONGLONG nread = n2-n1+1;
    749776 if(data.Size()<nread) data.SetSize(nread);
    750777
     
    773800  \return <0 means not found
    774801*/
    775 long FitsABTColRd::FirstRow(double val1,double val2,long rowstart)
    776 {
    777  long row = -1;
     802LONGLONG FitsABTColRd::FirstRow(double val1,double val2,LONGLONG rowstart)
     803{
     804 LONGLONG row = -1;
    778805 if(NBline==0) return row;
    779806 // Change buffer for efficiency
     
    782809 if(rowstart<0) rowstart = 0;
    783810 if(rowstart>=NBline) rowstart = NBline-1;
    784  for(long i=rowstart;i<NBline;i++) {
     811 for(LONGLONG i=rowstart;i<NBline;i++) {
    785812   double val = Read(i);
    786813   if(val<val1 || val>val2) continue;
     
    802829  \endverbatim
    803830*/
    804 long FitsABTColRd::LastRow(double val1,double val2,long rowstart)
    805 {
    806  long row = -1;
     831LONGLONG FitsABTColRd::LastRow(double val1,double val2,LONGLONG rowstart)
     832{
     833 LONGLONG row = -1;
    807834 if(NBline==0) return row;
    808835 // Change buffer for efficiency
     
    810837 if(bsens>=0) {ChangeBuffer(BuffLen,-1); bchange=true;}
    811838 if(rowstart<0 || rowstart>=NBline) rowstart = NBline-1;
    812  for(long i=rowstart;i>=0;i--) {
     839 for(LONGLONG i=rowstart;i>=0;i--) {
    813840   double val = Read(i);
    814841   if(val<val1 || val>val2) continue;
     
    853880  fbt.Print(3);
    854881  // Read element by element
    855   for(long i=0;i<fbt.GetNbLine();i++) {
     882  for(LONGLONG i=0;i<fbt.GetNbLine();i++) {
    856883    double x = fbt.Read(i);
    857884    if(i%lpmod==0) cout<<i<<": "<<x<<endl;
     
    859886  // Read into a vector
    860887  TVector<double> data;
    861   long n = fbt.Read(32,50,data);
     888  LONGLONG n = fbt.Read(32,50,data);
    862889    cout<<"Number of values read: "<<n<<endl;
    863890  data.ReSize(100);
     
    10271054 // Get NAXIS 1 et 2
    10281055 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)) {
    10301058   FitsOpenFile::printerror(sta);
    10311059   throw RangeCheckError("FitsImg2DRd::Init: Error reading NAXIS cards\n");
     
    10651093{
    10661094 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*/
     1102LONGLONG FitsImg2DRd::ReadKeyLL(char *keyname)
     1103{
     1104 return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname);
    10671105}
    10681106
     
    10881126\warning TMatrix data(Naxis2,Naxis1)
    10891127*/
    1090 size_t FitsImg2DRd::Read(TMatrix<uint_2>& data)
     1128LONGLONG FitsImg2DRd::Read(TMatrix<uint_2>& data)
    10911129{
    10921130 int sta=0;
     
    10941132 data.ReSize(Naxis[1],Naxis[0]);
    10951133
    1096  for(int j=0;j<Naxis[1];j++) {
    1097    long deb = 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];
    10981136   fits_read_img(GetFitsPtr(),TUSHORT,deb,nel,&NulVal,arr,NULL,&sta);
    10991137   if(sta) {
     
    11021140       NotAvailableOperation("FitsImg2DRd::Read(TMatrix<uint_2>): Error Reading Fits file\n");
    11031141   }
    1104    for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
     1142   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
    11051143 }
    11061144
     
    11101148
    11111149/*! Read image into a TMatrix<int_4> */
    1112 size_t FitsImg2DRd::Read(TMatrix<int_4>& data)
     1150LONGLONG FitsImg2DRd::Read(TMatrix<int_4>& data)
    11131151{
    11141152 int sta=0;
     
    11171155 int T = (sizeof(long)==4) ? TLONG: TINT;
    11181156
    1119  for(int j=0;j<Naxis[1];j++) {
    1120    long deb = 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];
    11211159   fits_read_img(GetFitsPtr(),T,deb,nel,&NulVal,arr,NULL,&sta);
    11221160   if(sta) {
     
    11251163       NotAvailableOperation("FitsImg2DRd::Read(TMatrix<int_4>): Error Reading Fits file\n");
    11261164   }
    1127    for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
     1165   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
    11281166 }
    11291167
     
    11331171
    11341172/*! Read image into a TMatrix<int_8> */
    1135 size_t FitsImg2DRd::Read(TMatrix<int_8>& data)
     1173LONGLONG FitsImg2DRd::Read(TMatrix<int_8>& data)
    11361174{
    11371175 int sta=0;
     
    11391177 data.ReSize(Naxis[1],Naxis[0]);
    11401178
    1141  for(int j=0;j<Naxis[1];j++) {
    1142    long deb = 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];
    11431181   fits_read_img(GetFitsPtr(),TLONGLONG,deb,nel,&NulVal,arr,NULL,&sta);
    11441182   if(sta) {
     
    11471185       NotAvailableOperation("FitsImg2DRd::Read(TMatrix<int_8>): Error Reading Fits file\n");
    11481186   }
    1149    for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
     1187   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
    11501188 }
    11511189
     
    11551193
    11561194/*! Read image into a TMatrix<float> */
    1157 size_t FitsImg2DRd::Read(TMatrix<float>& data)
     1195LONGLONG FitsImg2DRd::Read(TMatrix<float>& data)
    11581196{
    11591197 int sta=0;
     
    11611199 data.ReSize(Naxis[1],Naxis[0]);
    11621200
    1163  for(int j=0;j<Naxis[1];j++) {
    1164    long deb = 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];
    11651203   fits_read_img(GetFitsPtr(),TFLOAT,deb,nel,&NulVal,arr,NULL,&sta);
    11661204   if(sta) {
     
    11691207       NotAvailableOperation("FitsImg2DRd::Read(TMatrix<float>): Error Reading Fits file\n");
    11701208   }
    1171    for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
     1209   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
    11721210 }
    11731211
     
    11771215
    11781216/*! Read image into a TMatrix<double> */
    1179 size_t FitsImg2DRd::Read(TMatrix<double>& data)
     1217LONGLONG FitsImg2DRd::Read(TMatrix<double>& data)
    11801218{
    11811219 int sta=0;
     
    11831221 data.ReSize(Naxis[1],Naxis[0]);
    11841222
    1185  for(int j=0;j<Naxis[1];j++) {
    1186    long deb = 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];
    11871225   fits_read_img(GetFitsPtr(),TDOUBLE,deb,nel,&NulVal,arr,NULL,&sta);
    11881226   if(sta) {
     
    11911229       NotAvailableOperation("FitsImg2DRd::Read(TMatrix<double>): Error Reading Fits file\n");
    11921230   }
    1193    for(int i=0;i<Naxis[0];i++) data(j,i) = arr[i];
     1231   for(LONGLONG i=0;i<Naxis[0];i++) data(j,i) = arr[i];
    11941232 }
    11951233
     
    13431381 // Get NAXIS 1, 2 et 3
    13441382 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)) {
    13461385   FitsOpenFile::printerror(sta);
    13471386   throw RangeCheckError("FitsImg3DRd::Init: Error reading NAXIS cards\n");
     
    13841423
    13851424/*!
     1425  Read a fitsheader key into long long
     1426  \param keyname : name of the key
     1427  \return value into long long
     1428*/
     1429LONGLONG FitsImg3DRd::ReadKeyLL(char *keyname)
     1430{
     1431 return FitsOpenFile::ReadKeyLL(GetFitsPtr(),keyname);
     1432}
     1433
     1434/*!
    13861435  Read a fitsheader key into string
    13871436  \param keyname : name of the key
     
    14011450Read 3D image into a TArray<uint_2>
    14021451*/
    1403 size_t FitsImg3DRd::Read(TArray<uint_2>& data)
     1452LONGLONG FitsImg3DRd::Read(TArray<uint_2>& data)
    14041453{
    14051454 int sta=0;
     
    14071456 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
    14081457
    1409  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1410    long deb = 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];
    14111460   fits_read_img(GetFitsPtr(),TUSHORT,deb,nel,&NulVal,arr,NULL,&sta);
    14121461   if(sta) {
     
    14151464       NotAvailableOperation("FitsImg3DRd::Read(TArray<uint_2>): Error Reading Fits file\n");
    14161465   }
    1417    for(int i=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];
    14181467 }
    14191468
     
    14231472
    14241473/*! Read 3D image into a TArray<int_4> */
    1425 size_t FitsImg3DRd::Read(TArray<int_4>& data)
     1474LONGLONG FitsImg3DRd::Read(TArray<int_4>& data)
    14261475{
    14271476 int sta=0;
     
    14301479 int T = (sizeof(long)==4) ? TLONG: TINT;
    14311480
    1432  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1433    long deb = 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];
    14341483   fits_read_img(GetFitsPtr(),T,deb,nel,&NulVal,arr,NULL,&sta);
    14351484   if(sta) {
     
    14381487       NotAvailableOperation("FitsImg3DRd::Read(TArray<int_4>): Error Reading Fits file\n");
    14391488   }
    1440    for(int i=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];
    14411490 }
    14421491
     
    14461495
    14471496/*! Read 3D image into a TArray<int_8> */
    1448 size_t FitsImg3DRd::Read(TArray<int_8>& data)
     1497LONGLONG FitsImg3DRd::Read(TArray<int_8>& data)
    14491498{
    14501499 int sta=0;
     
    14521501 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
    14531502
    1454  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1455    long deb = 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];
    14561505   fits_read_img(GetFitsPtr(),TLONGLONG,deb,nel,&NulVal,arr,NULL,&sta);
    14571506   if(sta) {
     
    14601509       NotAvailableOperation("FitsImg3DRd::Read(TArray<int_8>): Error Reading Fits file\n");
    14611510   }
    1462    for(int i=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];
    14631512 }
    14641513
     
    14681517
    14691518/*! Read 3D image into a TArray<float> */
    1470 size_t FitsImg3DRd::Read(TArray<float>& data)
     1519LONGLONG FitsImg3DRd::Read(TArray<float>& data)
    14711520{
    14721521 int sta=0;
     
    14741523 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
    14751524
    1476  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1477    long deb = 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];
    14781527   fits_read_img(GetFitsPtr(),TFLOAT,deb,nel,&NulVal,arr,NULL,&sta);
    14791528   if(sta) {
     
    14821531       NotAvailableOperation("FitsImg3DRd::Read(TArray<float>): Error Reading Fits file\n");
    14831532   }
    1484    for(int i=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];
    14851534 }
    14861535
     
    14901539
    14911540/*! Read 3D image into a TArray<double> */
    1492 size_t FitsImg3DRd::Read(TArray<double>& data)
     1541LONGLONG FitsImg3DRd::Read(TArray<double>& data)
    14931542{
    14941543 int sta=0;
     
    14961545 sa_size_t ndim[3] = {Naxis[0],Naxis[1],Naxis[2]}; data.ReSize(3,ndim);
    14971546
    1498  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1499    long deb = 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];
    15001549   fits_read_img(GetFitsPtr(),TDOUBLE,deb,nel,&NulVal,arr,NULL,&sta);
    15011550   if(sta) {
     
    15041553       NotAvailableOperation("FitsImg3DRd::Read(TArray<double>): Error Reading Fits file\n");
    15051554   }
    1506    for(int i=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];
    15071556 }
    15081557
  • trunk/SophyaExt/FitsIOServer/fabtcolread.h

    r3114 r3128  
    4343  void Print(void);
    4444
    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);
    4849  static void   printerror(int sta);
    4950
     
    7273  void ChangeBuffer(long blen=100,long bsens=1);
    7374
    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);
    8587
    8688  //! return the value of the first row
     
    9193                    {return Read(NBline-1,usebuffer);}
    9294
    93   long FirstRow(double val1,double val2,long rowstart=-1);
    94   long LastRow(double val1,double val2,long rowstart=-1);
     95  LONGLONG FirstRow(double val1,double val2,LONGLONG rowstart=-1);
     96  LONGLONG LastRow(double val1,double val2,LONGLONG rowstart=-1);
    9597
    9698  //! Set debug level
     
    115117         {if(FitsOF) return FitsOF->HDUType(); else return 0;}
    116118  //! Get the number of rows in the FITS HDU to be read
    117   inline long GetNbLine(void) const {return NBline;}
     119  inline LONGLONG GetNbLine(void) const {return NBline;}
    118120  //! Get the number of columns in the FITS HDU to be read
    119121  inline int GetNbCol(void) const {return NBcol;}
     
    148150  string ColLabel,ColTUnit,ColTForm;
    149151  int ColNum,ColTypeCode,NBcol;
    150   long NBline;
     152  LONGLONG NBline;
    151153
    152154  double NulVal;
     
    154156  long BuffLen, BuffSens;
    155157
    156   unsigned long NFitsRead;
     158  LONGLONG NFitsRead;
    157159  FitsOpenFile* FitsOF;
    158   long LineDeb, LineFin;
     160  LONGLONG LineDeb, LineFin;
    159161  double *Buffer;
    160162  long NBuffer;
     
    188190  virtual ~FitsImg2DRd();
    189191
    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);
    199202
    200203  //! Set debug level
     
    216219         {if(FitsOF) return FitsOF->HDUType(); else return 0;}
    217220  //! Get NAXIS1
    218   inline long Naxis1(void) const {return Naxis[0];}
     221  inline LONGLONG Naxis1(void) const {return Naxis[0];}
    219222  //! Get NAXIS2
    220   inline long Naxis2(void) const {return Naxis[1];}
     223  inline LONGLONG Naxis2(void) const {return Naxis[1];}
    221224
    222225protected:
    223226  void Init(FitsOpenFile* fof,int ihdu,int lp);
    224227
    225   long Naxis[2];
     228  LONGLONG Naxis[2];
    226229  double NulVal;
    227230  unsigned short DbgLevel;
     
    251254  virtual ~FitsImg3DRd();
    252255
    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);
    262266
    263267  //! Set debug level
     
    279283         {if(FitsOF) return FitsOF->HDUType(); else return 0;}
    280284  //! Get NAXIS1
    281   inline long Naxis1(void) const {return Naxis[0];}
     285  inline LONGLONG Naxis1(void) const {return Naxis[0];}
    282286  //! Get NAXIS2
    283   inline long Naxis2(void) const {return Naxis[1];}
     287  inline LONGLONG Naxis2(void) const {return Naxis[1];}
    284288  //! Get NAXIS3
    285   inline long Naxis3(void) const {return Naxis[2];}
     289  inline LONGLONG Naxis3(void) const {return Naxis[2];}
    286290
    287291protected:
    288292  void Init(FitsOpenFile* fof,int ihdu,int lp);
    289293
    290   long Naxis[3];
     294  LONGLONG Naxis[3];
    291295  double NulVal;
    292296  unsigned short DbgLevel;
  • trunk/SophyaExt/FitsIOServer/fabtwriter.cc

    r3114 r3128  
    5353 DoubleKey.resize(0);
    5454 LongKey.resize(0);
     55 LongLongKey.resize(0);
    5556 StringKey.resize(0);
    5657
     
    7879
    7980 // create d'un Primary HDU
    80  //long naxes[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)) {
    8283 //  printerror(sta);
    8384 //  throw NullPtrError("FitsWriter::cr_or_upd_fits: Error creating Primary extension\n");
     
    125126}
    126127
     128/*! Write a long long value into Fits Header */
     129void 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
    127139/*! Write a string value into Fits Header */
    128140void FitsWriter::WriteKey(const char *keyname,string val,char* comment)
     
    142154 int sta=0;
    143155 if(DoubleKey.size()>0)
    144    for(unsigned int i=0;i<DoubleKey.size();i++) {
     156   for(unsigned long i=0;i<DoubleKey.size();i++) {
    145157     char* key = const_cast<char*>(DoubleKey[i].keyname.c_str());
    146158     char* com = const_cast<char*>(DoubleKey[i].comment.c_str());
     
    150162   }
    151163 if(LongKey.size()>0)
    152    for(unsigned int i=0;i<LongKey.size();i++) {
     164   for(unsigned long i=0;i<LongKey.size();i++) {
    153165     char* key = const_cast<char*>(LongKey[i].keyname.c_str());
    154166     char* com = const_cast<char*>(LongKey[i].comment.c_str());
     
    157169       printerror(sta);
    158170   }
     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   }
    159179 if(StringKey.size()>0)
    160    for(unsigned int i=0;i<StringKey.size();i++) {
     180   for(unsigned long i=0;i<StringKey.size();i++) {
    161181     char* key = const_cast<char*>(StringKey[i].keyname.c_str());
    162182     char* com = const_cast<char*>(StringKey[i].comment.c_str());
     
    167187 DoubleKey.resize(0);
    168188 LongKey.resize(0);
     189 LongLongKey.resize(0);
    169190 StringKey.resize(0);
    170191}
    171192
    172 void FitsWriter::printerrorwrite(const char* type,int col,long row,int sta)
     193void FitsWriter::printerrorwrite(const char* type,int col,LONGLONG row,int sta)
    173194{
    174195 if(sta==NUM_OVERFLOW) {NOverFlow++; return;}
     
    176197 char str[256];
    177198 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);
    179200 throw NotAvailableOperation(str);
    180201}
     
    208229  int c5 = fbtw.AddCol("vard","","arcmin",TDOUBLE);    // col=4
    209230  fbtw.SetDebug(3);
    210   for(long i=0;i<1000;i++) {
     231  for(LONGLONG i=0;i<1000;i++) {
    211232    double x = i;
    212233    fbtw.Write(c1,i,1000.*x); // if overflow, managed by cfitsio
     
    228249  TVector<float>  dataf(100);
    229250  TVector<int_4>  datal(100);
    230   for(long i=0;i<9990;i+=100) {
    231     long i2=i+100-1; if(i2>=9990) i2=9990-1;
    232     for(long j=0;j<100;j++) datad(i) =  ...;
    233     for(long j=0;j<100;j++) dataf(i) =  ...;
    234     for(long j=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) =  ...;
    235256    fbtw.Write(1,i,datal);
    236257    fbtw.Write(2,i,dataf);
     
    251272   cout<<"Writing Keys"<<endl;
    252273   fbtw.WriteKey("MYKEYL",(long)123456789,"my LONG key");
     274   fbtw.WriteKey("MYKEYLL",(LONGLONG)123456789,"my LONGLONG key");
    253275   fbtw.WriteKey("MYKEYD",1.9999999,"my DOUBLE key");
    254276   fbtw.WriteKey("MYKEYC","how are you ?","my CHAR* key");
     
    265287   cout<<"Writing Keys"<<endl;
    266288   fbtw2.WriteKey("MYKEYL",(long)-123456789,"my new LONG key");
     289   fbtw2.WriteKey("MYKEYLL",(LONGLONG)-123456789,"my new LONGLONG key");
    267290   fbtw2.WriteKey("MYKEYD",-1.9999999,"my new clef DOUBLE key");
    268291   fbtw2.WriteKey("MYKEYC","how are you NOW ?","my new CHAR* key");
     
    275298
    276299   cout<<">>>>> Write into the 2 tables simultaneously"<<endl;
    277    for(int i=0;i<NNN;i++) {
     300   for(LONGLONG i=0;i<NNN;i++) {
    278301     fbtw.Write(i1,i,i+1.);
    279302     fbtw.Write(i2,i,i+11.);
     
    462485   throw ParmError("FitsABTWriter::createtbl: Zero column asked !\n");
    463486
    464  long nrows = 0;
     487 LONGLONG nrows = 0;
    465488 char *extname = NULL;
    466489 char **ttype   = (char **) malloc(tfields*sizeof(char *));
     
    472495   strcpy(extname,ExtName.c_str());
    473496 }
    474  int i;
    475  for(i=0;i<tfields;i++) {
     497 for(int i=0;i<tfields;i++) {
    476498   ttype[i] = (char *) malloc((strlen(Label[i].c_str())+1)*sizeof(char));
    477499     strcpy(ttype[i],Label[i].c_str());
     
    491513 // menage
    492514 if(extname) delete [] extname;
    493  for(i=0;i<tfields;i++) {
     515 for(int i=0;i<tfields;i++) {
    494516   if(ttype[i]) delete [] ttype[i];
    495517   if(tform[i]) delete [] tform[i];
     
    525547
    526548/*! Write signed char (1 Byte) data to FITS file (see below) */
    527 void FitsABTWriter::Write(int col,long row,int_1 val)
     549void FitsABTWriter::Write(int col,LONGLONG row,int_1 val)
    528550{
    529551#ifdef TSBYTE
     
    538560
    539561/*! Write unsigned char (1 Byte) data to FITS file (see below) */
    540 void FitsABTWriter::Write(int col,long row,uint_1 val)
     562void FitsABTWriter::Write(int col,LONGLONG row,uint_1 val)
    541563{
    542564  if(FirstTime) createtbl();
     
    547569
    548570/*! Write short (2 Bytes) data to FITS file (see below) */
    549 void FitsABTWriter::Write(int col,long row,int_2 val)
     571void FitsABTWriter::Write(int col,LONGLONG row,int_2 val)
    550572{
    551573  if(FirstTime) createtbl();
     
    556578
    557579/*! Write unsigned short (2 Bytes) data to FITS file (see below) */
    558 void FitsABTWriter::Write(int col,long row,uint_2 val)
     580void FitsABTWriter::Write(int col,LONGLONG row,uint_2 val)
    559581{
    560582  if(FirstTime) createtbl();
     
    565587
    566588/*! Write long (4 Bytes) data to FITS file (see below) */
    567 void FitsABTWriter::Write(int col,long row,int_4 val)
     589void FitsABTWriter::Write(int col,LONGLONG row,int_4 val)
    568590{
    569591  if(FirstTime) createtbl();
     
    576598
    577599/*! Write unsigned long (4 Bytes) data to FITS file (see below) */
    578 void FitsABTWriter::Write(int col,long row,uint_4 val)
     600void FitsABTWriter::Write(int col,LONGLONG row,uint_4 val)
    579601{
    580602  if(FirstTime) createtbl();
     
    587609
    588610/*! Write long long (8 Bytes) data to FITS file (see below) */
    589 void FitsABTWriter::Write(int col,long row,int_8 val)
     611void FitsABTWriter::Write(int col,LONGLONG row,int_8 val)
    590612{
    591613#ifdef TLONGLONG
     
    600622
    601623/*! Write float data to FITS file (see below) */
    602 void FitsABTWriter::Write(int col,long row,float val)
     624void FitsABTWriter::Write(int col,LONGLONG row,float val)
    603625{
    604626  if(FirstTime) createtbl();
     
    609631
    610632/*! Write double data to FITS file (see below) */
    611 void FitsABTWriter::Write(int col,long row,double val)
     633void FitsABTWriter::Write(int col,LONGLONG row,double val)
    612634{
    613635  if(FirstTime) createtbl();
     
    628650
    629651/*! Write a vector of unsigned short (2 Bytes) data to FITS file (see below) */
    630 long FitsABTWriter::Write(int col,long row,TVector<uint_2>& val)
    631 {
    632   if(FirstTime) createtbl();
    633   long nel = val.Size();
     652LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<uint_2>& val)
     653{
     654  if(FirstTime) createtbl();
     655  LONGLONG nel = val.Size();
    634656  int sta=0;
    635657  if(fits_write_col(FitsPtr,TUSHORT,col+1,row+1,1,nel,val.Data(),&sta))
     
    639661
    640662/*! Write a vector of long (4 Bytes) data to FITS file (see below) */
    641 long FitsABTWriter::Write(int col,long row,TVector<int_4>& val)
    642 {
    643   if(FirstTime) createtbl();
    644   long nel = val.Size();
     663LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<int_4>& val)
     664{
     665  if(FirstTime) createtbl();
     666  LONGLONG nel = val.Size();
    645667  int sta=0;
    646668  // Bug ou inconsistence cfitsio sur machine ou long=8Bytes ?
     
    652674
    653675/*! Write a vector of long long (8 Bytes) data to FITS file (see below) */
    654 long FitsABTWriter::Write(int col,long row,TVector<int_8>& val)
     676LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<int_8>& val)
    655677{
    656678#ifdef TLONGLONG
    657679  if(FirstTime) createtbl();
    658   long nel = val.Size();
     680  LONGLONG nel = val.Size();
    659681  int sta=0;
    660682  if(fits_write_col(FitsPtr,TLONGLONG,col+1,row+1,1,nel,val.Data(),&sta))
     
    667689
    668690/*! Write a vector of float data to FITS file (see below) */
    669 long FitsABTWriter::Write(int col,long row,TVector<float>&  val)
    670 {
    671   if(FirstTime) createtbl();
    672   long nel = val.Size();
     691LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<float>&  val)
     692{
     693  if(FirstTime) createtbl();
     694  LONGLONG nel = val.Size();
    673695  int sta=0;
    674696  if(fits_write_col(FitsPtr,TFLOAT,col+1,row+1,1,nel,val.Data(),&sta))
     
    678700
    679701/*! Write a vector of double data to FITS file (see below) */
    680 long FitsABTWriter::Write(int col,long row,TVector<double>& val)
    681 {
    682   if(FirstTime) createtbl();
    683   long nel = val.Size();
     702LONGLONG FitsABTWriter::Write(int col,LONGLONG row,TVector<double>& val)
     703{
     704  if(FirstTime) createtbl();
     705  LONGLONG nel = val.Size();
    684706  int sta=0;
    685707  if(fits_write_col(FitsPtr,TDOUBLE,col+1,row+1,1,nel,val.Data(),&sta))
     
    785807
    786808 int sta=0;
    787  if(fits_create_img(FitsPtr,BitPix,2,Naxis,&sta)) {
     809 if(fits_create_imgll(FitsPtr,BitPix,2,Naxis,&sta)) {
    788810   printerror(sta);
    789811   throw NullPtrError("FitsImg2DWriter::createimg: Error creating image extension\n");
     
    802824 uint_2* arr = new uint_2[Naxis[0]];
    803825
    804  for(int l=0;l<Naxis[1];l++) {
    805    for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
    806    long deb = 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;
    807829   fits_write_img(FitsPtr,TUSHORT,deb,nel,arr,&sta);
    808830   if(sta) {
     
    823845 int_4* arr = new int_4[Naxis[0]];
    824846
    825  for(int l=0;l<Naxis[1];l++) {
    826    for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
    827    long deb = 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;
    828850   fits_write_img(FitsPtr,T,deb,nel,arr,&sta);
    829851   if(sta) {
     
    843865 float* arr = new float[Naxis[0]];
    844866
    845  for(int l=0;l<Naxis[1];l++) {
    846    for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
    847    long deb = 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;
    848870   fits_write_img(FitsPtr,TFLOAT,deb,nel,arr,&sta);
    849871   if(sta) {
     
    863885 double* arr = new double[Naxis[0]];
    864886
    865  for(int l=0;l<Naxis[1];l++) {
    866    for(int c=0;c<Naxis[0];c++) arr[c] = data(l,c);
    867    long deb = 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;
    868890   fits_write_img(FitsPtr,TDOUBLE,deb,nel,arr,&sta);
    869891   if(sta) {
     
    972994
    973995 int sta=0;
    974  if(fits_create_img(FitsPtr,BitPix,3,Naxis,&sta)) {
     996 if(fits_create_imgll(FitsPtr,BitPix,3,Naxis,&sta)) {
    975997   printerror(sta);
    976998   throw NullPtrError("FitsImg3DWriter::createimg: Error creating 3D image extension\n");
     
    9911013 uint_2* arr = new uint_2[Naxis[0]];
    9921014
    993  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    994    for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
    995    long deb = 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;
    9961018   fits_write_img(FitsPtr,TUSHORT,deb,nel,arr,&sta);
    9971019   if(sta) {
     
    10151037 int_4* arr = new int_4[Naxis[0]];
    10161038
    1017  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1018    for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
    1019    long deb = 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;
    10201042   fits_write_img(FitsPtr,T,deb,nel,arr,&sta);
    10211043   if(sta) {
     
    10381060 float* arr = new float[Naxis[0]];
    10391061
    1040  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1041    for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
    1042    long deb = 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;
    10431065   fits_write_img(FitsPtr,TFLOAT,deb,nel,arr,&sta);
    10441066   if(sta) {
     
    10611083 double* arr = new double[Naxis[0]];
    10621084
    1063  for(int k=0;k<Naxis[2];k++) for(int j=0;j<Naxis[1];j++) {
    1064    for(int i=0;i<Naxis[0];i++) arr[i] = data(i,j,k);
    1065    long deb = 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;
    10661088   fits_write_img(FitsPtr,TDOUBLE,deb,nel,arr,&sta);
    10671089   if(sta) {
  • trunk/SophyaExt/FitsIOServer/fabtwriter.h

    r3114 r3128  
    3434  //! Write a long value in Fits header.
    3535  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);
    3638  //! Write a string value in Fits header.
    3739  void WriteKey(const char *keyname,string val,char* comment=NULL);
     
    4345
    4446  //! Return the number of overflows managed by cfitsio
    45   inline unsigned long GetNOverFlow(void) {return NOverFlow;}
     47  inline LONGLONG GetNOverFlow(void) {return NOverFlow;}
    4648
    4749  //! Return the c-fitsio file pointer
    4850  inline fitsfile * GetFitsPtr() { return FitsPtr; }
    4951protected:
    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;};
    5356
    5457  void cr_or_upd_fits(const char *cfname,bool update,int lp);
    5558
    5659  void writekeys(void);
    57   void printerrorwrite(const char* type,int col,long row,int sta);
     60  void printerrorwrite(const char* type,int col,LONGLONG row,int sta);
    5861  void printerror(int sta) const;
    5962
     
    6366  unsigned short DbgLevel;
    6467  fitsfile *FitsPtr;
    65   unsigned long NOverFlow;
     68  LONGLONG NOverFlow;
    6669
    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;
    7074};
    7175
     
    9599     {return addcol(label,tform,tunit,datatype);}
    96100
    97   void Write(int col,long row,int_1 val);
    98   void Write(int col,long row,uint_1 val);
    99   void Write(int col,long row,int_2 val);
    100   void Write(int col,long row,uint_2 val);
    101   void Write(int col,long row,int_4 val);
    102   void Write(int col,long row,uint_4 val);
    103   void Write(int col,long row,int_8 val);
    104   void Write(int col,long row,float val);
    105   void Write(int col,long row,double val);
    106   long Write(int col,long row,TVector<uint_2>& val);
    107   long Write(int col,long row,TVector<int_4>& val);
    108   long Write(int col,long row,TVector<int_8>& val);
    109   long Write(int col,long row,TVector<float>& val);
    110   long Write(int col,long row,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);
    111115
    112116  //! Return the number of created columns
     
    153157
    154158  int BitPix;
    155   long Naxis[2];
     159  LONGLONG Naxis[2];
    156160  bool FirstTime;
    157161};
     
    182186
    183187  int BitPix;
    184   long Naxis[3];
     188  LONGLONG Naxis[3];
    185189  bool FirstTime;
    186190};
  • trunk/SophyaExt/FitsIOServer/fboloread.cc

    r2615 r3128  
    2828
    2929  cout<<"Reading element by elements"<<endl;
    30   for(long i=0; i<fbr.GetNbLine(); i++) {
     30  for(LONGLONG i=0; i<fbr.GetNbLine(); i++) {
    3131    double a = fbr.GetAlpha(i);
    3232    double d = fbr.GetDelta(i);
     
    4343  TVector<float> Vc1;
    4444  TVector<int_4> Vs;
    45   for(long i=0, istep=1000; i<fbr.GetNbLine(); i+=istep) {
    46     long i2=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;
    4747    fbr.GetSNum(i,i2,Vs);
    4848    fbr.GetBolo(i,i2,Vb);
     
    148148
    149149 // Set the number of rows as the smallest of for connected columns
    150  long nrows = mFABT[col]->GetNbLine();
     150 LONGLONG nrows = mFABT[col]->GetNbLine();
    151151 if(NBline==0) NBline = nrows;
    152152 else if(nrows<NBline) NBline = nrows;
     
    222222 for(col=0; col<(int)mFABT.size(); col++) {
    223223   if(mFABT[col]==NULL) continue;
    224    long nbl = mFABT[col]->GetNbLine();
     224   LONGLONG nbl = mFABT[col]->GetNbLine();
    225225   if(nbl==0) continue;
    226226   if(NBline==0 || nbl<NBline) NBline = nbl;
  • trunk/SophyaExt/FitsIOServer/fboloread.h

    r2322 r3128  
    4444
    4545  //! return Alpha value for row "n" into double
    46   inline double GetAlpha(long n,bool usebuffer=true)
     46  inline double GetAlpha(LONGLONG n,bool usebuffer=true)
    4747                {return GetCol(ColAlpha,n,usebuffer);}
    4848  //! return Delta value for row "n" into double
    49   inline double GetDelta(long n,bool usebuffer=true)
     49  inline double GetDelta(LONGLONG n,bool usebuffer=true)
    5050                {return GetCol(ColDelta,n,usebuffer);}
    5151  //! return Bolo value for row "n" into double
    52   inline double GetBolo(long n,bool usebuffer=true)
     52  inline double GetBolo(LONGLONG n,bool usebuffer=true)
    5353                {return GetCol(ColBolo,n,usebuffer);}
    5454  //! return Flag value for row "n" into double
    55   inline double GetFlag(long n,bool usebuffer=true)
     55  inline double GetFlag(LONGLONG n,bool usebuffer=true)
    5656         {if(!IsFlag()) return 0.; return GetCol(ColFlag,n,usebuffer);}
    5757  //! return SNum value for row "n" into double
    58   inline double GetSNum(long n,bool usebuffer=true)
     58  inline double GetSNum(LONGLONG n,bool usebuffer=true)
    5959                {return GetCol(ColSNum,n,usebuffer);}
    6060  //! return column "col" value for row "n" into double
    61   inline double GetCol(int col,long n,bool usebuffer=true) {
     61  inline double GetCol(int col,LONGLONG n,bool usebuffer=true) {
    6262    if(col<0 || col>=(int)mFABT.size())
    6363      throw ParmError("FitsBoloRead::GetCol: bad column number\n");
     
    6868
    6969  //! return Alpha values for rows [n1,n2] into TVector
    70   inline long GetAlpha(long n1,long n2,TVector<double>& data)
     70  inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<double>& data)
    7171              {return GetCol(ColAlpha,n1,n2,data);}
    72   inline long GetAlpha(long n1,long n2,TVector<float>& data)
     72  inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<float>& data)
    7373              {return GetCol(ColAlpha,n1,n2,data);}
    74   inline long GetAlpha(long n1,long n2,TVector<int_4>& data)
     74  inline LONGLONG GetAlpha(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
    7575              {return GetCol(ColAlpha,n1,n2,data);}
    7676
    7777  //! return Delta values for rows [n1,n2] into TVector
    78   inline long GetDelta(long n1,long n2,TVector<double>& data)
     78  inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<double>& data)
    7979              {return GetCol(ColDelta,n1,n2,data);}
    80   inline long GetDelta(long n1,long n2,TVector<float>& data)
     80  inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<float>& data)
    8181              {return GetCol(ColDelta,n1,n2,data);}
    82   inline long GetDelta(long n1,long n2,TVector<int_4>& data)
     82  inline LONGLONG GetDelta(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
    8383              {return GetCol(ColDelta,n1,n2,data);}
    8484
    8585  //! return Bolo values for rows [n1,n2] into TVector
    86   inline long GetBolo(long n1,long n2,TVector<double>& data)
     86  inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<double>& data)
    8787              {return GetCol(ColBolo,n1,n2,data);}
    88   inline long GetBolo(long n1,long n2,TVector<float>& data)
     88  inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<float>& data)
    8989              {return GetCol(ColBolo,n1,n2,data);}
    90   inline long GetBolo(long n1,long n2,TVector<int_4>& data)
     90  inline LONGLONG GetBolo(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
    9191              {return GetCol(ColBolo,n1,n2,data);}
    9292
    9393  //! return Flag values for rows [n1,n2] into TVector
    94   inline long GetFlag(long n1,long n2,TVector<double>& data)
     94  inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<double>& data)
    9595              {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
    96   inline long GetFlag(long n1,long n2,TVector<float>& data)
     96  inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<float>& data)
    9797              {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
    98   inline long GetFlag(long n1,long n2,TVector<int_4>& data)
     98  inline LONGLONG GetFlag(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
    9999              {if(!IsFlag()) return 0; return GetCol(ColFlag,n1,n2,data);}
    100100
    101101  //! return Sample Number values for rows [n1,n2] into TVector
    102   inline long GetSNum(long n1,long n2,TVector<double>& data)
     102  inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<double>& data)
    103103              {return GetCol(ColSNum,n1,n2,data);}
    104   inline long GetSNum(long n1,long n2,TVector<float>& data)
     104  inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<float>& data)
    105105              {return GetCol(ColSNum,n1,n2,data);}
    106   inline long GetSNum(long n1,long n2,TVector<int_4>& data)
     106  inline LONGLONG GetSNum(LONGLONG n1,LONGLONG n2,TVector<int_4>& data)
    107107              {return GetCol(ColSNum,n1,n2,data);}
    108108
    109109  //! return column "col" values for rows [n1,n2] into TVector
    110   inline long GetCol(int col,long n1,long n2,TVector<double>& data) {
     110  inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<double>& data) {
    111111    if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
    112112    return mFABT[col]->Read(n1,n2,data);
    113113  }
    114   inline long GetCol(int col,long n1,long n2,TVector<float>& data) {
     114  inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<float>& data) {
    115115    if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
    116116    return mFABT[col]->Read(n1,n2,data);
    117117  }
    118   inline long GetCol(int col,long n1,long n2,TVector<int_4>& data) {
     118  inline LONGLONG GetCol(int col,LONGLONG n1,LONGLONG n2,TVector<int_4>& data) {
    119119    if(col<0 || col>=(int)mFABT.size()) return 0; if(mFABT[col]==NULL) return 0;
    120120    return mFABT[col]->Read(n1,n2,data);
     
    144144  void SetNbLine(int col=-1);
    145145  //! Get the number of rows to be read
    146   inline long GetNbLine(void) const {return NBline;}
     146  inline LONGLONG GetNbLine(void) const {return NBline;}
    147147  //! Get the number of columns in the FITS HDU to be read
    148148  inline int  GetNbCol(void) const {return mFABT.size();}
     
    175175  void Gess_If_Not_Define(int col);
    176176
    177   long NBline;
     177  LONGLONG NBline;
    178178  unsigned short DbgLevel;
    179179  long BuffLen, BuffSens;
  • trunk/SophyaProg/Tests/tstcolread.cc

    r2828 r3128  
    9999
    100100  if(vsearch) {
    101     long mid = fbt->GetNbLine()/2;
     101    LONGLONG mid = fbt->GetNbLine()/2;
    102102    cout<<"Search vs1="<<vs1<<" vs2="<<vs2<<endl;
    103103    cout<<"FirstRow: "<<fbt->FirstRow(vs1,vs2,-1)<<endl;
     
    109109#ifdef NO_VECTOR
    110110  cout<<"Writting element by elements"<<endl;
    111   for(long i=0;i<fbt->GetNbLine();i++) {
     111  for(LONGLONG i=0;i<fbt->GetNbLine();i++) {
    112112    double x = fbt->Read(i);
    113113    if(i%lpmod==0) cout<<i<<": "<<x<<endl;
     
    125125  TVector<float> dataf;
    126126  TVector<int_4> datal;
    127   long istep = fbt->GetNbLine()/10; if(istep>1000) istep=1000;
    128   for(long i=0;i<fbt->GetNbLine();i+=istep) {
    129     long i2=i+istep-1; if(i2>=fbt->GetNbLine()) i2=fbt->GetNbLine()-1;
    130     long n = fbt->Read(i,i2,data);
     127  LONGLONG istep = fbt->GetNbLine()/10; if(istep>1000) istep=1000;
     128  for(LONGLONG i=0;i<fbt->GetNbLine();i+=istep) {
     129    LONGLONG i2=i+istep-1; if(i2>=fbt->GetNbLine()) i2=fbt->GetNbLine()-1;
     130    LONGLONG n = fbt->Read(i,i2,data);
    131131    fbt->Read(i,i2,dataf);
    132132    fbt->Read(i,i2,datal);
Note: See TracChangeset for help on using the changeset viewer.