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

Draft for FESOM recipe #52

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
known_third_party =pandas,pangeo_forge,prefect,requests
known_third_party =pandas,pangeo_forge,pangeo_forge_recipes,prefect,requests
24 changes: 24 additions & 0 deletions recipes/FESOM/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
title: "SWOT-AdAC data (FESOM)"
description: "FESOM regional data for SWOT-AdAC Xovers"
pangeo_forge_version: "0.3.3"
pangeo_notebook_version: "2021.05.04"
recipes:
- dict_object: "recipe:recipes"
provenance:
providers:
- name: "AWI"
description: "AWI Helmholtz Centre for Polar and Marine Research"
roles:
- producer
- licensor
url: https://github.com/roxyboy/SWOT-AdAC-ocean-model-intercomparison
license: "CC-BY-NC-SA-4.0"
maintainers:
- name: "Nikolay Koldunov"
github: koldunovn
bakery:
id: "devseed.bakery.development.aws.us-west-2" # must come from a valid list of bakeries
target: pangeo-forge-aws-bakery-flowcachebucketpangeofor-196cpck7y0pbl
resources:
memory: 4096
cpu: 1024
45 changes: 45 additions & 0 deletions recipes/FESOM/recipe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from itertools import product

from pangeo_forge_recipes.patterns import ConcatDim, FilePattern, MergeDim
from pangeo_forge_recipes.recipes import XarrayZarrRecipe


def gen_url(time, variable):

base = "https://swift.dkrz.de/v1/dkrz_035d8f6ff058403bb42f8302e6badfbc/SWOT_intercomparison"

if int(time) <= 4: # fma/winter data was corrected
base = base + "2"

return base + f"/2012-{time}_{variable}_cubic.nc"


surf_ocean_vars = ["dflux", "ssh", "sss", "sst", "tx_sur", "ty_sur", "u_surf", "v_surf"]
int_ocean_vars = ["3D_" + var for var in ("salt", "temp", "u", "v", "w")]

var_dict = {
"surf": {"vars": surf_ocean_vars},
"int": {"vars": int_ocean_vars},
}


def create_recipe(datatype, season, vars=var_dict, url_func=gen_url):
"""
"""
merge_dim = MergeDim("variable", keys=vars[datatype]["vars"])

month_range = (2, 3, 4,) if season == "fma" else (8, 9, 10,)
months = [f"{m:02d}" for m in month_range]
concat_dim = ConcatDim("time", keys=months)

pattern = FilePattern(url_func, concat_dim, merge_dim)
chunks = {"time": 10}
return XarrayZarrRecipe(pattern, target_chunks=chunks, subset_inputs=chunks)


datatypes = list(var_dict)
seasons = ("fma", "aso")
recipes = {
f"FESOM/{datatype}/{season}": create_recipe(datatype=datatype, season=season)
for datatype, season in product(datatypes, seasons)
}