Changeset 3684 in Sophya for trunk/AddOn/TAcq


Ignore:
Timestamp:
Nov 27, 2009, 11:53:26 AM (16 years ago)
Author:
ansari
Message:

Ajout de la possibilite creation/lecture fichiers fits 3D (type cube) - Reza 27/11/2009

Location:
trunk/AddOn/TAcq
Files:
2 edited

Legend:

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

    r3671 r3684  
    8686  nax1 = 1;
    8787  nax2 = 1;
     88  nax3 = 1;
     89  fgnax3 = false;
    8890  totwsz = 0;
    8991  header = new char[MFITSHLEN];
     
    152154  nax1 = na1;
    153155  nax2 = na2;
    154 }
     156  nax3 = 1;
     157  fgnax3 = false;
     158}
     159
     160/* --Methode-- */
     161void MiniFITSFile::setDTypeNaxis(MiniFITS_DT dt, size_t na1, size_t na2, size_t na3)
     162{
     163  // Interdit si fichier ouvert en lecture ...
     164  if ((fip!=NULL)&&(rwmode == MF_Read)) 
     165     throw MiniFITSException("MiniFITSFile::setDTypeNaxis()/Error ReadOnly file");
     166
     167  dtype = dt;
     168  nax1 = na1;
     169  nax2 = na2;
     170  nax3 = na3;
     171  fgnax3 = true;
     172}
     173
    155174
    156175/* --Methode-- */
     
    192211  buff[strlen(buff)] = ' ';
    193212  buff = header+160;
    194   strcpy(buff, "NAXIS   =                    2 / number of data axes");
     213  if (fgnax3)
     214    strcpy(buff, "NAXIS   =                    2 / number of data axes");
     215  else
     216    strcpy(buff, "NAXIS   =                    3 / number of data axes");
    195217  buff[strlen(buff)] = ' ';
    196218  buff = header+240;
     
    200222  sprintf(buff, "NAXIS2  = %20ld / nb of rows = NumberOfPaquets", (long)nax2);
    201223  buff[strlen(buff)] = ' ';
    202   buff = header+400+nkeya_*80;
     224  buff = header+400;
     225  if (fgnax3)
     226    sprintf(buff, "NAXIS3  = %20ld / nb of rows = NumberOfFibers", (long)nax3);
     227  else
     228    strcpy(buff,"COMMENT  BAO-Radio / MiniFITSFile ");
     229  buff[strlen(buff)] = ' ';
     230 
     231  buff = header+480+nkeya_*80;
    203232  strcpy(buff,"COMMENT  BAO-Radio / MiniFITSFile ");
    204233  buff[strlen(buff)] = ' ';
    205   buff = header+480+nkeya_*80;
     234  buff = header+560+nkeya_*80;
    206235  strcpy(buff,"END");
    207236  buff[strlen(buff)] = ' ';
     
    213242int MiniFITSFile::AddKeyI(const char* key, long val, const char* comm)
    214243{
    215   if (nkeya_ >= 29) return 0;
     244  if (nkeya_ >= 28) return 0;
    216245  char cle[10];
    217246  strncpy(cle,key,8);
     
    220249    if (cle[i]=='\0') cle[i]=' ';
    221250  cle[9]='\0';
    222   char* buff=header+400+nkeya_*80;
     251  char* buff=header+480+nkeya_*80;
    223252  if (comm!=NULL) {
    224253    char tcom[50];
     
    236265int MiniFITSFile::AddKeyD(const char* key, double val, const char* comm)
    237266{
    238   if (nkeya_ >= 29) return 0;
     267  if (nkeya_ >= 28) return 0;
    239268  char cle[10];
    240269  strncpy(cle,key,8);
     
    243272    if (cle[i]=='\0') cle[i]=' ';
    244273  cle[9]='\0';
    245   char* buff=header+400+nkeya_*80;
     274  char* buff=header+480+nkeya_*80;
    246275  if (comm!=NULL) {
    247276    char tcom[50];
     
    259288int MiniFITSFile::AddKeyS(const char* key, const char* val, const char* comm)
    260289{
    261   if (nkeya_ >= 29) return 0;
     290  if (nkeya_ >= 28) return 0;
    262291  char cle[10];
    263292  strncpy(cle,key,8);
     
    274303  if ((l<70)&&(comm!=NULL)) strncpy(tcom+l,comm,70-l);
    275304  tcom[70]='\0';
    276   char* buff=header+400+nkeya_*80;
     305  char* buff=header+480+nkeya_*80;
    277306  sprintf(buff,"%s %s", cle, tcom);
    278307  buff[strlen(buff)] = ' ';
     
    291320  bool fgok1=false;
    292321  bool fgok2=false;
     322  bool fgok3=false;
    293323  for(int kh=80; kh<2800; kh+=80) {
    294324        buff = header+kh;
     
    303333//        cout << " FOUND : NAXIS2= " << nax2 << endl;           
    304334        }
     335        else if (strncmp(buff, "NAXIS3  =", 9) == 0)  {
     336          nax3 = atol(buff+10);
     337          fgok3 = true;
     338//        cout << " FOUND : NAXIS2= " << nax2 << endl;           
     339        }
    305340        else if (strncmp(buff, "BITPIX  =", 9) == 0)  {
    306341          int bpix = atoi(buff+10);
     
    315350  if (!(fgok1&&fgok2&&fgokt)) 
    316351     throw MiniFITSException("MiniFITSFile::DecodeHeader()/Error- Missing/wrong NAXIS1/2,BITPIX");
     352  if (fgok3)  fgnax3=true;
    317353  return;
    318354}
  • trunk/AddOn/TAcq/minifits.h

    r3683 r3684  
    5151  string DataTypeToString(); 
    5252
    53   size_t NAxis1() { return nax1; }
    54   size_t NAxis2() { return nax2; }
     53  inline size_t NAxes()  { return ((fgnax3)?3:2); }
     54  inline size_t NAxis1() { return nax1; }
     55  inline size_t NAxis2() { return nax2; }
     56  inline size_t NAxis3() { return ((fgnax3)?nax3:0); }
    5557
    5658  void setDTypeNaxis(MiniFITS_DT dt, size_t na1, size_t na2);
     59  void setDTypeNaxis(MiniFITS_DT dt, size_t na1, size_t na2, size_t na3);
    5760
    5861  // Lecture avec indication de la taille (nb d'elements) et offset
     
    100103  MiniFITS_Mode rwmode;
    101104  MiniFITS_DT dtype;
    102   size_t nax1, nax2;
     105  size_t nax1, nax2, nax3;
     106  bool fgnax3;  // true -> NAXIS=3 3D file
    103107  size_t totwsz;  // total bytes ecrits
    104108  char* header; //  entete FITS
Note: See TracChangeset for help on using the changeset viewer.