Changeset 676 in Sophya
- Timestamp:
- Dec 8, 1999, 9:26:04 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fitsioserver.cc
r674 r676 32 32 nbcols=n2; 33 33 if (naxis == 1) nbcols=1; 34 if (naxis > 2 )34 if (naxis > 2 && n3>1) 35 35 { 36 36 cout<<" FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl; … … 40 40 if (mat.NRows() != nbrows || mat.NCols() != nbcols ) 41 41 { 42 cout << " found " << nbrows << " rows ";43 cout << " expected " << mat.NRows() << endl;44 cout << " found " << nbcols << " columns " ;45 cout << " expected " << mat.NCols() << endl;42 // cout << " found " << nbrows << " rows "; 43 // cout << " expected " << mat.NRows() << endl; 44 // cout << " found " << nbcols << " columns " ; 45 // cout << " expected " << mat.NCols() << endl; 46 46 mat.ReSize(nbrows,nbcols); 47 47 cout << " resize the vector to nbrows= " << nbrows << " nbcols= " << nbcols << endl; … … 65 65 nbcols=n2; 66 66 if (naxis == 1) nbcols=1; 67 if (naxis > 2 )67 if (naxis > 2 && n3>1) 68 68 { 69 69 cout<<" FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl; … … 73 73 if (mat.NRows() != nbrows || mat.NCols() != nbcols ) 74 74 { 75 cout << " found " << nbrows << " rows ";76 cout << " expected " << mat.NRows() << endl;77 cout << " found " << nbcols << " columns " ;78 cout << " expected " << mat.NCols() << endl;75 // cout << " found " << nbrows << " rows "; 76 // cout << " expected " << mat.NRows() << endl; 77 // cout << " found " << nbcols << " columns " ; 78 // cout << " expected " << mat.NCols() << endl; 79 79 mat.ReSize(nbrows,nbcols); 80 80 cout << " resize the vector to nbrows= " << nbrows << " nbcols= " << nbcols << endl; … … 98 98 nbcols=n2; 99 99 if (naxis == 1) nbcols=1; 100 if (naxis > 2 )100 if (naxis > 2 && n3>1) 101 101 { 102 102 cout<<" FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl; … … 106 106 if (mat.NRows() != nbrows || mat.NCols() != nbcols ) 107 107 { 108 cout << " found " << nbrows << " rows ";109 cout << " expected " << mat.NRows() << endl;110 cout << " found " << nbcols << " columns " ;111 cout << " expected " << mat.NCols() << endl;108 // cout << " found " << nbrows << " rows "; 109 // cout << " expected " << mat.NRows() << endl; 110 // cout << " found " << nbcols << " columns " ; 111 // cout << " expected " << mat.NCols() << endl; 112 112 mat.ReSize(nbrows,nbcols); 113 113 cout << " resize the vector to nbrows= " << nbrows << " nbcols= " << nbcols << endl; … … 290 290 strip (keyname, 'B',' '); 291 291 strip(strval, 'B',' '); 292 strip(strval, 'B','\''); 292 293 293 294 switch( dtype ) … … 376 377 nside= dvl.GetI("NSIDE"); 377 378 const char* ordering= dvl.GetS("ORDERING").c_str(); 378 char* ring = " 'RING";379 if ( strncmp(ordering, ring, 3) != 0)379 char* ring = "RING"; 380 if ( strncmp(ordering, ring,4) != 0) 380 381 381 382 // if (ordering!="RING ") … … 420 421 nside= dvl.GetI("NSIDE"); 421 422 const char* ordering= dvl.GetS("ORDERING").c_str(); 422 char* ring = " 'RING";423 if ( strncmp(ordering, ring, 3) != 0)423 char* ring = "RING"; 424 if ( strncmp(ordering, ring,4) != 0) 424 425 425 426 // if (ordering!="RING ") … … 1426 1427 fits_read_img(fptr, TFLOAT, 1, nelements, &fnullval, r_4tab_, 1427 1428 &anynull, &status); 1429 for (int kk=0; kk<nelements; kk++) cout << r_4tab_[kk] << endl; 1428 1430 if( status ) printerror( status ); 1429 1431 break; … … 1450 1452 status = 0; 1451 1453 char card[FLEN_CARD]; 1452 int num = 0; 1453 char comment2[FLEN_COMMENT] = "x"; 1454 char keyname[16]; 1455 char * datekey= "DATE"; 1456 char * endkey= "END"; 1457 char typ='x'; 1458 int ival; 1459 double dval; 1460 char strval[90]; 1461 // on a convenu que les mots cles utilisateur sont apres le mot cle DATE 1462 // on va jusqu'au mot cle DATE 1463 int flen_keyword = 9; 1464 // FLEN_KEYWORD est la longueur max d'un mot-cle. Il doit y avoir une 1465 // erreur dans la librairie fits qui donne FLEN_KEYWORD=72 1466 // contrairement a la notice qui donne FLEN_KEYWORD=9 (ch. 5, p.39) 1467 while (status == 0 && strncmp(keyname, datekey,4) != 0 ) 1468 { 1469 num++; 1470 fits_read_record(fptr, num, card, &status); 1471 strncpy(keyname,card,flen_keyword-1); keyname[10] = '\0'; 1472 } 1473 if (status != 0 ) 1474 { 1475 cout << " fitsio::planck_read_img : erreur, mot cle DATE absent " << endl; 1476 } 1477 // on recupere la liste des mots-cles utilisateurs 1478 while (status == 0) 1479 { 1480 num++; 1481 // on lit un record pour recuperer le nom du mot-cle 1482 fits_read_record(fptr, num, card, &status); 1483 strncpy(keyname,card,flen_keyword-1); keyname[10] = '\0'; 1484 char value[FLEN_VALUE]; 1485 // on recupere le premier caractere du commentaire, qui contient 1486 // le code du type de la valeur 1487 // (tant que ce n est pas le mot cle END) 1488 fits_read_keyword(fptr, keyname, value, comment2, &status); 1489 if ( strncmp(keyname, endkey,flen_keyword-1) != 0) 1490 { 1491 typ = comment2[0]; 1492 // quand le type est connu, on lit la valeur 1493 switch (typ) 1494 { 1495 case 'I' : 1496 fits_read_key(fptr, TINT, keyname, &ival, comment2, &status); 1497 if( status ) printerror( status ); 1498 strip (keyname, 'B',' '); 1499 dvl[keyname] = (int_4)ival; 1500 break; 1501 case 'D' : 1502 fits_read_key(fptr, TDOUBLE, keyname, &dval, comment2, &status); 1503 if( status ) printerror( status ); 1504 strip (keyname, 'B',' '); 1505 dvl[keyname] = dval; 1506 break; 1507 case 'S' : 1508 fits_read_key(fptr, TSTRING, keyname, strval, comment2, &status); 1509 if( status ) printerror( status ); 1510 strip (keyname, 'B',' '); 1511 strip(strval, 'B',' '); 1512 dvl[keyname]=strval; 1513 break; 1514 default : 1515 // cout << " FITSIOSERVER::planck_read_img -> DVList Type ? for key " 1516 // << (string)keyname << endl; 1517 break; 1518 } 1519 } 1520 } 1521 1454 char keyname[LEN_KEYWORD]= ""; 1455 char strval[FLEN_VALUE]; 1456 char comment1[FLEN_COMMENT]; 1457 char dtype; 1458 char * comkey = "COMMENT"; 1459 int keypos; 1460 fits_get_hdrpos(fptr,&nkeys,&keypos,&status); 1461 if( status ) printerror( status ); 1462 // cout << " planck_read_img : nombre de mots-cles : " << nkeys << endl; 1463 for(int j = 1; j <= nkeys; j++) 1464 { 1465 fits_read_keyn(fptr,j,card,strval,comment1,&status); 1466 strncpy(keyname,card,LEN_KEYWORD-1); 1467 if ( strncmp(keyname,comkey ,LEN_KEYWORD-1) != 0) 1468 { 1469 fits_get_keytype(strval,&dtype,&status); 1470 // cout<<" keyname= "<< keyname <<" dtype= "<<dtype <<endl; 1471 strip (keyname, 'B',' '); 1472 strip(strval, 'B',' '); 1473 strip(strval, 'B','\''); 1474 switch( dtype ) 1475 { 1476 case 'C': 1477 dvl[keyname]= strval; 1478 break; 1479 case 'I': 1480 int ival; 1481 ctoi(strval,&ival); 1482 dvl[keyname]= (int_4)ival; 1483 break; 1484 case 'L': 1485 int ilog; 1486 if (strncmp(strval,"T" ,1) ==0) ilog=1; 1487 else ilog=0; 1488 dvl[keyname]= (int_4)ilog; 1489 break; 1490 case 'F': 1491 double dval; 1492 ctof(strval,&dval); 1493 dvl[keyname]= dval; 1494 break; 1495 default : 1496 cout << " FitsIOServer : type de mot-cle bizarre: " << keyname <<" dtype= "<<dtype << endl; 1497 break; 1498 } 1499 } 1500 } 1522 1501 1523 1502 // close the file … … 1681 1660 strip (keyname, 'B',' '); 1682 1661 strip(strval, 'B',' '); 1683 switch( dtype ) 1684 { 1662 strip(strval, 'B','\''); 1663 switch( dtype ) 1664 { 1685 1665 case 'C': 1686 1666 dvl[keyname]= strval; … … 1691 1671 dvl[keyname]= (int_4)ival; 1692 1672 break; 1673 case 'L': 1674 int ilog; 1675 if (strncmp(strval,"T" ,1) ==0) ilog=1; 1676 else ilog=0; 1677 dvl[keyname]= (int_4)ilog; 1678 break; 1693 1679 case 'F': 1694 1680 double dval; … … 1697 1683 break; 1698 1684 default : 1699 cout << " FitsIOServer : mot-cle bizarre "<< endl;1685 cout << " FitsIOServer : type de mot-cle bizarre: " << keyname <<" dtype= "<<dtype << endl; 1700 1686 break; 1701 1687 }
Note:
See TracChangeset
for help on using the changeset viewer.