Skip to content

Commit

Permalink
change ref to datatree
Browse files Browse the repository at this point in the history
  • Loading branch information
giovp committed Oct 14, 2023
1 parent 172faf7 commit eebb006
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions multiscale_spatial_image/multiscale_spatial_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MultiscaleSpatialImage:
"""

def __init__(self, xarray_obj: DataTree):
self._obj = xarray_obj
self._dt = xarray_obj

def to_zarr(
self,
Expand Down Expand Up @@ -59,11 +59,11 @@ def to_zarr(
"""

multiscales = []
scale0 = self._obj[self._obj.groups[1]]
scale0 = self._dt[self._dt.groups[1]]
for name in scale0.ds.data_vars.keys():
ngff_datasets = []
for child in self._obj.children:
image = self._obj[child].ds
for child in self._dt.children:
image = self._dt[child].ds
scale_transform = []
translate_transform = []
for dim in image.dims:
Expand All @@ -84,7 +84,7 @@ def to_zarr(

ngff_datasets.append(
{
"path": f"{self._obj[child].name}/{name}",
"path": f"{self._dt[child].name}/{name}",
"coordinateTransformations": [
{
"type": "scale",
Expand Down Expand Up @@ -122,6 +122,6 @@ def to_zarr(

# NGFF v0.4 metadata
ngff_metadata = {"multiscales": multiscales, "multiscaleSpatialImageVersion": 1}
self._obj.ds = self._obj.ds.assign_attrs(**ngff_metadata)
self._dt.ds = self._dt.ds.assign_attrs(**ngff_metadata)

self._obj.to_zarr(store, **kwargs)
self._dt.to_zarr(store, **kwargs)

0 comments on commit eebb006

Please sign in to comment.