Skip to content

Commit

Permalink
fix: attempt to fix zarr writing
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaransweet committed Feb 10, 2025
1 parent e7553b2 commit 516c845
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/hazard/models/degree_days.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def run_single(
pp = self._item_path(item)
logger.info(f"Writing array to {str(pp)}")
target.write(str(pp), average_deg_days)
pp = self._item_path(item)
pp_map = pp.with_name(pp.name + "_map")
self._generate_map(
str(pp),
Expand All @@ -196,7 +195,7 @@ def _generate_map(
target: ReadWriteDataArray,
):
logger.info(f"Generating map projection for file {path}; reading file")
da = target.read(path)
da = target.read(f"{path}/{PurePosixPath(path).name}")
logger.info("Reprojecting to EPSG:3857")
# reprojected = transform_epsg4326_to_epsg3857(average_deg_days.sel(latitude=slice(85, -85)))
reprojected = transform_epsg4326_to_epsg3857(da)
Expand Down
9 changes: 1 addition & 8 deletions src/hazard/sources/osc_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,8 @@ def write(
):
if self.write_xarray_compatible_zarr and spatial_coords:
pp = PurePosixPath(path)
da = da.copy()
da.name = pp.name
# if da.name != pp.name:
# raise ValueError(
# f"when writing NetCDF style coordinates, final element of path (here {pp.name}) must be \
# the same as the array name (here {da.name})"
# )
parent_path = pp.parent
self.write_data_array(str(parent_path), da)
self.write_data_array(str(pp), da)
else:
self.write_zarr(path, da, chunks)

Expand Down

0 comments on commit 516c845

Please sign in to comment.