Skip to content

WIP: update to earthkit 1.0 API - #269

Draft
aaron-hopkinson wants to merge 15 commits into
mainfrom
earthkit-1.0
Draft

WIP: update to earthkit 1.0 API#269
aaron-hopkinson wants to merge 15 commits into
mainfrom
earthkit-1.0

Conversation

@aaron-hopkinson

Copy link
Copy Markdown
Contributor

Unfinished - WIP draft PR for visibility

@github-project-automation github-project-automation Bot moved this to To be triaged in Anemoi-dev Mar 20, 2026
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file tests labels Mar 20, 2026
@aaron-hopkinson aaron-hopkinson self-assigned this Mar 20, 2026
@HCookie HCookie moved this from To be triaged to Now In Progress in Anemoi-dev May 6, 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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use set(f.get(self.MATCHING.select) for f in data) if select=parameter.variable throughout

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>`_

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from anemoi.transform.filters.fields import filter_registry

# Mapping from old metadata keys to component-based accessor paths
_KEY_MAPPING = {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure we have only one version of this



class UnstructuredGridFieldList(FieldArray):
class UnstructuredGridFieldList(SimpleFieldList):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer required

"height_above_ground": "sfc",
"potential_vorticity": "pv",
"potential_temperature": "pt",
}

@aaron-hopkinson aaron-hopkinson Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double check/maybe more here?

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.")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check where this is used

Comment thread tests/utils/__init__.py
exclude_keys = []
exclude_keys = set(exclude_keys)

# TODO: remove this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look into this

Comment thread tests/utils/__init__.py

return ekd.ArrayField(array=[1], metadata=MetadataOverride(**metadata))

def group_component_dict(components: Mapping[str, Any]) -> dict[str, dict[str, Any]]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may no longer be required?

Comment thread tests/test_fields.py
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think about this

Comment thread tests/test_grouping.py


@pytest.mark.xfail(reason="vertical grouping not yet implemented")
@pytest.mark.xfail(reason="vertical grouping test to be revisited")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo

Comment thread pyproject.toml
"earthkit-geo>=0.3",
"earthkit-meteo>=0.4.1",
"earthkit-regrid>=0.4",
"earthkit-data==1.0.0rc12",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update

Comment thread tests/test_wrappers.py


def test_new_field_with_metadata_update_param(field):
# new_field_with_metadata works similar to new_field_from_numpy except

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"similarly"


for rule in self.rules[key]:
if rule.match(field.metadata()):
if rule.match(_FieldMetadataMapping(field)):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ATS approval needed dependencies Pull requests that update a dependency file tests

Projects

Status: Now In Progress

Development

Successfully merging this pull request may close these issues.

2 participants