|
| 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 | +} |
0 commit comments