0
点赞
收藏
分享

微信扫一扫

I-Nodal节点仪专用sps分拆

英乐 2022-02-07 阅读 31
pythonsps

I-Nodal节点仪切割数据时,只能先切割线,再由线合并成炮,而施工sps均为完整sps,即一炮由多条测线构成,切割节点仪数据时,需要对sps数据进行按线拆分,为便于施工,写了本次小脚本。

import pandas as pd
import sys
import time
time_start = time.time()
########################输入输出sps文件都是sps2.1格式,sps软件8.0版本#############################
###################读取原始sps信息,即全sps文件,输出sps2.1格式sps软件8.0版本######################
filename  = 'PHSPS_1122(1-26817)节点'  ####SPS文件名
rline_need = 12222  ####选定测线
filepalce=r'E:/prc/python/节点/'
print('读取 '+filename+' sps文件......')
data = []
for line in open(filepalce+filename + '.X', 'r'):
    data.append(line)
############计算头卡行数########
i = 0
while data[i][0] == 'H':
    i = i + 1
ii = i  ##计算头卡行数
###########读取关系文件获得文件号与桩号对应关系####
v = data[ii:]
xlenth = len(v)
del data
datalor=[]
for i in range(0, xlenth):
        if int(v[i][49:54])==rline_need:  ##筛选需要的检波线
            datalor.append([int(v[i][10:15]),int(float(v[i][17:24])),int(v[i][28:34]),\
                            int(v[i][38:43]),int(v[i][43:48]),\
                            int(v[i][49:54]),int(v[i][62:66]),int(v[i][72:76])])
print('分选 '+str(rline_need)+' sps文件......')
pddataor2=pd.DataFrame(datalor)
######################删除变量,减少内存开销#############################
del v,datalor
##################检查测线的正确性#######################################
if len(pddataor2)==0:
    print('无 '+str(rline_need)+' 测线号,请输入正确测线号。')
    sys.exit(1)
############################################################################
pddataor2.columns=['ffid','shotline','shotpoint','chanfrom','chanto','rline','rpointfrom','rpointto']
pddataor2['tt']=1
pddatal4=pddataor2.values.tolist()
del pddataor2
print('写入 '+str(rline_need)+' sps中...')
f=open(filepalce+str(rline_need)+'线汇总版.X','w+')       # 要更改文件名
f.write('H00 SPS format version num.     SPS2.1;                                         '+"\n")
f.write('H01 Description of survey area  cd2,,N/A,N/A;                                   '+"\n")
f.write('H02 Date of survey              ;                                               '+"\n")
f.write('H021Post-plot date of issue     ;                                               '+"\n")
f.write('H022Tape/disk identifier        DISK;                                           '+"\n")
f.write('H03 Client                      N/A;                                            '+"\n")
f.write('H04 Geophysical contractor      N/A;                                            '+"\n")
f.write('H05 Positioning contractor      N/A;                                            '+"\n")
f.write('H06 Pos. proc. contractor       N/A;                                            '+"\n")
f.write('H07 Field computer system(s)    428XL;                                          '+"\n")
f.write('H08 Coordinate location         Center of source and of receiver pattern;       '+"\n")
f.write('H09 Offset from coord. location 0.0M,0.0DEG;                                    '+"\n")
f.write('H10 Clock time w.r.t. GMT       ;                                               '+"\n")
f.write('H11 Spare                       ;                                               '+"\n")
f.write('H12 Geodetic datum,-spheroid    ;                                               '+"\n")
f.write('H13 Spare                       ;                                               '+"\n")
f.write('H14 Geodetic datum parameters   ;                                               '+"\n")
f.write('H15 Spare                       ;                                               '+"\n")
f.write('H16 Spare                       ;                                               '+"\n")
f.write('H17 Vertical datum description  ;                                               '+"\n")
f.write('H18 Projection type             UTM;                                            '+"\n")
f.write('H19 Projection zone             ;                                               '+"\n")
f.write('H20 Description of grid units   Metres;                                         '+"\n")
f.write('H201Factor to metre                 1.00000000;                                 '+"\n")
f.write('H220Long. of central meridian   ;                                               '+"\n")
f.write('H231Grid origin                 ;                                               '+"\n")
f.write('H232Grid coord. at origin       ;                                               '+"\n")
f.write('H241Scale factor                ;                                               '+"\n")
f.write('H242Lat., long. scale factor    ;                                               '+"\n")
f.write('H256Lat., long. initial line    ;                                               '+"\n")
f.write('H257Circular bearing of H256    ;                                               '+"\n")
f.write('H258Quadrant bearing of H256    ;                                               '+"\n")
f.write('H259Angle from skew             ;                                               '+"\n")
f.write('H300Project code and description;                                               '+"\n")
f.write('H310Line number format          ;                                               '+"\n")
f.write('H400Type,Model,Polarity         ;                                               '+"\n")
f.write('H401Crew name,Comment           ;                                               '+"\n")
f.write('H402Sample int.,Record Len.     1,0.000000,N/A;                                 '+"\n") 
f.write('H403Number of channels          1,5376;                                         '+"\n")
f.write('H404Tape type,format,density    ;                                               '+"\n")
f.write('H405Filter_alias Hz,dB pnt,slope;                                               '+"\n")
f.write('H406Filter_notch Hz,-3dB points ;                                               '+"\n")
f.write('H407Filter_low Hz,dB pnt,slope  ;                                               '+"\n")
f.write('H408Time delay FTB-SOD app Y/N  ;                                               '+"\n")
f.write('H409Multi component recording   ;                                               '+"\n")
f.write('H410Aux. channel 1 contents     ;                                               '+"\n")
f.write('H411Aux. channel 2 contents     ;                                               '+"\n")
f.write('H412Aux. channel 3 contents     ;                                               '+"\n")
f.write('H413Aux. channel 4 contents     ;                                               '+"\n")
f.write('H414Spare                       ;                                               '+"\n")
f.write('H415Spare                       ;                                               '+"\n")
f.write('H416Spare                       ;                                               '+"\n")
f.write('H417Spare                       ;                                               '+"\n")
f.write('H418Spare                       ;                                               '+"\n")
f.write('H419Spare                       ;                                               '+"\n")
f.write('H600Type,model,polarity         G1,geophone 1;                                  '+"\n")
f.write('H601Damp coeff,natural freq.    ;                                               '+"\n")
f.write('H602Nunits,len(X),width(Y)      ;                                               '+"\n")
f.write('H603Unit spacing X,Y            ;                                               '+"\n")
f.write('H604Spare                       ;                                               '+"\n")
f.write('H605Spare                       ;                                               '+"\n")
f.write('H606Spare                       ;                                               '+"\n")
f.write('H607Spare                       ;                                               '+"\n")
f.write('H608Spare                       ;                                               '+"\n")
f.write('H700Type,model,polarity         E1,explosive 1;                                 '+"\n")
f.write('H701Size,vert. stk fold         ;                                               '+"\n")
f.write('H702Nunits,len(X),width(Y)      ;                                               '+"\n") 
f.write('H703Unit spacing X,Y            ;                                               '+"\n")
f.write('H711Nom. shot depth,charge len. ;                                               '+"\n")
f.write('H712Nom. soil,drill method      ;                                               '+"\n")
f.write('H713Weathering thickness        ;                                               '+"\n")
f.write('H26      1         2         3         4         5         6         7         8'+"\n")
for i in range(len(pddatal4)):
    ffid = int(pddatal4[i][0])
    shotline = int(pddatal4[i][1])
    shotpoint = int(pddatal4[i][2])
    chanfrom = int(pddatal4[i][3])
    chanto = int(pddatal4[i][4])
    rline = int(pddatal4[i][5])
    rpointfrom = int(pddatal4[i][6])
    rpointto = int(pddatal4[i][7])
    tt=int(pddatal4[i][8])
    print('X1 ','     %6d%d%d%-6d       %-6d %d%5d%5d%d%5d        %-4d      %-4d   %d'\
          %(ffid,tt,tt,shotline,shotpoint,tt,chanfrom,chanto,tt,rline,rpointfrom,rpointto,tt),file=f)
f.close()
print("SPS写入成功!")
time_end=time.time()
timecost = str(round(time_end-time_start,4))
print('耗时 '+timecost+' S')
举报

相关推荐

0 条评论