|
| 1 | +/* Dip estimation from convection */ |
| 2 | +/* |
| 3 | + Copyright (C) 2025 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 <math.h> |
| 20 | + |
| 21 | +#include <rsf.h> |
| 22 | +#include "predict.h" |
| 23 | + |
| 24 | +int main (int argc, char* argv[]) |
| 25 | +{ |
| 26 | + int order, n1, n2, i1, i2, nw; |
| 27 | + float **conv, *trace, eps; |
| 28 | + sf_file cnv, dip; |
| 29 | + |
| 30 | + sf_init(argc, argv); |
| 31 | + cnv = sf_input("in"); |
| 32 | + dip = sf_output("out"); |
| 33 | + |
| 34 | + if (SF_FLOAT != sf_gettype(cnv)) sf_error("Need float input"); |
| 35 | + if (!sf_histint(cnv,"n1",&n1)) sf_error("Need n1= in input"); |
| 36 | + if (!sf_histint(cnv,"n2",&nw)) sf_error("Need n2= in input"); |
| 37 | + if (!sf_histint(cnv,"n3",&n2)) sf_error("Need n3= in input"); |
| 38 | + |
| 39 | + order = nw/2; |
| 40 | + |
| 41 | + sf_unshiftdim(cnv,dip,2); |
| 42 | + |
| 43 | + if (!sf_getfloat("eps",&eps)) eps=0.01; |
| 44 | + /* regularization */ |
| 45 | + |
| 46 | + predict_init (n1, n2, eps*eps, order, 1, false); |
| 47 | + |
| 48 | + conv = sf_floatalloc2(n1,nw); |
| 49 | + trace = sf_floatalloc(n1); |
| 50 | + |
| 51 | + for (i2=0; i2 < n2; i2++) { |
| 52 | + for (i1=0; i1 < n1; i1++) { |
| 53 | + trace[i1] = i1; |
| 54 | + } |
| 55 | + sf_floatread(conv[0],n1*nw,cnv); |
| 56 | + predict_step(false,true,trace,conv); |
| 57 | + for (i1=0; i1 < n1; i1++) { |
| 58 | + trace[i1] = i1 - trace[i1]; |
| 59 | + } |
| 60 | + sf_floatwrite(trace,n1,dip); |
| 61 | + } |
| 62 | + |
| 63 | + exit(0); |
| 64 | +} |
| 65 | + |
| 66 | + |
| 67 | + |
0 commit comments