Skip to content

Commit

Permalink
add instantiate_recipe func
Browse files Browse the repository at this point in the history
  • Loading branch information
cisaacstern committed Jul 16, 2021
1 parent 1ebaa69 commit 0548f8b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions recipes/cesm-pop-lowres-1deg/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
from pangeo_forge_recipes.recipes import XarrayZarrRecipe


def make_full_path(variable, time):
def make_full_path(variable, time, api_params=""):
"""Returns a valid path to the source files
Parameters
----------
variable: str
A string representing each variable
"""
return (
f"https://tds.ucar.edu/thredds/fileServer/datazone/campaign/cesm/collections/ASD/"
f"v5_rel04_BC5_ne30_g16/ocn/proc/tseries/daily/v5_rel04_BC5_ne30_g16.pop.h.nday1."
f"{variable}.{time}.nc"
f"{variable}.{time}.nc{api_params}"
)


Expand All @@ -37,8 +33,12 @@ def make_full_path(variable, time):

merge_dim = MergeDim("variable", keys=vars)

pattern = FilePattern(make_full_path, concat_dim, merge_dim)

chunks = {"time": 200}

recipe = XarrayZarrRecipe(pattern, target_chunks=chunks)

def instantiate_recipe(api_params):

make_full_path.__defaults__ = (api_params,)
pattern = FilePattern(make_full_path, concat_dim, merge_dim)

return XarrayZarrRecipe(pattern, target_chunks=chunks)

0 comments on commit 0548f8b

Please sign in to comment.