Changeset 838 in Sophya for trunk/SophyaExt
- Timestamp:
- Apr 7, 2000, 5:43:14 PM (25 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsioserver.cc
r833 r838 10 10 //************************************************************************ 11 11 12 #include "machdefs.h" 12 #include "machdefs.h" 13 13 #include <iostream.h> 14 14 15 15 // #include <sstream> Ca ne passe pas pour le moment avec g++ - Reza 23/12/99 16 16 17 #include <list>17 //#include <list> 18 18 #include <string> 19 19 … … 80 80 if(DTYPE == TDOUBLE) 81 81 { 82 Sphere Gorski<double> *sph= new SphereGorski<double>(nside);82 SphereHealpix<double> *sph= new SphereHealpix<double>(nside); 83 83 load(*sph,flnm,hdunum); 84 84 return sph; … … 87 87 else if(DTYPE == TFLOAT) 88 88 { 89 Sphere Gorski<float> *sph= new SphereGorski<float>(nside);89 SphereHealpix<float> *sph= new SphereHealpix<float>(nside); 90 90 load(*sph,flnm,hdunum); 91 91 return sph; … … 313 313 } 314 314 315 315 316 // get the number of columns 316 317 int ncols= 0; … … 328 329 long repeat; 329 330 int ntest= 0; 330 int ii; 331 for(ii = 0; ii < ncols; ii++) 331 for(int ii = 0; ii < ncols; ii++) 332 332 { 333 333 int DTYPE; … … 354 354 char **clname; 355 355 clname= new char*[tfields.size()]; 356 for(i i = 0; ii < tfields.size(); ii++)356 for(int ii = 0; ii < tfields.size(); ii++) 357 357 { 358 358 // ostringstream ne passe pas sur tous les compilos .. Reza 23/12/99 359 359 // ostringstream oss; oss<<"Col_"<<ii+1; 360 // string ss= oss.str(); 360 // string ss= oss.str(); 361 361 // clname[ii]= new char[FLEN_VALUE]; 362 362 clname[ii] = new char[16]; … … 367 367 // create a NTuple 368 368 NTuple nt0(tfields.size(),clname); 369 for(i i = 0; ii < tfields.size(); ii++)369 for(int ii = 0; ii < tfields.size(); ii++) 370 370 delete [] clname[ii]; 371 371 delete [] clname; … … 396 396 } 397 397 398 399 398 400 // get number of keywords 399 401 int nkeys,keypos; … … 411 413 int num= 8; 412 414 415 416 417 413 418 for(int j = num+1; j <= nkeys; j++) 414 419 { … … 427 432 strip(strval, 'B',' '); 428 433 strip(strval, 'B','\''); 434 429 435 switch( dtype ) 430 436 { … … 435 441 int ival; 436 442 fits_read_key(fptr,TINT,keyname,&ival,NULL,&status); 437 nt0.Info()[keyname]= (int_4) ival; // Portage mac DY443 nt0.Info()[keyname]= (int_4) ival; // Portage mac DY 438 444 break; 439 445 case 'L': … … 449 455 break; 450 456 } 457 451 458 } 452 459 } 453 460 461 462 454 463 // copy in the input NTuple 455 464 ntpl= nt0; … … 492 501 { 493 502 sph.Resize(nside); 494 cout << "FitsIoServer::load(Sphere Gorski<double> ...) ReSizing to NSide= " << nside << endl;503 cout << "FitsIoServer::load(SphereHealpix<double> ...) ReSizing to NSide= " << nside << endl; 495 504 } 496 505 // else … … 504 513 505 514 506 void FitsIoServer::load(Sphere Gorski<float>& sph,char flnm[],int hdunum)515 void FitsIoServer::load(SphereHealpix<float>& sph,char flnm[],int nth) 507 516 { 508 517 int npixels= 0; 509 518 int nside = 0; 510 519 int hdunum=nth+1; 511 520 FITS_tab_typ_= TFLOAT; 512 521 DVList dvl; … … 528 537 { 529 538 cout<<" FITSIOSERVER: no resolution parameter on fits file "<<endl; 530 throw IOExc("FitsIoServer::load(Sphere Gorski<float>& ," + (string)flnm + ", ) Error No resolution parameter !");539 throw IOExc("FitsIoServer::load(SphereHealpix<float>& ," + (string)flnm + ", ) Error No resolution parameter !"); 531 540 } 532 541 if (nside != sph.SizeIndex()) 533 542 { 534 543 sph.Resize(nside); 535 cout << " FitsIoServer::load(Sphere Gorski<float> ...)";544 cout << " FitsIoServer::load(SphereHealpix<float> ...)"; 536 545 cout << " ReSizing to NSide= " << nside << endl; 537 546 } … … 541 550 } 542 551 543 void FitsIoServer::load(Sphere Gorski<double>& sph,char flnm[],int hdunum)552 void FitsIoServer::load(SphereHealpix<double>& sph,char flnm[],int nth) 544 553 { 545 554 int npixels= 0; 546 555 int nside = 0; 547 556 int hdunum=nth+1; 548 557 FITS_tab_typ_ = TDOUBLE; 549 558 DVList dvl; 550 559 planck_read_bntbl(flnm,hdunum,npixels,dvl); 551 552 560 nside= dvl.GetI("NSIDE"); 553 561 … … 562 570 { 563 571 if(nside <= 0) 564 throw IOExc("FitsIoServer::load(Sphere Gorski<double>& ," + (string)flnm + ", ) No resol parameter !");572 throw IOExc("FitsIoServer::load(SphereHealpix<double>& ," + (string)flnm + ", ) No resol parameter !"); 565 573 566 574 if(nside != sph.SizeIndex()) 567 575 { 568 576 sph.Resize(nside); 569 cout << " FitsIoServer::load(Sphere Gorski<double> ...)";577 cout << " FitsIoServer::load(SphereHealpix<double> ...)"; 570 578 cout << " ReSizing to NSide= " << nside << endl; 571 579 } 572 580 } 581 // 582 583 for(int j = 0; j < sph.NbPixels(); j++) sph(j)= (double)r_8tab_[j]; 584 } 585 586 void FitsIoServer::load(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char flnm[]) 587 { 588 int npixels= 0; 589 int nside = 0; 590 int hdunum=2; 591 FITS_tab_typ_ = TDOUBLE; 592 DVList dvl; 593 planck_read_bntbl(flnm,hdunum,npixels,dvl,3); 594 nside= dvl.GetI("NSIDE"); 595 596 const char* ordering= dvl.GetS("ORDERING").c_str(); 597 598 char* ring = "RING"; 599 if(strncmp(ordering,ring,4) != 0) 600 cout << " numerotation non RING" << endl; 601 602 // number of pixels in the spheres 603 if(sph1.NbPixels() != npixels || sph2.NbPixels() != npixels || sph3.NbPixels() != npixels) 604 { 605 if(nside <= 0) 606 throw IOExc("FitsIoServer::load(SphereHealpix<double>& ," + (string)flnm + ", ) No resol parameter !"); 607 608 if(nside != sph1.SizeIndex() || nside != sph2.SizeIndex() || nside != sph3.SizeIndex()) 609 { 610 sph1.Resize(nside); 611 sph2.Resize(nside); 612 sph3.Resize(nside); 613 cout << " FitsIoServer::load(SphereHealpix<double> ...)"; 614 cout << " ReSizing to NSide= " << nside << endl; 615 } 616 } 573 617 574 for(int j = 0; j < sph.NbPixels(); j++) sph(j)= (double)r_8tab_[j]; 575 } 618 for(int j = 0; j < sph1.NbPixels(); j++) sph1(j)= (double)r_8tab_[j]; 619 for(int j = 0; j < sph2.NbPixels(); j++) sph2(j)= (double)r_8tab_[j+npixels]; 620 for(int j = 0; j < sph3.NbPixels(); j++) sph3(j)= (double)r_8tab_[j+2*npixels]; 621 } 622 623 void FitsIoServer::load(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char flnm[]) 624 { 625 int npixels= 0; 626 int nside = 0; 627 int hdunum=2; 628 FITS_tab_typ_= TFLOAT; 629 DVList dvl; 630 631 planck_read_bntbl(flnm,hdunum,npixels,dvl,3); 632 nside= dvl.GetI("NSIDE"); 633 634 const char* ordering= dvl.GetS("ORDERING").c_str(); 635 636 char* ring = "RING"; 637 if(strncmp(ordering,ring,4) != 0) 638 cout << " numerotation non RING" << endl; 639 640 641 // number of pixels in the sphere 642 if(sph1.NbPixels() != npixels || sph2.NbPixels() != npixels || sph3.NbPixels() != npixels) 643 { 644 if (nside <= 0 ) 645 { 646 cout<<" FITSIOSERVER: no resolution parameter on fits file "<<endl; 647 throw IOExc("FitsIoServer::load(SphereHealpix<float>& ," + (string)flnm + ", ) Error No resolution parameter !"); 648 } 649 if(nside != sph1.SizeIndex() || nside != sph2.SizeIndex() || nside != sph3.SizeIndex()) 650 { 651 sph1.Resize(nside); 652 sph2.Resize(nside); 653 sph3.Resize(nside); 654 cout << " FitsIoServer::load(SphereHealpix<float> ...)"; 655 cout << " ReSizing to NSide= " << nside << endl; 656 } 657 } 658 659 for(int j = 0; j < sph1.NbPixels(); j++) sph1(j)= (float)r_4tab_[j]; 660 for(int j = 0; j < sph2.NbPixels(); j++) sph2(j)= (float)r_4tab_[j+npixels]; 661 for(int j = 0; j < sph3.NbPixels(); j++) sph3(j)= (float)r_4tab_[j+2*npixels]; 662 } 663 664 576 665 577 666 void FitsIoServer::load(SphericalMap<float>& sph, char flnm[]) … … 954 1043 planck_write_img(filename, 1, npixels, 0, 0, dvl); 955 1044 956 // decider ulterieurement ce qu'on fait de ce qui suit, specifique957 // pour l'instant, aux spheres gorski.958 959 /*960 // write supplementary keywords961 fits_write_comment(fptr, " ", &status);962 if( status ) printerror( status );963 964 965 strcpy(comment,"HEALPIX Pixelisation");966 strcpy(svalue, "HEALPIX");967 fits_write_key(fptr, TSTRING, "PIXTYPE", svalue, comment, &status);968 if( status ) printerror( status );969 970 971 strcpy(comment,"pixel ordering scheme, either RING or NESTED");972 strcpy(svalue, "RING");973 fits_write_key(fptr, TSTRING, "ORDERING", svalue, comment, &status);974 if( status ) printerror( status );975 976 977 strcpy(comment,"Random generator seed");978 int iseed= sph.iseed();979 fits_write_key(fptr, TINT, "RANDSEED", &iseed, comment, &status);980 if( status ) printerror( status );981 982 983 strcpy(comment,"--------------------------------------------");984 fits_write_comment(fptr, comment, &status);985 if( status ) printerror( status );986 987 strcpy(comment," Above keywords are still likely to change !");988 fits_write_comment(fptr, comment, &status);989 if( status ) printerror( status );990 991 strcpy(comment,"--------------------------------------------");992 fits_write_comment(fptr, comment, &status);993 if( status ) printerror( status );994 995 */996 1045 997 1046 delete[] r_8tab_; r_8tab_ = NULL; … … 1015 1064 1016 1065 } 1017 void FitsIoServer::save(Sphere Gorski<float>& sph, char filename[])1066 void FitsIoServer::save(SphereHealpix<float>& sph, char filename[], int nth) 1018 1067 { 1019 1068 int npixels = sph.NbPixels(); … … 1033 1082 char* extname="SIMULATION"; 1034 1083 char* comment1=" Sky Map Pixelisation Specific Keywords"; 1035 planck_write_bntbl(filename, npixels, typeOfContent, extname, comment1, dvl );1084 planck_write_bntbl(filename, npixels, typeOfContent, extname, comment1, dvl,1,nth); 1036 1085 delete[] r_4tab_; r_4tab_ = NULL; 1037 1086 1038 1087 } 1039 void FitsIoServer::save(Sphere Gorski<double>& sph, char filename[])1088 void FitsIoServer::save(SphereHealpix<double>& sph, char filename[], int nth) 1040 1089 { 1041 1090 int npixels = sph.NbPixels(); … … 1055 1104 char* extname="SIMULATION"; 1056 1105 char* comment1=" Sky Map Pixelisation Specific Keywords"; 1057 planck_write_bntbl(filename, npixels, typeOfContent, extname, comment1, dvl );1106 planck_write_bntbl(filename, npixels, typeOfContent, extname, comment1, dvl,1, nth); 1058 1107 delete[] r_8tab_; r_8tab_ = NULL; 1059 1108 1060 1109 } 1061 1062 void FitsIoServer::save(LocalMap<double>& locm, char filename[]) 1110 void FitsIoServer::save(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char filename[]) 1111 { 1112 int npixels = sph1.NbPixels(); 1113 if (npixels != sph2.NbPixels() || npixels != sph3.NbPixels()) 1114 { 1115 cout << " trois spheres avec differents nombres de pixels !" << endl; 1116 } 1117 FITS_tab_typ_ = TDOUBLE; 1118 if (r_8tab_ != NULL ) { delete[] r_8tab_; r_8tab_ = NULL; } 1119 r_8tab_=new r_8[3*npixels]; 1120 1121 1122 for (int j = 0; j < npixels; j++) r_8tab_[j]= (r_8)sph1(j); 1123 for (int j = 0; j < npixels; j++) r_8tab_[j+npixels]= (r_8)sph2(j); 1124 for (int j = 0; j < npixels; j++) r_8tab_[j+2*npixels]= (r_8)sph3(j); 1125 DVList dvl; 1126 dvl.SetS("PIXTYPE","HEALPIX "); 1127 1128 // ulterieurement: verifier que les 3 spheres ont memes caracterisitiques 1129 dvl["ORDERING"]=sph1.TypeOfMap(); 1130 dvl["NSIDE"] = (int_4)sph1.SizeIndex(); 1131 1132 dvl["FIRSTPIX"]=(int_4)0; 1133 dvl["LASTPIX"]=(int_4)(npixels-1); 1134 char* typeOfContent="TEMPERATURE+POLAR"; 1135 char* extname="SIMULATION"; 1136 char* comment1=" Sky Map Pixelisation Specific Keywords"; 1137 planck_write_bntbl(filename, npixels, typeOfContent, extname, comment1, dvl,3); 1138 delete[] r_8tab_; r_8tab_ = NULL; 1139 1140 } 1141 1142 void FitsIoServer::save(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char filename[]) 1143 { 1144 int npixels = sph1.NbPixels(); 1145 if (npixels != sph2.NbPixels() || npixels != sph3.NbPixels()) 1146 { 1147 cout << " trois spheres avec differents nombres de pixels !" << endl; 1148 } 1149 FITS_tab_typ_ = TFLOAT; 1150 if (r_4tab_ != NULL ) { delete[] r_4tab_; r_4tab_ = NULL; } 1151 r_4tab_=new r_4[3*npixels]; 1152 1153 for (int j = 0; j < npixels; j++) r_4tab_[j]= (r_4)sph1(j); 1154 for (int j = 0; j < npixels; j++) r_4tab_[j+npixels]= (r_4)sph2(j); 1155 for (int j = 0; j < npixels; j++) r_4tab_[j+2*npixels]= (r_4)sph3(j); 1156 1157 DVList dvl; 1158 dvl.SetS("PIXTYPE","HEALPIX "); 1159 // ulterieurement: verifier que les 3 spheres ont memes caracterisitiques 1160 dvl["ORDERING"]=sph1.TypeOfMap(); 1161 dvl["NSIDE"] = (int_4)sph1.SizeIndex(); 1162 dvl["FIRSTPIX"]=(int_4)0; 1163 dvl["LASTPIX"]=(int_4)(npixels-1); 1164 char* typeOfContent="TEMPERATURE+POLAR"; 1165 char* extname="SIMULATION"; 1166 char* comment1=" Sky Map Pixelisation Specific Keywords"; 1167 planck_write_bntbl(filename, npixels, typeOfContent, extname, comment1, dvl,3); 1168 delete[] r_4tab_; r_4tab_ = NULL; 1169 1170 } 1171 1172 1173 void FitsIoServer::save(const LocalMap<double>& locm, char filename[]) 1063 1174 { 1064 1175 int nbrows = locm.Size_x(); … … 1264 1375 cout << " FitsIOServer : type de tableau non traite en ecriture " << endl; 1265 1376 break; 1266 } 1377 } 1267 1378 1268 1379 // write the current date … … 1336 1447 } 1337 1448 1338 void FitsIoServer::planck_write_bntbl(char flnm[], int npixels, char typeOfContent[], char extname[], char comment1[], DVList& dvl) 1339 { 1340 1449 void FitsIoServer::planck_write_bntbl(char flnm[], int npixels, char typeOfContent[], char extname[], char comment1[], DVList& dvl, int tfields, int nth) 1450 { 1341 1451 1342 1452 // pointer to the FITS file, defined in fitsio.h … … 1345 1455 // initialize status before calling fitsio routines 1346 1456 int status = 0; 1347 1348 // delete old file if it already exists 1349 remove(flnm); 1350 1351 // create new FITS file 1352 fits_create_file(&fptr, flnm, &status); 1353 //DBG cerr << " DBG - Apres fits_create_file status = " << status << endl; 1354 if( status ) printerror( status ); 1355 1356 // primary header 1357 // int bitpix=LONG_IMG; 1358 // int naxis=0; 1359 // fits_create_img(fptr, bitpix, naxis, NULL, &status); 1360 // write the current date 1361 // fits_write_date(fptr, &status); 1362 //DBG cerr << " DBG - Apres write_date status = " << status << endl; 1363 // if( status ) printerror( status ); 1364 1365 1366 long nrows=npixels/1024; 1367 if (nrows==0) nrows=1; 1368 if (npixels%1024 !=0) nrows++; 1369 int tfields=1; 1457 if (nth == 1 ) 1458 { 1459 // delete old file if it already exists 1460 remove(flnm); 1461 // create new FITS file 1462 fits_create_file(&fptr, flnm, &status); 1463 //DBG cerr << " DBG - Apres fits_create_file status = " << status << endl; 1464 if( status ) printerror( status ); 1465 } 1466 else 1467 { 1468 fits_open_file(&fptr, flnm,READWRITE, &status); 1469 int hdunum=0; 1470 fits_get_num_hdus(fptr, &hdunum, &status); 1471 if( status ) printerror( status, " write_bntbl: probleme dans le nombre de headers"); 1472 cout << " on a retrouve " << hdunum << " headers" << endl; 1473 for (int k=1; k<hdunum; k++) 1474 { 1475 fits_movrel_hdu(fptr, 1, NULL, &status); 1476 if( status ) printerror( status," write_bntbl: probleme pour avancer au header suivant" ); 1477 int hdutype=0; 1478 fits_get_hdu_type(fptr, &hdutype, &status); 1479 if( status ) printerror( status," write_bntbl: probleme pour lire un type de header" ); 1480 if (hdutype != BINARY_TBL ) 1481 { 1482 cout << " le fichier contient autre chose que des binary table: " << hdutype << endl; 1483 } 1484 } 1485 if (hdunum != nth) 1486 { 1487 cout <<" il n'y a que " << hdunum-1 << "write_bntbl: spheres stockees, la presente sphere sera en position " << hdunum << endl; 1488 } 1489 } 1490 1491 1492 1493 long nrows; 1494 char format[5]; 1495 if (npixels < 1024) 1496 { 1497 nrows = npixels; 1498 strcpy(format,"1"); 1499 } 1500 else 1501 { 1502 nrows = npixels/1024; 1503 strcpy(format,"1024"); 1504 if (npixels%1024 !=0) nrows++; 1505 } 1506 // int tfields=1; 1370 1507 char **ttype, **tform; 1371 1508 ttype= new char*[tfields]; 1372 1509 tform= new char*[tfields]; 1373 char* f ormat;1374 if ( FITS_tab_typ_ == TDOUBLE) format="1024D";1375 if ( FITS_tab_typ_ == TFLOAT) format="1024E";1376 if ( FITS_tab_typ_ == TINT) format="1024I";1510 char* ff="D"; 1511 if ( FITS_tab_typ_ == TDOUBLE) strcat(format,"D"); 1512 if ( FITS_tab_typ_ == TFLOAT) strcat(format,"E"); 1513 if ( FITS_tab_typ_ == TINT) strcat(format,"I"); 1377 1514 for(int i = 0; i < tfields; i++) 1378 1515 { … … 1400 1537 { 1401 1538 case TDOUBLE : 1402 fits_write_col(fptr, TDOUBLE, 1, 1, 1, nelements, r_8tab_, &status); 1403 if( status ) 1404 printerror( status, "planck_write_bntbl: Error writing double table" ); 1539 for (int k=1; k<=tfields; k++) 1540 { 1541 fits_write_col(fptr, TDOUBLE, k, 1, 1, nelements, r_8tab_+(k-1)*nelements, &status); 1542 if( status ) 1543 printerror( status, "planck_write_bntbl: Error writing double table" ); 1544 } 1405 1545 break; 1406 1546 1407 1547 case TFLOAT : 1408 1548 //DBG!!! $CHECK$ Reza for (int kk=0; kk<10; kk++) cout << r_4tab_[kk] << endl; 1409 fits_write_col(fptr, TFLOAT, 1, 1, 1, nelements, r_4tab_, &status); 1410 if( status ) 1411 printerror( status, "planck_write_bntbl: Error writing float table" ); 1549 for (int k=1; k<=tfields; k++) 1550 { 1551 fits_write_col(fptr, TFLOAT, k, 1, 1, nelements, r_4tab_+(k-1)*nelements, &status); 1552 if( status ) printerror( status, "planck_write_bntbl: Error writing float table" ); 1553 } 1412 1554 break; 1413 1555 case TINT : 1414 fits_write_col(fptr, TINT, 1, 1, 1, nelements, i_4tab_, &status); 1415 if( status ) 1416 printerror( status, "planck_write_bntbl: Error writing int table"); 1556 for (int k=1; k<=tfields; k++) 1557 { 1558 fits_write_col(fptr, TINT, k, 1, 1, nelements, i_4tab_+(k-1)*nelements, &status); 1559 if( status ) 1560 printerror( status, "planck_write_bntbl: Error writing int table"); 1561 } 1417 1562 break; 1418 1563 default : … … 1636 1781 } 1637 1782 1638 void FitsIoServer::planck_read_bntbl(char flnm[], int hdunum, int& npixels, DVList& dvl )1783 void FitsIoServer::planck_read_bntbl(char flnm[], int hdunum, int& npixels, DVList& dvl,int tfields ) 1639 1784 { 1640 1785 int status=0; 1641 1786 int nkeys,keypos; 1642 1787 int hdutype; 1643 int tfields;1788 // int tfields; 1644 1789 int datype; 1645 1790 long lastpix; … … 1686 1831 //cout << " nombre de mots-cles : " << nkeys << endl; 1687 1832 fits_get_num_cols(fptr, &tfields, &status); 1688 if (tfields != 1) 1689 { 1690 cout << "FitsIoServer:: il y a plus d'une colonne" << endl; 1691 throw IOExc("FitsIoServer::planck_read_bntbl(" + (string)flnm + ") Error >1 column !"); 1692 // return; 1693 } 1833 // if (tfields != 1) 1834 // { 1835 // cout << "FitsIoServer:: il y a plus d'une colonne" << endl; 1836 // throw IOExc("FitsIoServer::planck_read_bntbl(" + (string)flnm + ") Error >1 column !"); 1837 // } 1694 1838 fits_get_num_rows(fptr, &nrows, &status); 1695 1839 //cout << "nblignes= " << nrows << endl; … … 1734 1878 } 1735 1879 if (r_8tab_ != NULL) { delete [] r_8tab_; r_8tab_ = NULL; } 1736 r_8tab_=new r_8[ npixels]; 1737 fits_read_col(fptr, TDOUBLE, 1, 1, 1, npixels, &dnullval, 1738 r_8tab_, 1880 r_8tab_=new r_8[ tfields*npixels]; 1881 for (int k=1; k<=tfields; k++) 1882 { 1883 fits_read_col(fptr, TDOUBLE, k, 1, 1, npixels, &dnullval, 1884 r_8tab_+(k-1)*npixels, 1739 1885 &anynull, &status); 1740 1886 if( status ) printerror( status, "probleme dans lecture du tableau de doubles" ); 1887 } 1741 1888 break; 1742 1889 case TFLOAT : … … 1748 1895 } 1749 1896 if (r_4tab_ != NULL) { delete [] r_4tab_; r_4tab_ = NULL; } 1750 r_4tab_=new r_4[npixels]; 1751 fits_read_col(fptr, TFLOAT, 1, 1, 1, npixels, &fnullval, 1752 r_4tab_, &anynull, &status); 1753 if( status ) printerror( status,"probleme dans lecture du tableau de floats" ); 1897 r_4tab_=new r_4[ tfields*npixels]; 1898 for (int k=1; k<=tfields; k++) 1899 { 1900 fits_read_col(fptr, TFLOAT, k, 1, 1, npixels, &fnullval, 1901 r_4tab_+(k-1)*npixels, &anynull, &status); 1902 if( status ) printerror( status,"probleme dans lecture du tableau de floats" ); 1903 } 1754 1904 break; 1755 1905 … … 1762 1912 } 1763 1913 if (i_4tab_ != NULL) { delete [] i_4tab_; i_4tab_ = NULL; } 1764 i_4tab_=new int_4[npixels]; 1765 fits_read_col(fptr, TLONG, 1, 1, 1, npixels, &inullval, 1766 i_4tab_, &anynull, &status); 1767 //fits_read_img(fptr, TINT, 1, nelements, &inullval, i_4tab_, 1768 // &anynull, &status); 1769 if( status ) printerror( status,"probleme dans lecture du tableau de ints" ); 1914 i_4tab_=new int_4[ tfields*npixels]; 1915 for (int k=1; k<=tfields; k++) 1916 { 1917 fits_read_col(fptr, TLONG, k, 1, 1, npixels, &inullval, 1918 i_4tab_+(k-1)*npixels, &anynull, &status); 1919 if( status ) printerror( status,"probleme dans lecture du tableau de ints" ); 1920 } 1770 1921 break; 1771 1922 … … 1784 1935 char blank[LEN_KEYWORD]= ""; 1785 1936 1937 // 1786 1938 for(int j = 1; j <= nkeys; j++) 1787 1939 { -
trunk/SophyaExt/FitsIOServer/fitsioserver.h
r770 r838 5 5 #include "tvector.h" 6 6 #include "sphericalmap.h" 7 #include "sphere gorski.h"7 #include "spherehealpix.h" 8 8 #include "localmap.h" 9 9 #include "ntuple.h" 10 //#include "outilsinit.h" 10 11 #include "cimage.h" 11 12 #include "dvlist.h" 12 13 #include "anydataobj.h" 13 14 #include "FitsIO/fitsio.h" 14 #include "FitsIO/fitsio.h" 15 15 16 16 #define LEN_KEYWORD 9 … … 39 39 void load(ImageR4& DpcImg,char flnm[]); 40 40 void load(ImageI4& DpcImg,char flnm[]); 41 void load(SphereGorski<float>& sph, char flnm[], int hdunum=2); 42 void load(SphereGorski<double>& sph, char flnm[], int hdunum=2); 41 void load(SphereHealpix<float>& sph, char flnm[], int nth=1); 42 void load(SphereHealpix<double>& sph, char flnm[], int nth=1); 43 void load(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char filename[]); 44 void load(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char filename[]); 43 45 void save(TMatrix<double>& mat, char flnm[]); 44 46 void save(TMatrix<float>& mat, char flnm[]); … … 47 49 void save(SphericalMap<double>& sph, char flnm[]); 48 50 void save(SphericalMap<float>& sph, char flnm[]); 49 void save(SphereGorski<float>& sph, char filename[]); 50 void save(SphereGorski<double>& sph, char filename[]); 51 void save(LocalMap<double>& locm, char flnm[]); 51 52 // nth : numero d'ordre de la sphere sur le fichier de sauvegarde 53 // si on veut sauver une seule sphere : nth=1 54 // so veut sauver par exemple 3 spheres, on appelle 3 fois save 55 // avec respectivement nth=1, 2, 3 56 void save(SphereHealpix<float>& sph, char filename[], int nth=1); 57 void save(SphereHealpix<double>& sph, char filename[], int nth=1); 58 59 void save(SphereHealpix<double>& sph1,SphereHealpix<double>& sph2,SphereHealpix<double>& sph3, char filename[]); 60 void save(SphereHealpix<float>& sph1,SphereHealpix<float>& sph2,SphereHealpix<float>& sph3, char filename[]); 61 void save(const LocalMap<double>& locm, char flnm[]); 52 62 void save(const ImageR4& DpcImg,char flnm[]); 53 63 void save(const ImageI4& DpcImg,char flnm[]); … … 68 78 69 79 void planck_read_img(char flnm[],int &naxis,int &n1,int &n2,int &n3,DVList &dvl); 70 void planck_read_bntbl(char flnm[], int hdunum, int& npixels, DVList& dvl );71 void planck_write_bntbl(char flnm[], int npixels, char typeOfContent[], char extname[], char comment1[], DVList& dvl );80 void planck_read_bntbl(char flnm[], int hdunum, int& npixels, DVList& dvl,int tfields=1); 81 void planck_write_bntbl(char flnm[], int npixels, char typeOfContent[], char extname[], char comment1[], DVList& dvl, int tfields=1, int nth=1); 72 82 void write_picture(long* naxes,float* map,char* filename) const; 73 83
Note:
See TracChangeset
for help on using the changeset viewer.