Table of Contents

Class VectorMeanReducer

Namespace
EncDotNet.S100.Pipelines.Coverage.Pyramid
Assembly
EncDotNet.S100.Core.dll

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

VectorMeanReducer

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

speeds ReadOnlySpan<float>

Speed samples for this window (row-major).

directions ReadOnlySpan<float>

Direction samples for this window, in degrees clockwise from north (S-111 §10.5.1).

noDataSpeed float

NODATA sentinel for the speed field.

noDataDirection float

NODATA sentinel for the direction field.

Returns

(float X, float Y)

The pooled speed and direction. NODATA in either paired field excludes the cell from the reduction; if every cell is NODATA in either field the corresponding NODATA sentinel is returned.