我有从Seg-Y文件创建的输出日志。 示例:
TRACE HEADER====================================================================================================================
MIN MAX MEAN COUNT
Trace sequence number within line [001-004]: 1 140400 70200.50 140400
Trace sequence number within SEGY file [005-008]: 1 140400 70200.50 140400
Original field record number [009-012]: 1001 4900 2950.50 140400
Trace number within original field record [013-016]: 1 36 18.50 140400
Energy source point [017-020]: 1001 4900 2950.50 140400
Not used for NFH [021-024]: 0 0 0.00 140400
Hydrophone number in gun source [025-028]: 1 18 9.50 140400
Trace identification code [029-030]: 1 1 1.00 140400
No of vertically summed traces yielding this trace [031-032]: 1 1 1.00 140400
No of horizontally stacked traces yielding this trace [033-034]: 1 1 1.00 140400
Production1/test2 [035-036]: 1 1 1.00 140400
Distance from COS to centre of receiver group [037-040]: 0 68 22.72 140400
Receiver group depth (scalar #1) [041-044]: 460 580 529.82 140400
Tidal observation to vertical datum (scalar #1) [045-048]: -82 61 3.00 140400
Source depth (scalar #1) [049-052]: 580 650 613.37 140400
Not used [053-056]: 0 0 0.00 140400
Not used [057-060]: 0 0 0.00 140400
Water depth at source (scalar #1) [061-064]: 298955 357609 330298.17 140400
Water depth at receiver group (scalar #1) [065-068]: 298946 357610 330298.17 140400
Scalar #1 (-ve => divisor) [069-070]: -100 -100 -100.00 140400
Scalar #2 (-ve => divisor) [071-072]: -100 -100 -100.00 140400
Source coordinate - X (scalar #2) [073-076]: 53664190 53702900 53682718.56 140400
Source coordinate - Y (scalar #2) [077-080]: 97593580 107341780 102467937.72 140400
Receiver group coordinate - X (scalar #2) [081-084]: 53663450 53703800 53682718.74 140400
Receiver group coordinate - Y (scalar #2) [085-088]: 97592690 107342690 102467936.95 140400
Coordinate units [089-090]: 1 1 1.00 140400
Water velocity (as used in p1 water depth) [091-092]: 1496 1496 1496.00 140400
Not used [093-094]: 0 0 0.00 140400
Skew static correction (Scalar #3). Not used for NFH [095-096]: 0 0 0.00 140400
Water bottom time at CDP/bin centre (Scalar #3) [097-098]: 3997 4781 4415.75 140400
Source static correction (Scalar #3). Not used for NFH [099-100]: 0 0 0.00 140400
Receiver group static corr (Scalar #3). Not used for NFH [101-102]: 0 0 0.00 140400
Total static corr applied (Scalar #3). Not used for NFH [103-104]: 0 0 0.00 140400
Lag time A. Not used for NFH [105-106]: 0 0 0.00 140400
Delay recording time (Scalar #3) [107-108]: -50 -50 -50.00 140400
Original delay recording time. Not used for NFH [109-110]: 0 0 0.00 140400
Mute time - start (Scalar #3). Not used for NFH [111-112]: 0 0 0.00 140400
Mute time - end (Scalar #3). Not used for NFH [113-114]: 0 0 0.00 140400
Number of samples in this trace [115-116]: 22529 22529 22529.00 140400
Sample interval for this trace in microsecs [117-118]: 500 500 500.00 140400
Gain type of field instruments [119-120]: 1 1 1.00 140400
Instrument gain - constant. Not used for NFH [121-122]: 0 0 0.00 140400
Instrument early/initial gain. Not used for NFH [123-124]: 0 0 0.00 140400
Streamer section serial number. Not used for NFH [125-128]: 0 0 0.00 140400
Continuous recording shot timer. Not used for NFH [129-132]: 0 0 0.00 140400
Value obs jitter in aux chan timing. Not used for NFH [133-134]: 0 0 0.00 140400
Not used [135-136]: 0 0 0.00 140400
Not used [137-138]: 0 0 0.00 140400
Not used [139-140]: 0 0 0.00 140400
Anti-alias filter frequency [141-142]: 800 800 800.00 140400
Anti-alias filter slope [143-144]: 240 240 240.00 140400
Not used [145-146]: 0 0 0.00 140400
Bandpass filter type [147-148]: 0 0 0.00 140400
Low cut filter frequency [149-150]: 3 3 3.00 140400
High cut frequency [151-152]: 800 800 800.00 140400
Low cut filter slope [153-154]: 6 6 6.00 140400
High cut filter slope [155-156]: 240 240 240.00 140400
Year data recorded [157-158]: 2017 2017 2017.00 140400
Day of year data recorded [159-160]: 134 135 134.09 140400
Hour of day data recorded [161-162]: 0 23 17.44 140400
Minute of hour data recorded [163-164]: 0 59 29.70 140400
Second of minute data recorded [165-166]: 0 59 29.58 140400
Time basis code [167-168]: 4 4 4.00 140400
Not used [169-170]: 0 0 0.00 140400
This file elevation datum [171-172]: 2 2 2.00 140400
Final survey elevation datum. Not used for NFH [173-174]: 0 0 0.00 140400
Start time of data ms. Not used for NFH [175-176]: 0 0 0.00 140400
End time of data ms. Not used for NFH [177-178]: 0 0 0.00 140400
Scalar #3 (-ve => divisor). Not used for NFH [179-180]: 0 0 0.00 140400
Gun string id number [181-182]: 1 6 3.50 140400
Sailed line sequence number [183-184]: 101 101 101.00 140400
Gun mask [185-186]: 1 2 1.50 140400
Original gun mask [187-188]: 7 56 31.50 140400
Numerical sail line number [189-192]: 4300 4300 4300.00 140400
Receiver cable depth [193-196]: 460 580 529.82 140400
Shot point number [197-200]: 1001 4900 2950.50 140400
Calibration scalar [201-202]: 643 2808 2000.00 140400
Trace value measurement [203-204]: 3 3 3.00 140400
3D inline number [205-208]: 4298 4314 4305.40 140400
3D crossline number [209-212]: 10009 25608 17808.88 140400
Ensemble coordinate - X [213-216]: 53663820 53703350 53682718.65 140400
Ensemble coordinate - Y [217-220]: 97593135 107342235 102467937.34 140400
Gun boat identifier. Not sued for NFH [221-222]: 0 0 0.00 140400
Streamer boat identifier. Not used NFH [223-224]: 0 0 0.00 140400
Waterbottom time at CDP/bin centre ms [225-228]: 3997 4781 4415.75 140400
Source-receiver azimuth [229-230]: 0 359 172.57 140400
这些日志有很多,因为每个Seg-Y文件都会创建一个日志。 我已经创建了一个shell脚本,它从这些日志中提取信息并以列方式打印出来。
见以下链接:
该脚本主要使用grep和awk。
我打算做的是在tcl中编写相同的脚本,这样我就可以在Tk上使用GUI,并使用数组或列表以某种方式使用拆分实现相同的功能,但我是Tcl的新手并且无法获得我正在从日志中正确提取信息,我已经在构建前端GUI,只是想让tcl脚本排序,以便我可以开始用GUI绑定它。
我想从EBCDIC Header部分提取linename,RANGE,FILE等 线路NUmber,Reel NUmber等来自BInary标题部分 以及Trace Header Part的所有MIN-MAX
在我的报告中,我希望列名与行名相同。
感谢您的帮助。
答案 0 :(得分:0)
有很多方法可以做到这一点。也许最简单的就是使用
exec <yourexistingscript>
你知道你的脚本会把正确的东西拉出来,只要让Tcl运行它。
否则,这是我从头开始编写文件解析代码的基本框架:
set fh [open "file.dat", "r"]
while {[gets $fh line] >= 0} {
if {<line matches pattern 1>} {
}
if {<line matches pattern 2>} {
}
}
close $fh
等,其中<line matches pattern N>
部分是[string match...]
或[regexp ...]
行,具体取决于具体情况。这基本上就是awk
的工作原理。一个基于行的东西,上面有匹配和代码。
这些匹配中的代码也会根据情况而有所不同,但是典型的块使用[split]
来区分某些分隔符。看起来空间可能在这里工作,但我还没有仔细阅读你的文件。