Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make weights_pyramid_path optional for pyramid task #238

Merged
merged 1 commit into from
Jun 24, 2022
Merged
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
8 changes: 5 additions & 3 deletions cmip6_downscaling/methods/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from dataclasses import asdict
from pathlib import PosixPath

import datatree
import datatree as dt
import fsspec
import pandas as pd
Expand Down Expand Up @@ -509,7 +508,7 @@ def _pyramid_postprocess(dt: dt.DataTree, levels: int, other_chunks: dict = None

@task(log_stdout=True)
def pyramid(
ds_path: UPath, weights_pyramid_path: str, levels: int = 2, other_chunks: dict = None
ds_path: UPath, weights_pyramid_path: str = None, levels: int = 2, other_chunks: dict = None
) -> UPath:
'''Task to create a data pyramid from an xarray Dataset

Expand Down Expand Up @@ -544,7 +543,10 @@ def pyramid(

ds.attrs.update({'title': ds.attrs['title']}, **get_cf_global_attrs(version=version))
target_pyramid = dt.open_datatree('az://static/target-pyramid', engine='zarr')
weights_pyramid = datatree.open_datatree(weights_pyramid_path, engine='zarr')
if weights_pyramid_path is not None:
weights_pyramid = dt.open_datatree(weights_pyramid_path, engine='zarr')
else:
weights_pyramid = None
# create pyramid
dta = pyramid_regrid(
ds,
Expand Down