|
| 1 | +/* Generate angle gathers using the Zoeppritz equation */ |
| 2 | +/* |
| 3 | + Copyright (C) 2008 University of Texas at Austin |
| 4 | + |
| 5 | + This program is free software; you can redistribute it and/or modify |
| 6 | + it under the terms of the GNU General Public License as published by |
| 7 | + the Free Software Foundation; either version 2 of the License, or |
| 8 | + (at your option) any later version. |
| 9 | + |
| 10 | + This program is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + GNU General Public License for more details. |
| 14 | + |
| 15 | + You should have received a copy of the GNU General Public License |
| 16 | + along with this program; if not, write to the Free Software |
| 17 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | +*/ |
| 19 | +#include <rsf.h> |
| 20 | + |
| 21 | +#include "zoeppritz.h" |
| 22 | + |
| 23 | +int main(int argc, char* argv[]) |
| 24 | +{ |
| 25 | + bool incp, outp, refl; |
| 26 | + int ia, na, icoef, j, i1, i2, n1, n2, n3; |
| 27 | + float vp1,vp2,vs1,vs2,rho1,rho2; |
| 28 | + float a0, da, a, rc[4], ang[4], *r; |
| 29 | + float *vpt, *vst, *rhot; |
| 30 | + sf_file vp, vs, rho, out; |
| 31 | + |
| 32 | + sf_init(argc,argv); |
| 33 | + vp = sf_input("in"); |
| 34 | + vs = sf_input("vs"); |
| 35 | + rho = sf_input("rho"); |
| 36 | + out = sf_output("out"); |
| 37 | + |
| 38 | + if (SF_FLOAT != sf_gettype(vp)) sf_error("Need float type"); |
| 39 | + if (!sf_histint(vp, "n1", &n1)) sf_error("Need n1="); |
| 40 | + n2 = sf_leftsize(vp, 1); /* number of traces */ |
| 41 | + |
| 42 | + vpt = sf_floatalloc(n1); |
| 43 | + vst = sf_floatalloc(n1); |
| 44 | + rhot = sf_floatalloc(n1); |
| 45 | + |
| 46 | + n3 = sf_shiftdim(vp, out, 1); |
| 47 | + if (n3 != n1*n2) sf_error("size mismatch"); |
| 48 | + |
| 49 | + if (!sf_getint("na",&na)) na=90; |
| 50 | + /* number of angles */ |
| 51 | + |
| 52 | + if (!sf_getfloat("a0",&a0)) a0=0.; |
| 53 | + /* first angle */ |
| 54 | + |
| 55 | + if (!sf_getfloat("da",&da)) da=90./na; |
| 56 | + /* angle increment */ |
| 57 | + |
| 58 | + sf_putint(out,"n1",na); |
| 59 | + sf_putfloat(out,"o1",a0); |
| 60 | + sf_putfloat(out,"d1",da); |
| 61 | + |
| 62 | + sf_putstring(out,"label1","Incident Angle"); |
| 63 | + sf_putstring(out,"unit1","\\^o\\_"); |
| 64 | + |
| 65 | + a0 *= SF_PI/180.; |
| 66 | + da *= SF_PI/180.; |
| 67 | + |
| 68 | + r = sf_floatalloc(na); |
| 69 | + |
| 70 | + if (!sf_getint("icoef",&icoef)) icoef=4; |
| 71 | + /* [1,2,3,4] particle displacement, displacement potential, energy, real part */ |
| 72 | + |
| 73 | + if (!sf_getbool("incp",&incp)) incp=true; |
| 74 | + /* incident P (or S) */ |
| 75 | + |
| 76 | + if (!sf_getbool("outp",&outp)) outp=true; |
| 77 | + /* rellected/transmitted P (or S) */ |
| 78 | + |
| 79 | + if (!sf_getbool("refl",&refl)) refl=true; |
| 80 | + /* reflection or transmission */ |
| 81 | + |
| 82 | + if (outp) { |
| 83 | + j = refl? 0:2; |
| 84 | + } else { |
| 85 | + j = refl? 1:3; |
| 86 | + } |
| 87 | + |
| 88 | + |
| 89 | + for (i2=0; i2 < n2; i2++) { |
| 90 | + sf_floatread(vpt,n1,vp); |
| 91 | + sf_floatread(vst,n1,vs); |
| 92 | + sf_floatread(rhot,n1,rho); |
| 93 | + |
| 94 | + vp1 = vpt[0]; |
| 95 | + vs1 = SF_MAX(vst[0],SF_EPS); |
| 96 | + rho1 = rhot[0]; |
| 97 | + for (i1=0; i1 < n1; i1++) { |
| 98 | + vp2 = vpt[i1]; |
| 99 | + vs2 = SF_MAX(vst[i1],SF_EPS); |
| 100 | + rho2 = rhot[i1]; |
| 101 | + |
| 102 | + for (ia=0; ia < na; ia++) { |
| 103 | + a = a0 + ia*da; |
| 104 | + a = incp? sinf(a)/vp1: sinf(a)/vs1; |
| 105 | + |
| 106 | + zoeppritz (icoef,vp1,vp2,vs1,vs2,rho1,rho2,incp,a,rc,ang); |
| 107 | + r[ia] = rc[j]; |
| 108 | + } |
| 109 | + |
| 110 | + sf_floatwrite(r,na,out); |
| 111 | + |
| 112 | + vp1 = vp2; |
| 113 | + vs1 = vs2; |
| 114 | + rho1 = rho2; |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + exit(0); |
| 119 | +} |
0 commit comments