2017-06-20 163 views
0

我有從Seg-Y文件創建的輸出日誌。 實施例:tcl腳本從多個具有相同格式的文本文件中提取值並生成基於列的報告

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腳本,它從這些日誌中提取信息並以列的形式打印出來。

見下面的鏈接:

http://textuploader.com/d0z0u

腳本使用的grep和awk爲主。

我打算做的是在tcl中編寫相同的腳本,這樣我就可以在Tk上創建一個GUI,並使用數組或列表以某種方式實現相同的功能使用split,但我是Tcl的新手,無法獲取我的頭部正確地從日誌中提取信息,我已經在構建前端GUI,只是想要將tcl腳本排序,以便我可以開始使用GUI進行綁定。

我想從EBCDIC頭部分 行號,卷號從二進制頭部分 和等提取linename,範圍,文件等等等等所有的MIN-MAX從跟蹤頭部分

我在報告希望列名與行名相同。

感謝您的幫助。

+0

這有點不清楚,你的問題究竟是什麼,即你究竟想知道什麼。請具體。 – user1934428

回答

0

有很多方法可以做到這一點。也許最簡單的是隻使用

exec <yourexistingscript>

你知道你的腳本拉正確的東西了,只是還Tcl的運行。

否則,下面是我如何寫在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]以某些分隔符分隔線條。它看起來像一個空間可能在這裏工作,但我沒有細讀你的文件。

相關問題