Skip to content

Commit 4351294

Browse files
committed
sfnhcrssurf build approximated reflection surface
Program sfnhcrssurf generate the aproximated reflection surface t(m,h) based on non-hyperbolic CRS approximation, it's useful to compare the fitness error between approximation and data reflection surface.
1 parent cd349d8 commit 4351294

File tree

3 files changed

+145
-1
lines changed

3 files changed

+145
-1
lines changed

Mnhcrssurf.c

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/* Version 1.0 - Build Non-Hyperbolic CRS approximation surface giver RN, RNIP and BETA parameters.
2+
3+
Programer: Rodolfo A. C. Neves (Dirack) 19/09/2019
4+
5+
6+
7+
License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.
8+
9+
*/
10+
11+
#include <math.h>
12+
#include <stdio.h>
13+
#include <stdlib.h>
14+
#include <rsf.h>
15+
16+
int main(int argc, char* argv[])
17+
{
18+
19+
float m0; // central CMP
20+
float om; // CMP axis origin
21+
float dm; // CMP sampling
22+
int nm; // Number of CMP's
23+
float oh; // Offset axis origin
24+
float dh; // Offset sampling
25+
int nh; // Number of Offsets
26+
bool verb; // Key to turn On/Off active mode
27+
float v0; // Near surface velocity
28+
float t0; // Normal ray time travel
29+
float *c; // Temporary parameters vector - last iteration
30+
float **t; // CRS surface t(m,h)
31+
float RN, RNIP, BETA; // CRS parameters
32+
float Fd, Fd1, Fd2;
33+
float c1, a1, a2, b2;
34+
float m;
35+
float h;
36+
int nc, ih, im;
37+
38+
/* RSF files I/O */
39+
sf_file in, out, par;
40+
41+
/* RSF files axis */
42+
sf_axis ax,ay,az;
43+
44+
sf_init(argc,argv);
45+
46+
in = sf_input("in");
47+
par = sf_input("param");
48+
out = sf_output("out");
49+
50+
if (!sf_getfloat("m0",&m0)) m0=0;
51+
/* central CMP of the approximation (Km) */
52+
53+
if (!sf_getfloat("v0",&v0)) v0=1.5;
54+
/* Near surface velocity (Km/s) */
55+
56+
if (!sf_getfloat("t0",&t0)) t0=1.5;
57+
/* Normal ray traveltime (s) */
58+
59+
if (!sf_histint(in,"n1",&nh)) sf_error("No n1= in input");
60+
if (!sf_histfloat(in,"d1",&dh)) sf_error("No d1= in input");
61+
if (!sf_histfloat(in,"o1",&oh)) sf_error("No o1= in input");
62+
if (!sf_histint(in,"n2",&nm)) sf_error("No n2= in input");
63+
if (!sf_histfloat(in,"d2",&dm)) sf_error("No d2= in input");
64+
if (!sf_histfloat(in,"o2",&om)) sf_error("No o2= in input");
65+
66+
if(!sf_histint(par,"n1",&nc)) sf_error("No n1= in parameters input");
67+
68+
if(! sf_getbool("verb",&verb)) verb=0;
69+
/* 1: active mode; 0: quiet mode */
70+
71+
if (verb) {
72+
73+
sf_warning("Active mode on!!!");
74+
sf_warning("Command line parameters: ");
75+
sf_warning("m0=%f v0=%f t0=%f",m0,v0,t0);
76+
sf_warning("Input file parameters: ");
77+
sf_warning("n1=%i d1=%f o1=%f",nh,dh,oh);
78+
sf_warning("n2=%i d2=%f o2=%f",nm,dm,om);
79+
sf_warning("Param file parameters: ");
80+
sf_warning("n1=%i",nc);
81+
}
82+
83+
c = sf_floatalloc(nc);
84+
sf_floatread(c,nc,par);
85+
86+
RN = c[0];
87+
RNIP = c[1];
88+
BETA = c[2];
89+
90+
91+
t = sf_floatalloc2(nh,nm);
92+
93+
for (im=0; im < nm; im++){
94+
95+
for(ih=0;ih<nh;ih++){
96+
97+
m = om + (im * dm);
98+
m = m - m0;
99+
h = oh + (ih * dh);
100+
101+
a1=(2*sin(BETA))/(v0);
102+
a2=(2*cos(BETA)*cos(BETA)*t0)/(v0*RN);
103+
b2=(2*cos(BETA)*cos(BETA)*t0)/(v0*RNIP);
104+
c1=2*b2+a1*a1-a2;
105+
106+
Fd=(t0+a1*m)*(t0+a1*m)+a2*m*m;
107+
Fd2=(t0+a1*(m-h))*(t0+a1*(m-h))+a2*(m-h)*(m-h);
108+
Fd1=(t0+a1*(m+h))*(t0+a1*(m+h))+a2*(m+h)*(m+h);
109+
t[im][ih]=sqrt((Fd+c1*h*h+sqrt(Fd2*Fd1))*0.5);
110+
111+
}
112+
}
113+
114+
/* axis = sf_maxa(n,o,d)*/
115+
ax = sf_maxa(nh, oh, dh);
116+
ay = sf_maxa(nm, om, dm);
117+
az = sf_maxa(1, 0, 1);
118+
119+
/* sf_oaxa(file, axis, axis index) */
120+
sf_oaxa(out,ax,1);
121+
sf_oaxa(out,ay,2);
122+
sf_oaxa(out,az,3);
123+
sf_floatwrite(t[0],nh*nm,out);
124+
125+
exit(0);
126+
}

SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import bldutil
55
# Put your name programs in progs variable
66
# without 'M' preffix and '.c' extension
77
progs = '''
8-
vfsacrenh
8+
vfsacrenh nhcrssurf
99
'''
1010

1111
try: # distributed version

experiments/vfsacrenh/SConstruct

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,23 @@ Flow('crsParameters','dataCube',
6464
vfsacrenh m0=%g v0=%g t0=%g verb=y
6565
''' % (m0,v0,t0))
6666

67+
# Aproximation Error
68+
Flow('dataReflectionSurface','dataCube','envelope | max1 | window n1=1 | real')
69+
Flow('crsAppSurface',['dataReflectionSurface','crsParameters'],
70+
'''
71+
nhcrssurf param=${SOURCES[1]} m0=%g v0=%g t0=%g verb=y
72+
''' % (m0,v0,t0))
73+
74+
Flow('error',['crsAppSurface','dataReflectionSurface'],
75+
'''
76+
add scale=1,-1 ${SOURCES[1]} |
77+
math output="abs(input)"
78+
''')
79+
80+
Result('error',
81+
'''
82+
grey color=j bias=2 scalebar=y barlabel=Time barunit=s barreverse=y title="Error CMP Gather 5Km" label1=Half-Offset unit1=km label2=Midpoint unit2=km
83+
''')
84+
6785
End()
6886

0 commit comments

Comments
 (0)