Skip to content

Commit

Permalink
Adapt XArrayField to changes in earthkit-data Field : Merge pull requ…
Browse files Browse the repository at this point in the history
…est #138 from ecmwf/feature/adapt-xarray-fields-to-earthkit-data-changes

Adapt XArrayField to changes in earthkit-data Field
  • Loading branch information
floriankrb authored Nov 18, 2024
2 parents 80de4c6 + bd8d2ec commit d0faa61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/anemoi/datasets/create/functions/sources/xarray/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import datetime
import logging
from functools import cached_property

from earthkit.data.core.fieldlist import Field
from earthkit.data.core.fieldlist import math
Expand Down Expand Up @@ -46,8 +47,6 @@ def __init__(self, owner, selection):
This is actually a nD object, but the first dimensions are always 1.
The other two dimensions are latitude and longitude.
"""
super().__init__(owner.array_backend)

self.owner = owner
self.selection = selection

Expand Down Expand Up @@ -86,7 +85,8 @@ def to_numpy(self, flatten=False, dtype=None, index=None):

return values # .reshape(self.shape)

def _make_metadata(self):
@cached_property
def _metadata(self):
return XArrayMetadata(self)

def grid_points(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from functools import cached_property

import numpy as np
from earthkit.data.utils.array import ensure_backend

from .field import XArrayField

Expand All @@ -30,7 +29,6 @@ def __init__(
grid,
time,
metadata,
array_backend=None,
):
self.ds = ds
self.variable = variable
Expand All @@ -48,7 +46,6 @@ def __init__(
self.by_name = {c.variable.name: c for c in coordinates}

self.length = math.prod(self.shape)
self.array_backend = ensure_backend(array_backend)

@property
def name(self):
Expand Down

0 comments on commit d0faa61

Please sign in to comment.