Description
Interpolate selected fields from an auxiliary dataset at the coordinates in
the input dataset. Use inverse-distance weighting for multidimensional keys,
or one-dimensional linear/previous/next/nearest joins for a single key.
Interpolation options:
1. suitable for unstructured data
2. IDW for multi-dimensional data
3. linear, previous, next, and nearest joins for a one-dimensional key
For linear, previous/hold, next, and nearest interpolation, exactly one in.*
field is required. Auxiliary keys are sorted internally. The outside option is
clamp, zero, or error. The duplicate option is error, first, last, or mean.
Nearest chooses the previous sample when distances are equal. IDW remains the
default and retains support for multiple interpolation dimensions.
IDW requires finite coordinates/values, a positive finite radius and positive
finite dimension weights. A query with no positive-weight auxiliary point
inside the radius is an error, not a NaN result. The old radius option is a
deprecated alias for idw.radius and emits a warning; supplying both is an error.
Unknown parameter names are rejected before processing.
Synopsis
sginterp <stdin aux= in.x=AUX(x) out.var=AUX(var) method=SG_METHOD_IDW idw.eps=1.0 idw.radius=1000000 radius= outside=SG_TEMPORAL_CLAMP duplicate=SG_TEMPORAL_DUPLICATE_ERROR >stdout
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
in |
ifile |
stdin
|
input dataset |
aux (required) |
ifile |
No default | auxiliary dataset with all columns in one group |
in.x |
field |
AUX(x)
|
index fields |
out.var |
field |
AUX(var)
|
variable fields |
method |
enum |
SG_METHOD_IDW
|
interpolation method; non-IDW methods require one interpolation field |
idw.eps |
floats |
1.0
|
relative weighting for each interpolation dimension |
idw.radius |
float |
1000000
|
maximum weighted interpolation distance |
radius |
float |
Unknown | deprecated compatibility alias for idw.radius; warns when supplied |
outside |
enum |
SG_TEMPORAL_CLAMP
|
behavior outside the auxiliary key range |
duplicate |
enum |
SG_TEMPORAL_DUPLICATE_ERROR
|
behavior for duplicate auxiliary keys |
out |
ofile |
stdout
|
output dataset |
Input and output
Input
input dataset
Output
output dataset
Examples
1. Interpolate velocity and temperature onto input depths
sginterp aux=reference.sg in.depth=z out.data=vel out.temperature=temp \
<input.sg >interpolated.sgInput depth is the query coordinate; auxiliary z is the reference coordinate.
Auxiliary vel and temp values become output data and temperature using IDW.
Keep all auxiliary columns in one group and verify coordinate units and ranges.
2. Interpolate ocean-bottom depth onto receiver positions
sginterp aux=reference.sg in.recx=x in.recy=y out.wdepth=data \
<receivers.sg >depths.sgInput recx/recy query auxiliary x/y; auxiliary data becomes output wdepth.
Use compatible coordinate units, one auxiliary group and appropriate IDW weights.
3. Interpolate a variable in a five-dimensional sampled model space
sginterp aux=models.sg out.data=var in.p1=m1 in.p2=m2 in.p3=m3 \
in.p4=m4 in.p5=m5 <queries.sg >interpolated.sgInput p1 through p5 query auxiliary m1 through m5; var becomes output data.
Keep auxiliary cases in one group and choose dimension weights for their units.
4. Linearly interpolate values at irregular one-dimensional coordinates
sginterp in.time=time aux=reference.sg out.value=value method=linear \
<queries.sg >interpolated.sgExactly one input coordinate field is required. Auxiliary keys are sorted;
the default outside policy clamps and the default duplicate policy rejects.
These illustrative invocations require matching datasets and output checks;
they are not evidence of executed or scientifically validated experiments.
References
- Shepard, Donald. 1968. A two-dimensional interpolation function for
irregularly-spaced data. Proceedings of the 1968 ACM National Conference.
pp.517-524.