From be6face3dd47a8da0d75b0f3a2900b1face3394a Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Sun, 21 Apr 2024 22:26:17 -0400 Subject: [PATCH] Fix output widget bug --- hypercoast/hypercoast.py | 6 +++++- hypercoast/ui.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hypercoast/hypercoast.py b/hypercoast/hypercoast.py index 532ae1d..52edb22 100644 --- a/hypercoast/hypercoast.py +++ b/hypercoast/hypercoast.py @@ -2,7 +2,7 @@ import ipyleaflet import leafmap - +import xarray as xr from .emit import read_emit, plot_emit, viz_emit, emit_to_netcdf, emit_to_image @@ -38,6 +38,7 @@ def add(self, obj, position="topright", **kwargs): from .ui import SpectralWidget SpectralWidget(self, position=position) + self.set_plot_options(add_marker_cluster=True) else: super().add(obj, **kwargs) @@ -159,6 +160,9 @@ def add_emit( xds = read_emit(source) source = emit_to_image(xds, wavelengths=wavelengths) + elif isinstance(source, xr.Dataset): + xds = source + source = emit_to_image(xds, wavelengths=wavelengths) self.add_raster( source, diff --git a/hypercoast/ui.py b/hypercoast/ui.py index 0747c2a..6579abe 100644 --- a/hypercoast/ui.py +++ b/hypercoast/ui.py @@ -205,7 +205,8 @@ def cleanup(self): if hasattr(self._host_map, "_spectral_data"): self._host_map._spectral_data = {} - self._output_widget.clear_output() + if hasattr(self, "_output_widget") and self._output_widget is not None: + self._output_widget.clear_output() if self.on_close is not None: self.on_close()