Skip to content

Instantly share code, notes, and snippets.

@tommylees112
Created August 17, 2021 22:42
Show Gist options
  • Save tommylees112/9838c79a5a9e455b2d71926af0c19510 to your computer and use it in GitHub Desktop.
Save tommylees112/9838c79a5a9e455b2d71926af0c19510 to your computer and use it in GitHub Desktop.
Open xarray image in napari
import napari
import xarray as xr
from pathlib import Path
data_dir = Path("/path/to/data")
# open data
ds = xr.open_dataset(data_dir / "data.nc")
da = ds["VARIABLE_NAME"]
# initialise viewer and view
viewer = napari.Viewer()
new_layer = viewer.add_image(da, colormap="magma")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment