Skip to content

Commit da8b919

Browse files
committed
Build CRE traveltime curve
Use equation described in the paper 'The common reflection element (CRE) method revisited', Geophysics vol 65, number 3 (2000) to get the CRE traveltime curve given m,h CRE coordinates, RNIP and BETA CRS parameters.
1 parent 2872fdd commit da8b919

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

Mgetcretimecurve.c

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/* Version 1.0 - Calculate CRE traveltime curve t(m,h) given CRS zero offset parameters (RNIP, BETA)
2+
3+
Programer: Rodolfo A. C. Neves (Dirack) 14/09/2019
4+
5+
Email: rodolfo_profissional@hotmail.com
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* m; // CMP
20+
float* t; // CRE traveltime curve
21+
float h; // Half offset
22+
float alpha; // Assymetry parameter
23+
float m0; // central CMP
24+
float v0; // Near surface velocity
25+
float t0; // Normal ray traveltime
26+
float* p; // RNIP and BETA temporary vector
27+
float RNIP;
28+
float BETA;
29+
int np; // Number of parameters
30+
bool verb;
31+
float dh; // Half offset sampling
32+
float oh; // Half offset axis origin
33+
int nh; // Half offset number of samples
34+
int i; // loop counter
35+
float c1, c2; // temporary variables
36+
37+
/* RSF files I/O */
38+
sf_file in, out, par;
39+
40+
/* RSF files axis */
41+
sf_axis ax,ay,az;
42+
43+
sf_init(argc,argv);
44+
45+
in = sf_input("in"); // m(h) vector (CRE coordinates)
46+
par = sf_input("param"); // CRS parameters (RNIP, BETA)
47+
out = sf_output("out"); // CRE traveltime curve t(m,h)
48+
49+
if (!sf_getfloat("m0",&m0)) m0=0;
50+
/* central CMP (Km) */
51+
52+
if (!sf_getfloat("v0",&v0)) v0=1.5;
53+
/* Near surface velocity (Km/s) */
54+
55+
if (!sf_getfloat("t0",&t0)) t0=0;
56+
/* Normal ray traveltime (s) */
57+
58+
if (!sf_histint(par,"n1",&np)){
59+
sf_error("No n1= in the parameter file");
60+
}else if(np != 2){
61+
sf_error("Number of parameters should be 2 in the input file: RNIP e BETA");
62+
}else{
63+
p = sf_floatalloc(2);
64+
sf_floatread(p,2,par);
65+
RNIP = p[0];
66+
if(RNIP == 0) sf_error("RNIP can't be zero");
67+
BETA = p[1];
68+
}
69+
70+
if (!sf_histint(in,"n1",&nh)) sf_error("No n1= in input file");
71+
if (!sf_histfloat(in,"d1",&dh)) sf_error("No d1= in input file");
72+
if (!sf_histfloat(in,"o1",&oh)) sf_error("No o1= in input file");
73+
74+
if(! sf_getbool("verb",&verb)) verb=0;
75+
/* 1: active mode; 0: quiet mode */
76+
77+
alpha = sin(BETA)/RNIP;
78+
79+
if (verb) {
80+
81+
sf_warning("Active mode on!!!");
82+
sf_warning("Command line parameters: ");
83+
sf_warning("m0=%f t0=%f v0=%f",m0,t0,v0);
84+
sf_warning("CRS parameters: ");
85+
sf_warning("RNIP=%f BETA=%f",RNIP,BETA);
86+
sf_warning("Input file dimensions: ");
87+
sf_warning("n1=%i d1=%f o1=%f",nh,dh,oh);
88+
sf_warning("Assymetry parameter:");
89+
sf_warning("alpha=%f", alpha);
90+
}
91+
92+
m = sf_floatalloc(nh);
93+
sf_floatread(m,nh,in);
94+
t = sf_floatalloc(nh);
95+
96+
for(i=0;i<nh;i++){
97+
h = (dh*i) + oh;
98+
c1 = (m[i]-m0+h)/(RNIP);
99+
c2 = (m[i]-m0-h)/(RNIP);
100+
t[i] = (t0-2*RNIP/v0)+(RNIP/v0)*sqrt(1-2*alpha*(m[i]-m0+h)+c1*c1)+(RNIP/v0)*sqrt(1-2*alpha*(m[i]-m0-h)+c2*c2);
101+
}
102+
103+
/* axis = sf_maxa(n,o,d)*/
104+
ax = sf_maxa(nh, oh, dh);
105+
ay = sf_maxa(1, 0, 1);
106+
az = sf_maxa(1, 0, 1);
107+
108+
/* sf_oaxa(file, axis, axis index) */
109+
sf_oaxa(out,ax,1);
110+
sf_oaxa(out,ay,2);
111+
sf_oaxa(out,az,3);
112+
sf_floatwrite(t,nh,out);
113+
114+
exit(0);
115+
}

0 commit comments

Comments
 (0)