Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions xdggs/accessor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import numpy.typing as npt
import xarray as xr

from xdggs.grid import DGGSInfo
from xdggs.index import DGGSIndex
from xdggs.plotting import explore

if TYPE_CHECKING:
from lonboard.basemap import MaplibreBasemap
from lonboard.experimental.view import BaseView
from matplotlib.colors import Colormap

from xdggs.plotting import MapWithControls


@xr.register_dataset_accessor("dggs")
@xr.register_dataarray_accessor("dggs")
Expand Down Expand Up @@ -208,7 +219,19 @@ def zoom_to(self, level: int):

return xr.DataArray(zoomed, coords={self._name: self.cell_ids}, dims=dims)

def explore(self, *, cmap="viridis", center=None, alpha=None, coords=None):
def explore(
self,
*,
cmap: str | Colormap = "viridis",
center: int | float | None = None,
vmin: int | float | None = None,
vmax: int | float | None = None,
robust: bool = False,
alpha: float | None = None,
coords: list[str] | None = None,
view: BaseView | None = None,
basemap: MaplibreBasemap | None = None,
) -> MapWithControls:
"""interactively explore the data using `lonboard`

Requires `lonboard`, `matplotlib`, and `arro3.core` to be installed.
Expand All @@ -233,13 +256,17 @@ def explore(self, *, cmap="viridis", center=None, alpha=None, coords=None):
-----
Plotting currently is restricted to 1D `DataArray` objects.
"""
if isinstance(self._obj, xr.Dataset):
raise ValueError("does not work with Dataset objects, yet")

return explore(
self._obj,
cmap=cmap,
center=center,
alpha=alpha,
colorize_params={
"cmap": cmap,
"center": center,
"vmin": vmin,
"vmax": vmax,
"robust": robust,
"alpha": alpha,
},
coords=coords,
view=view,
basemap=basemap,
)
255 changes: 0 additions & 255 deletions xdggs/plotting.py

This file was deleted.

Loading