切换到宽版
  • 1842阅读
  • 2回复

segy 的 格式说明及源码 [复制链接]

上一主题 下一主题
离线heqi168
 
发帖
437
财富
3028
威望
5
交易币
0
只看楼主 倒序阅读 使用道具 0楼 发表于: 2008-11-03 | 石油求职招聘就上: 阿果石油英才网
#define SEGY5     405
#define SEGY6     406
#define SEGY_ZERO 400


// the next segment is written by ycq in 1999.1.20

static   int   our_bh_sp[9]={4,12,16,18,20,24,56,60,64};
static   int   our_bh_os[9]={4,2,2,2,2,2,4,4,4};
static   int   our_th_sp[7]={20,24,28,36,114,116,220};
static   int   our_th_os[7]={4,4,2,4,2,2,4};

/************************************
int   bh_sp[9],bh_os[9],th_sp[7],th_os[7],th_base,th_step,th_off_id;
int   th_record_no,th_within_cdp;
************************************/

/*******************************************************/
static void    tranvalue(char *str,int old_p,int new_p,int size)
{
   char    ch;
   int     i;

   for(i=0;i<size;i++)
   {
      ch=str[i+old_p];
      str[i+old_p]=str[i+new_p];
      str[i+new_p]=ch;
   }
}

/********************************************************/
int   IoSeisTape::InitModifyFile(const char *name,int &id3200)
{
   int   i;
   FILE   *fp;
   char   buffer[120];

   if((fp=fopen(name,"r")==NULL) return(1);

   fscanf(fp,"%s",buffer);
   if(strcmp(buffer,"lyh_ok!")
   {
      fclose(fp); return(1);
   }

   id3200 = 3200;
   fscanf(fp,"%d",&i);
   if ( i != 0 ) id3200 = 0;


   for(i=0;i<9;i++)
   {
      fscanf(fp,"%d %d",&bh_sp,&bh_os);
   }
   for(i=0;i<7;i++)
   {
      fscanf(fp,"%d %d",&th_sp,&th_os);
   }

   fscanf(fp,"%d %d %d",&th_off_id,&th_base,&th_step);

   th_record_no=-1;
   th_within_cdp=-1;

   fclose(fp);
   return(0);
}



/********************************************************/
/*   record_no=0: the buf is 400 bytes;
   record_no>;0: the buf is datas.
*/
void   IoSeisTape::ModifySEGYData(char *buf,int record_no)
{
   int   i;
   TH   *th;

   if(record_no==0)
   {
      for(i=0;i<9;i++)
      {
         tranvalue(buf,our_bh_sp,bh_sp,bh_os);
      }
   }

   if ( record_no >; 0 )
   {
      for(i=0;i<7; i++)
      {
         tranvalue(buf,our_th_sp,th_sp,th_os);
      }

      if(th_off_id)
      {
         th=(TH *)&buf[0];
         if(th->;cdpnum!=th_record_no)
         {
            th_record_no=(int)th->;cdpnum;
            th_within_cdp=1;
         }
         th->;offset=th_base+th_step*(th->;tcdp-th_within_cdp);
         th_within_cdp=(int)th->;tcdp;
      }
   }
}




struct SSEEGGYY{/* segy - trace identification header */

  long tracl;/* trace sequence number within line */

  long tracr;/* trace sequence number within reel */

  long fldr;  /* field record number */

  long tracf;  /* trace number within field record */

  long ep;  /* energy source point number */

  long cdp;  /* CDP ensemble number */

  long cdpt;  /* trace number within CDP ensemble */

  short trid;  /* trace identification code:
      1 = seismic data
      2 = dead
      3 = dummy
      4 = time break
      5 = uphole
      6 = sweep
      7 = timing
      8 = water break
      9---, N = optional use (N = 32,767)

      Following are CWP id flags:

       9 = autocorrelation

      10 = Fourier transformed - no packing
           xr[0],xi[0], ..., xr[N-1],xi[N-1]

      11 = Fourier transformed - unpacked Nyquist
           xr[0],xi[0],...,xr[N/2],xi[N/2]

      12 = Fourier transformed - packed Nyquist
            even N:
           xr[0],xr[N/2],xr[1],xi[1], ...,
        xr[N/2 -1],xi[N/2 -1]
        (note the exceptional second entry)
           odd N:
           xr[0],xr[(N-1)/2],xr[1],xi[1], ...,
        xr[(N-1)/2 -1],xi[(N-1)/2 -1],xi[(N-1)/2]
        (note the exceptional second & last entries)

      13 = Complex signal in the time domain
           xr[0],xi[0], ..., xr[N-1],xi[N-1]

      14 = Fourier transformed - amplitude/phase
           a[0],p[0], ..., a[N-1],p[N-1]

      15 = Complex time signal - amplitude/phase
           a[0],p[0], ..., a[N-1],p[N-1]

      16 = Real part of complex trace from 0 to Nyquist

      17 = Imag part of complex trace from 0 to Nyquist

      18 = Amplitude of complex trace from 0 to Nyquist

      19 = Phase of complex trace from 0 to Nyquist

      21 = Wavenumber time domain (k-t)

      22 = Wavenumber frequency (k-omega)

      23 = Envelope of the complex time trace

      24 = Phase of the complex time trace

      25 = Frequency of the complex time trace

      30 = Depth-Range (z-x) traces

      101 = Seismic data packed to bytes (by supack1)
      
      102 = Seismic data packed to 2 bytes (by supack2)
      */

  short nvs;  /* number of vertically summed traces (see vscode
         in bhed structure) */

  short nhs;  /* number of horizontally summed traces (see vscode
         in bhed structure) */

  short duse;  /* data use:
        1 = production
        2 = test */

  long offset;  /* distance from source point to receiver
         group (negative if opposite to direction
         in which the line was shot) */

  long gelev;  /* receiver group elevation from sea level
         (above sea level is positive) */

  long selev;  /* source elevation from sea level
         (above sea level is positive) */

  long sdepth;  /* source depth (positive) */

  long gdel;  /* datum elevation at receiver group */

  long sdel;  /* datum elevation at source */

  long swdep;  /* water depth at source */

  long gwdep;  /* water depth at receiver group */

  short scalel;  /* scale factor for previous 7 entries
         with value plus or minus 10 to the
         power 0, 1, 2, 3, or 4 (if positive,
         multiply, if negative divide) */

  short scalco;  /* scale factor for next 4 entries
         with value plus or minus 10 to the
         power 0, 1, 2, 3, or 4 (if positive,
         multiply, if negative divide) */

  long  sx;  /* X source coordinate */

  long  sy;  /* Y source coordinate */

  long  gx;  /* X group coordinate */

  long  gy;  /* Y group coordinate */

  short counit;  /* coordinate units code:
        for previous four entries
        1 = length (meters or feet)
        2 = seconds of arc (in this case, the
        X values are longitude and the Y values
        are latitude, a positive value designates
        the number of seconds east of Greenwich
        or north of the equator */

  short wevel;  /* weathering velocity */

  short swevel;  /* subweathering velocity */

  short sut;  /* uphole time at source */

  short gut;  /* uphole time at receiver group */

  short sstat;  /* source static correction */

  short gstat;  /* group static correction */

  short tstat;  /* total static applied */

  short laga;  /* lag time A, time in ms between end of 240-
         byte trace identification header and time
         break, positive if time break occurs after
         end of header, time break is defined as
         the initiation pulse which maybe recorded
         on an auxiliary trace or as otherwise
         specified by the recording system */

  short lagb;  /* lag time B, time in ms between the time break
         and the initiation time of the energy source,
         may be positive or negative */

  short delrt;  /* delay recording time, time in ms between
         initiation time of energy source and time
         when recording of data samples begins
         (for deep water work if recording does not
         start at zero time) */

  short muts;  /* mute time--start */

  short mute;  /* mute time--end */

  unsigned short ns;  /* number of samples in this trace */

  unsigned short dt;  /* sample interval; in micro-seconds */

  short gain;  /* gain type of field instruments code:
        1 = fixed
        2 = binary
        3 = floating point
        4 ---- N = optional use */

  short igc;  /* instrument gain constant */

  short igi;  /* instrument early or initial gain */

  short corr;  /* correlated:
        1 = no
        2 = yes */

  short sfs;  /* sweep frequency at start */

  short sfe;  /* sweep frequency at end */

  short slen;  /* sweep length in ms */

  short styp;  /* sweep type code:
        1 = linear
        2 = cos-squared
        3 = other */

  short stas;  /* sweep trace length at start in ms */

  short stae;  /* sweep trace length at end in ms */

  short tatyp;  /* taper type: 1=linear, 2=cos^2, 3=other */

  short afilf;  /* alias filter frequency if used */

  short afils;  /* alias filter slope */

  short nofilf;  /* notch filter frequency if used */

  short nofils;  /* notch filter slope */

  short lcf;  /* low cut frequency if used */

  short hcf;  /* high cut frequncy if used */

  short lcs;  /* low cut slope */

  short hcs;  /* high cut slope */

  short year;  /* year data recorded */

  short day;  /* day of year */

  short hour;  /* hour of day (24 hour clock) */

  short minute;  /* minute of hour */

  short sec;  /* second of minute */

  short timbas;  /* time basis code:
        1 = local
        2 = GMT
        3 = other */

  short trwf;  /* trace weighting factor, defined as 1/2^N
         volts for the least sigificant bit */

  short grnors;  /* geophone group number of roll switch
         position one */

  short grnofr;  /* geophone group number of trace one within
         original field record */

  short grnlof;  /* geophone group number of last trace within
         original field record */

  short gaps;  /* gap size (total number of groups dropped) */

  short otrav;  /* overtravel taper code:
        1 = down (or behind)
        2 = up (or ahead) */

  /* local assignments */
  float d1;  /* sample spacing for non-seismic data */

  float f1;  /* first sample location for non-seismic data */

  float d2;  /* sample spacing between traces */

  float f2;  /* first trace location */

  float ungpow;  /* negative of power used for dynamic
         range compression */

  float unscale;  /* reciprocal of scaling factor to normalize
         range */

  short mark;  /* mark selected traces */

  short unass1[7];  /* unassigned--NOTE: last entry causes*/
  long  linenum;  /* line number */
  short unass2[8];  /* unassigned--NOTE: last entry causes
         a break in the word alignment, if we REALLY
         want to maintain 240 bytes, the following
         entry should be an odd number of short/UINT2
         OR do the insertion above the "mark" keyword
         entry */

        void display();
        void display1();

};


struct FileHeader{ /* bhed - binary header */
long  jobid;  /* job identification number */
long  lino;   /* line number (only one line per reel) */
long  reno;   /* reel number */
short ntrpr;  /* number of data traces per record */
short nart;   /* number of auxiliary traces per record */
short hdt;    /* sample interval in micro secs for this reel */
short dto;    /* same for original field recording */
short hns;    /* number of samples per trace for this reel */
short nso;    /* same for original field recording */
short format; /* data sample format code:
    1 = floating point (4 bytes) 32 bits
    2 = fixed point (4 bytes)    32 bits
    3 = fixed point (2 bytes)    16 bits
    4 = fixed point w/gain code (4 bytes) 32 bits
    5 = INT1 (CHAR) 8 bits    
    6 = DEC float  32 bits */
short fold;   /* CDP fold expected per CDP ensemble */
short tsort;  /* trace sorting code:
    1 = as recorded (no sorting)
    2 = CDP ensemble
    3 = single fold continuous profile
    4 = horizontally stacked */
short vscode; /* vertical sum code:
    1 = no sum
    2 = two sum ...
    N = N sum (N = 32,767) */
short hsfs;   /* sweep frequency at start */
short hsfe;   /* sweep frequency at end */
short hslen;  /* sweep length (ms) */
short hstyp;  /* sweep type code:
    1 = linear
    2 = parabolic
    3 = exponential
    4 = other  */
short schn;   /* trace number of sweep channel */
short hstas;  /* sweep trace taper length at start if
      tapered (the taper starts at zero time
      and is effective for this length) */

short hstae;  /* sweep trace taper length at end (the ending
      taper starts at sweep length minus the taper
      length at end) */
short htatyp; /* sweep trace taper type code:
    1 = linear
    2 = cos-squared
    3 = other */
short hcorr;  /* correlated data traces code:
    1 = no
    2 = yes */
short bgrcv;  /* binary gain recovered code:
    1 = yes
    2 = no */
short rcvm;   /* amplitude recovery method code:
    1 = none
    2 = spherical divergence
    3 = AGC
    4 = other */
short mfeet;  /* measurement system code:
    1 = meters
    2 = feet */
short polyt;  /* impulse signal polarity code:
    1 = increase in pressure or upward
        geophone case movement gives
        negative number on tape
    2 = increase in pressure or upward
        geophone case movement gives
        positive number on tape */
short vpol;   /* vibratory polarity code:
    code seismic signal lags pilot by
    1 337.5 to  22.5 degrees
    2  22.5 to  67.5 degrees
    3  67.5 to 112.5 degrees
    4 112.5 to 157.5 degrees
    5 157.5 to 202.5 degrees
    6 202.5 to 247.5 degrees
    7 247.5 to 292.5 degrees
    8 293.5 to 337.5 degrees */
short hunass[170]; /* unassigned */
        void display();
};

/* SEGY trace header */
struct KxnTh {
        long  t1;
        long  t3;
        long  recid;  /*   9 Fixed32 Original field record        */
        long  t7;
        long  t9;
        long  cdpnum; /*  21 Fixed32 CDP number                   */
        long  tcdp;   /*  25 Fixed32 Trace number within CDP      */
        short t15;
        short t16;
        short t17;
        short datause;/*  35 Fixed16 Data use (production)        */
        long  offset; /*  37 Fixed32 Offset (unsigned)            */
        long  t21;
        short tn23;
        short t24;
        short tn25;
        short t26;
        char  tn27[20];
        long  t37;
        long  t39;
        char  tn41[8];
        short cuf;    /*  89 Fixed16 Coordinate units flag        */
        short t46;
        short tn47;
        short t48;
        short t49;
        short tn50;
        short t51;
        short t52;
        char  tn53[4];
        short tn55;
        short t56;
        short t57;
        short nos;    /* 115 Fixed16 Number of samples            */
        short sr;     /* 117 Fixed16 Sample rate in us            */
        short tn60;
        char  tn61[60];
        short t91;
        short t92;
        short t93;
        short tn94;
        float tymax;
        float tymin;
        char  tnull[44];

    void display();

}; /* SEGY trace header */

void FileHeader::display()
{
  cout << "\n job identification number " << jobid;
  cout << "\n line number : " << lino;
  cout << "\n reel number " << reno;
  cout << "\n number of data traces per record " << ntrpr;
  cout << "\n number of auxiliary traces per record " << nart;
  cout << "\n sample interval in micro secs for this reel " << hdt;
  cout << "\n same for original field recording " << dto;
  cout << "\n number of samples per trace for this reel " << hns;
  cout << "\n same for original field recording " << nso;
  cout << "\n data sample format code: " << format;
  cout << "\n CDP fold expected per CDP ensemble " << fold;
  cout << "\n sorting code:  " << tsort;
  cout << "\n vertical sum code: " << vscode;
  cout << "\n sweep frequency at start " << hsfs;
  cout << "\n sweep frequency at end " << hsfe;
  cout << "\n sweep length (ms) " << hslen;
  cout << "\n sweep type code: " << hstyp;
  cout << "\n trace number of sweep channel " << schn;
  cout << "\n sweep trace taper length at start " << hstas;


  cout << "\n sweep trace taper length at end  " << hstae;
  cout << "\n sweep trace taper type code: " << htatyp;
  cout << "\n correlated data traces code: " << hcorr;
  cout << "\n binary gain recovered code: " << bgrcv;
  cout << "\n amplitude recovery method code: " << rcvm;
  cout << "\n measurement system code: " << mfeet;
  cout << "\n impulse signal polarity code: " << polyt;
  cout << "\n vibratory polarity code: " << vpol;

}

void SSEEGGYY::display()
{
    cout << "\n 1-4 bytes trace sequence number within line " << tracl;
    cout << "\n 5-8 bytes trace sequence number within reel " << tracr;
    cout << "\n 9-12 bytes field record number " <<  fldr;
    cout << "\n 13-16 bytes trace number within field record " <<  tracf;
    cout << "\n 17-20 bytes shot point number " << ep;
    cout << "\n 21-24 bytes CDP ensemble number " << cdp;
    cout << "\n 25-28 bytes trace number within CDP ensemble " << cdpt;
    cout << "\n 29-30 bytes trace identification code " << trid;
    cout << "\n 31-32 bytes number of vertically summed traces" << nvs;

    cout << "\n 33-34 bytes number of horizontally summed traces" << nhs;
    cout << "\n 35-36 bytes data use flag" << duse;
    cout << "\n 37-40 bytes distance from source point to receiver " << offset;

    cout <<"\n 41-44 bytes receiver surface elevation "<< gelev;
    cout <<"\n 45-48 bytes source surface elevation "<< selev;
    cout <<"\n 49-52 bytes source depth "<< sdepth;
    cout <<"\n 53-56 bytes Datum Elevation at receiver "<< gdel;
    cout <<"\n 57-60 bytes Datum Elevation at source "<< sdel;
    cout <<"\n 61-64 bytes water depth at source "<< swdep;
    cout <<"\n 73-76 bytes Source X-Coordinate "<< sx;
    cout <<"\n 77-80 bytes Source Y-Coordinate "<< sy;
    cout <<"\n 81-84 bytes Group X-Coordinate "<< gx;
    cout <<"\n 85-88 bytes Group Y-Coordinate "<< gy;
    cout <<"\n 115-116 bytes number of samples in this trace "<<ns;
    cout<<"\n 117-118 bytes Sample Rate "<<dt<<endl;
    
}

void SSEEGGYY::display1()
{
    cout << "\n 21-24 bytes CDP ensemble number " << cdp;
    cout << "\n 29-30 bytes trace identification code " << trid;
    cout << "\n 37-40 bytes distance from source point to receiver " << offset;

    cout <<"\n 111-112 bytes Mute start time " << muts;
    cout <<"\n 115-116 bytes number of samples in this trace "<<ns;
    cout<<"\n 117-118 bytes Sample Rate "<<dt<<endl;
    cout<<"\n 221-224 bytes line number "<<linenum<<endl;
    
}

void KxnTh::display()
{
    cout << " cdpnum : " << cdpnum
         << " valid : " << t15
         << " tcdp : " << tcdp
         << " offset : " << offset
         << endl;
}

static void outDeviceType(int dtype)
{
    switch ( dtype )
    {
        case TAPE_DRIVER:
           //cout << " device type : " << " tape driver " << endl;
           break;
        case FILE_DRIVER:
           //cout << " device type : " << " file driver " << endl;
           break;
        case DB_DRIVER:
           //cout << " device type : " << " database type " << endl;
           break;
        default:
           cout << " Unknown data driver type " << endl;
    }
}

// static SSEEGGYY syp;
// static FileHeader fhp;
// static KxnTh th;

IoSeisTape::IoSeisTape(int type,int nrecords)
{
    _tapeType=type;
    _nrecords=nrecords;
    _headerLen=240;

    data8 = NULL;
    data16 = NULL;
    data32 = NULL;

    _data_buf_len = 0;
    _data_buf = NULL;
    _thead = NULL;

    _minreftime = 0;
    _maxreftime = 0;

    _cmps = 0;
    _cmp_offset = 0;
    _line_offset = 0;

    _parafile = NULL;
    _segy_modify_flag = 0;
}

IoSeisTape::IoSeisTape(int type)
{
    _tapeType =type;

    switch(type)
   {
     case CGG:
        _headerLen=256;
     case GRISYS:
        if(_headerLen!=256) _headerLen=512;
        _volumeHlen=80; //80 bytes ascii text. volumeHeader
        _fileHlen  =80; //80 bytes ascii text. fileHeader
        _fileNumber=30; //30 bytes. file number.
        break;

     case SEGY:
        _headerLen=240;
        _volumeHlen=3200;//3200 bytes EBCD text.
        _fileNumber=400; //400 binary coded block.
        break;

     case CODE4:
        _volumeHlen=80;
        _fileHlen=80;
        break;
    }

    _data_buf_len = 0;
    _data_buf = NULL;
    _thead = NULL;

    _minreftime = 0;
    _maxreftime = 0;

    _cmps = 0;
    _cmp_offset = 0;
    _line_offset = 0;

    _parafile = NULL;
    _segy_modify_flag = 0;
}


int IoSeisTape::setSegyModifyParafile(const char *filename)
{
    if ( filename == NULL ) return -1;

    // get volume header length here
    if(InitModifyFile(filename, _volumeHlen))
    {
       cout << " segy modify parameter file error!" << endl;
       return -1;
    }

    _segy_modify_flag = 1;

    delete _parafile;
    _parafile = new char[strlen(filename)+1];
    strcpy(_parafile,filename);

    return 0;
}


int IoSeisTape::readTapeHeader()
{
    int status=0;
    int amt_read=0;
    cout << " _tapeType : " << _tapeType << endl;

    if(_tapeType==CODE4)
    {
        int tmp=0;
        amt_read = readVolumeH();  //volume label
        if(amt_read<=-10)           // tapetype error???????????
        {
            return(amt_read);
        }

        _recordLength=amt_read;
        ioConvertEBtoAS();

        if(buffer[3]<=57&&buffer[3]>;=4tmp=tmp+(buffer[3]-'0')*1000000;
        if(buffer[4]<=57&&buffer[4]>;=4tmp=tmp+(buffer[4]-'0')*100000;
        if(buffer[5]<=57&&buffer[5]>;=4tmp=tmp+(buffer[5]-'0')*10000;
        if(buffer[6]<=57&&buffer[6]>;=4tmp=tmp+(buffer[6]-'0')*1000;
        if(buffer[7]<=57&&buffer[7]>;=4tmp=tmp+(buffer[7]-'0')*100;
        if(buffer[8]<=57&&buffer[8]>;=4tmp=tmp+(buffer[8]-'0')*10;
        if(buffer[9]<=57&&buffer[9]>;=4tmp=tmp+(buffer[9]-'0');
        _reelNumber=tmp;
        printf("_reelNumber : %d\n", _reelNumber);


        amt_read = readHd1();      //hd1
        _recordLength=amt_read;
        ioConvertEBtoAS();

        amt_read = readHd2();     //hd2
        _recordLength=amt_read;
        ioConvertEBtoAS();

// EOF -1???? 93,5,31
        amt_read = tapeRead(2000);
//        cout<<"Should be an EOF"<<amt_read<<endl;
//  93,5,31
// read C card

        amt_read=readCcard();
        return(amt_read);
    }

    if(_tapeType==CGG||_tapeType==GRISYS)
    {
        int tmp=0;

        amt_read=readVolumeH();
        cout << " readVolumeH() : " << amt_read << endl;
        if(amt_read <= -10)           // tapetype error???????????
        {
            return(amt_read);
        }
        
        if(buffer[4]<=57&&buffer[4]>;=4tmp=tmp+(buffer[4]-'0')*100000;
        if(buffer[5]<=57&&buffer[5]>;=4tmp=tmp+(buffer[5]-'0')*10000;
        if(buffer[6]<=57&&buffer[6]>;=4tmp=tmp+(buffer[6]-'0')*1000;
        if(buffer[7]<=57&&buffer[7]>;=48)tmp=tmp+(buffer[7]-'0')*100;
        if(buffer[8]<=57&&buffer[8]>;=48)tmp=tmp+(buffer[8]-'0')*10;
        if(buffer[9]<=57&&buffer[9]>;=48)tmp=tmp+(buffer[9]-'0');
        _reelNumber=tmp;

        cout << " call readFileH() of CGG type " << endl;
        tmp = readFileH();

        cout << " read EOF of CGG : " << tmp << endl;
        tmp = tapeRead(20000); //should be EOF if CGG.!!!!!!!
        cout << " read 30 file of CGG : " << tmp << endl;
        tmp = tapeRead(20000); //should be file !!!!!!!
        // while ( tmp <= 4000 )
        // {
        //     cout << " read 30 file of CGG : " << tmp << endl;
        //     sleep(5);
        //     tmp = tapeRead(20000);
        // }
        return(amt_read);
     }  

     if(_tapeType == SEGY)
     {  
        cout << "GJHFJKKKKKKKKKK" << endl;

        if ( _volumeHlen >; 0 )
        {
            amt_read = readVolumeH();

            if(amt_read<=-10)           // tapetype error???????????
            {
                return(amt_read);
            }
        }

        // cout << "\nbefore readFileN \n"<< endl;
        // outDeviceType(_device_type);
        amt_read = readFileN();

        if ( _segy_modify_flag == 1 ) ModifySEGYData(buffer,0);
        // cout << "\nend readFileN \n"<< endl;
        // outDeviceType(_device_type);

        // memcpy(&fhp, buffer, 320);
        // fhp.display();

        _reelNumber = ioConvertChtoInt(buffer+8,4);
        printf("\n_reelNumber after ioConvertChtoInt :%d\n", _reelNumber);
        union{
            char string[2];
            short int num;
        }stringsint;

       /**********
        stringsint.string[0]=buffer[12];
        stringsint.string[1]=buffer[13];
        _trace_gather = (int)stringsint.num;
        printf("\_trace_gather :%d\n", _trace_gather);
       **********/

        stringsint.string[0]=buffer[16];
        stringsint.string[1]=buffer[17];
        _interval =(int)stringsint.num/1000;

        stringsint.string[0]=buffer[20];
        stringsint.string[1]=buffer[21];
        // 1993,11.11  _maxreftime=(int)stringsint.num*_interval;
        _maxreftime=(int)stringsint.num;
        // add by lyh
        // cout << " 1111111111111111111 _maxreftime " << _maxreftime << endl;

        stringsint.string[0]=buffer[24];
        stringsint.string[1]=buffer[25];
        _dataFormat = (int)stringsint.num;
        // cout << " 11111 _dataFormat : " << _dataFormat << endl;
        if ( _dataFormat <= 4 )
            _dataFormat += (SEGY1-1);
        else
            _dataFormat += SEGY_ZERO;
      
        
        // cout << " 22222 _dataFormat : " << _dataFormat
        //      << " SEGY1 : " << SEGY1 << endl;

        return(amt_read);
     }  

     if(_tapeType==NSEGY)
     {  
        union{
            char string[2];
            short int num;
        }stringsint;

        int flag400=0;
        int amt_read;
        for(int i=0;i<_nrecords;i++)
        {
            amt_read=tapeRead(4000);
            if(amt_read==400&&flag400==0)
            {
               flag400=1;
               _reelNumber=ioConvertChtoInt(buffer+8,4);

               stringsint.string[0]=buffer[16];
               stringsint.string[1]=buffer[17];
               _interval =(int)stringsint.num/1000;

               stringsint.string[0]=buffer[20];
               stringsint.string[1]=buffer[21];
               _maxreftime=(int)stringsint.num*_interval;
               //cout << " 222222222222222222222222222222 " << endl;
               // if ( _maxsample >; _maxreftime/_interval+1 )
               //      _maxsample = _maxreftime/_interval+1;

               stringsint.string[0]=buffer[24];
               stringsint.string[1]=buffer[25];
               // _dataFormat = (int)stringsint.num + SEGY1-1;
               if ( _dataFormat <= 4 )
                   _dataFormat += (SEGY1-1);
               else
                   _dataFormat += SEGY_ZERO;
               //cout << " 33333 _dataFormat : " << _dataFormat << endl;
           }
        }
        if(flag400==0) amt_read=-12; // no 400 bytes records.
        return(amt_read);
    }

}

int IoSeisTape::readCcard()
{
    while(1)
    {
        int amt_read=tapeRead(200);
        _recordLength=amt_read;
        ioConvertEBtoAS();
//        // printf("%s %d\n",buffer,amt_read);
        if(strncmp(buffer,"C MAX REF",9)==0)
        {
            int tmp;

            // max ref time.
            tmp=0;
            if(buffer[20]<=57&&buffer[20]>;=48)tmp=(buffer[20]-'0')*1000;
            if(buffer[21]<=57&&buffer[21]>;=48)tmp=tmp+(buffer[21]-'0')*100;
            if(buffer[22]<=57&&buffer[22]>;=48)tmp=tmp+(buffer[22]-'0')*10;
            if(buffer[23]<=57&&buffer[23]>;=48)tmp=tmp+(buffer[23]-'0');
            _maxreftime=tmp;

            // _interval
            tmp=0;
            if(buffer[44]<=57&&buffer[44]>;=48) tmp=(buffer[44]-'0')*10;
            if(buffer[45]<=57&&buffer[45]>;=48) tmp=tmp+buffer[45]-'0';
            _interval=tmp;

            //cout << " 3333333333333333333333333333333 " << endl;
            // if ( _maxsample >; _maxreftime/_interval+1 )
            //      _maxsample = _maxreftime/_interval+1;
            //_dataFormat
            _dataFormat=CODE41;
            if(strncmp(buffer+78,"FL",2)==0)_dataFormat=CODE42;
//            cout<<"maxref"<<_maxreftime<<"_interval"<<_interval<<endl;
//            cout<<"_dataFormat"<<_dataFormat<<endl;
        }    

        if(strncmp(buffer,"C TRACE HEADER LENGTH",21)==0)
        {
            int tmp;
            
            //hederlen
            tmp=0;
      if(buffer[23]<=57&&buffer[23]>;=48)tmp=(buffer[23]-'0')*100;
      if(buffer[24]<=57&&buffer[24]>;=48)tmp=tmp+(buffer[24]-'0')*10;
      if(buffer[25]<=57&&buffer[25]>;=48)tmp=tmp+(buffer[25]-'0');

            _headerLen=tmp*4;          // *2 ???????????????????
//            cout<<"in code4?headerlen"<<_headerLen<<endl;
//           cout<<"trace_headerLen"<<_headerLen<<endl;
        }    

        if(strncmp(buffer,"C EOF",5)==0)
        {
            break;
        }
    }
    return (1);

}

int IoSeisTape::readVolumeH()
{
      // int amt_read=tapeRead(4000);
      // int amt_read=tapeRead(40000);

      outDeviceType(_device_type);
      if ( _fp != NULL )
          cout << " ftell : " << ftell(_fp) << endl;
      else cout << endl;

      int amt_read=-1;
      if ( _device_type == FILE_DRIVER )
          amt_read = tapeRead(_volumeHlen);
      if ( _device_type == TAPE_DRIVER )
          amt_read = tapeRead(40000);

      //cout << " after read readVolumeH " ;
      outDeviceType(_device_type);
      if ( _fp != NULL )
          cout << " ftell : " << ftell(_fp) << endl;
      else cout << endl;

      //cout << " tapeRead(4000) : " << amt_read << endl;
    
      if(isascii(buffer[0])==1&&_tapeType==CODE4)
      {
          printf(" The tape type is not correct \n";
          printf(" It is a CGG or GRISYS tape.\n";
          return(-10);
      }

      cout << "\n _volumeHlen : " <<  _volumeHlen
           << " amt_read : " <<  amt_read << endl;

      if(amt_read!=_volumeHlen)
      {
          printf("The tape type is not correct\n";
          if(amt_read==3200)
          {
             printf("It is a SEGY tape\n ";
             return(-11);
          }
          if(amt_read==80)  

评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
离线landmark
发帖
111
财富
0
威望
9
交易币
0
只看该作者 1楼 发表于: 2009-01-02 | 石油求职招聘就上: 阿果石油英才网
thanks,you are great!
离线godhet
发帖
48
财富
7
威望
0
交易币
0
只看该作者 2楼 发表于: 2011-12-25 | 石油求职招聘就上: 阿果石油英才网
谢谢分享

网站事务咨询:QQ:1392013 | 26189883
阿果石油网为免费个人网站,为石油人提供免费的在线即时技术交流场所,拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论和行为!
如有言论或会员共享的资料涉及到您的权益,请立即通知网站管理员,本站将在第一时间给予配合处理,谢谢!