edu.mines.jtk.interp.SimpleGridder3 Maven / Gradle / Ivy
Show all versions of edu-mines-jtk Show documentation
/****************************************************************************
Copyright 2009, Colorado School of Mines and others.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
package edu.mines.jtk.interp;
import edu.mines.jtk.dsp.Sampling;
/**
* Simple griding of scattered samples of 3D functions f(x1,x2,x3).
* Each gridded value is simply the average of the values of all known
* samples that lie within the corresponding grid cell. For a grid cell
* that contains no such known samples, the gridded value is null.
*
* Note that this simple method performs no interpolation for grid cells
* that do not contain at least one scattered sample. It may however be
* used as a first step in other more sophisticated gridding methods. In
* particular, the averaging performed by this simple gridder provides a
* crude form of anti-alias filtering when grid cells contain multiple
* scattered samples.
* @author Dave Hale, Colorado School of Mines
* @version 2009.07.22
*/
public class SimpleGridder3 implements Gridder3 {
/**
* Constructs a simple gridder with specified known samples.
* The specified arrays are referenced, not copied.
* @param f array of known sample values f(x1,x2,x3).
* @param x1 array of known sample x1 coordinates.
* @param x2 array of known sample x2 coordinates.
* @param x3 array of known sample x3 coordinates.
*/
public SimpleGridder3(float[] f, float[] x1, float[] x2, float[] x3) {
setScattered(f,x1,x2,x3);
}
/**
* Sets the null value used for grid cells that contain no known samples.
* @param fnull the null value.
*/
public void setNullValue(float fnull) {
_fnull = fnull;
}
/**
* Gets the non-null samples from the specified gridded sample values.
* @param fnull the null value.
* @param s1 sampling of x1.
* @param s2 sampling of x2.
* @param s3 sampling of x3.
* @param g array of gridded sample values.
* @return array {f,x1,x2,x3} of arrays of non-null samples.
*/
public static float[][] getGriddedSamples(
float fnull, Sampling s1, Sampling s2, Sampling s3, float[][][] g)
{
int n1 = s1.getCount();
int n2 = s2.getCount();
int n3 = s3.getCount();
int n = 0;
for (int i3=0; i30.0f) ?
g[i3][i2][i1]/c[i3][i2][i1] :
_fnull;
}
}
}
return g;
}
///////////////////////////////////////////////////////////////////////////
// private
private int _n;
private float _fnull;
private float[] _f,_x1,_x2,_x3;
}