Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Sep 20, 2023
1 parent c3a0791 commit c5af801
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
28 changes: 28 additions & 0 deletions ecml_tools/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ def shape(self):
def dates(self):
return self.z.dates[:] # Convert to numpy

@property
def latitudes(self):
return self.z.latitudes[:]

@property
def longitudes(self):
return self.z.longitudes[:]

@property
def statistics(self):
return self.z.statistics[:]

@cached_property
def resolution(self):
return self.z.attrs["resolution"]
Expand Down Expand Up @@ -121,6 +133,14 @@ def check_compatibility(self, d1, d2):
f"Incompatible frequencies: {d1.frequency} and {d2.frequency} ({d1} {d2})"
)

@property
def latitudes(self):
return self.datasets[0].latitudes

@property
def longitudes(self):
return self.datasets[0].longitudes


class Concat(Combined):
def __len__(self):
Expand Down Expand Up @@ -213,6 +233,14 @@ def shape(self):
def dates(self):
return self.dataset.dates[self.indices]

@property
def latitudes(self):
return self.dataset.latitudes

@property
def longitudes(self):
return self.dataset.longitudes


def name_to_path(name):
if isinstance(name, zarr.hierarchy.Group):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
def _(date, var, k=0):
d = date.year * 10000 + date.month * 100 + date.day
v = ord(var) - ord("a") + 1
return d * 100 + v + k * 1_000_000_000
assert 0 <= k <= 9
return d * 100 + v + k / 10.0


def create_zarr(
Expand Down Expand Up @@ -45,6 +46,7 @@ def create_zarr(
root.dates = dates
root.attrs["frequency"] = frequency
root.attrs["resolution"] = 0
root.attrs["name_to_index"] = {k: i for i, k in enumerate(vars)}

return root

Expand Down

0 comments on commit c5af801

Please sign in to comment.