Skip to content

Commit

Permalink
add support for lazy point and raster agregation
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelquast committed Jun 19, 2024
1 parent 50cbb5f commit c80e6b4
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions eomaps/eomaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2940,18 +2940,33 @@ def _shade_map(
dataset_lazy = False
if (
isinstance(self.data, xar.Dataset)
and self.shape.name == "shade_raster"
and self.data_specs.parameter is not None
and len(zdata.shape) == 2
and zdata.chunks is not None
and self.data.chunks
and self.get_crs("in") == self.get_crs("out")
):
# pass chunked 2D datasets directly to allow lazy-loading
_log.info("EOmaps: Chunked xarray dataset is handled lazily with dask!")

Check warning on line 2948 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2948

Added line #L2948 was not covered by tests

df = self.data

Check warning on line 2950 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2950

Added line #L2950 was not covered by tests
self.shape.glyph = ds.glyphs.QuadMeshRectilinear(
"x", "y", self.data_specs.parameter
)

if self.shape.name == "shade_raster":
if (

Check warning on line 2953 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2952-L2953

Added lines #L2952 - L2953 were not covered by tests
len(zdata.shape) == 2
and len(self._data_manager.x0.shape) == 1
and len(self._data_manager.y0.shape) == 1
):

self.shape.glyph = ds.glyphs.QuadMeshRectilinear(

Check warning on line 2959 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2959

Added line #L2959 was not covered by tests
self.data_specs.x, self.data_specs.y, self.data_specs.parameter
)
else:
self.shape.glyph = ds.glyphs.QuadMeshCurvilinear(

Check warning on line 2963 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2963

Added line #L2963 was not covered by tests
self.data_specs.x, self.data_specs.y, self.data_specs.parameter
)

elif self.shape.name == "shade_points":
df = self.data.to_dask_dataframe()

Check warning on line 2968 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2967-L2968

Added lines #L2967 - L2968 were not covered by tests

self.shape.aggregator.column = self.data_specs.parameter

Check warning on line 2970 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2970

Added line #L2970 was not covered by tests

dataset_lazy = True

Check warning on line 2972 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2972

Added line #L2972 was not covered by tests
Expand Down Expand Up @@ -2979,6 +2994,10 @@ def _shade_map(
)

else:
# required to avoid ambiguities
if isinstance(zdata, xar.DataArray):
zdata = zdata.data

Check warning on line 2999 in eomaps/eomaps.py

View check run for this annotation

Codecov / codecov/patch

eomaps/eomaps.py#L2999

Added line #L2999 was not covered by tests

if len(zdata.shape) == 2:
if (zdata.shape == x0.shape) and (zdata.shape == y0.shape):
# 2D coordinates and 2D raster
Expand Down

0 comments on commit c80e6b4

Please sign in to comment.