Skip to content

Commit

Permalink
[feat](Parameters test): Add multi thread convergence surface
Browse files Browse the repository at this point in the history
Add a multi thread convergence surface test to show how semblance varies
with number of threads and iterations
  • Loading branch information
Dirack committed Feb 9, 2024
1 parent a14aeb3 commit bad0528
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_parameters/mt_fixed_temp0_c0/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
all: generate_data generate_plot view

generate_data: SConstruct
scons

generate_plot: plot_test.py
python plot_test.py > surface.asc

view: SConscript
scons -f $< view
26 changes: 26 additions & 0 deletions test/test_parameters/mt_fixed_temp0_c0/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# SConstruct (Madagascar Script)
#
# Purpose: Parameters test of VFSA process.
#
# Site: https://dirack.github.io
#
# Version 1.0
#
# Programer: Rodolfo A. C. Neves (Dirack) 10/11/2020
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

# Madagascar library
from rsf.proj import *

s="surface"
Flow(s,s+'.asc','dd type=float form=native | smooth rect1=5 rect2=5 repeat=2')

Result(s,'grey color=j scalebar=y title=Semblance')

End()
85 changes: 85 additions & 0 deletions test/test_parameters/mt_fixed_temp0_c0/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# SConstruct (Madagascar Script)
#
# Purpose: Parameters test of VFSA process.
#
# Site: https://dirack.github.io
#
# Version 1.0
#
# Programer: Rodolfo A. C. Neves (Dirack) 10/11/2020
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

# Madagascar library
from rsf.proj import *

# Python math library
import math

# Modeling: Gaussian reflector in a velocity linear model
# velocity increases with depth and a 0.5 velocity gradient
Flow('gaussianReflector',None,
'''
math d1=0.01 n1=2001 o1=-5 unit1=km label1=Offset
output="4-3*exp(-(x1-5)^2/9)"
''')

# Velocity Model
Flow('velocityModel','gaussianReflector',
'''
window min1=0 max1=10 |
spray axis=1 n=451 d=0.01 o=0 label=Depth unit=km |
math output="1.5+0.5*x1+0.0*x2"
''')

Flow('reflectorDip','gaussianReflector','math output="2/3*(x1-5)*input" ')

# Kirchoff Modeling
Flow('dataCube','gaussianReflector reflectorDip',
'''
kirmod cmp=y dip=${SOURCES[1]}
nh=161 dh=0.025 h0=0
ns=401 ds=0.025 s0=0
freq=10 dt=0.004 nt=1001
vel=1.5 gradz=0.5 gradx=0.0 verb=y |
put d2=0.0125 label3="CMP" unit3="Km" label2="Offset" unit2="Km" label1=Time unit1=s
''')


orep=0
drep=1
nrep=10

ont=0.
dnt=1
nnt=200

om0=5
dm0=0.1
nm0=1
ot0=1.1
dt0=0.1
nt0=1
v0=1.5

for nti in range(nnt):
for nrepi in range(nrep):

repeat = orep+drep*nrepi
nt = ont+dnt*nti

parameters='crsParameters_rep_%d_nt_%d' % (nrepi,nti)
# Very Fast Simulated Aneelling Global Optimization (VFSA)
Flow(parameters,'dataCube',
'''
vfsacrsnh om0=%g dm0=%g nm0=%d ot0=%g dt0=%g nt0=%d v0=%g verb=y repeat=%d
half=y
c0=0.4 temp0=2.5 itmax=%d
''' % (om0,dm0,nm0,ot0,dt0,nt0,v0,repeat,math.floor(nt)))

End()
42 changes: 42 additions & 0 deletions test/test_parameters/mt_fixed_temp0_c0/plot_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import subprocess

orep=0
drep=1
nrep=10

ont=0
dnt=1
nnt=200

om0=5
dm0=0.1
nm0=1
ot0=1.1
dt0=0.1
nt0=1
v0=1.5

lc0=[]
lnt=[]
lrn=[]
lrnip=[]
lbeta=[]
lsemb=[]

for nti in range(nnt):


nt = ont+dnt*nti
for nrepi in range(nrep):

repeat = orep+drep*nrepi

fileinput = 'crsParameters_rep_%d_nt_%d.rsf' % (nrepi,nti)
result = subprocess.check_output(['sfdisfil <'+fileinput+' number=n format="%f "'], shell=True)
lista = result.split()
lc0.append(float(lista[0]))
lnt.append(float(lista[1]))
lsemb.append(float(lista[3]))
print(float(lista[3]))

print("n1=%d d1=%g o1=%g label1=Threads n2=%d d2=%g o2=%g label2=Iterations data_format=ascii_float in=surface.asc" % (nrep,drep,orep,nnt,dnt,ont))

0 comments on commit bad0528

Please sign in to comment.