Repository navigation
v1.2.0
v1.2.0
New: Sampler for reusable bilinear weights
BilinearValue unpacks the whole field on every call (~408 µs per point on an RDPS rotated grid), which rules it out for rendering, regridding, or reading the same points from many fields on one grid.
NewSampler(f)builds once per grid;Weights(lat, lon)returns the four corner indices and fractions, andInterpolateapplies them to theValues()of any field on that grid.- Supports templates 3.0, 3.1 and regular 3.40.
BilinearWeights.Outsideflags points beyond the grid edge (clamped to the edge cell, as before).NearestCorner()returns the heaviest corner for categorical fields such as precipitation type.Sampler.Matches(f)checks that a field shares the grid.BilinearValueis now built on the same weights/interpolate steps with the same arithmetic order, so its results are unchanged.
Verification
Sampler results are bit-identical to BilinearValue, errors included, across 69 decodable fixture grids (57 on 3.0, 4 on 3.1, 8 on 3.40). The existing suite passes unchanged.
| lookup | cost per point |
|---|---|
BilinearValue |
408 µs |
Sampler.Weights + Interpolate |
0.21 µs |