-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Mdiffsim.c
143 lines (114 loc) · 4.39 KB
/
Mdiffsim.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* Version 1.0 - Generate diffraction simulated hyperbolas in the stacked section
Programer: Rodolfo A. C. Neves (Dirack) 14/03/2020
Email: rodolfo_profissional@hotmail.com
License: GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.txt>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <rsf.h>
#include <math.h>
#include "ricker.h"
int main(int argc, char* argv[])
{
float* pm0; // picked m0's in the stacked section
float* pt0; // picked t0's in the stacked section
float* v; // picked velocity for m0's and t0's
float** stackedSection; // stacked section A(t0,m0)
float** diffractionSection; // diffraction section A(t0,m0)
float aperture; // simulated hyperbolas aperture (km)
int nt0; // number of t0's in stacked section
float dt0; // t0 axis sampling
float ot0; // t0 axis origin
int nm0; // number of m0's in stacked section
float dm0; // m0 axis sampling
float om0; // m0 axis origin
bool verb; // verbose parameter
int im0; // center hyperbola index
int it0; // center hyperbola index
float m0; // center hyperbola m0 coordinate
float t0; // center hyperbola t0 coordinate
int ntraces; // aperture in number of traces
float m; // CMP coordinate of a hyperbola sample
float t; // time coordinate of a hyperbola sample
int it; // time index coordinate of a hyperbola sample
int i; // loop counter
int j; // loop counter
int k; // loop counter
int nv; // Number of diffraction hyperbolas velocities
int npt0; // Number of picked t0's
int npm0; // Number of picked m0's
float* ricker; // Generated ricker waveleti
float freq; // Max frequency of ricker wavelet
int rickerCenter; // Center sample of the ricker wavelet (max amplitude)
/* RSF files I/O */
sf_file in, out, v_file, pt0_file, pm0_file, diff_file;
/* RSF files axis */
sf_init(argc,argv);
in = sf_input("in");
pt0_file = sf_input("t0");
pm0_file = sf_input("m0");
v_file = sf_input("v");
out = sf_output("out");
diff_file = sf_output("diff");
/* Read stacked section geometry */
if(!sf_histint(in,"n1",&nt0)) sf_error("No n1= in input");
if(!sf_histfloat(in,"o1",&ot0)) sf_error("No o1= in input");
if(!sf_histfloat(in,"d1",&dt0)) sf_error("No d1= in input");
if(!sf_histint(in,"n2",&nm0)) sf_error("No n2= in input");
if(!sf_histfloat(in,"d2",&dm0)) sf_error("No d2= in input");
if(!sf_histfloat(in,"o2",&om0)) sf_error("No o2= in input");
/* Read auxiliary files geometry */
if(!sf_histint(pt0_file,"n1",&npt0)) sf_error("No n1= in t0's file");
if(!sf_histint(pm0_file,"n1",&npm0)) sf_error("No n1= in m0's file");
if(!sf_histint(v_file,"n1",&nv)) sf_error("No n1= in v's file");
/* Vectors should have the same dimension */
if(!(npt0==npm0)) sf_error("Auxiliary files (t0,m0 and v) should have the same n1!");
if(!(npm0==nv)) sf_error("Auxiliary files (t0,m0 and v) should have the same n1!");
if(!sf_getbool("verb",&verb)) verb=0;
/* 1: active mode; 0: quiet mode */
if(!sf_getfloat("aperture",&aperture)) aperture=1;
/* Diffraction hyperbolas aperture (Km) */
if (!sf_getfloat("freq",&freq)) freq=0.2/dt0;
/* peak frequency for Ricker wavelet (Hz) */
if(verb){
sf_warning("Active mode on!!!");
sf_warning("Input file parameters: ");
sf_warning("n1=%d d1=%f o1=%f",nt0,dt0,ot0);
sf_warning("n2=%d d2=%f o2=%f",nm0,dm0,om0);
}
/* Read input files */
stackedSection = sf_floatalloc2(nt0,nm0);
diffractionSection = sf_floatalloc2(nt0,nm0);
sf_floatread(stackedSection[0],nt0*nm0,in);
pt0 = sf_floatalloc(npt0);
sf_floatread(pt0,npt0,pt0_file);
pm0 = sf_floatalloc(npm0);
sf_floatread(pm0,npm0,pm0_file);
v = sf_floatalloc(nv);
sf_floatread(v,nv,v_file);
/* Ricker wavelet trace */
ricker = sf_floatalloc(nt0);
ricker_init(nt0*2,freq*dt0,2);
rickerCenter = (int) (nt0/2);
ricker[rickerCenter] = 1;
sf_freqfilt(nt0,ricker);
ntraces = round(aperture/dm0);
for(k=0;k<nv;k++){
/* Calculate center hyperbola coordinates */
im0 = round(pm0[k]/dm0);
it0 = round(pt0[k]/dt0);
m0 = im0*dm0+om0;
t0 = it0*dt0+ot0;
for(i=im0-ntraces;i<im0+ntraces;i++){
m = (i*dm0)-m0;
t = sqrt(t0*t0 + ((m*m)/(v[k]*v[k])));
it = (int) round(t/dt0);
for(j=-10;j<11;j++){
diffractionSection[i][j+it]=ricker[j+rickerCenter];
stackedSection[i][j+it]+=ricker[j+rickerCenter];
}/* Loop over a time window */
} /* loop over one diffraction hyperbola */
} /* Loop over hyperbolas */
sf_floatwrite(stackedSection[0],nt0*nm0,out);
sf_floatwrite(diffractionSection[0],nt0*nm0,diff_file);
}