InterpolationTransform: vector wind average

Open
#675 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start with logger/transforms/interpolation_transform.py and read how field_spec sources are parsed, cached, and validated, along with the existing averaging algorithms. Implement paired speed/direction handling and the vector_average and wind_steadiness algorithms with the stated timestamp, missing-value, and min_count rules; add tests for the new behavior and startup checks. Done means both algorithms produce one output per field spec and reject the unsupported source/options described in the issue.

Written by the indexing model from the issue text.

Description

enhancement

Split out from #664 (item 3). The rest of that issue is done in #666, #667 and #674.

Problem

polar_average averages directions as unit vectors and ignores speed, so a brief 1-knot puff counts as much as a sustained 30-knot wind. The meteorological standard (WMO) is to average the u/v wind components weighted by speed. That gives a resultant direction, and a steadiness ratio (resultant speed ÷ scalar mean speed) that shows when a direction average means little because the wind is swinging around.

Proposed design

These are the decisions reached while working on #664. They are open to revision.

One output per field_spec entry, as for every other InterpolationTransform algorithm:

  • Average speed: the scalar mean speed, which is the usual met convention. This needs nothing new; it is boxcar_average on the speed field.
  • vector_average (new): the speed-weighted resultant direction.
  • wind_steadiness (new): resultant speed ÷ scalar mean speed, from 0 (no consistent direction) to 1 (steady).
  • Output names: both new algorithms name their output after the direction field, plus result_prefix.

Speed and direction are given as a pair:

field_spec:
- sources: [TrueWindSpeed]
  algorithm: boxcar_average
  window: 60
  result_prefix: Avg                 # → AvgTrueWindSpeed
- sources: [{speed: TrueWindSpeed, direction: TrueWindDir}]
  algorithm: vector_average
  window: 60
  result_prefix: Avg                 # → AvgTrueWindDir
- sources: [{speed: TrueWindSpeed, direction: TrueWindDir}]
  algorithm: wind_steadiness
  window: 60
  result_prefix: Steadiness          # → SteadinessTrueWindDir

The dict form of field_spec would take source: {speed: ..., direction: ...}.

Pairing and options

  • Pairing: speed and direction samples are paired by exact timestamp. That holds when both come from the same record, which is the usual case, including through CachedDataReader. Unpaired samples are ignored.
  • Missing values: a pair with either value missing (None or NaN) is ignored.
  • min_count: counts valid pairs.
  • outlier_mads: refused, since it has no obvious meaning for vectors.
  • Startup checks: both new algorithms require a paired source, and every other algorithm refuses one.

Implementation notes

  • Where the code goes: logger/transforms/interpolation_transform.py, about 95 lines plus tests:
    • accept a pair in both field_spec forms and cache both fields;
    • pair the samples before computing;
    • the two algorithms;
    • the startup checks.
  • One existing line would crash: transform() builds a non_empty map that nothing reads, by looking up each source in a dict. That raises TypeError when the source is itself a dict. The lookup can simply be deleted.
  • Template: averaging_logger_template could later gain optional variables for this, added without changing existing definitions.
Dominant language
Python
Stars
57
Forks
30
Avg merge
3h 14m
Merged PRs (30d)
56

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OceanDataTools/openrvdas

All issues in OceanDataTools/openrvdas

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.