Commit dc209e1b authored by Clément Haëck's avatar Clément Haëck
Browse files

Overhaul get_data open_mf_kw

parent 0e5748b6
......@@ -27,8 +27,8 @@ def create_dataset(module: str, pregex_func: Callable,
Set various function in `module`.
See doc on datasets for more details.
"""
# Fixes and climato are default arguments names
args_names |= {'fixes', 'climato'}
# Fixes, climato and open_mf_kw are default arguments names
args_names |= {'fixes', 'climato', 'open_mf_kw'}
# Process arguments before feeding it to func
# See process_args below for details
......@@ -94,13 +94,21 @@ def create_dataset(module: str, pregex_func: Callable,
def get_data(args):
finder = get_finder(args)
# preprocess_finder is special case
# Copy open_mf arguments and update it with those found in args
# open_mf_kw should be left unchanged (so we can call get_data
# multiple times)
open_mf_kw_run = open_mf_kw.copy()
open_mf_kw_run.update(args.get('open_mf_kw', {}))
# Apply finder.get_func_process_filename
if 'preprocess_finder' in open_mf_kw:
# Some kwargs are not intented to open_mfdataset.
# preprocess_finder can be set to None dynamically if another
# preprocess function should superseed
if open_mf_kw.get('preprocess_finder', None) is not None:
pp_args = open_mf_kw.pop('preprocess_finder_args', [])
pp_kw = open_mf_kw.pop('preprocess_finder_kwargs', {})
open_mf_kw['preprocess'] = finder.get_func_process_filename(
open_mf_kw.pop('preprocess_finder', *pp_args, **pp_kw)
open_mf_kw.pop('preprocess_finder'), *pp_args, **pp_kw
)
if len(finder.files) == 0:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment