Skip to content

Commit

Permalink
Work on grid
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Oct 17, 2024
1 parent d093e1b commit b880509
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/anemoi/transform/grids/unstructured.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Geography:

def __init__(self, latitudes, longitudes, uuidOfHGrid=None):

assert isinstance(latitudes, np.ndarray)
assert isinstance(longitudes, np.ndarray)
assert isinstance(latitudes, np.ndarray), type(latitudes)
assert isinstance(longitudes, np.ndarray), type(longitudes)

LOG.info(f"Latitudes: {len(latitudes)}, Longitudes: {len(longitudes)}")
assert len(latitudes) == len(longitudes)
Expand All @@ -35,6 +35,9 @@ def __init__(self, latitudes, longitudes, uuidOfHGrid=None):
self.latitudes = latitudes
self.longitudes = longitudes

def shape(self):
return self.latitudes.shape


def _load(url_or_path, param):
parsed = urlparse(url_or_path)
Expand All @@ -56,24 +59,28 @@ class UnstructuredGridField:
"""An unstructured field."""

def __init__(self, geography):
self._latitudes = geography.latitudes
self._longitudes = geography.longitudes
self.geography = geography

def metadata(self, *args, default=None, **kwargs):

if len(args) == 0 and len(kwargs) == 0:
return self

def metadata(self, name, default=None):
if name == "uuidOfHGrid":
return self.geography.uuidOfHGrid
return default

def grid_points(self):
return self._latitudes, self._longitudes
return self.geography.latitudes, self.geography.longitudes

@property
def resolution(self):
return "unknown"

@property
def shape(self):
return (len(self._latitudes),)
return self.geography.shape()

def to_latlon(self, flatten=False):
return dict(lat=self.geography.latitudes, lon=self.geography.longitudes)


class UnstructuredGridFieldList(FieldArray):
Expand Down

0 comments on commit b880509

Please sign in to comment.