使用python3读取segy文件道头信息

# code for read headers of each trace
import matplotlib.pyplot as mp
import numpy as np 
import sys
import struct
import binascii

fileName = "BAOFU_amp.segy"
nTrace = 4
nSample = 3001
fSegy = open(fileName,"rb")

fSegyHeader = {'tracr':[5,8]   ,'ep':[17,20]    , 'cdp':[21,24]    , 'offset':[37,40], 
               'gelev':[41,44] , 'selev': [45,48] , 'sdepth':[49,52],  'scalel':[69,70],
               'scalco':[71,72], 'sx':[73,76]     , 'sy':[77,80]    ,  'gx':[81,84]    , 'gy':[85,88]}   

for iTrace in range(nTrace):
    fSegy.seek(240*iTrace+3600+nSample*4*iTrace,0) # 每一道都跳过240字节道头
    traceHeader = fSegy.read(240)
    for key in fSegyHeader.keys():
        tempValue = traceHeader[fSegyHeader[key][0]:fSegyHeader[key][1]]
        hexValue = tempValue.hex()
        decValue = int(hexValue,16)
        print(key,decValue)

# SEGY数据道头:
#         int tracl;      /* 001-004  trace sequence number within line */
#         int tracr;      /* 005-008  trace sequence number within reel */
#         int fldr;       /* 009-012  field record number */
#         int tracf;      /* 013-016  trace number within field record */
#         int ep;         /* 017-020  energy source point number */
#         int cdp;        /* 021-024  CDP ensemble number */
#         int cdpt;       /* 025-028  trace number within CDP ensemble */
#         short trid;     /* 029-030  trace identification code, see the end of this struct definition for details*/
#         short nvs;      /* 031-032  number of vertically summed traces */
#         short nhs;      /* 033-034  number of horizontally summed traces */
#         short duse;     /* 035-036  data use: 1 = production 2 = test */
#         int offset;     /* 037-040  distance from source point to receiver group (negative if opposite to direction in which the line was shot) */
#         int gelev;      /* 041-044  receiver group elevation from sea level (above sea level is positive) */
#         int selev;      /* 045-048  source elevation from sea level (above sea level is positive) */
#         int sdepth;     /* 049-052  source depth (positive) */
#         int gdel;       /* 053-056  datum elevation at receiver group */
#         int sdel;       /* 057-060  datum elevation at source */
#         int swdep;      /* 061-064  water depth at source */
#         int gwdep;      /* 065-068  water depth at receiver group */
#         short scalel;   /* 069-070  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;   /* 071-072  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) */
#         int  sx;        /* 073-076  X source coordinate */
#         int  sy;        /* 077-080  Y source coordinate */
#         int  gx;        /* 081-084  X group coordinate */
#         int  gy;        /* 085-088  Y group coordinate */
#         short counit;   /* 089-090  coordinate units code: 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;    /* 091-092  weathering velocity */
#         short swevel;   /* 093-094  subweathering velocity */
#         short sut;      /* 095-096  uphole time at source */
#         short gut;      /* 097-098  uphole time at receiver group */
#         short sstat;    /* 099-100  source static correction */
#         short gstat;    /* 101-102  group static correction */
#         short tstat;    /* 103-104  total static applied */
#         short laga;     /* 105-106  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;     /* 107-108  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;    /* 109-110  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;     /* 111-112  mute time--start */
#         short mute;     /* 113-114  mute time--end */
#         unsigned short ns;      /* 115-116  number of samples in this trace */
#         unsigned short dt;      /* 117-118  sample interval; in micro-seconds */
#         short gain;     /* 119-120  gain type of field instruments code: 1 = fixed 2 = binary 3 = floating point 4 ---- N = optional use */
#         short igc;      /* 121-122  instrument gain constant */
#         short igi;      /* 123-124  instrument early or initial gain */
#         short corr;     /* 125-126  correlated: 1 = no 2 = yes */
#         short sfs;      /* 127-128  sweep frequency at start */
#         short sfe;      /* 129-130  sweep frequency at end */
#         short slen;     /* 131-132  sweep length in ms */
#         short styp;     /* 133-134  sweep type code: 1 = linear 2 = cos-squared 3 = other */
#         short stas;     /* 135-136  sweep trace length at start in ms */
#         short stae;     /* 137-138  sweep trace length at end in ms */
#         short tatyp;    /* 139-140  taper type: 1=linear, 2=cos^2, 3=other */
#         short afilf;    /* 141-142  alias filter frequency if used */
#         short afils;    /* 143-144  alias filter slope */
#         short nofilf;   /* 145-146  notch filter frequency if used */
#         short nofils;   /* 147-148  notch filter slope */
#         short lcf;      /* 149-150  low cut frequency if used */
#         short hcf;      /* 151-152  high cut frequncy if used */
#         short lcs;      /* 153-154  low cut slope */
#         short hcs;      /* 155-156  high cut slope */
#         short year;     /* 157-158  year data recorded */
#         short day;      /* 159-160  day of year */
#         short hour;     /* 161-162  hour of day (24 hour clock) */
#         short minute;   /* 163-164  minute of hour */
#         short sec;      /* 165-166  second of minute */
#         short timbas;   /* 167-168  time basis code: 1 = local 2 = GMT 3 = other */
#         short trwf;     /* 169-170  trace weighting factor, defined as 1/2^N volts for the least sigificant bit */
#         short grnors;   /* 171-172  geophone group number of roll switch position one */
#         short grnofr;   /* 173-174  geophone group number of trace one within original field record */
#         short grnlof;   /* 175-176  geophone group number of last trace within original field record */
#         short gaps;     /* 177-178  gap size (total number of groups dropped) */
#         short otrav;    /* 179-180  overtravel taper code: 1 = down (or behind) 2 = up (or ahead) */
        
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值