Changeset 3688 in Sophya for trunk/AddOn/TAcq/minifits.cc


Ignore:
Timestamp:
Nov 29, 2009, 12:13:54 AM (16 years ago)
Author:
ansari
Message:

Introduction de la classe FitsCubeWriter - Reza 28/11/2009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/minifits.cc

    r3684 r3688  
    220220  buff[strlen(buff)] = ' ';
    221221  buff = header+320;
    222   sprintf(buff, "NAXIS2  = %20ld / nb of rows = NumberOfPaquets", (long)nax2);
     222  if (fgnax3)
     223    sprintf(buff, "NAXIS2  = %20ld / Number of fibers ", (long)nax2);
     224  else
     225    sprintf(buff, "NAXIS2  = %20ld / nb of rows = NumberOfPaquets", (long)nax2);
    223226  buff[strlen(buff)] = ' ';
    224227  buff = header+400;
    225228  if (fgnax3)
    226     sprintf(buff, "NAXIS3  = %20ld / nb of rows = NumberOfFibers", (long)nax3);
     229    sprintf(buff, "NAXIS3  = %20ld / Number of paquets ", (long)nax3);
    227230  else
    228231    strcpy(buff,"COMMENT  BAO-Radio / MiniFITSFile ");
     
    311314
    312315/* --Methode-- */
     316string MiniFITSFile::GetKey(const char* key)
     317{
     318  char rs[80];
     319  char cle[10];
     320  strncpy(cle,key,8);
     321  cle[8]='=';
     322  for(int i=0;i<8;i++)
     323    if (cle[i]=='\0') cle[i]=' ';
     324  cle[9]='\0';
     325  for(int kh=80; kh<2800; kh+=80) {
     326    char * buff = header+kh;
     327    if (strncmp(buff, cle, 9) == 0)  {
     328      strncpy(rs, buff+10, 70);
     329      rs[70]='\0';
     330      break;
     331    }
     332  }
     333  return rs;
     334}
     335
     336/* --Methode-- */
    313337void MiniFITSFile::DecodeHeader()
    314338{
     
    322346  bool fgok3=false;
    323347  for(int kh=80; kh<2800; kh+=80) {
    324         buff = header+kh;
    325         if (strncmp(buff, "NAXIS1  =", 9) == 0)  {
    326           nax1 = atol(buff+10);
    327           fgok1 = true;
    328 //        cout << " FOUND : NAXIS1= " << nax1 << endl;
    329         }
    330         else if (strncmp(buff, "NAXIS2  =", 9) == 0)  {
    331           nax2 = atol(buff+10);
    332           fgok2 = true;
    333 //        cout << " FOUND : NAXIS2= " << nax2 << endl;           
    334         }
    335         else if (strncmp(buff, "NAXIS3  =", 9) == 0)  {
    336           nax3 = atol(buff+10);
    337           fgok3 = true;
    338 //        cout << " FOUND : NAXIS2= " << nax2 << endl;           
    339         }
    340         else if (strncmp(buff, "BITPIX  =", 9) == 0)  {
    341           int bpix = atoi(buff+10);
    342           fgokt = true;
    343           if (bpix == 8)  dtype = MF_Byte;
    344           else if (bpix == 16)  dtype = MF_Int16;
    345           else if (bpix == -32)  dtype = MF_Float32;
    346           else fgokt = false;
    347 //        cout << " FOUND : bpix= " << bpix << endl;             
    348         }
     348    buff = header+kh;
     349    if (strncmp(buff, "NAXIS1  =", 9) == 0)  {
     350      nax1 = atol(buff+10);
     351      fgok1 = true;
     352      //          cout << " FOUND : NAXIS1= " << nax1 << endl;
     353    }
     354    else if (strncmp(buff, "NAXIS2  =", 9) == 0)  {
     355      nax2 = atol(buff+10);
     356      fgok2 = true;
     357      //          cout << " FOUND : NAXIS2= " << nax2 << endl;           
     358    }
     359    else if (strncmp(buff, "NAXIS3  =", 9) == 0)  {
     360      nax3 = atol(buff+10);
     361      fgok3 = true;
     362      //          cout << " FOUND : NAXIS2= " << nax2 << endl;           
     363    }
     364    else if (strncmp(buff, "BITPIX  =", 9) == 0)  {
     365      int bpix = atoi(buff+10);
     366      fgokt = true;
     367      if (bpix == 8)  dtype = MF_Byte;
     368      else if (bpix == 16)  dtype = MF_Int16;
     369      else if (bpix == -32)  dtype = MF_Float32;
     370      else fgokt = false;
     371      //          cout << " FOUND : bpix= " << bpix << endl;             
     372    }
    349373  }
    350374  if (!(fgok1&&fgok2&&fgokt)) 
    351      throw MiniFITSException("MiniFITSFile::DecodeHeader()/Error- Missing/wrong NAXIS1/2,BITPIX");
     375    throw MiniFITSException("MiniFITSFile::DecodeHeader()/Error- Missing/wrong NAXIS1/2,BITPIX");
    352376  if (fgok3)  fgnax3=true;
    353377  return;
Note: See TracChangeset for help on using the changeset viewer.