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 INALT60 recipe #26

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
20 changes: 20 additions & 0 deletions recipes/INALT60/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
title: 'SWOT-AdAC data (INALT60)'
description: 'INALT60 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: 'GEOMAR'
description: 'GEOMAR Helmholtz Centre for Ocean Research Kiel'
roles:
- producer
- licensor
url: https://github.com/roxyboy/SWOT-AdAC-ocean-model-intercomparison
license: 'CC-BY-NC-SA-4.0'
maintainers:
- name: 'Charles Stern'
github: reneschubert
bakery:
id: 'pangeo-ldeo-nsf-earthcube'
51 changes: 51 additions & 0 deletions recipes/INALT60/recipe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from pangeo_forge_recipes.patterns import (
ConcatDim,
FilePattern,
MergeDim,
pattern_from_file_sequence,
)
from pangeo_forge_recipes.recipes import XarrayZarrRecipe

months = [f'{m:02d}' for m in (2, 3, 4, 8, 9, 10)]
concat_months = ConcatDim('time_counter', keys=months)


def gen_url(variable, time_counter, freq, dim):
base = (
'https://data.geomar.de/downloads/20.500.12085/'
'0e95d316-f1ba-47e3-b667-fc800afafe22/data/'
)
return base + f'INALT60_{freq}_{dim}_{variable}_{time_counter}.nc'


surf_ocean_vars = ['u', 'v', 'hts']

pattern_dict = {
'surf_ocean_4h': {'vars': surf_ocean_vars, 'args': ('4h', 'surface')},
'surf_ocean_5d': {'vars': surf_ocean_vars, 'args': ('5d', 'surface')},
'surf_flux_1d': {'vars': ['flux', 'taux', 'tauy'], 'args': ('1d', 'surface')},
'int_ocean_1d': {'vars': ['ts', 'u', 'v', 'w'], 'args': ('1d', 'upper1000m')},
}


def create_recipe(key, patterns=pattern_dict, url_func=gen_url, concat_dim=concat_months):
url_func.__defaults__ = patterns[key]['args']
merge_dim = MergeDim('variable', keys=patterns[key]['vars'])
pattern = FilePattern(url_func, merge_dim, concat_dim)
return XarrayZarrRecipe(pattern, target_chunks={'time_counter': 15})


recipes = {list(pattern_dict)[i]: create_recipe(list(pattern_dict)[i]) for i in range(4)}


def grid_recipe():
url = (
'https://data.geomar.de/downloads/20.500.12085/'
'0e95d316-f1ba-47e3-b667-fc800afafe22/data/'
'INALT60_mesh_mask.nc'
)
pattern = pattern_from_file_sequence([url], 'time_counter', 1)
return XarrayZarrRecipe(pattern)


recipes['grid'] = grid_recipe()