WIP: update to earthkit 1.0 API - #269
Draft
aaron-hopkinson wants to merge 15 commits into
Draft
Conversation
aaron-hopkinson
force-pushed
the
earthkit-1.0
branch
from
May 8, 2026 09:03
43e60b7 to
997b870
Compare
aaron-hopkinson
force-pushed
the
earthkit-1.0
branch
from
June 19, 2026 13:26
997b870 to
9bb4e70
Compare
aaron-hopkinson
force-pushed
the
earthkit-1.0
branch
from
June 22, 2026 14:10
e270e5e to
b145453
Compare
aaron-hopkinson
commented
Jul 23, 2026
|
|
||
| input_params = set(data.metadata(self.MATCHING.select)) | ||
| # TODO: reconsider implementation if/when fieldlist supports "parameter.variable" key | ||
| input_params = set(f.parameter.variable() for f in data) |
Contributor
Author
There was a problem hiding this comment.
could use set(f.get(self.MATCHING.select) for f in data) if select=parameter.variable throughout
aaron-hopkinson
commented
Jul 23, 2026
| will call the ``interpolate`` function from `earthkit-regrid | ||
| <https://earthkit-regrid.readthedocs.io/en/latest/interpolate.html>`_ if | ||
| will call the ``regrid`` function from `earthkit-geo | ||
| <https://earthkit-geo.readthedocs.io/en/latest/interpolate.html>`_ if |
Contributor
Author
There was a problem hiding this comment.
aaron-hopkinson
commented
Jul 23, 2026
| the keys ``method``, ``in_grid`` and ``out_grid`` are provided and if a | ||
| `pre-generated matrix | ||
| <https://earthkit-regrid.readthedocs.io/en/latest/inventory/index.html>`_ | ||
| <https://earthkit-geo.readthedocs.io/en/latest/inventory/index.html>`_ |
Contributor
Author
There was a problem hiding this comment.
aaron-hopkinson
commented
Jul 23, 2026
| from anemoi.transform.filters.fields import filter_registry | ||
|
|
||
| # Mapping from old metadata keys to component-based accessor paths | ||
| _KEY_MAPPING = { |
Contributor
Author
There was a problem hiding this comment.
make sure we have only one version of this
aaron-hopkinson
commented
Jul 23, 2026
|
|
||
|
|
||
| class UnstructuredGridFieldList(FieldArray): | ||
| class UnstructuredGridFieldList(SimpleFieldList): |
Contributor
Author
There was a problem hiding this comment.
no longer required
aaron-hopkinson
commented
Jul 23, 2026
| "height_above_ground": "sfc", | ||
| "potential_vorticity": "pv", | ||
| "potential_temperature": "pt", | ||
| } |
Contributor
Author
There was a problem hiding this comment.
double check/maybe more here?
aaron-hopkinson
commented
Jul 23, 2026
| def new_flavoured_field(field: ekd.Field, flavour: Flavour) -> ekd.Field: | ||
| """Create a new field with a flavour.""" | ||
| return NewFlavouredField(field, flavour) | ||
| raise NotImplementedError("Not implemented yet.") |
Contributor
Author
There was a problem hiding this comment.
check where this is used
aaron-hopkinson
commented
Jul 23, 2026
| exclude_keys = [] | ||
| exclude_keys = set(exclude_keys) | ||
|
|
||
| # TODO: remove this? |
Contributor
Author
There was a problem hiding this comment.
look into this
aaron-hopkinson
commented
Jul 23, 2026
|
|
||
| return ekd.ArrayField(array=[1], metadata=MetadataOverride(**metadata)) | ||
|
|
||
| def group_component_dict(components: Mapping[str, Any]) -> dict[str, dict[str, Any]]: |
Contributor
Author
There was a problem hiding this comment.
may no longer be required?
aaron-hopkinson
commented
Jul 23, 2026
| def test_field_new_metadata(sample_field): | ||
| """Test that a new field can be created with new metadata.""" | ||
| assert "foo" not in sample_field.metadata() | ||
| # TODO: consider whether new_field_with_metadata should allow setting ekd field labels |
Contributor
Author
There was a problem hiding this comment.
think about this
aaron-hopkinson
commented
Jul 23, 2026
|
|
||
|
|
||
| @pytest.mark.xfail(reason="vertical grouping not yet implemented") | ||
| @pytest.mark.xfail(reason="vertical grouping test to be revisited") |
aaron-hopkinson
commented
Jul 23, 2026
| "earthkit-geo>=0.3", | ||
| "earthkit-meteo>=0.4.1", | ||
| "earthkit-regrid>=0.4", | ||
| "earthkit-data==1.0.0rc12", |
aaron-hopkinson
commented
Jul 23, 2026
|
|
||
|
|
||
| def test_new_field_with_metadata_update_param(field): | ||
| # new_field_with_metadata works similar to new_field_from_numpy except |
Contributor
Author
There was a problem hiding this comment.
"similarly"
aaron-hopkinson
commented
Jul 23, 2026
|
|
||
| for rule in self.rules[key]: | ||
| if rule.match(field.metadata()): | ||
| if rule.match(_FieldMetadataMapping(field)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unfinished - WIP draft PR for visibility