From 35d45a9b419fe1f09d40126bdf98baa45fc08015 Mon Sep 17 00:00:00 2001 From: Klaus Zimmermann Date: Tue, 1 Jun 2021 15:58:47 +0200 Subject: [PATCH] Pre-commit changes --- esmvalcore/preprocessor/_ancillary_vars.py | 84 ++++++++++++---------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/esmvalcore/preprocessor/_ancillary_vars.py b/esmvalcore/preprocessor/_ancillary_vars.py index 6ac632da46..0ba68bf4a4 100644 --- a/esmvalcore/preprocessor/_ancillary_vars.py +++ b/esmvalcore/preprocessor/_ancillary_vars.py @@ -1,13 +1,13 @@ """Preprocessor functions for ancillary variables and cell measures.""" import logging -import iris import dask.array as da +import iris -from esmvalcore.preprocessor._io import load, concatenate_callback, concatenate -from esmvalcore.cmor.fix import fix_metadata, fix_data -from esmvalcore.cmor.check import cmor_check_metadata, cmor_check_data +from esmvalcore.cmor.check import cmor_check_data, cmor_check_metadata +from esmvalcore.cmor.fix import fix_data, fix_metadata +from esmvalcore.preprocessor._io import concatenate, concatenate_callback, load logger = logging.getLogger(__name__) @@ -23,33 +23,47 @@ def _load_fx(fx_info, check_level, **extra_facets): dataset = fx_info['dataset'] mip = fx_info['mip'] freq = fx_info['frequency'] - loaded_cube = fix_metadata(loaded_cube, short_name=short_name, - project=project, dataset=dataset, - mip=mip, frequency=freq, - check_level=check_level, **extra_facets) + loaded_cube = fix_metadata(loaded_cube, + short_name=short_name, + project=project, + dataset=dataset, + mip=mip, + frequency=freq, + check_level=check_level, + **extra_facets) fx_cubes.append(loaded_cube[0]) fx_cube = concatenate(fx_cubes) - fx_cube = cmor_check_metadata(fx_cube, cmor_table=project, mip=mip, - short_name=short_name, frequency=freq, + fx_cube = cmor_check_metadata(fx_cube, + cmor_table=project, + mip=mip, + short_name=short_name, + frequency=freq, check_level=check_level) - fx_cube = fix_data(fx_cube, short_name=short_name, project=project, - dataset=dataset, mip=mip, frequency=freq, - check_level=check_level, **extra_facets) - - fx_cube = cmor_check_data(fx_cube, cmor_table=project, mip=mip, - short_name=fx_cube.var_name, frequency=freq, + fx_cube = fix_data(fx_cube, + short_name=short_name, + project=project, + dataset=dataset, + mip=mip, + frequency=freq, + check_level=check_level, + **extra_facets) + + fx_cube = cmor_check_data(fx_cube, + cmor_table=project, + mip=mip, + short_name=fx_cube.var_name, + frequency=freq, check_level=check_level) return fx_cube def add_cell_measure(cube, fx_cube, measure): - """ - Broadcast fx_cube and add it as a cell_measure in - the cube containing the data. + """Broadcast fx_cube and add it as a cell_measure in the cube containing + the data. Parameters ---------- @@ -81,22 +95,20 @@ def add_cell_measure(cube, fx_cube, measure): raise ValueError(f"Dimensions of {cube.var_name} and " f"{fx_cube.var_name} cubes do not match. " "Cannot broadcast cubes.") from exc - measure = iris.coords.CellMeasure( - fx_data, - standard_name=fx_cube.standard_name, - units=fx_cube.units, - measure=measure, - var_name=fx_cube.var_name, - attributes=fx_cube.attributes) + measure = iris.coords.CellMeasure(fx_data, + standard_name=fx_cube.standard_name, + units=fx_cube.units, + measure=measure, + var_name=fx_cube.var_name, + attributes=fx_cube.attributes) cube.add_cell_measure(measure, range(0, measure.ndim)) - logger.debug('Added %s as cell measure in cube of %s.', - fx_cube.var_name, cube.var_name) + logger.debug('Added %s as cell measure in cube of %s.', fx_cube.var_name, + cube.var_name) def add_ancillary_variable(cube, fx_cube): - """ - Broadcast fx_cube and add it as an ancillary_variable in - the cube containing the data. + """Broadcast fx_cube and add it as an ancillary_variable in the cube + containing the data. Parameters ---------- @@ -133,10 +145,9 @@ def add_ancillary_variable(cube, fx_cube): def add_fx_variables(cube, fx_variables, check_level, **extra_facets): - """ - Load requested fx files, check with CMOR standards and add the - fx variables as cell measures or ancillary variables in - the cube containing the data. + """Load requested fx files, check with CMOR standards and add the fx + variables as cell measures or ancillary variables in the cube containing + the data. Parameters ---------- @@ -178,8 +189,7 @@ def add_fx_variables(cube, fx_variables, check_level, **extra_facets): def remove_fx_variables(cube): - """ - Remove fx variables present as cell measures or ancillary variables in + """Remove fx variables present as cell measures or ancillary variables in the cube containing the data. Parameters