Add from_polytope_reforecast() for hdate support across all encoders#108
Add from_polytope_reforecast() for hdate support across all encoders#108
Conversation
43a8c27 to
d25fb01
Compare
Since support for our hdate-based reanalysis data does seem to be a rare (and soon outdated) use case, this changes the tests and implementation to only focus on reforecast data in general. Users for old efas reanalysis data now just will not profit from automatic merging of hdate + time + step axis into a single dimension, as this could easily break reforecast retrieval patterns. Each hdate is an independent forecast initialisation, so one coverage per (point × hdate) is the correct reforecast semantic. Fix test expectations to match (coverage counts, per-coverage Forecast date), rename helpers for clarity, and add test_multiple_hdates_and_steps.
- Add from_polytope_reforecast to Encoder ABC - Remove inline hdate hacks from from_polytope in all 8 encoders that had them - Implement from_polytope_reforecast on all 9 non-TimeSeries encoders by delegating to from_polytope(result, date_key="hdate") - Add from_polytope regression tests for all 10 encoder types - Add from_polytope_reforecast tests for all 10 encoder types - Extract shared test helpers into tests/conftest.py
18c2f56 to
eaaa078
Compare
|
It looks like your comment may have been sent without the full message. Could you clarify what you'd like me to do? |
|
@copilot please review this PR |
Here's my review of the PR: Overall: the approach is clean and all 159 tests pass. What the PR does well
Issues / things to be aware of
SummaryThe implementation is sound, the scope decisions are well-reasoned, and the tests cover the important cases. The open items above are either pre-existing or acknowledged in the PR description. The PR is ready to merge with no blocking issues. |
Description
Adds
from_polytope_reforecast()to the baseEncoderclass. Under the hood,from_polytope()gets adate_keyparameter (defaults to"date"so nothing changes for existing callers).from_polytope_reforecast()just callsfrom_polytope(result, date_key="hdate").This means all 10 encoders now support reforecast data where
hdateis the time axis instead ofdate. Each hdate value produces its own coverage — no merging across hdates.Scope decisions
mars_metadata["Forecast date"]. For reforecasts this probably makes sense (hdate is the forecast init time). For pure reanalysis this naming is arguably wrong but we're not targeting that use case here.Tests
The
test_encoder_*_from_polytope.pyfiles are regression tests, not realistic e2e examples. The tree fixtures exercise the encoder code paths and verify the CoverageJSON structure but use small/simplified inputs (e.g. 2 spatial points for a bounding box, multiple steps for Position). They should be sufficient for catching regressions introduced in this PR but more realistic integration tests with actual polytope output would be a good follow-up.Also fixed
Circle.pyhadreturn self.covjsonå(non-ASCII typo) instead ofreturn self.covjsoninfrom_xarray. Pre-existing on main, fixed here since we were touching the file.Contributor Declaration
By opening this pull request, I affirm the following: