h1

Springnote

November 25, 2008

책 구절을 메모해 놓은 노트가 달인노트로 뽑혔다.

달인노트

달인노트

h1

gpl backup

November 18, 2008

Gpl Backup Manager (gplbackup)

self document
Gpl Backup Manager
    : backup files matching extensions recursively

Usage :
    gplbackup [cfg filename]

Optional parameters :
    cfg filename     : configuration file(yaml file) name
    --cfg > gplbackup.yml
       : generate sample 'gplbackup.yml' file

Configuration file
    see sample 'gplbackup.yml' file. (use --cfg option)

Gpl backup manager는 현재 디렉토리 하위의 디렉토리를 돌아다니며 원하는 확장자의 파일들을 backup해주는 프로그램입니다. 백업할 때에는 (현재 디렉토리에서 상대적인) 디렉토리 구조를 그대로 만들어주며 백업을 합니다. Backup 하고자 하는 디렉토리와 파일 설정은 yml 파일을 이용하여 해줍니다. 예제 yml 파일은
gplbackup --cfg > gplbackup.yml
과 같이 생성할 수 있습니다. 이렇게 생기는 yml 파일은 아래와 같습니다. 파일은 YAML 문법을 따르는데, 간단하기 때문에 YAML 문법을 몰라도 아래 파일을 수정하여 사용할 수 있습니다.

Sample yml file

# Gpl Backup Manager Configuration File
# Date : 2008.02.21
# Source directories you want to backup
sourceDirectory :
- Documents
- lib

# Extensions of files you want to backup
extensions :
- .f
- .f90
- .c
- .rb
- .sh
- Makefile
- .tex

# A directory name to which the backup files will be copied
targetDirectory : hostname

# Print the copying process (T/F)
verbose : T

# Make "hostnameBak-2008.02.21.tgz" file
# using the targetDirectory (T/F)
makeTarBall : T

# Remove the targetDirectory after backup (T/F)
# - when you want tgz file only
removeBackupDir : F

# Files containing these words in their absolute path
# will be omitted
exclude :
- 'backup'
- 'lib/dms'
- 'lib/UMFPACK'
- 'lib/SU'
- 'lib/seplib'
- '.svn'

예제의 yml 파일에서 #으로 시작하는 부분은 comment입니다.
sourceDirectory :
아래에 ‘-’을 긋고 backup하고자 하는 디렉토리 이름을 적습니다. Backup은 하위 디렉토리까지 recursive하게 합니다. ‘- .’과 같이 적으면 현재 디렉토리와  하위 디렉토리의 모든 파일들을 대상으로 backup합니다. 이 때 모든 파일들을 다 backup하는 것이 아니라
extensions :
에 해당하는 파일들만 backup합니다. 꼭 확장자가 아니라도
- Makefile
과 같이 파일 이름의 끝부분이 같으면 backup합니다. Backup할 때에는 현재 디렉토리 아래에
targetDirectory :
에 지정된 디렉토리를 만들고, 그 아래 파일이 들어있는 디렉토리를 만들어 backup합니다. targetDirectory 이름은 현재 hostname을 기준으로 만듭니다.
verbose :
makeTarBall :
removeBackupDir :

은 T, F로 표시하고 backup 과정을 화면으로 보여줄지, 디렉토리를 만들어 backup한 후 디렉토리를 tgz 파일로 압축할 것인지, 압축 후 backup 디렉토리를 지울 것인지 지정해줍니다. 압축 파일명은 기본적으로 targetDirectory 이름에 현재 날짜를 더해서 만들어줍니다. 같은 이름의 파일이 존재할 경우 뒤에 숫자를 붙여 새로 만들 파일의 이름을 변경해줍니다.

Backup할 때에는 ‘extensions :’에 맞더라도 절대경로에 ‘exclude :’의 내용이 들어가 있는 파일은 제외합니다.

Learning by doing

실행 예를 볼까요? 현재 디렉토리 아래에 gplbackup.yml 파일과 test1, test2, test3 세 개의 디렉토리가 있고, 각각의 디렉토리에는 다음과 같은 파일들이 있습니다.

$ ls -R
.:
gplbackup.yml  test1  test2  test3

./test1:
file1  file2  file2.f90

./test2:
file2.f  file2.f90  file3.f90

./test3:
file1.f90  file2.c

gplbackup.yml 파일의 내용은 다음과 같습니다.

$ cat gplbackup.yml
# Gpl Backup Manager Configuration File
# Date : 2008.11.18
# Source directories you want to backup
sourceDirectory :
- .

# Extensions of files you want to backup
extensions :
- .f90

# A directory name to which the backup files will be copied
targetDirectory : node480Bak

# Print the copying process (T/F)
verbose : T

# Make "node480Bak-2008.11.18.tgz" file
# using the targetDirectory (T/F)
makeTarBall : T

# Remove the targetDirectory after backup (T/F)
# - when you want tgz file only
removeBackupDir : F

# Files containing these words in their absolute path
# will be omitted
exclude :
- 'test3'

현재 디렉토리 아래의 모든 디렉토리를 돌며 backup하는데 .f90 파일만 backup하고, 경로에 ‘test3′이라는 문자열이 들어간 파일은 제외합니다. 실행 결과는 다음과 같습니다.


$ gplbackup gplbackup.yml
in .
cp  ./test2/file2.f90     node480Bak/./test2
cp  ./test2/file3.f90     node480Bak/./test2
cp  ./test1/file2.f90     node480Bak/./test1
3 files are backed up

making tgz ball : node480Bak/
node480Bak/test2/
node480Bak/test2/file2.f90
node480Bak/test2/file3.f90
node480Bak/test1/
node480Bak/test1/file2.f90

node480Bak-20081118.tgz : 207 bytes

현재 디렉토리 밑에 ‘node480Bak’ 라는 디렉토리를 만들고(hostname이 ‘node480′입니다) 그 아래에 디렉토리 구조를 유지하며 .f90 파일들을 backup합니다. yml 파일에서 verbose: T 라고 했기 때문에 backup 과정을 화면으로 출력해주고, makeTarBall: T 라고 했기 때문에 backup 디렉토리를 압축하여 node480Bak-20081118.tgz 파일을 만들어줍니다. 또한, 압축 파일의 크기도 보여줍니다.

이 프로그램은 ruby 프로그래밍 언어로 만들었기 때문에 실행하기 위해서는 ruby(version 1.8 이상)가 필요합니다. 개인적으로 상당히 유용하게 쓰고 있는데, 필요하신 분은 여기에서 받아 쓰세요~^^

이 글은 스프링노트에서 작성되었습니다.

h1

gpl muting utils

November 6, 2008

Gpl Mute Interpolator(gplMuteintp)

self document

Gpl Mute Interpolator : read polyg.#### files
     and interpolate missing numbers
Usage :
    gplMuteintp.rb first=[] last=[] step=[]
Required parameters :
    first    : shot number of the first shotgather
    last    : shot number of the last shotgather
Optional parameter :
    step=last-first    : shot step

Examples

예를 들어, shotgather가 1200번부터 1300번까지 있는데 1200번, 1204번, 1208번, … , 1300번까지 4개씩 건너 뛰며 xmute script로 Muting을 했다고 합시다.

(이 때 한 shotgather 내에서 muting은 왼쪽에서 오른쪽으로 진행하는 것이 좋습니다.)

그럼 polyg.1200, polyg.1204, polyg.1208, … , polyg.1300 번까지 polygon 파일들이 생성되었겠죠. 이 파일들이 이 프로그램의 input이 됩니다.

이 프로그램은 앞에서 muting해놓은 polyg.#### 파일들을 interpolation하여 중간중간 비어있는 polyg.1201, polyg.1202, polyg.1203, polyg.1205, …, polyg.1299 파일들(output)을 생성해내는 프로그램입니다. 이 때의 실행 명령은
gplMuteintp.rb first=1200 last=1300 step=4
가 됩니다. 1200번부터 시작하여 4씩 더해가며 이미 존재하는 polyg.#### 파일들로 비어있는 polyg.#### 파일들을 생성해냅니다.

1200번과 1204번을 이용하여 1201~1203번을 interpolation하고,

1204번과 1208번을 이용하여 1205~1207번을 interpolation합니다.

만약 step을 써주지 않으면 first와 last 사이에 있는 모든 파일들을 다 interpolation하여 생성합니다.

Garbage in, garbage out 이라고, 좋은 결과를 얻기 위해서는 muting한 결과가 좋음을 확인하고 써야합니다.

step간격은 자료에 따라 다릅니다. shotgather 모양에 거의 변화가 없는 경우 step을 크게 둘 수 있고, 모양이 불규칙한 경우에는 step을 작게 하거나 전체를 다 직접 muting해야겠죠.

Gpl Muter(gplMute)

self document

Gpl Muter : mute shotgathers using polyg.#### files
Usage :
    gplMute.rb first=[] last=[] step=[] [optional parameters]
Required parameters :
    first   : shot number of the first shotgather
    last    : shot number of the last shotgather
Optional parameters
    -i              : include all
        if not given, skip [first,last,step]
    step=last-first : shot step
        # skip shotgathers matching [do first,last,step]
    fout=muteshot   : output muted file name
    perc=85         : suximage percent
    hbox=1000       : suximage hbox
    wbox=1270       : suximage wbox
    x1end           : suximage x1end
    d2=1            : suximage d2
    fin             : su file name containing the shot gathers

Examples

이 프로그램은 앞에서 interpolation해 놓은 파일들을 가지고 실제 muting을 하여 잘 되었는지 확인하는 프로그램입니다.

shot을 포함한 su 파일은 shot 번호를 기준으로 shots####_####.su 파일들 중에서 자동으로 찾습니다.
gplMute.rb first=1200 last=1300 step=4 x1end=4.5
와 같이 실행을 하면 1200번, 1204번, 1208번, … , 1300번은 건너뛰고(앞에서 이미 확인했으니까요, -i 옵션을 주면 다 포함합니다), 1201번, 1202번, 1203번, 1205번, … , 1299번까지 interpolation한 polyg.#### 파일들을 이용하여 muting한 결과를 보여줍니다. 결과를 보여준 후에는 확인을 합니다.
ok? [ (y)es or enter | (r)eplace | (n)ot good | (q)uit ]
라고 메시지가 나오는데,

muting이 잘 되었을 경우에는 y 또는 그냥 enter를 치면 다음 shot으로 넘어갑니다.

muting 결과가 매우 마음에 들지 않을 때에는 n 을 입력하여 해당 shot을 다시 muting하고 확인하는 과정을 반복합니다.

일부분만 수정하면 될 경우(대부분의 경우) r 을 입력합니다. 이 경우 아래와 같이 muting 되지 않은 shotgather와 polyg.#### curve를 함께 보여줍니다.

mutereplace1.png
이 그림에서 수정하고 싶은 부분에 mouse를 찍고 저장하면 해당 위치에 있던 이전 데이터가 새로 muting한 데이터로 바뀌게 됩니다. 새로운 muting 결과를 보여주면 위의 확인과정을 반복합니다.

Gpl Mute Checker(gplMutecheck)

Self Document

Gpl Mute Checker : check & modify muted shotgathers
Usage :
    gplMutecheck.rb first=[] last=[] [optional parameters]
Required parameters :
    first   : shot number of the first shotgather
    last    : shot number of the last shotgather
Optional parameters
    step=1          : shot step [do first,last,step]
    fout=muteshot   : output muted file name
    perc=85         : suximage percent
    hbox=1000       : suximage hbox
    wbox=1270       : suximage wbox
    x1end           : suximage x1end
    d2=1            : suximage d2
    fin             : su file name
                      containing the shot gathers

이 프로그램은 앞의 gplMute와 거의 같은데 [do first,last,step]에 해당하는 번호의 shotgather만 muting합니다. 처음에 몇 개씩 건너뛰며 muting했던 자료를 확인하기 위해 사용할 수 있겠죠. polygon file이 없을 경우 처음부터 muting을 합니다. 따라서 xmute.sh 스크립트 대신 사용할 수도 있겠죠. 하나의 shot에서 작업하는 동안 다음번 shot 을 suwind로 미리 만들어 놓기 때문에 suwind로 인한 속도 지체 현상이 많이 감소하였습니다. 그럼 su 파일을 쪼갤 필요가 없겠죠?

(실행 파일들은 muting하는 server에 있습니다~^^)

이 글은 스프링노트에서 작성되었습니다.