Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue/37 test cre stack in multi layer model #42

Merged
merged 27 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
17cd7de
Abstract modeling steps in the creStack.py recipe
Dirack May 13, 2020
fb34a61
Abstract the multi layer modeling step
Dirack May 13, 2020
2a302c1
Use only multi layer model in this experiment
Dirack May 14, 2020
cc371da
Ignore asc files
Dirack May 26, 2020
2da772d
Configure parameters of the multi layer experiment #37
Dirack May 26, 2020
28de03d
Separate input generation from cre stacking #37
Dirack May 27, 2020
b15de79
Use an aperture parameter in sfgetcregather #38
Dirack May 27, 2020
2ad36b7
Correct bug in aperture definition #38
Dirack May 27, 2020
67b934c
Stablish recipes as new dependecy madagascarRecipe #38
Dirack May 27, 2020
b33aa7b
Merge branch 'hotfix/issue/38' of github.com:Dirack/creGatherInterpol…
Dirack May 27, 2020
ebdd6e6
Correct SConscript parameters Resolve #38
Dirack May 28, 2020
dedf56a
Merge pull request #40 from Dirack/hotfix/issue/38
Dirack May 28, 2020
d7063ba
Multi layer experiment using CDS condition #37
Dirack May 28, 2020
ed9043d
Correct bug referenced in issue #39
Dirack May 28, 2020
529896e
Update velocity analisys recipe #37
Dirack May 30, 2020
9ae1632
Merge branch 'feature/issue/37' of github.com:Dirack/creGatherStack i…
Dirack May 30, 2020
a3b63f7
Test to obtain full stacked section #37
Dirack May 30, 2020
a42d88d
Error report function to madagascarRecipes #37
Dirack Jun 1, 2020
7bd7483
Add error report function to SConstruct #37
Dirack Jun 1, 2020
f30e2e0
Put zero samples if trace is outside the model #38
Dirack Jun 1, 2020
4dd77c4
Bug Report information to hotfix #38
Dirack Jun 1, 2020
72ed7c1
Put zeroed traces in the CRE gather when out of bounds Resolve #38
Dirack Jun 1, 2020
e410469
Merge pull request #41 from Dirack/hotfix/issue/38
Dirack Jun 1, 2020
7f56418
Add error report function to SConstructs Resolve #37
Dirack Jun 1, 2020
73b00a9
Change number of CMPs of the experiment #38
Dirack Jun 3, 2020
3f6b469
Merge branch 'hotfix/issue/38' into feature/issue/37
Dirack Jun 3, 2020
8d882d2
Split CRE gather traces concatenation in a SConscript #37
Dirack Jun 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ backup/
checkpoints
*.jp2
.ipynb_checkpoints/

*.asc
23 changes: 17 additions & 6 deletions Mgetcregather.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ int main(int argc, char* argv[])
float ot; // Time axis origin
int nt; // Number of time samples
int i,j; // loop counter
int cre_n; // Number of CRE Gather traces
int cre_n; // Number of traces in CRE vector
float cre_d; // CRE Gather sampling
float cre_o; // CRE Gather axis origin
int trac_m; // CMP sample index
int aperture; // Number of traces in CRE Gather
float mMax; // maximum CMP coordinate of the model

/* RSF files I/O */
sf_file in, out, out_m, cremh;
Expand Down Expand Up @@ -64,6 +66,13 @@ int main(int argc, char* argv[])
if(!sf_histfloat(cremh,"d1",&cre_d)) sf_error("No d1= in cremh file");
if(!sf_histfloat(cremh,"o1",&cre_o)) sf_error("No o1= in cremh file");

if(!sf_getint("aperture",&aperture)) aperture=1;
/* Number of traces in a CRE Gather*/

if(aperture > cre_n){
sf_error("The aperture can't be > n1 in cremh file\naperture=%i n2=%i",aperture,cre_n);
}

if(! sf_getbool("verb",&verb)) verb=0;
/* 1: active mode; 0: quiet mode */

Expand All @@ -84,26 +93,28 @@ int main(int argc, char* argv[])

m = sf_floatalloc(cre_n);
sf_floatread(m,cre_n,cremh);
creGather = sf_floatalloc2(nt,cre_n);
creGather = sf_floatalloc2(nt,aperture);

mMax = om+dm*nm;

for(i=0;i<cre_n;i++){
for(i=0;i<aperture;i++){
trac_m = (int)((double)m[i]/dm);

for(j=0;j<nt;j++){
creGather[i][j] = t[trac_m][i][j];
creGather[i][j] = (m[i] <= mMax)? t[trac_m][i][j] : 0.;
}
}

/* eixo = sf_maxa(n,o,d)*/
ax = sf_maxa(nt, ot, dt);
ay = sf_maxa(nh, oh, dh);
ay = sf_maxa(aperture, oh, dh);
az = sf_maxa(1, 0, 1);

/* sf_oaxa(arquivo, eixo, índice do eixo) */
sf_oaxa(out,ax,1);
sf_oaxa(out,ay,2);
sf_oaxa(out,az,3);
sf_floatwrite(creGather[0],cre_n*nt,out);
sf_floatwrite(creGather[0],aperture*nt,out);

/* eixo do vetor m */
am = sf_maxa(cre_n,oh,dh);
Expand Down
84 changes: 84 additions & 0 deletions experiments/multiLayerModel/cds/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# SConscript (Madagascar Script)
#
# Purpose: Generate model and data cubes to CRE stacking process.
# This script generates model, original and PEF interpolated data cubes.
# It depends of the 'creStack.py' script that defines functions.
#
# Site: http://www.dirackslounge.online
#
# Version 1.0
#
# Programer: Rodolfo A. C. Neves (Dirack) 04/03/2020
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

# Madagascar package
from rsf.proj import *

# CRE recipe
from madagascarRecipes.pefInterpolation import pefInterpolation as pefin
from madagascarRecipes.kimodel import multiLayerModel as mlmod
from madagascarRecipes.kimodel import kirchoffNewtonModeling as kinewmod

xmax = 6.0
zmax = 2.0

layers = ((0.30,0.50,0.20,0.30),
(1.65,1.85,1.55,1.65))

velocities = (1.508,
1.690,
2.0)

# Generate multi layer model and data cube
mlmod(interfaces='interfaces',
dipsfile='interfacesDip',
modelfile='mod1',
xmax=xmax,
zmax=zmax,
layers=layers,
velocities=velocities)

kinewmod(reflectors='interfaces',
reflectorsDip='interfacesDip',
filename='multiLayerDataCube',
velocities=velocities)

# PEF interpolation of the data cube
a1=10
a2=2
rect1=50
rect2=2

pefin(dataCube='multiLayerDataCube',
interpolated='interpolatedDataCube',
nm=201,
dm=0.025,
nt=1001,
dt=0.004,
nhi=161,
a1=a1,
a2=a2,
rect1=rect1,
rect2=rect2)

# Do the PEF interpolation one more time
# to increase the CMP sampling
pefin('interpolatedDataCube',
'interpolatedDataCube2',
nm=402,
dm=0.0125,
nt=1001,
dt=0.004,
nhi=161,
a1=a1,
a2=a2,
rect1=rect1,
rect2=rect2)

End()
61 changes: 61 additions & 0 deletions experiments/multiLayerModel/cds/SConscript2
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# SConscript (Madagascar Script)
#
# Purpose: Contatenate CRE stacked traces.
#
# Site: http://www.dirackslounge.online
#
# Version 1.0
#
# Programer: Rodolfo A. C. Neves (Dirack) 04/03/2020
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

# Madagascar package
from rsf.proj import *

# Error report function
import atexit
from madagascarRecipes.errorReport import print_build_failures

import glob

# Build the cre stacked section
# throughout cre stacked traces sorting
files = glob.glob('creStackedTrace-*.rsf')
length = len(files)

sortedFiles = []
for i in range(length):
string = 'creStackedTrace-m0-%i.rsf' % i
sortedFiles.append(string)

Flow('stackedSection',sortedFiles,
'''
rcat axis=2 ${SOURCES[1:%d]} --out=stdout
''' % len(files))

Result('stackedSection','grey title="Stacked Section"')

Flow('filtStackedSection','stackedSection',
'''
bandpass fhi=20 --out=stdout
''')

Result('filtStackedSection','grey title="Filtered Stacked Section"')

# Use aliases to split building
Alias('stack',['stackedSection.rsf','filtStackedSection.rsf'])

# Show error message if fail

message = '''
SCosncript Failed build
'''

atexit.register(print_build_failures,message)
End()
167 changes: 167 additions & 0 deletions experiments/multiLayerModel/cds/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# SConstruct (Madagascar Script)
#
# Purpose: Build the interpolation process twice to improve CMP sampling
# and CRE stacking results (Use CDS condition).
#
# Site: http://www.dirackslounge.online
#
# Version 1.0
#
# Programer: Rodolfo A. C. Neves (Dirack) 04/03/2020
#
# Email: rodolfo_profissional@hotmail.com
#
# License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.

# Madagascar package
from rsf.proj import *

# Import glob python library
import glob

# Error report function
import atexit
from madagascarRecipes.errorReport import print_build_failures

# Call SConscript to generate input: original and interpolated data cubes
# SConscript('SConscript')

# CRE stacking
# It uses Very Fast Simulated Aneeling and non hyperbolic CRS
# to get zero offset CRS parameters (RN, RNIP and BETA) from data cube
v0 = 1.5
ot0 = 0.3
dt0 = 0.008
nt0 = 331
om0 = 2
dm0 = 0.025
nm0 = 108
dataCube='multiLayerDataCube'

for i in range(nm0):

parametersCube = []
creGatherCube = []
creTimeCurveCube = []
creGatherCubeForM0List = []
creTimeCurveCubeForM0List = []
creGatherIndex = 0

m0 = om0 + (i * dm0)

for j in range(nt0):

t0 = ot0 + (dt0 * j)

crsParameters = 'crsParameters-m0-%g-t0-%g' % (i,j)
creMhCoordinates = 'creMhCoordinates-m0-%g-t0-%g' % (i,j)
creGather = 'creGather-m0-%g-t0-%g' % (i,j)
creMcoordinate = 'creMcoordinate-m0-%g-t0-%g' % (i,j)
creTimeCurve = 'creTimeCurve-m0-%g-t0-%g' % (i,j)
creGatherPlot = 'crePlot-m0-%g-t0-%g' % (i,j)

# Very Fast Simulated Aneelling Global Optimization (VFSA)
Flow(crsParameters,'interpolatedDataCube2',
'''
vfsacrsnh m0=%g v0=%g t0=%g verb=y repeat=3
''' % (m0,v0,t0))

# Calculate CRE trajectory
Flow(creMhCoordinates,['interpolatedDataCube2',crsParameters],
'''
cretrajec verb=y m0=%g param=${SOURCES[1]} |
put unit1="Offset" label1="Km"
''' % (m0))

#Get CRE Gather from interpolated Data Cube
Flow([creGather,creMcoordinate],['interpolatedDataCube2',creMhCoordinates],
'''
getcregather aperture=50 verb=y cremh=${SOURCES[1]} m=${TARGETS[1]} |
put label1="Time" unit1="s" label2="Offset" unit2="km"
''')

# Calculate CRE traveltime curve t(m,h)
Flow(creTimeCurve,[creMcoordinate, crsParameters],
'''
getcretimecurve cds=y param=${SOURCES[1]} t0=%g m0=%g v0=%g verb=y |
put label1="Offset" unit1="Km"
''' % (t0,m0,v0))

parametersCube.append(crsParameters)
creGatherCube.append(creGather)
creTimeCurveCube.append(creTimeCurve)
creGatherIndex = creGatherIndex + 1

# Concatenate cre gathers for each m0
creGatherCubeForM0 = "creGatherCube-m0-%i" % i
creGatherCubeForM0List.append(creGatherCubeForM0)
Flow(creGatherCubeForM0,creGatherCube,
'''
rcat axis=3 ${SOURCES[1:%d]}
''' % nt0)

# Concatenate cre Time curves for each m0
creTimeCurveCubeForM0 = "creTimeCurveCube-m0-%i" % i
creTimeCurveCubeForM0List.append(creTimeCurveCubeForM0)
Flow(creTimeCurveCubeForM0,creTimeCurveCube,
'''
rcat axis=2 ${SOURCES[1:%d]}
'''% nt0)

# Stack one m0 per turn
creTimeCurveCube = []
creGatherCube = []
creGatherTrace = "creGatherTrace-m0-%i" % i
creTimeCurveTrace = "creTimeCurveTrace-m0-%i" % i
creStackedTrace = "creStackedTrace-m0-%i" % i

# Get cre Gathers organized by t0 and m0
Flow(creGatherTrace,creGatherCubeForM0List,
'''
put n4=1 d4=%g o4=%g d3=%g o3=%g label3=t0 unit3=s label4=m0 unit4=Km
''' % (dm0,m0,dt0,ot0))

# Get all the traveltime curves organized by t0 and m0
Flow(creTimeCurveTrace,creTimeCurveCubeForM0List,
'''
put label3="m0" unit3="Km" label2="t0" unit2="s" d2=%g o2=%g d3=%g o3=%g
''' % (dt0,ot0,dm0,m0))

# CRE stacking
Flow(creStackedTrace,[creGatherTrace,creTimeCurveTrace],
'''
crestack timeCurves=${SOURCES[1]} verb=y |
put label1=t0 unit1=s label2=m0 unit2=Km --out=stdout
''')

# Build the cre stacked section
# throughout cre stacked traces sorting
files = glob.glob('creStackedTrace-*.rsf')
length = len(files)

sortedFiles = []
for i in range(length):
string = 'creStackedTrace-m0-%i.rsf' % i
sortedFiles.append(string)

Flow('stackedSection',sortedFiles,
'''
rcat axis=2 ${SOURCES[1:%d]} --out=stdout
''' % len(files))

Flow('filtStackedSection','stackedSection',
'''
bandpass fhi=20 --out=stdout
''')

# Show error message if fail
message = '''
SConstruct Failed build when m0={m0} and t0={t0}
'''.format(m0=(i*dm0+om0),t0=(j*dt0+ot0))

atexit.register(print_build_failures,message)

End()
Loading