Class VectorMeanReducer
Vector-mean reducer for a paired (speed, direction) field (S-111 surface currents; S-111 §10.5.1).
public sealed class VectorMeanReducer : IVectorPyramidReducer
- Inheritance
-
VectorMeanReducer
- Implements
- Inherited Members
Remarks
Directly averaging directions (angles in degrees) produces the wrong answer at the 0°/360° branch cut — e.g. mean of (10°, 350°) is 0° (net "north"), not 180° (which a naive average would give). This reducer projects each (speed, direction) sample into Cartesian (u, v) components, means them, then recomposes the resultant into (‖r‖, atan2). The resultant magnitude is not the mean speed: it is the magnitude of the mean current vector, which is what a portrayal wants (net flow through the pooled cell).
NODATA sentinels (either paired field) exclude the cell from the
reduction. An entirely-NODATA window returns
the caller-supplied (noDataSpeed, noDataDirection) pair.
Fields
Instance
Shared instance; the reducer holds no state.
public static readonly VectorMeanReducer Instance
Field Value
Methods
Reduce(ReadOnlySpan<float>, ReadOnlySpan<float>, float, float)
Reduces two paired windows to a single (speed, direction) pair.
public (float Speed, float Direction) Reduce(ReadOnlySpan<float> speeds, ReadOnlySpan<float> directions, float noDataSpeed, float noDataDirection)
Parameters
speedsReadOnlySpan<float>Speed samples for this window (row-major).
directionsReadOnlySpan<float>Direction samples for this window, in degrees clockwise from north (S-111 §10.5.1).
noDataSpeedfloatNODATA sentinel for the speed field.
noDataDirectionfloatNODATA sentinel for the direction field.