Ignore:
Timestamp:
Dec 8, 1999, 9:26:04 AM (26 years ago)
Author:
ansari
Message:

load matrix with naxis=3, naxis3=1

File:
1 edited

Legend:

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

    r674 r676  
    3232  nbcols=n2;
    3333  if (naxis == 1) nbcols=1;
    34   if (naxis > 2)
     34  if (naxis > 2 && n3>1)
    3535    {
    3636      cout<<"  FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl;
     
    4040  if (mat.NRows() != nbrows || mat.NCols() != nbcols )
    4141    {
    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;
    4646      mat.ReSize(nbrows,nbcols);
    4747      cout << " resize the vector to nbrows=  " << nbrows  << " nbcols= " << nbcols << endl;
     
    6565  nbcols=n2;
    6666  if (naxis == 1) nbcols=1;
    67   if (naxis > 2)
     67  if (naxis > 2 && n3>1)
    6868    {
    6969      cout<<"  FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl;
     
    7373  if (mat.NRows() != nbrows || mat.NCols() != nbcols )
    7474    {
    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;
    7979      mat.ReSize(nbrows,nbcols);
    8080      cout << " resize the vector to nbrows=  " << nbrows  << " nbcols= " << nbcols << endl;
     
    9898  nbcols=n2;
    9999  if (naxis == 1) nbcols=1;
    100   if (naxis > 2)
     100  if (naxis > 2 && n3>1)
    101101    {
    102102      cout<<"  FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl;
     
    106106  if (mat.NRows() != nbrows || mat.NCols() != nbcols )
    107107    {
    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;
    112112      mat.ReSize(nbrows,nbcols);
    113113      cout << " resize the vector to nbrows=  " << nbrows  << " nbcols= " << nbcols << endl;
     
    290290       strip (keyname, 'B',' ');
    291291       strip(strval, 'B',' ');
     292       strip(strval, 'B','\'');
    292293       
    293294       switch( dtype )
     
    376377  nside= dvl.GetI("NSIDE");
    377378  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)
    380381
    381382    //  if (ordering!="RING    ")
     
    420421  nside= dvl.GetI("NSIDE");
    421422  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)
    424425
    425426    //  if (ordering!="RING    ")
     
    14261427      fits_read_img(fptr, TFLOAT, 1, nelements,  &fnullval, r_4tab_,
    14271428                    &anynull, &status);
     1429      for (int kk=0; kk<nelements; kk++) cout << r_4tab_[kk] << endl;
    14281430      if( status )  printerror( status );
    14291431      break;
     
    14501452  status = 0;
    14511453  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     }
    15221501
    15231502  // close the file
     
    16811660            strip (keyname, 'B',' ');
    16821661            strip(strval, 'B',' ');
    1683             switch( dtype )
    1684               {
     1662            strip(strval, 'B','\'');
     1663            switch( dtype ) 
     1664              {
    16851665              case 'C':
    16861666                dvl[keyname]= strval;     
     
    16911671                dvl[keyname]= (int_4)ival;
    16921672                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;
    16931679              case 'F':
    16941680                double dval;
     
    16971683                break;
    16981684              default :
    1699                 cout << " FitsIOServer : mot-cle bizarre " << endl;
     1685                cout << " FitsIOServer : type de mot-cle bizarre: "  << keyname <<" dtype= "<<dtype << endl;
    17001686                break;
    17011687              }
Note: See TracChangeset for help on using the changeset viewer.