Enable independent HC and RC in wind downscaling - #2324
Conversation
… and function names, etc
82e18ff to
41f9625
Compare
brhooper
left a comment
There was a problem hiding this comment.
Thanks @mo-AliceLake , this looks to have made a lot of progress towards allowing independent application of roughness and height corrections for wind downscaling.
I've added a few comments suggesting ways in which I think the code might be improved. I haven't gotten as far as reviewing the unit tests yet, I hope to review them tomorrow. I have noted that the acceptance tests need updating following changes to the names of things.
brhooper
left a comment
There was a problem hiding this comment.
Thanks @mo-AliceLake, one additional comment that I should have added yesterday. I think the unit tests look fine.
brhooper
left a comment
There was a problem hiding this comment.
Thanks @mo-AliceLake I think that these changes have improved the code.
I think the associated CLI (improver/cli/wind_downscaling.py) still needs updating to import the new plugin name. This is currently causing some of the acceptance tests to fail.
Description
This PR restructures the WindTerrainAdjustment plugin (previously RoughnessCorrection) to provide clean, explicit control over applying Roughness Correction (RC), Height Correction (HC), or their combined behaviour. The goal is to make HC‑only and RC‑only configurations explicitly selectable, allowing clearer scientific experimentation and operational configurations (e.g. HC‑only over UK-domain, etc).
Previously, HC and RC were tightly coupled within a single routine. Running only one of the corrections was possible but relied on implicit side‑effects (e.g. suppressing RC by passing z0=None), which was neither obvious nor robust. This PR replaces those implicit behaviours with a clear interface.
Previously, HC and RC were tightly coupled inside a single routine (do_rc_hc_all). This made it difficult to:
Summary of Changes
Introduced explicit correction modes:
do_rc_hc_allroutine into three:do_hc()do_rc()do_hc_and_rc()(chained, preserving legacy HC+RC behaviour)modeargument to the plugin constructor, allowing users to select:"hc_and_rc"(default, identical to previous behaviour)"hc""rc"Clarified RC dependency on z0:
In the new interface, requesting RC (mode="rc" or "hc_and_rc") now requires a valid roughness‑length (z0) field. If it is missing, the plugin raises a clear ValueError.
This replaces the old implicit behaviour where suppressing RC was only achievable indirectly by passing z0=None. The new behaviour is explicit and predictable.
Unified masking and validation
Missing‑data, sea‑point, and invalid‑height masking has been consolidated and made consistent across RC, HC, and combined modes.
Testing