Ejemplo n.º 1
0
 /**
  * Applies the shifts {@code u} to the trace {@code g}.
  *
  * @param sf the sampling that {@code g} is being warped to.
  * @param u the shifts to apply to {@code g}.
  * @param sg the sampling of {@code g}.
  * @param g the trace to be warped.
  * @return the warped image.
  */
 public static float[][][] applyShifts(
     Sampling sf, final float[][][] u, Sampling sg, final float[][][] g) {
   final int n1 = u[0][0].length;
   final int n2 = u[0].length;
   final int n3 = u.length;
   final int ng = g[0][0].length;
   final double dg = sg.getDelta();
   final double df = sf.getDelta();
   final double fg = sg.getDelta();
   final double ff = sf.getDelta();
   final float[][][] hf = new float[n3][n2][n1];
   final SincInterp si = new SincInterp();
   int n23 = n3 * n2;
   Parallel.loop(
       n23,
       new Parallel.LoopInt() {
         public void compute(int i23) {
           int i2 = i23 % n2;
           int i3 = i23 / n2;
           double v = ff;
           for (int i1 = 0; i1 < n1; i1++, v = ff + i1 * df) {
             hf[i3][i2][i1] = si.interpolate(ng, dg, fg, g[i3][i2], (float) v + u[i3][i2][i1]);
           }
         }
       });
   return hf;
 }
Ejemplo n.º 2
0
 /**
  * Applies the shifts {@code u} to the trace {@code g}.
  *
  * @param sf the sampling that {@code g} is being warped to.
  * @param u the shifts to apply to {@code g}.
  * @param sg the sampling of {@code g}.
  * @param g the trace to be warped.
  * @return the warped trace.
  */
 public static float[] applyShifts(Sampling sf, final float[] u, Sampling sg, final float[] g) {
   final int n1 = u.length;
   final int ng = g.length;
   final double dg = sg.getDelta();
   final double df = sf.getDelta();
   final double fg = sg.getDelta();
   final double ff = sf.getDelta();
   final float[] hf = new float[n1];
   final SincInterp si = new SincInterp();
   double v = ff;
   for (int i1 = 0; i1 < n1; i1++, v = ff + i1 * df)
     hf[i1] = si.interpolate(ng, dg, fg, g, (float) v + u[i1]);
   return hf;
 }
Ejemplo n.º 3
0
 /**
  * Computes an array of VpVs ratios an array of shifts u using a backward difference
  * approximation. The relationship is defined as vpvs(t) = 1+2*(du/dt)
  *
  * @param u
  * @return computed vpvs values.
  */
 public static float[] vpvsBd(Sampling su, float[] u) {
   float dui = 1.0f / (float) su.getDelta();
   int n = u.length;
   float[] vpvs = new float[n];
   vpvs[0] = 1.0f + 2.0f * (u[1] - u[0]) * dui; // at i1=0, forward difference
   for (int i1 = 1; i1 < n; ++i1) vpvs[i1] = 1.0f + 2.0f * (u[i1] - u[i1 - 1]) * dui;
   return vpvs;
 }
Ejemplo n.º 4
0
 private static float[] getValues(Sampling s) {
   int n = s.getCount();
   double f = s.getFirst();
   double d = s.getDelta();
   float[] x = new float[n];
   for (int i = 0; i < n; i++) x[i] = (float) (f + i * d);
   return x;
 }
Ejemplo n.º 5
0
 public static double[] getSubStrainMax(Sampling su, float[] u, double[] rmax) {
   float dui = 1.0f / (float) su.getDelta();
   int n = u.length;
   int nm1 = n - 1;
   double[] rmaxNew = new double[n];
   rmaxNew[0] = rmax[0] - (u[1] - u[0]) * dui; // forward diff
   rmaxNew[nm1] = rmax[nm1] - (u[nm1] - u[nm1 - 1]) * dui; // backward diff
   for (int i1 = 1; i1 < nm1; i1++) rmaxNew[i1] = rmax[i1] - (u[i1 + 1] - u[i1 - 1]) * 0.5 * dui;
   return rmaxNew;
 }
Ejemplo n.º 6
0
 private static float[] firstDerivative(Sampling s, float[] f) {
   int n = f.length;
   int nm1 = n - 1;
   float[] g = new float[n];
   float di = 1.0f / (float) s.getDelta();
   float di2 = 0.5f * di;
   g[0] = (f[1] - f[0]) * di; // forward diff
   g[nm1] = (f[nm1] - f[nm1 - 1]) * di; // backward diff
   for (int i1 = 1; i1 < nm1; i1++) g[i1] = (f[i1 + 1] - f[i1 - 1]) * di2;
   return g;
 }