From 65617ece09b00ba9fe28fb6498ead9677769aff5 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 17 Sep 2024 15:03:11 +0100 Subject: [PATCH 1/5] plop a few str --- esmvalcore/preprocessor/_io.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esmvalcore/preprocessor/_io.py b/esmvalcore/preprocessor/_io.py index 900d026943..e8fa8ef508 100644 --- a/esmvalcore/preprocessor/_io.py +++ b/esmvalcore/preprocessor/_io.py @@ -401,11 +401,11 @@ def save(cubes, and all(cube.has_lazy_data() for cube in cubes)): logger.debug( "Not saving cubes %s to %s to avoid data loss. " - "The cube is probably unchanged.", cubes, filename) + "The cube is probably unchanged.", str(cubes), filename) return filename for cube in cubes: - logger.debug("Saving cube:\n%s\nwith %s data to %s", cube, + logger.debug("Saving cube:\n%s\nwith %s data to %s", str(cube), "lazy" if cube.has_lazy_data() else "realized", filename) if optimize_access: cube = cubes[0] From f905f39147eb61496a0433c34280ae681fea58cb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:12:41 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .editorconfig | 1 - .github/CODEOWNERS | 1 - CITATION.cff | 2 +- NOTICE | 2 - doc/contributing.rst | 22 ++++---- doc/quickstart/install.rst | 2 +- doc/quickstart/run.rst | 2 +- doc/recipe/index.rst | 2 +- esmvalcore/_citation.py | 9 ++- esmvalcore/_main.py | 7 ++- esmvalcore/_recipe/recipe.py | 14 +++-- esmvalcore/cmor/_fixes/__init__.py | 7 +-- esmvalcore/cmor/_fixes/cesm/cesm2.py | 2 - esmvalcore/cmor/_fixes/cmip5/access1_0.py | 4 +- esmvalcore/cmor/_fixes/cmip5/access1_3.py | 2 - esmvalcore/cmor/_fixes/cmip5/bnu_esm.py | 36 +++--------- esmvalcore/cmor/_fixes/cmip5/canesm2.py | 5 +- esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py | 2 - esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py | 4 +- .../cmor/_fixes/cmip5/cesm1_fastchem.py | 1 - esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py | 1 - esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py | 5 +- esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py | 1 - esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py | 1 - esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py | 1 - esmvalcore/cmor/_fixes/cmip5/fio_esm.py | 10 +--- esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py | 19 ++----- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py | 16 ++---- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py | 21 ++----- esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py | 1 - esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py | 1 - esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py | 5 +- esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py | 2 - esmvalcore/cmor/_fixes/cmip5/inmcm4.py | 17 ++---- esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py | 1 - esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py | 1 - esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py | 1 - esmvalcore/cmor/_fixes/cmip5/miroc5.py | 18 ++---- esmvalcore/cmor/_fixes/cmip5/miroc_esm.py | 12 +--- .../cmor/_fixes/cmip5/miroc_esm_chem.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py | 1 - esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py | 1 - esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py | 9 +-- esmvalcore/cmor/_fixes/cmip5/mri_esm1.py | 5 +- esmvalcore/cmor/_fixes/cmip5/noresm1_m.py | 1 - esmvalcore/cmor/_fixes/cmip5/noresm1_me.py | 2 - esmvalcore/cmor/_fixes/cmip6/access_cm2.py | 1 - esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py | 1 - esmvalcore/cmor/_fixes/cmip6/canesm5.py | 2 - esmvalcore/cmor/_fixes/cmip6/cesm2.py | 18 ++---- esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py | 3 +- esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py | 1 - .../cmor/_fixes/cmip6/cesm2_waccm_fv2.py | 5 +- esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py | 1 - esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py | 1 - esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py | 1 - .../cmor/_fixes/cmip6/ec_earth3_veg_lr.py | 1 - esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py | 9 +-- esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py | 9 +-- esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py | 1 - .../cmor/_fixes/cmip6/hadgem3_gc31_ll.py | 1 - .../cmor/_fixes/cmip6/ipsl_cm5a2_inca.py | 1 - esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py | 5 +- .../cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py | 1 - esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py | 4 -- esmvalcore/cmor/_fixes/cmip6/miroc6.py | 4 +- esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py | 1 - esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py | 4 +- esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py | 1 - esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py | 2 - esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py | 1 - .../cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py | 4 +- .../cordex/ichec_ec_earth/cclm4_8_17.py | 4 +- .../cordex/ichec_ec_earth/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ichec_ec_earth/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ichec_ec_earth/rca4.py | 3 +- .../_fixes/cordex/ichec_ec_earth/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/cclm4_8_17.py | 4 +- .../_fixes/cordex/miroc_miroc5/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/wrf361h.py | 2 +- .../cordex/mohc_hadgem2_es/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/mohc_hadgem2_es/hirham5.py | 1 - .../_fixes/cordex/mohc_hadgem2_es/rca4.py | 3 +- .../_fixes/cordex/mohc_hadgem2_es/remo2015.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py | 4 +- .../cordex/mpi_m_mpi_esm_lr/racmo22e.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/regcm4_6.py | 3 +- .../cordex/ncc_noresm1_m/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ncc_noresm1_m/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ncc_noresm1_m/rca4.py | 3 +- .../_fixes/cordex/ncc_noresm1_m/remo2015.py | 3 +- esmvalcore/cmor/_fixes/emac/emac.py | 3 - esmvalcore/cmor/_fixes/fix.py | 14 ++--- esmvalcore/cmor/_fixes/icon/_base_fixes.py | 15 ++--- esmvalcore/cmor/_fixes/icon/icon.py | 1 - esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py | 12 ++-- esmvalcore/cmor/_fixes/native6/era5_land.py | 11 ++-- esmvalcore/cmor/_fixes/native_datasets.py | 13 ----- esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py | 1 - esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py | 4 +- esmvalcore/cmor/_fixes/obs4mips/ssmi.py | 1 - esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py | 5 +- esmvalcore/cmor/_fixes/shared.py | 2 - esmvalcore/cmor/_utils.py | 3 - esmvalcore/cmor/check.py | 5 -- esmvalcore/cmor/fix.py | 3 - esmvalcore/cmor/table.py | 56 +++++++++---------- esmvalcore/config/__init__.py | 1 - esmvalcore/config/_config_object.py | 3 - esmvalcore/config/_esgf_pyclient.py | 2 +- esmvalcore/config/_validated_config.py | 5 +- .../config/extra_facets/access-mappings.yml | 34 +++++------ esmvalcore/dataset.py | 3 +- esmvalcore/iris_helpers.py | 6 -- esmvalcore/preprocessor/__init__.py | 4 +- esmvalcore/preprocessor/_area.py | 8 --- esmvalcore/preprocessor/_compare_with_refs.py | 2 - esmvalcore/preprocessor/_cycles.py | 1 - esmvalcore/preprocessor/_derive/_baseclass.py | 2 - esmvalcore/preprocessor/_derive/_shared.py | 3 - esmvalcore/preprocessor/_derive/alb.py | 1 - esmvalcore/preprocessor/_derive/ctotal.py | 1 - esmvalcore/preprocessor/_derive/lvp.py | 1 - esmvalcore/preprocessor/_derive/lwp.py | 1 - esmvalcore/preprocessor/_derive/ohc.py | 6 +- esmvalcore/preprocessor/_derive/rlnst.py | 8 +-- esmvalcore/preprocessor/_derive/rlnstcs.py | 8 +-- esmvalcore/preprocessor/_derive/rlus.py | 1 - esmvalcore/preprocessor/_derive/rsnst.py | 1 - esmvalcore/preprocessor/_derive/rsnstcs.py | 1 - .../preprocessor/_derive/rsnstcsnorm.py | 10 ++-- esmvalcore/preprocessor/_derive/rsus.py | 1 - esmvalcore/preprocessor/_derive/siextent.py | 1 + esmvalcore/preprocessor/_derive/sispeed.py | 6 +- esmvalcore/preprocessor/_derive/sithick.py | 4 +- esmvalcore/preprocessor/_derive/sm.py | 1 - esmvalcore/preprocessor/_derive/toz.py | 1 - esmvalcore/preprocessor/_detrend.py | 3 +- esmvalcore/preprocessor/_mapping.py | 33 +++++------ esmvalcore/preprocessor/_multimodel.py | 25 ++++----- esmvalcore/preprocessor/_other.py | 15 ++--- esmvalcore/preprocessor/_regrid.py | 4 +- esmvalcore/preprocessor/_regrid_esmpy.py | 11 +--- .../preprocessor/_regrid_unstructured.py | 16 ++---- esmvalcore/preprocessor/_rolling_window.py | 1 - esmvalcore/preprocessor/_shared.py | 17 ++---- esmvalcore/preprocessor/_time.py | 22 -------- esmvalcore/preprocessor/_trend.py | 2 - esmvalcore/preprocessor/_units.py | 1 - esmvalcore/preprocessor/_volume.py | 7 --- esmvalcore/preprocessor/shapefiles/ar6.prj | 2 +- esmvalcore/typing.py | 4 +- .../cmor/_fixes/cmip5/test_bnu_esm.py | 2 +- .../cmor/_fixes/cmip5/test_cnrm_cm5.py | 4 +- .../cmor/_fixes/cmip5/test_ec_earth.py | 10 ++-- .../cmor/_fixes/cmip5/test_fio_esm.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_cm2p1.py | 6 +- .../cmor/_fixes/cmip5/test_gfdl_cm3.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_esm2g.py | 8 +-- .../cmor/_fixes/cmip5/test_gfdl_esm2m.py | 6 +- .../cmor/_fixes/cmip5/test_hadgem2_cc.py | 4 +- .../cmor/_fixes/cmip5/test_miroc_esm_chem.py | 2 +- .../cmor/_fixes/cmip5/test_mri_esm1.py | 2 +- .../cmor/_fixes/cmip5/test_noresm1_me.py | 2 +- .../cmor/_fixes/cmip6/test_gfdl_cm4.py | 4 +- .../cordex/test_cnrm_cerfacs_cnrm_cm5.py | 3 +- .../cmor/_fixes/cordex/test_miroc_miroc5.py | 2 +- tests/integration/cmor/_fixes/test_fix.py | 4 +- .../cmor/_fixes/test_native_datasets.py | 1 - tests/integration/conftest.py | 6 +- tests/integration/data_finder.yml | 6 +- .../_extract_region/test_intersect.py | 6 +- .../preprocessor/_mask/__init__.py | 3 +- .../preprocessor/_regrid/__init__.py | 5 +- .../_regrid/test_extract_coordinate_points.py | 21 +++---- .../_regrid/test_extract_point.py | 21 +++---- .../_regrid/test_get_cmor_levels.py | 6 +- .../preprocessor/_regrid/test_regrid.py | 7 +-- .../_regrid/test_regrid_unstructured.py | 2 +- .../_supplementary_vars/test_register.py | 2 +- tests/integration/test_citation.py | 7 ++- tests/parse_pymon.py | 6 +- .../multimodel_statistics/test_multimodel.py | 10 ---- tests/unit/cmor/test_cmor_check.py | 54 +++++++++--------- tests/unit/preprocessor/_derive/test_toz.py | 1 + .../preprocessor/_detrend/test_detrend.py | 3 +- .../preprocessor/_mapping/test_mapping.py | 7 ++- tests/unit/preprocessor/_regrid/__init__.py | 16 ++---- .../preprocessor/_regrid/test__create_cube.py | 7 +-- .../preprocessor/_regrid/test__stock_cube.py | 7 +-- .../test_regrid_iris_esmf_regrid.py | 2 +- .../unit/preprocessor/_volume/test_volume.py | 11 ++-- tests/unit/test_dataset.py | 7 ++- tests/unit/test_iris_io.py | 6 +- tests/unit/test_naming.py | 16 +++--- 196 files changed, 391 insertions(+), 794 deletions(-) diff --git a/.editorconfig b/.editorconfig index 97c8ef6e5a..ddab414f89 100644 --- a/.editorconfig +++ b/.editorconfig @@ -27,4 +27,3 @@ indent_size = 2 [*.{md,Rmd}] trim_trailing_whitespace = false - diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1c8122dcbe..eba6cf5dd4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,2 @@ esmvalcore/cmor @jvegasbsc .github/workflows @valeriupredoi - diff --git a/CITATION.cff b/CITATION.cff index 51f53cfb36..4d3da6e4c7 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -208,7 +208,7 @@ authors: affiliation: "DLR, Germany" family-names: Cammarano given-names: Diego - - + - affiliation: "ACCESS-NRI, Australia" family-names: Yousong given-names: Zeng diff --git a/NOTICE b/NOTICE index 5bf9f5d0cd..5e413cd5ba 100644 --- a/NOTICE +++ b/NOTICE @@ -50,5 +50,3 @@ In addition to using the Software, we encourage the community to join the Softwa To join the ESMValTool Development Team, please contact Dr. Birgit Hassler (birgit.hassler@dlr.de) and Dr. Axel Lauer (axel.lauer@dlr.de). ========================================== - - diff --git a/doc/contributing.rst b/doc/contributing.rst index 814ab79263..658306a53b 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -743,15 +743,15 @@ Perform the steps listed below with two persons, to reduce the risk of error. `PyPI `__, and `readthedocs `__. -The release of ESMValCore is tied to the release of ESMValTool. +The release of ESMValCore is tied to the release of ESMValTool. The detailed steps can be found in the ESMValTool :ref:`documentation `. -To start the procedure, ESMValCore gets released as a +To start the procedure, ESMValCore gets released as a release candidate to test the recipes in ESMValTool. If bugs are found -during the testing phase of the release candidate, make as many release -candidates for ESMValCore as needed in order to fix them. +during the testing phase of the release candidate, make as many release +candidates for ESMValCore as needed in order to fix them. -To make a new release of the package, be it a release candidate or the final release, +To make a new release of the package, be it a release candidate or the final release, follow these steps: 1. Check that all tests and builds work @@ -795,13 +795,13 @@ Use the script to create create a draft of the release notes. This script uses the titles and labels of merged pull requests since the previous release. -Open a discussion to allow members of the development team to nominate pull -requests as highlights. Add the most voted pull requests as highlights at the -beginning of changelog. After the highlights section, list any backward -incompatible changes that the release may include. The +Open a discussion to allow members of the development team to nominate pull +requests as highlights. Add the most voted pull requests as highlights at the +beginning of changelog. After the highlights section, list any backward +incompatible changes that the release may include. The :ref:`backward compatibility policy`. -lists the information that should be provided by the developer of any backward -incompatible change. Make sure to also list any deprecations that the release +lists the information that should be provided by the developer of any backward +incompatible change. Make sure to also list any deprecations that the release may include, as well as a brief description on how to upgrade a deprecated feature. Review the results, and if anything needs changing, change it on GitHub and re-run the script until the changelog looks acceptable. diff --git a/doc/quickstart/install.rst b/doc/quickstart/install.rst index 7ef5015fe3..804c86ed20 100644 --- a/doc/quickstart/install.rst +++ b/doc/quickstart/install.rst @@ -201,7 +201,7 @@ Pre-installed versions on HPC clusters / other servers If you would like to use pre-installed versions on HPC clusters (currently CEDA-JASMIN and DKRZ-Levante), -and other servers (currently Met Office Linux estate), please have a look at +and other servers (currently Met Office Linux estate), please have a look at :ref:`these instructions `. diff --git a/doc/quickstart/run.rst b/doc/quickstart/run.rst index ebde6d4075..5eca15e714 100644 --- a/doc/quickstart/run.rst +++ b/doc/quickstart/run.rst @@ -79,7 +79,7 @@ This feature is available for projects that are hosted on the ESGF, i.e. CMIP3, CMIP5, CMIP6, CORDEX, and obs4MIPs. To control the strictness of the CMOR checker and the checks during concatenation -on auxiliary coordinates, supplementary variables, and derived coordinates, +on auxiliary coordinates, supplementary variables, and derived coordinates, use the flag ``--check_level``: .. code:: bash diff --git a/doc/recipe/index.rst b/doc/recipe/index.rst index 98c3f6c237..525b0467e1 100644 --- a/doc/recipe/index.rst +++ b/doc/recipe/index.rst @@ -8,4 +8,4 @@ The recipe format Overview Preprocessor - \ No newline at end of file + diff --git a/esmvalcore/_citation.py b/esmvalcore/_citation.py index 510aa8cb42..94ff97ad15 100644 --- a/esmvalcore/_citation.py +++ b/esmvalcore/_citation.py @@ -38,8 +38,7 @@ def _write_citation_files(filename, provenance): - """ - Write citation information provided by the recorded provenance. + """Write citation information provided by the recorded provenance. Recipe and cmip6 data references are saved into one bibtex file. cmip6 data references are provided by CMIP6 data citation service. @@ -135,9 +134,9 @@ def _save_citation_info_txt(product_name, info_urls, other_info): def _extract_tags(tags): """Extract tags. - Tags are recorded as a list of strings converted to a string in provenance. - For example, a single entry in the list `tags` could be the string - "['acknow_project', 'acknow_author']". + Tags are recorded as a list of strings converted to a string in + provenance. For example, a single entry in the list `tags` could be + the string "['acknow_project', 'acknow_author']". """ pattern = re.compile(r'[\w-]+') return set(pattern.findall(str(tags))) diff --git a/esmvalcore/_main.py b/esmvalcore/_main.py index 75c0b20c94..84dc5a35b0 100755 --- a/esmvalcore/_main.py +++ b/esmvalcore/_main.py @@ -206,8 +206,8 @@ def get_config_developer(cls, overwrite=False, path=None): class Recipes(): """List, show and retrieve installed recipes. - This group contains utilities to explore and manage the recipes available - in your installation of ESMValTool. + This group contains utilities to explore and manage the recipes + available in your installation of ESMValTool. Documentation for recipes included with ESMValTool is available at https://docs.esmvaltool.org/en/latest/recipes/index.html. @@ -294,7 +294,8 @@ class ESMValTool(): multiple models, either against predecessor versions or against observations. - Documentation is available at https://docs.esmvaltool.org. + Documentation is available at + https://docs.esmvaltool.org. To report issues or ask for improvements, please visit https://github.com/ESMValGroup/ESMValTool. diff --git a/esmvalcore/_recipe/recipe.py b/esmvalcore/_recipe/recipe.py index 1f2eb63488..5633ab0e57 100644 --- a/esmvalcore/_recipe/recipe.py +++ b/esmvalcore/_recipe/recipe.py @@ -399,12 +399,14 @@ def _update_multiproduct(input_products, order, preproc_dir, step): """Return new products that are aggregated over multiple datasets. These new products will replace the original products at runtime. - Therefore, they need to have all the settings for the remaining steps. - - The functions in _multimodel.py take output_products as function arguments. - These are the output_products created here. But since those functions are - called from the input products, the products that are created here need to - be added to their ancestors products' settings (). + Therefore, they need to have all the settings for the remaining + steps. + + The functions in _multimodel.py take output_products as function + arguments. These are the output_products created here. But since + those functions are called from the input products, the products + that are created here need to be added to their ancestors products' + settings (). """ products = {p for p in input_products if step in p.settings} if not products: diff --git a/esmvalcore/cmor/_fixes/__init__.py b/esmvalcore/cmor/_fixes/__init__.py index e50e749659..d9e50af443 100644 --- a/esmvalcore/cmor/_fixes/__init__.py +++ b/esmvalcore/cmor/_fixes/__init__.py @@ -1,6 +1,5 @@ -""" -Automatic fixes for input data +"""Automatic fixes for input data. -Module to apply automatic fixes at different levels to input data for known -errors. +Module to apply automatic fixes at different levels to input data for +known errors. """ diff --git a/esmvalcore/cmor/_fixes/cesm/cesm2.py b/esmvalcore/cmor/_fixes/cesm/cesm2.py index 5b92121555..ada216007a 100644 --- a/esmvalcore/cmor/_fixes/cesm/cesm2.py +++ b/esmvalcore/cmor/_fixes/cesm/cesm2.py @@ -12,7 +12,6 @@ (esmvalcore/_config/extra_facets/cesm-mappings.yml) and/or add classes to this file for variables that need more complex fixes (see esmvalcore/cmor/_fixes/emac/emac.py for examples). - """ import logging @@ -64,7 +63,6 @@ def _fix_time(self, cube): Example of monthly time coordinate after this fix (Jan. & Feb. 2000): Points: ``[2000-01-15, 2000-02-14]`` Bounds: ``[[2000-01-01, 2000-02-01], [2000-02-01, 2000-03-01]]`` - """ # Only modify time points if data contains a time dimension, is monthly # data, and does not describe point measurements. diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_0.py b/esmvalcore/cmor/_fixes/cmip5/access1_0.py index 4fa4da7554..eebc2fa616 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_0.py @@ -10,8 +10,7 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong calendar 'gregorian' instead of 'proleptic_gregorian'. @@ -23,7 +22,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_3.py b/esmvalcore/cmor/_fixes/cmip5/access1_3.py index f026181660..6f581197ff 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_3.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_3.py @@ -5,7 +5,6 @@ from ..fix import Fix from .access1_0 import Cl as BaseCl - Cl = BaseCl @@ -25,7 +24,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py index e01639a306..0198d08dda 100644 --- a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py @@ -10,8 +10,7 @@ class Cl(ClFixHybridPressureCoord): """Fixes for cl.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +22,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -35,8 +33,7 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -48,14 +45,12 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = Unit('kg m-2 s-1') return cubes def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes cube units. @@ -67,7 +62,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 12.0 / 44.0 @@ -79,8 +73,7 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -92,14 +85,12 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = Unit('1e-9') return cubes def fix_data(self, cube): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -112,7 +103,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29.0 / 16.0 * 1.e9 @@ -124,8 +114,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -137,14 +126,12 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = Unit('1e-6') return cubes def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes cube units. @@ -156,7 +143,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29.0 / 44.0 * 1.e6 @@ -168,8 +154,7 @@ class SpCo2(Fix): """Fixes for spco2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes cube units. @@ -181,7 +166,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1.e6 @@ -193,8 +177,7 @@ class Od550Aer(Fix): """Fixes for od550aer.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Masks invalid values. @@ -206,7 +189,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ data = da.ma.masked_equal(cube.core_data(), 1.e36) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/canesm2.py b/esmvalcore/cmor/_fixes/cmip5/canesm2.py index b445a4dc3a..e780f3e592 100644 --- a/esmvalcore/cmor/_fixes/cmip5/canesm2.py +++ b/esmvalcore/cmor/_fixes/cmip5/canesm2.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -10,8 +9,7 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +21,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 12.0 / 44.0 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py index 2e25296b8d..fe5dfbefa4 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py @@ -5,7 +5,6 @@ from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl @@ -24,7 +23,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ data = da.ma.masked_equal(cube.core_data(), 1.0e33) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py index 4c235dfcbc..ae30726e2b 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py @@ -7,8 +7,7 @@ class Cl(Fix): """Fixes for cl.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -20,7 +19,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py index d5ba1f7641..319b96d261 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py @@ -2,5 +2,4 @@ from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py index 818d14e4c2..86c5cbd349 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py @@ -2,5 +2,4 @@ from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py index 71e6547461..a5c5bcb017 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py @@ -1,4 +1,3 @@ - """Fixes for CNRM-CM5 model.""" from ..fix import Fix @@ -7,8 +6,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -19,7 +17,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1e6 diff --git a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py index 4c0a5a7564..846859c6b4 100644 --- a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py @@ -1,5 +1,4 @@ """Fixes for CSIRO-Mk3-6-0 model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py index 1c2df64db0..0067b9f172 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py @@ -23,7 +23,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py index c82151226f..c1b3962abd 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py @@ -20,7 +20,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py index cc9ed79421..4935a56f92 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py @@ -1,9 +1,7 @@ - """Fixes for FIO ESM model.""" from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl @@ -11,8 +9,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +20,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29. / 44. * 1.e6 @@ -35,8 +31,7 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -47,7 +42,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29. / 16. * 1.e9 diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py index bc1b3cf9b6..6104efdaaf 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py @@ -1,7 +1,6 @@ """Fixes for GFDL CM3 model.""" -from ..fix import Fix - from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars +from ..fix import Fix class AllVars(BaseAllVars): @@ -9,11 +8,10 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong units. @@ -24,7 +22,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -35,8 +32,7 @@ class Sftof(Fix): """Fix sftof.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units. @@ -47,7 +43,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -56,11 +51,10 @@ def fix_data(self, cube): class Tos(Fix): - """Fixes for tos""" + """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong standard_name. @@ -71,7 +65,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py index 3ba4a6dd83..1620f95b29 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py @@ -1,4 +1,3 @@ - """Fixes for GFDL ESM2G.""" import iris @@ -29,7 +28,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ _get_and_remove(cubes, 'Start time for average period') _get_and_remove(cubes, 'End time for average period') @@ -38,11 +36,10 @@ def fix_metadata(self, cubes): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong units. @@ -53,7 +50,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -75,7 +71,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1e6 @@ -98,7 +93,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ _get_and_remove(cubes, 'Latitude of tracer (h) points') _get_and_remove(cubes, 'Longitude of tracer (h) points') @@ -109,8 +103,7 @@ class Usi(Fix): """Fixes for usi.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes bad standard_name @@ -130,8 +123,7 @@ class Vsi(Fix): """Fixes for vsi.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes bad standard_name diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py index 7722118e48..0e626d80de 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py @@ -1,8 +1,7 @@ - """Fixes for GFDL ESM2M.""" -from ..fix import Fix from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars +from ..fix import Fix class AllVars(BaseAllVars): @@ -10,11 +9,10 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong units. @@ -25,7 +23,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -36,8 +33,7 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -48,7 +44,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -60,8 +55,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -72,7 +66,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1e6 @@ -84,8 +77,7 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong standard_name. @@ -96,7 +88,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py index 5ee8c8aff1..9dc63cb128 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py @@ -1,5 +1,4 @@ """Fixes for GISS-E2-H.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py index 0d538e7960..3d4cd617d8 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py @@ -1,5 +1,4 @@ """Fixes for GISS-E2-R.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py index 3531f78f06..e48ba4ade9 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py @@ -2,7 +2,6 @@ from ..fix import Fix from .hadgem2_es import AllVars as BaseAllVars - AllVars = BaseAllVars @@ -10,8 +9,7 @@ class O2(Fix): """Fixes for o2.""" def fix_metadata(self, cubes): - """ - Fix standard and long names. + """Fix standard and long names. Parameters ---------- @@ -20,7 +18,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py index f7360dae2b..1f9e81aa86 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py @@ -19,7 +19,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: lats = cube.coords('latitude') @@ -50,7 +49,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py index e89cea019d..d90c606b40 100644 --- a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py +++ b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py @@ -4,7 +4,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -12,8 +11,7 @@ class Gpp(Fix): """Fixes for gpp.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -25,7 +23,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= -1 @@ -37,8 +34,7 @@ class Lai(Fix): """Fixes for lai.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -50,7 +46,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 0.01 @@ -62,8 +57,7 @@ class Nbp(Fix): """Fixes for nbp.""" def fix_metadata(self, cubes): - """ - Fix missing scalar dimension. + """Fix missing scalar dimension. Parameters ---------- @@ -73,7 +67,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cubes[0].standard_name = ( 'surface_net_downward_mass_flux_of_carbon_dioxide_expressed_as_' @@ -86,8 +79,7 @@ class BaresoilFrac(Fix): """Fixes for baresoilFrac.""" def fix_metadata(self, cubes): - """ - Fix missing scalar dimension. + """Fix missing scalar dimension. Parameters ---------- @@ -97,7 +89,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ typebare = iris.coords.AuxCoord( 'bare_ground', diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py index 894af45317..5dfcb15ce2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py @@ -1,5 +1,4 @@ """Fixes for IPSL-CM5A-LR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py index 893b9779c2..98fab8515f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py @@ -1,5 +1,4 @@ """Fixes for IPSL-CM5A-MR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py index 03bed332d6..271f48728e 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py @@ -1,5 +1,4 @@ """Fixes for IPSL-CM5B-LR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc5.py b/esmvalcore/cmor/_fixes/cmip5/miroc5.py index ec0e009402..c2e1e253a2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc5.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc5.py @@ -5,7 +5,6 @@ from ..fix import Fix from ..shared import round_coordinates - Cl = ClFixHybridPressureCoord @@ -13,8 +12,7 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -26,7 +24,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -38,8 +35,7 @@ class Snw(Fix): """Fixes for snw.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -51,7 +47,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -96,8 +91,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes mask @@ -109,7 +103,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -133,7 +126,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ return round_coordinates(cubes) @@ -146,8 +138,7 @@ class Tos(Fix): """Fixes for tos.""" def fix_data(self, cube): - """ - Fix tos data. + """Fix tos data. Fixes mask @@ -159,7 +150,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py index fc94bc45cc..de93a2bf4e 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py @@ -15,8 +15,7 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -28,7 +27,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1000 @@ -40,8 +38,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes error in cube units @@ -53,7 +50,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = '1.0e-6' return cubes @@ -63,8 +59,7 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes error in air_pressure coordinate, sometimes called AR5PL35, and error in time coordinate. @@ -77,7 +72,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: # Fix air_pressure diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py index 83d6e28f20..400a7c0355 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py @@ -1,4 +1,3 @@ - """Fixes for MIROC ESM CHEM model.""" from ..fix import Fix @@ -7,8 +6,7 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -19,7 +17,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1000 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py index a24aebd499..e70672c4bf 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -10,8 +9,7 @@ class Pctisccp(Fix): """Fixes for pctisccp.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +21,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py index 92b1a6a06b..28317e6958 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py @@ -1,5 +1,4 @@ """Fixes for MPI-ESM-MR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py index 303e1b0fd1..0a04fd0bf0 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py @@ -1,5 +1,4 @@ """Fixes for MPI-ESM-P model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py index a21b82eb7f..55e3a20345 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py @@ -4,7 +4,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -12,8 +11,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix msftmyz data. + """Fix msftmyz data. Fixes mask @@ -25,7 +23,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -35,8 +32,7 @@ class ThetaO(Fix): """Fixes for thetao.""" def fix_data(self, cube): - """ - Fix thetao data. + """Fix thetao data. Fixes mask @@ -48,7 +44,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py index 694e4cc33f..8fbc47ce24 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py @@ -1,4 +1,3 @@ - """Fixes for MRI-ESM1 model.""" from dask import array as da @@ -9,8 +8,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix msftmyz data. + """Fix msftmyz data. Fixes mask @@ -21,7 +19,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py index 703ef054d7..e52f4a2f3d 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py @@ -1,5 +1,4 @@ """Fixes for NorESM1-M.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py index 08fe028419..beb6cc3f41 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py @@ -20,7 +20,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ return round_coordinates(cubes, 12, coord_names=['latitude']) @@ -42,6 +41,5 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ return round_coordinates(cubes, 12) diff --git a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py index 7627e9b3a4..ab5b5109d6 100644 --- a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py @@ -18,7 +18,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py index 59f09bcd28..e1688bdc58 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py @@ -1,7 +1,6 @@ """Fixes for CAMS-CSM1-0 model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/canesm5.py b/esmvalcore/cmor/_fixes/cmip6/canesm5.py index d4cdbc95e1..23f004042b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/canesm5.py +++ b/esmvalcore/cmor/_fixes/cmip6/canesm5.py @@ -18,7 +18,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1.e-6 @@ -40,7 +39,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.0) return cube diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2.py index 6ded187fbb..ea816506cc 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2.py @@ -61,7 +61,6 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. - """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix @@ -117,7 +116,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -128,8 +126,8 @@ class Prw(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """ - Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. + """Fix latitude_bounds and longitude_bounds data type and round to 4 + d.p. Parameters ---------- @@ -139,7 +137,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: for coord_name in ['latitude', 'longitude']: @@ -156,8 +153,7 @@ class Tas(Prw): """Fixes for tas.""" def fix_metadata(self, cubes): - """ - Add height (2m) coordinate. + """Add height (2m) coordinate. Fix also done for prw. Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. @@ -170,7 +166,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ super().fix_metadata(cubes) # Specific code for tas @@ -194,7 +189,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_typeland_coord(cube) @@ -215,7 +209,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_typesea_coord(cube) @@ -229,8 +222,7 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Round times to 1 d.p. for monthly means. + """Round times to 1 d.p. for monthly means. Required to get hist-GHG and ssp245-GHG Omon tos to concatenate. @@ -242,7 +234,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) @@ -267,7 +258,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py index 0783c125fe..d6abd98fc5 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py @@ -1,10 +1,9 @@ """Fixes for CESM2-FV2 model.""" +from ..common import SiconcFixScalarCoord from .cesm2 import Cl as BaseCl from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon from .cesm2 import Tas as BaseTas -from ..common import SiconcFixScalarCoord - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py index f7263a00dd..134bf8878b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py @@ -36,7 +36,6 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. - """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py index 89c55b3b10..7dc4e79a9e 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py @@ -1,12 +1,11 @@ """Fixes for CESM2-WACCM-FV2 model.""" -from .cesm2 import Tas as BaseTas +from ..common import SiconcFixScalarCoord from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon +from .cesm2 import Tas as BaseTas from .cesm2_waccm import Cl as BaseCl from .cesm2_waccm import Cli as BaseCli from .cesm2_waccm import Clw as BaseClw -from ..common import SiconcFixScalarCoord - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py index 00983b36a7..fc1db9d174 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py +++ b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py @@ -16,7 +16,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) ps_coord = cube.coord(var_name='ps') diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py index b5db40fc11..47c505fdd2 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py @@ -3,7 +3,6 @@ from .cnrm_cm6_1 import Cli as BaseCli from .cnrm_cm6_1 import Clw as BaseClw - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py index 838ae3836c..23ab942fef 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py @@ -5,7 +5,6 @@ from .cnrm_cm6_1 import Clw as BaseClw from .cnrm_cm6_1 import Omon as BaseOmon - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py index 333b4eb98b..59bb546aac 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py @@ -1,5 +1,4 @@ """Fixes for EC-Earth3-Veg-LR model.""" from ..common import OceanFixGrid - Siconc = OceanFixGrid diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py index f73b16f4b8..def9a936d1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py @@ -26,7 +26,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) coords_to_add = { @@ -51,8 +50,7 @@ class Tas(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """ - Add height (2m) coordinate. + """Add height (2m) coordinate. Parameters ---------- @@ -62,7 +60,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) try: @@ -88,8 +85,7 @@ class Uas(Fix): """Fixes for uas.""" def fix_metadata(self, cubes): - """ - Add height (10m) coordinate. + """Add height (10m) coordinate. Parameters ---------- @@ -99,7 +95,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py index c9788eb37c..b2e421fba9 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py @@ -1,10 +1,7 @@ """Fixes for GFDL-ESM4 model.""" -from ..common import SiconcFixScalarCoord, OceanFixGrid +from ..common import OceanFixGrid, SiconcFixScalarCoord from ..fix import Fix -from ..shared import ( - add_scalar_depth_coord, - fix_ocean_depth_coord, -) +from ..shared import add_scalar_depth_coord, fix_ocean_depth_coord class Fgco2(Fix): @@ -21,7 +18,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -42,7 +38,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py index 054a42255f..1724cce93b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py +++ b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py @@ -1,7 +1,6 @@ """Fixes for GISS-E2-1-H model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py index 99db1e2be1..003c8f623d 100644 --- a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridHeightCoord from .ukesm1_0_ll import AllVars as BaseAllVars - AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py index 57d925e6d1..11a25bc185 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py @@ -3,7 +3,6 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon - AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py index dfd7116275..7e326e5948 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py @@ -9,8 +9,7 @@ class AllVars(Fix): """Fixes for thetao.""" def fix_metadata(self, cubes): - """ - Fix cell_area coordinate. + """Fix cell_area coordinate. Parameters ---------- @@ -20,7 +19,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) if cube.coords('latitude'): @@ -68,7 +66,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py index 3a8a94b8de..2b551a8177 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py @@ -3,7 +3,6 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon - AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py index a9b200cde6..92a446be1c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py @@ -38,7 +38,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ coords_to_change = { 'latitude': 'lat', @@ -100,7 +99,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): @@ -124,7 +122,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 2.0) @@ -145,7 +142,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc6.py b/esmvalcore/cmor/_fixes/cmip6/miroc6.py index cf1d40ca86..e799a86577 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc6.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc6.py @@ -15,8 +15,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. + """Fix latitude_bounds and longitude_bounds data type and round to 4 + d.p. Parameters ---------- diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py index aa28ae13cc..a5e18b302c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py @@ -1,7 +1,6 @@ """Fixes for MIROC-ES2L model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py index 201ffcca63..f603b9d197 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py +++ b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py @@ -1,8 +1,8 @@ """Fixes for MPI-ESM1-2-XR model.""" -from .mpi_esm1_2_hr import Tas as BaseTas -from .mpi_esm1_2_hr import Ta as BaseFix from .mpi_esm1_2_hr import SfcWind as BaseSfcWind +from .mpi_esm1_2_hr import Ta as BaseFix +from .mpi_esm1_2_hr import Tas as BaseTas class Tas(BaseTas): diff --git a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py index 720670b4d5..04f1617200 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py @@ -1,7 +1,6 @@ """Fixes for MRI-ESM2-0 model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py index dc0aa1ccb8..2cd1926eff 100644 --- a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py +++ b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -28,7 +27,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= -1 diff --git a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py index 8bef01c21f..6d7d279d6e 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py @@ -17,7 +17,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ parent_units = 'parent_time_units' bad_value = 'days since 1850-01-01-00-00-00' diff --git a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py index 1806f3f0a0..0f75e65197 100644 --- a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by CNRM-CERFACS-CNRM-CM5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py index 88d2123420..19d0a2dfdc 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - CLMcomCCLM4817 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + CLMcomCCLM4817 as BaseFix AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py index 2f816ba55e..9333eb9b33 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py index 9f4cb7a2bc..b79a6399a7 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py @@ -1,5 +1,4 @@ """Fixes for rcm RACMO22E driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py index 114715a5c9..aad85b4848 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py @@ -1,6 +1,5 @@ """Fixes for rcm RCA4 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py index c50d9a23e2..56bff0f673 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py @@ -1,5 +1,4 @@ """Fixes for rcm REMO2015 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py index ac0460904d..181b42dba6 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - CLMcomCCLM4817 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + CLMcomCCLM4817 as BaseFix AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py index fbd13bdfab..bcbe5356e2 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py @@ -1,5 +1,4 @@ """Fixes for rcm REMO2015 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py index f8a69bca9b..e1e691efa2 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py @@ -1,5 +1,6 @@ """Fixes for rcm WRF361H driven by MIROC-MIROC5.""" import iris + from esmvalcore.cmor.fix import Fix @@ -20,7 +21,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ fixed_cubes = iris.cube.CubeList() for cube in cubes: diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py index 7964a583e0..45524e8654 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py index 5dfb91f274..0a6a43b7b1 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py @@ -16,7 +16,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: cube.coord('latitude').attributes = {} diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py index 740711fcea..2ad0fe36f6 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py @@ -1,6 +1,5 @@ """Fixes for rcm RCA4 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py index cea145f2d3..c7f3912fb0 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py @@ -1,6 +1,5 @@ """Fixes for rcm REMO2015 driven by MOHC-HadGEM2.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py index 4875edfc93..dbad46ea88 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py index 676e0dfc47..ebf390b9f9 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py @@ -1,5 +1,4 @@ """Fixes for rcm RACMO22E driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py index f863ed1712..fc54fd47e2 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py @@ -1,6 +1,5 @@ """Fixes for rcm RegCM4-6 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py index 1aa2d11b1b..36d52de57e 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py index e9e2e38734..1a924d6b04 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py @@ -1,5 +1,4 @@ """Fixes for rcm RACMO22E driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py index 58d14599da..3452f432ab 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py @@ -1,6 +1,5 @@ """Fixes for rcm RCA4 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py index 9722263d70..4276048585 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py @@ -1,5 +1,4 @@ """Fixes for rcm REMO2015 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/emac/emac.py b/esmvalcore/cmor/_fixes/emac/emac.py index 99cf9ee142..9bd961783a 100644 --- a/esmvalcore/cmor/_fixes/emac/emac.py +++ b/esmvalcore/cmor/_fixes/emac/emac.py @@ -8,7 +8,6 @@ is that ``fix_metadata`` takes all cubes (and thus all input variables of the input file) as argument while ``fix_data`` only takes one cube (the output variable) as single argument. - """ import logging @@ -47,7 +46,6 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): This fix removes the ``formula_terms`` attribute of the hybrid pressure level variables to make the corresponding coefficients appear correctly in the class:`iris.cube.CubeList` object returned by :mod:`iris.load`. - """ if 'alevel' not in self.vardef.dimensions: return filepath @@ -383,7 +381,6 @@ def fix_metadata(self, cubes): Convert geopotential Phi given by EMAC to geopotential height Z using Z = Phi / g0 (g0 is standard acceleration of gravity) - """ g0_value = constants.value('standard acceleration of gravity') g0_units = constants.unit('standard acceleration of gravity') diff --git a/esmvalcore/cmor/_fixes/fix.py b/esmvalcore/cmor/_fixes/fix.py index cf2aed42ec..2723579ef8 100644 --- a/esmvalcore/cmor/_fixes/fix.py +++ b/esmvalcore/cmor/_fixes/fix.py @@ -61,7 +61,6 @@ def __init__( frequency: Expected frequency of the variable. If not given, use the one from the CMOR table entry of the variable. - """ self.vardef = vardef if extra_facets is None: @@ -99,7 +98,6 @@ def fix_file( Path to the corrected file. It can be different from the original filepath if a fix has been applied, but if not it should be the original filepath. - """ return filepath @@ -119,7 +117,6 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> Sequence[Cube]: ------- Iterable[iris.cube.Cube] Fixed cubes. They can be different instances. - """ return cubes @@ -147,7 +144,6 @@ def get_cube_from_list( ------- iris.cube.Cube Variable's cube. - """ if short_name is None: short_name = self.vardef.short_name @@ -170,7 +166,6 @@ def fix_data(self, cube: Cube) -> Cube: ------- iris.cube.Cube Fixed cube. It can be a difference instance. - """ return cube @@ -231,7 +226,6 @@ def get_fixes( ------- list[Fix] Fixes to apply for the given data. - """ vardef = get_var_info(project, mip, short_name) @@ -313,7 +307,6 @@ def get_fixed_filepath( ------- Path Path to the fixed file. - """ output_dir = Path(output_dir) if add_unique_suffix: @@ -341,7 +334,6 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> CubeList: ------- CubeList Fixed cubes. - """ # Make sure the this fix also works when no extra_facets are given if 'project' in self.extra_facets and 'dataset' in self.extra_facets: @@ -384,7 +376,6 @@ def fix_data(self, cube: Cube) -> Cube: ------- Cube Fixed cube. - """ return cube @@ -758,7 +749,10 @@ def _fix_coord_direction( cmor_coord: CoordinateInfo, cube_coord: Coord, ) -> tuple[Cube, Coord]: - """Fix coordinate direction (increasing vs. decreasing).""" + """Fix coordinate direction (increasing vs. + + decreasing). + """ # Skip fix for a variety of reasons if cube_coord.ndim > 1: return (cube, cube_coord) diff --git a/esmvalcore/cmor/_fixes/icon/_base_fixes.py b/esmvalcore/cmor/_fixes/icon/_base_fixes.py index c4afecc4f8..ede854bc0a 100644 --- a/esmvalcore/cmor/_fixes/icon/_base_fixes.py +++ b/esmvalcore/cmor/_fixes/icon/_base_fixes.py @@ -56,7 +56,6 @@ def _create_mesh(self, cube: Cube) -> MeshXY: neighboring cells) the number of nodes is 6 times higher with :func:`iris.mesh.MeshXY.from_coords` compared to using the information already present in the horizontal grid file. - """ horizontal_grid = self.get_horizontal_grid(cube) @@ -155,11 +154,10 @@ def _get_grid_url(self, cube): def _get_node_coords(self, horizontal_grid): """Get node coordinates from horizontal grid. - Extract node coordinates from dummy variable 'dual_area' in horizontal - grid file (in ICON jargon called 'vertex latitude' and 'vertex - longitude'), remove their bounds (not accepted by UGRID), and adapt - metadata. - + Extract node coordinates from dummy variable 'dual_area' in + horizontal grid file (in ICON jargon called 'vertex latitude' + and 'vertex longitude'), remove their bounds (not accepted by + UGRID), and adapt metadata. """ dual_area_cube = horizontal_grid.extract_cube( NameConstraint(var_name='dual_area')) @@ -236,7 +234,6 @@ def add_additional_cubes(self, cubes): ------ InputFilesNotFound A specified file does not exist. - """ facets_to_consider = [ 'zg_file', @@ -321,7 +318,6 @@ def _get_downloaded_grid(self, grid_url: str, grid_name: str) -> CubeList: In order to make this function thread-safe, the downloaded grid file is first saved to a temporary location, then copied to the actual location later. - """ grid_path = self.CACHE_DIR / grid_name @@ -402,7 +398,6 @@ def get_horizontal_grid(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. - """ if self.extra_facets.get('horizontal_grid') is not None: grid = self._get_grid_from_facet() @@ -441,7 +436,6 @@ def get_mesh(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. - """ # If specified by the user, use `horizontal_grid` facet to determine # grid name; otherwise, use the `grid_file_uri` attribute of the cube @@ -472,7 +466,6 @@ def _get_start_index(horizontal_grid): Note ---- UGRID expects this to be a int32. - """ vertex_index = horizontal_grid.extract_cube( NameConstraint(var_name='vertex_index')) diff --git a/esmvalcore/cmor/_fixes/icon/icon.py b/esmvalcore/cmor/_fixes/icon/icon.py index 707a47f20c..d714657764 100644 --- a/esmvalcore/cmor/_fixes/icon/icon.py +++ b/esmvalcore/cmor/_fixes/icon/icon.py @@ -100,7 +100,6 @@ def _add_coord_from_grid_file(self, cube, coord_name): Invalid ``coord_name`` is given; input cube does not contain a single unnamed dimension that can be used to add the new coordinate. - """ # The following dict maps from desired coordinate name in output file # (dict keys) to coordinate name in grid file (dict values) diff --git a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py index 362d950f6c..96889cd7b9 100644 --- a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py +++ b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py @@ -19,8 +19,8 @@ class AllVars(Fix): def fix_file(self, filepath, output_dir, add_unique_suffix=False): """Select IPSLCM variable in filepath. - This is done only if input file is a multi-variable one. This - is diagnosed by searching in the input filepathame for the + This is done only if input file is a multi-variable one. This is + diagnosed by searching in the input filepathame for the extra_facet value for key 'group'. In such cases, it is worth to use an external tool for @@ -28,8 +28,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): up to, and including, V3.0.2), and CDO can be used, depending on extra_facets key `use_cdo` - However, we take care of ESMValTool policy re. dependencies licence - + However, we take care of ESMValTool policy re. dependencies + licence """ if "_" + self.extra_facets.get( "group", "non-sense") + ".nc" not in str(filepath): @@ -61,8 +61,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): def fix_metadata(self, cubes): """Fix metadata for any IPSLCM variable + filter out other variables. - Fix the name of the time coordinate, which is called time_counter - in the original file. + Fix the name of the time coordinate, which is called + time_counter in the original file. Remove standard_name 'time' in auxiliary time coordinates """ diff --git a/esmvalcore/cmor/_fixes/native6/era5_land.py b/esmvalcore/cmor/_fixes/native6/era5_land.py index 5b6fbff276..6c32cc6dcb 100644 --- a/esmvalcore/cmor/_fixes/native6/era5_land.py +++ b/esmvalcore/cmor/_fixes/native6/era5_land.py @@ -1,11 +1,12 @@ """Fixes for ERA5-Land.""" import logging -from esmvalcore.cmor._fixes.native6.era5 import (Pr, - Evspsbl, - Evspsblpot, - AllVars) - +from esmvalcore.cmor._fixes.native6.era5 import ( + AllVars, + Evspsbl, + Evspsblpot, + Pr, +) logger = logging.getLogger(__name__) logger.info("Load classes from era5.py") diff --git a/esmvalcore/cmor/_fixes/native_datasets.py b/esmvalcore/cmor/_fixes/native_datasets.py index 20cfa5590f..b773c63966 100644 --- a/esmvalcore/cmor/_fixes/native_datasets.py +++ b/esmvalcore/cmor/_fixes/native_datasets.py @@ -29,7 +29,6 @@ def fix_scalar_coords(self, cube): cube: iris.cube.Cube Input cube for which missing scalar coordinates will be added (in-place). - """ if 'height2m' in self.vardef.dimensions: add_scalar_height_coord(cube, 2.0) @@ -47,7 +46,6 @@ def fix_var_metadata(self, cube): ---------- cube: iris.cube.Cube Input cube whose metadata is changed in-place. - """ # Fix names if self.vardef.standard_name == '': @@ -103,7 +101,6 @@ def get_cube(self, cubes, var_name=None): ------ ValueError Desired variable is not available in the input cubes. - """ if var_name is None: var_name = self.extra_facets.get('raw_name', @@ -127,7 +124,6 @@ def fix_regular_time(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. - """ if not self.vardef.has_coord_with_standard_name('time'): return @@ -148,7 +144,6 @@ def fix_regular_lat(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. - """ if not self.vardef.has_coord_with_standard_name('latitude'): return @@ -169,7 +164,6 @@ def fix_regular_lon(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. - """ if not self.vardef.has_coord_with_standard_name('longitude'): return @@ -198,7 +192,6 @@ def guess_coord_bounds(cube, coord): iris.coords.AuxCoord or iris.coords.DimCoord Coordinate with bounds. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if isinstance(coord, str): coord = cube.coord(coord) @@ -226,7 +219,6 @@ def fix_time_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed time coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('time') @@ -254,7 +246,6 @@ def fix_alt16_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed altitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('altitude') @@ -284,7 +275,6 @@ def fix_height_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed height coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('height') @@ -314,7 +304,6 @@ def fix_plev_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed air_pressure coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('air_pressure') @@ -344,7 +333,6 @@ def fix_lat_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed latitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('latitude') @@ -373,7 +361,6 @@ def fix_lon_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed longitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('longitude') diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py index b8eab7b711..eafde5e3e2 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py @@ -21,7 +21,6 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. - """ for cube in cubes: # Put information from valid_range into mask and remove the diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py index 93ca03eaa6..f72a498759 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py @@ -8,8 +8,7 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Change unit of coordinate plev from hPa to Pa. @@ -22,7 +21,6 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py index cb150fe729..dfc01ba281 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py @@ -1,4 +1,3 @@ - """Fixes for SSMI model.""" from ..fix import Fix diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py index 2fa26842b9..982ab03783 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py @@ -1,4 +1,3 @@ - """Fixes for CCSM4 model.""" from iris.cube import CubeList @@ -9,8 +8,7 @@ class Prw(Fix): """Fixes for prw.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Remove error and number of observations cubes @@ -21,7 +19,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) return CubeList([cube]) diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index 3ec14d05ab..d3498c9b87 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -443,7 +443,6 @@ def get_next_month(month: int, year: int) -> tuple[int, int]: ------- tuple[int, int] Next month and next year. - """ if month != 12: return month + 1, year @@ -476,7 +475,6 @@ def get_time_bounds(time: Coord, freq: str) -> np.ndarray: ------ NotImplementedError Non-supported frequency is given. - """ bounds = [] dates = time.units.num2date(time.points) diff --git a/esmvalcore/cmor/_utils.py b/esmvalcore/cmor/_utils.py index be837d9c10..629d6be498 100644 --- a/esmvalcore/cmor/_utils.py +++ b/esmvalcore/cmor/_utils.py @@ -52,7 +52,6 @@ def _get_alternative_generic_lev_coord( ------ ValueError No valid alternative generic level coordinate present in cube. - """ alternatives_for_coord = _ALTERNATIVE_GENERIC_LEV_COORDS.get( coord_name, {} @@ -93,7 +92,6 @@ def _get_generic_lev_coord_names( Tuple of `standard_name`, `out_name`, and `name` of the generic level coordinate present in the cube. Values are ``None`` if generic level coordinate has not been found in cube. - """ standard_name = None out_name = None @@ -152,7 +150,6 @@ def _get_new_generic_level_coord( ------- CoordinateInfo New generic level coordinate. - """ new_coord = generic_level_coord.generic_lev_coords[new_coord_name] new_coord.generic_level = True diff --git a/esmvalcore/cmor/check.py b/esmvalcore/cmor/check.py index 09f7a6331d..b368d6d131 100644 --- a/esmvalcore/cmor/check.py +++ b/esmvalcore/cmor/check.py @@ -164,7 +164,6 @@ def check_metadata(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. - """ if logger is not None: self._logger = logger @@ -213,7 +212,6 @@ def check_data(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. - """ if logger is not None: self._logger = logger @@ -916,7 +914,6 @@ def cmor_check_metadata( ------- iris.cube.Cube Checked cube. - """ checker = _get_cmor_checker( cmor_table, @@ -959,7 +956,6 @@ def cmor_check_data( ------- iris.cube.Cube Checked cube. - """ checker = _get_cmor_checker( cmor_table, @@ -1005,7 +1001,6 @@ def cmor_check( ------- iris.cube.Cube Checked cube. - """ cube = cmor_check_metadata( cube, diff --git a/esmvalcore/cmor/fix.py b/esmvalcore/cmor/fix.py index d05af5ef64..8a5421e19a 100644 --- a/esmvalcore/cmor/fix.py +++ b/esmvalcore/cmor/fix.py @@ -72,7 +72,6 @@ def fix_file( ------- str or pathlib.Path Path to the fixed file. - """ # Update extra_facets with variable information given as regular arguments # to this function @@ -148,7 +147,6 @@ def fix_metadata( ------- iris.cube.CubeList Fixed cubes. - """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: @@ -269,7 +267,6 @@ def fix_data( ------- iris.cube.Cube Fixed cube. - """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: diff --git a/esmvalcore/cmor/table.py b/esmvalcore/cmor/table.py index a0c685654a..a2a5e0a255 100644 --- a/esmvalcore/cmor/table.py +++ b/esmvalcore/cmor/table.py @@ -25,7 +25,7 @@ CMORTable = Union['CMIP3Info', 'CMIP5Info', 'CMIP6Info', 'CustomInfo'] CMOR_TABLES: dict[str, CMORTable] = {} -"""dict of str, obj: CMOR info objects.""" +"""Dict of str, obj: CMOR info objects.""" _CMOR_KEYS = ( 'standard_name', @@ -102,7 +102,6 @@ def get_var_info( ------ KeyError No CMOR tables available for `project`. - """ if project not in CMOR_TABLES: raise KeyError( @@ -282,7 +281,6 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, ``None`` otherwise. - """ alt_names_list = self._get_alt_names_list(short_name) @@ -613,28 +611,28 @@ def __init__(self, table_type, short_name): super(VariableInfo, self).__init__() self.table_type = table_type self.modeling_realm = [] - """Modeling realm""" + """Modeling realm.""" self.short_name = short_name - """Short name""" + """Short name.""" self.standard_name = '' - """Standard name""" + """Standard name.""" self.long_name = '' - """Long name""" + """Long name.""" self.units = '' - """Data units""" + """Data units.""" self.valid_min = '' - """Minimum admitted value""" + """Minimum admitted value.""" self.valid_max = '' - """Maximum admitted value""" + """Maximum admitted value.""" self.frequency = '' - """Data frequency""" + """Data frequency.""" self.positive = '' - """Increasing direction""" + """Increasing direction.""" self.dimensions = [] - """List of dimensions""" + """List of dimensions.""" self.coordinates = {} - """Coordinates + """Coordinates. This is a dict with the names of the dimensions as keys and CoordinateInfo objects as values. @@ -703,7 +701,6 @@ def has_coord_with_standard_name(self, standard_name: str) -> bool: bool `True` if there is at least one coordinate with the given `standard_name`, `False` if not. - """ for coord in self.coordinates.values(): if coord.standard_name == standard_name: @@ -728,35 +725,34 @@ def __init__(self, name): self.generic_lev_coords = {} self.axis = "" - """Axis""" + """Axis.""" self.value = "" - """Coordinate value""" + """Coordinate value.""" self.standard_name = "" - """Standard name""" + """Standard name.""" self.long_name = "" - """Long name""" + """Long name.""" self.out_name = "" - """ - Out name + """Out name. This is the name of the variable in the file """ self.var_name = "" - """Short name""" + """Short name.""" self.units = "" - """Units""" + """Units.""" self.stored_direction = "" - """Direction in which the coordinate increases""" + """Direction in which the coordinate increases.""" self.requested = [] - """Values requested""" + """Values requested.""" self.valid_min = "" - """Minimum allowed value""" + """Minimum allowed value.""" self.valid_max = "" - """Maximum allowed value""" + """Maximum allowed value.""" self.must_have_bounds = "" - """Whether bounds are required on this dimension""" + """Whether bounds are required on this dimension.""" self.generic_lev_name = "" - """Generic level name""" + """Generic level name.""" def read_json(self, json_data): """Read coordinate information from json. @@ -992,7 +988,6 @@ class CustomInfo(CMIP5Info): Full path to the table or name for the table if it is present in ESMValTool repository. If ``None``, use default tables from `esmvalcore/cmor/tables/custom`. - """ def __init__(self, cmor_tables_path: Optional[str | Path] = None) -> None: @@ -1067,7 +1062,6 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, returns None if not. - """ return self.tables['custom'].get(short_name, None) diff --git a/esmvalcore/config/__init__.py b/esmvalcore/config/__init__.py index 7c2b8e379c..271fa956cc 100644 --- a/esmvalcore/config/__init__.py +++ b/esmvalcore/config/__init__.py @@ -7,7 +7,6 @@ By default, this will be loaded from the file ``~/.esmvaltool/config-user.yml``. If used within the ``esmvaltool`` program, this will respect the ``--config_file`` argument. - """ from ._config_object import CFG, Config, Session diff --git a/esmvalcore/config/_config_object.py b/esmvalcore/config/_config_object.py index 2e53857d70..89ad3b7f69 100644 --- a/esmvalcore/config/_config_object.py +++ b/esmvalcore/config/_config_object.py @@ -30,7 +30,6 @@ class Config(ValidatedConfig): Do not instantiate this class directly, but use :obj:`esmvalcore.config.CFG` instead. - """ _DEFAULT_USER_CONFIG_DIR = Path.home() / '.esmvaltool' @@ -161,7 +160,6 @@ def _get_config_user_path( _ESMVALTOOL_USER_CONFIG_FILE_ at the end of this method to make sure that subsequent calls of this method (also in suprocesses) use the correct user configuration file. - """ # (1) Try to get user configuration file from `filename` argument config_user = filename @@ -210,7 +208,6 @@ def _get_config_path_from_cli() -> None | str: ---- This only works if the script name is `esmvaltool`. Does not check if file exists. - """ if Path(sys.argv[0]).name != 'esmvaltool': return None diff --git a/esmvalcore/config/_esgf_pyclient.py b/esmvalcore/config/_esgf_pyclient.py index 51152344c4..5f4b1aab48 100644 --- a/esmvalcore/config/_esgf_pyclient.py +++ b/esmvalcore/config/_esgf_pyclient.py @@ -1,4 +1,4 @@ -"""esgf-pyclient configuration. +"""Esgf-pyclient configuration. The configuration is read from the file ~/.esmvaltool/esgf-pyclient.yml. """ diff --git a/esmvalcore/config/_validated_config.py b/esmvalcore/config/_validated_config.py index 27048397a7..dcc3e2ca36 100644 --- a/esmvalcore/config/_validated_config.py +++ b/esmvalcore/config/_validated_config.py @@ -49,8 +49,9 @@ class ValidatedConfig(MutableMapping): _warn_if_missing: tuple[tuple[str, str], ...] = () """Handle missing options. - Each sub-tuple in the tuple consists of an option for which a warning is - emitted and a string with more information for the user on that option. + Each sub-tuple in the tuple consists of an option for which a + warning is emitted and a string with more information for the user + on that option. """ # validate values on the way in diff --git a/esmvalcore/config/extra_facets/access-mappings.yml b/esmvalcore/config/extra_facets/access-mappings.yml index 9d4eb0621b..14c75f07b0 100644 --- a/esmvalcore/config/extra_facets/access-mappings.yml +++ b/esmvalcore/config/extra_facets/access-mappings.yml @@ -7,23 +7,23 @@ ACCESS-ESM1-5: '*': - + tas: raw_name: fld_s03i236 modeling_realm: atm - + pr: raw_name: fld_s05i216 modeling_realm: atm - + ps: raw_name: fld_s00i409 modeling_realm: atm - + clt: raw_name: fld_s02i204 modeling_realm: atm - + psl: raw_name: fld_s16i222 modeling_realm: atm @@ -31,7 +31,7 @@ ACCESS-ESM1-5: hus: raw_name: fld_s30i205 modeling_realm: atm - + zg: raw_name: fld_s30i207 modeling_realm: atm @@ -39,30 +39,30 @@ ACCESS-ESM1-5: va: raw_name: fld_s30i202 modeling_realm: atm - + ua: raw_name: fld_s30i201 modeling_realm: atm - + ta: raw_name: fld_s30i204 modeling_realm: atm - + rlus: - raw_name: - - fld_s02i207 - - fld_s02i201 - - fld_s03i332 + raw_name: + - fld_s02i207 + - fld_s02i201 + - fld_s03i332 - fld_s02i205 modeling_realm: atm - + rlds: raw_name: fld_s02i207 modeling_realm: atm rsus: - raw_name: + raw_name: - fld_s01i235 - - fld_s01i201 + - fld_s01i201 modeling_realm: atm - + diff --git a/esmvalcore/dataset.py b/esmvalcore/dataset.py index d4bd665aa6..07f07bc915 100644 --- a/esmvalcore/dataset.py +++ b/esmvalcore/dataset.py @@ -188,7 +188,8 @@ def _file_to_dataset( def _get_available_datasets(self) -> Iterator[Dataset]: """Yield datasets based on the available files. - This function requires that self.facets['mip'] is not a glob pattern. + This function requires that self.facets['mip'] is not a glob + pattern. """ dataset_template = self.copy() dataset_template.supplementaries = [] diff --git a/esmvalcore/iris_helpers.py b/esmvalcore/iris_helpers.py index eb9a96461e..b2a9f3183c 100644 --- a/esmvalcore/iris_helpers.py +++ b/esmvalcore/iris_helpers.py @@ -39,7 +39,6 @@ def add_leading_dim_to_cube(cube, dim_coord): ------ CoordinateMultiDimError ``dim_coord`` is not 1D. - """ # Only 1D dim_coords are supported if dim_coord.ndim > 1: @@ -134,7 +133,6 @@ def merge_cube_attributes( Input cubes whose attributes will be modified in-place. delimiter: Delimiter that is used to concatenate non-identical attributes. - """ if len(cubes) <= 1: return @@ -254,7 +252,6 @@ def rechunk_cube( ------- Cube Rechunked cube. This will always be a copy of the input cube. - """ cube = cube.copy() # do not modify input cube @@ -289,7 +286,6 @@ def has_regular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has a regular grid, else ``False``. - """ try: lat = cube.coord('latitude') @@ -318,7 +314,6 @@ def has_irregular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an irregular grid, else ``False``. - """ try: lat = cube.coord('latitude') @@ -345,7 +340,6 @@ def has_unstructured_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an unstructured grid, else ``False``. - """ try: lat = cube.coord('latitude') diff --git a/esmvalcore/preprocessor/__init__.py b/esmvalcore/preprocessor/__init__.py index 3800fb1413..b44dada778 100644 --- a/esmvalcore/preprocessor/__init__.py +++ b/esmvalcore/preprocessor/__init__.py @@ -206,9 +206,7 @@ ] DEFAULT_ORDER = tuple(__all__) -""" -By default, preprocessor functions are applied in this order. -""" +"""By default, preprocessor functions are applied in this order.""" # The order of initial and final steps cannot be configured INITIAL_STEPS = DEFAULT_ORDER[:DEFAULT_ORDER.index( diff --git a/esmvalcore/preprocessor/_area.py b/esmvalcore/preprocessor/_area.py index dd2f9b4b4b..78ff33f3a5 100644 --- a/esmvalcore/preprocessor/_area.py +++ b/esmvalcore/preprocessor/_area.py @@ -70,7 +70,6 @@ def extract_region( ------- iris.cube.Cube Smaller cube. - """ # first examine if any cell_measures are present cell_measures = cube.cell_measures() @@ -226,7 +225,6 @@ def zonal_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. - """ if cube.coord('longitude').points.ndim >= 2: raise ValueError( @@ -275,7 +273,6 @@ def meridional_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. - """ if cube.coord('latitude').points.ndim >= 2: raise ValueError( @@ -338,7 +335,6 @@ def area_statistics( iris.exceptions.CoordinateMultiDimError Cube has irregular or unstructured grid but supplementary variable `cell_area` is not available. - """ has_cell_measure = bool(cube.cell_measures('cell_area')) @@ -383,7 +379,6 @@ def extract_named_regions(cube: Cube, regions: str | Iterable[str]) -> Cube: regions is not list or tuple or set. ValueError region not included in cube. - """ # Make sure regions is a list of strings if isinstance(regions, str): @@ -599,7 +594,6 @@ def _get_bounds( ------- lat_min, lon_min, lat_max, lon_max Coordinates deliminating bounding box for shape ids. - """ all_bounds = np.vstack( [fiona.bounds(geom) for geom in geometries.values()] @@ -654,7 +648,6 @@ def fix_coordinate_ordering(cube: Cube) -> Cube: ------- iris.cube.Cube Cube with dimensions transposed to standard order - """ try: time_dim = cube.coord_dims('time') @@ -778,7 +771,6 @@ def extract_shape( See Also -------- extract_region: Extract a region from a cube. - """ shapefile = _update_shapefile_path(shapefile) with fiona.open(shapefile) as geometries: diff --git a/esmvalcore/preprocessor/_compare_with_refs.py b/esmvalcore/preprocessor/_compare_with_refs.py index 1634fc1752..0228a5eddc 100644 --- a/esmvalcore/preprocessor/_compare_with_refs.py +++ b/esmvalcore/preprocessor/_compare_with_refs.py @@ -102,7 +102,6 @@ def bias( true`` if ``reference=None``; ``reference=None`` and the input products are given as iterable of :class:`~iris.cube.Cube` objects; ``bias_type`` is not one of ``'absolute'`` or ``'relative'``. - """ ref_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) @@ -319,7 +318,6 @@ def distance_metric( `longitude` is not found in cube if a weighted metric shall be calculated, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. - """ reference_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) diff --git a/esmvalcore/preprocessor/_cycles.py b/esmvalcore/preprocessor/_cycles.py index 017d6ed71b..90e1284684 100644 --- a/esmvalcore/preprocessor/_cycles.py +++ b/esmvalcore/preprocessor/_cycles.py @@ -41,7 +41,6 @@ def amplitude(cube, coords): iris.exceptions.CoordinateNotFoundError A coordinate is not found in ``cube`` and cannot be added via :mod:`iris.coord_categorisation`. - """ if isinstance(coords, str): coords = [coords] diff --git a/esmvalcore/preprocessor/_derive/_baseclass.py b/esmvalcore/preprocessor/_derive/_baseclass.py index ba9325bfdd..c2076b1542 100644 --- a/esmvalcore/preprocessor/_derive/_baseclass.py +++ b/esmvalcore/preprocessor/_derive/_baseclass.py @@ -30,7 +30,6 @@ def required(project): ------- list of dict List of variable metadata. - """ @staticmethod @@ -58,5 +57,4 @@ def calculate(cubes): NotImplementedError If the desired variable derivation is not implemented, i.e. if this method is called from this base class and not a child class. - """ diff --git a/esmvalcore/preprocessor/_derive/_shared.py b/esmvalcore/preprocessor/_derive/_shared.py index e6d07011f1..dfe620b58e 100644 --- a/esmvalcore/preprocessor/_derive/_shared.py +++ b/esmvalcore/preprocessor/_derive/_shared.py @@ -61,7 +61,6 @@ def column_average(cube, hus_cube, zg_cube, ps_cube): ------- iris.cube.Cube Column-averaged mole fraction of a gas. - """ # Convert units of data hus_cube.convert_units('1') @@ -124,7 +123,6 @@ def pressure_level_widths(cube, ps_cube, top_limit=0.0): ------- iris.cube.Cube Cube of same shape as ``cube`` containing pressure level widths. - """ pressure_array = _create_pressure_array(cube, ps_cube, top_limit) @@ -172,7 +170,6 @@ def _get_pressure_level_widths(array, air_pressure_axis=1): For a 1D array with pressure level columns, return a 1D array with pressure level widths. - """ array = np.copy(array) if np.any(np.diff(array, axis=air_pressure_axis) > 0.0): diff --git a/esmvalcore/preprocessor/_derive/alb.py b/esmvalcore/preprocessor/_derive/alb.py index b0036077ad..dcc45362b8 100644 --- a/esmvalcore/preprocessor/_derive/alb.py +++ b/esmvalcore/preprocessor/_derive/alb.py @@ -2,7 +2,6 @@ authors: - crez_ba - """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/ctotal.py b/esmvalcore/preprocessor/_derive/ctotal.py index 18bef27071..45cd2610da 100644 --- a/esmvalcore/preprocessor/_derive/ctotal.py +++ b/esmvalcore/preprocessor/_derive/ctotal.py @@ -1,7 +1,6 @@ """Derivation of variable `ctotal`.""" import iris - from iris import Constraint from ._baseclass import DerivedVariableBase diff --git a/esmvalcore/preprocessor/_derive/lvp.py b/esmvalcore/preprocessor/_derive/lvp.py index 0faf0779c4..ad9db3f299 100644 --- a/esmvalcore/preprocessor/_derive/lvp.py +++ b/esmvalcore/preprocessor/_derive/lvp.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/lwp.py b/esmvalcore/preprocessor/_derive/lwp.py index 067126d5e9..4c79322496 100644 --- a/esmvalcore/preprocessor/_derive/lwp.py +++ b/esmvalcore/preprocessor/_derive/lwp.py @@ -33,7 +33,6 @@ def calculate(cubes): ---- Some datasets output the variable `clwvi` which only contains `lwp`. In these cases, the input `clwvi` cube is just returned. - """ # CMIP5 and CMIP6 names are slightly different, so use # variable name instead to extract cubes diff --git a/esmvalcore/preprocessor/_derive/ohc.py b/esmvalcore/preprocessor/_derive/ohc.py index d8d374b312..e9f1f52e67 100644 --- a/esmvalcore/preprocessor/_derive/ohc.py +++ b/esmvalcore/preprocessor/_derive/ohc.py @@ -1,8 +1,7 @@ """Derivation of variable `ohc`.""" import iris -from iris import Constraint - from cf_units import Unit +from iris import Constraint from ._baseclass import DerivedVariableBase @@ -38,8 +37,7 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute ocean heat content. + """Compute ocean heat content. Use c_p*rho_0= 4.09169e+6 J m-3 K-1 (Kuhlbrodt et al., 2015, Clim. Dyn.) diff --git a/esmvalcore/preprocessor/_derive/rlnst.py b/esmvalcore/preprocessor/_derive/rlnst.py index 4eecd9b90d..dcf1c643c9 100644 --- a/esmvalcore/preprocessor/_derive/rlnst.py +++ b/esmvalcore/preprocessor/_derive/rlnst.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint @@ -30,11 +29,10 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute variable `rlnst`. + """Compute variable `rlnst`. - Compute Net Atmospheric Longwave Cooling - to surface and outer space. + Compute Net Atmospheric Longwave Cooling to surface and outer + space. """ rlds_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air')) diff --git a/esmvalcore/preprocessor/_derive/rlnstcs.py b/esmvalcore/preprocessor/_derive/rlnstcs.py index 10613216a9..a1b39128fe 100644 --- a/esmvalcore/preprocessor/_derive/rlnstcs.py +++ b/esmvalcore/preprocessor/_derive/rlnstcs.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint @@ -30,11 +29,10 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute variable `rlnstcs`. + """Compute variable `rlnstcs`. - Compute Net Atmospheric Longwave Cooling - to surface and outer space assuming clear sky. + Compute Net Atmospheric Longwave Cooling to surface and outer + space assuming clear sky. """ rldscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rlus.py b/esmvalcore/preprocessor/_derive/rlus.py index 4d536c29ad..928b7d296a 100644 --- a/esmvalcore/preprocessor/_derive/rlus.py +++ b/esmvalcore/preprocessor/_derive/rlus.py @@ -2,7 +2,6 @@ authors: - lukas_brunner - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnst.py b/esmvalcore/preprocessor/_derive/rsnst.py index e2a2a53b21..80b6d7abf0 100644 --- a/esmvalcore/preprocessor/_derive/rsnst.py +++ b/esmvalcore/preprocessor/_derive/rsnst.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcs.py b/esmvalcore/preprocessor/_derive/rsnstcs.py index 976be64003..6a4271c649 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcs.py +++ b/esmvalcore/preprocessor/_derive/rsnstcs.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py index a6445bbb64..590a4bdd57 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py +++ b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from cf_units import Unit from iris import Constraint @@ -34,12 +33,11 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute `rsnstcs`. + """Compute `rsnstcs`. - Compute Heating from Shortwave Absorption - assuming clear sky normalized by - the incoming shortwave flux at the top of the atmosphere. + Compute Heating from Shortwave Absorption assuming clear sky + normalized by the incoming shortwave flux at the top of the + atmosphere. """ rsdscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_shortwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rsus.py b/esmvalcore/preprocessor/_derive/rsus.py index 326d063c26..cd3a6ad4dd 100644 --- a/esmvalcore/preprocessor/_derive/rsus.py +++ b/esmvalcore/preprocessor/_derive/rsus.py @@ -2,7 +2,6 @@ authors: - lukas_brunner - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/siextent.py b/esmvalcore/preprocessor/_derive/siextent.py index eee25e5a98..2e2bee96bb 100644 --- a/esmvalcore/preprocessor/_derive/siextent.py +++ b/esmvalcore/preprocessor/_derive/siextent.py @@ -6,6 +6,7 @@ from iris import Constraint from esmvalcore.exceptions import RecipeError + from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) diff --git a/esmvalcore/preprocessor/_derive/sispeed.py b/esmvalcore/preprocessor/_derive/sispeed.py index 168b2e5525..b28aa06214 100644 --- a/esmvalcore/preprocessor/_derive/sispeed.py +++ b/esmvalcore/preprocessor/_derive/sispeed.py @@ -1,10 +1,10 @@ """Derivation of variable `sispeed`.""" import logging + from iris import Constraint from .._regrid import regrid - from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) @@ -24,8 +24,7 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute sispeed module from velocity components siu and siv. + """Compute sispeed module from velocity components siu and siv. Arguments --------- @@ -34,7 +33,6 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. - """ siu = cubes.extract_cube(Constraint(name='sea_ice_x_velocity')) siv = cubes.extract_cube(Constraint(name='sea_ice_y_velocity')) diff --git a/esmvalcore/preprocessor/_derive/sithick.py b/esmvalcore/preprocessor/_derive/sithick.py index ad80709d8f..b28fa2881b 100644 --- a/esmvalcore/preprocessor/_derive/sithick.py +++ b/esmvalcore/preprocessor/_derive/sithick.py @@ -20,8 +20,7 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute sea ice thickness from volume and concentration. + """Compute sea ice thickness from volume and concentration. In CMIP5, `sit` is called `sea_ice_thickness` but it is not real thickness. It is ice volume per area unit. In CMIP6, it is called @@ -34,7 +33,6 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. - """ sivol = cubes.extract_cube(Constraint(name='sea_ice_thickness')) siconc = cubes.extract_cube(Constraint(name='sea_ice_area_fraction')) diff --git a/esmvalcore/preprocessor/_derive/sm.py b/esmvalcore/preprocessor/_derive/sm.py index deb3526dfd..efc3810d65 100644 --- a/esmvalcore/preprocessor/_derive/sm.py +++ b/esmvalcore/preprocessor/_derive/sm.py @@ -25,7 +25,6 @@ def calculate(cubes): Convert moisture content of soil layer (kg/m2) into volumetric soil moisture (m3/m3), assuming density of water 998.2 kg/m2 (at temperature 20 deg C). - """ mrsos_cube = cubes.extract_cube(NameConstraint(var_name='mrsos')) diff --git a/esmvalcore/preprocessor/_derive/toz.py b/esmvalcore/preprocessor/_derive/toz.py index 32fd9e8334..62514d4ca3 100644 --- a/esmvalcore/preprocessor/_derive/toz.py +++ b/esmvalcore/preprocessor/_derive/toz.py @@ -39,7 +39,6 @@ def calculate(cubes): ---- The surface pressure is used as a lower integration bound. A fixed upper integration bound of 0 Pa is used. - """ tro3_cube = cubes.extract_cube( iris.Constraint(name='mole_fraction_of_ozone_in_air')) diff --git a/esmvalcore/preprocessor/_detrend.py b/esmvalcore/preprocessor/_detrend.py index 5bc0ce6fc8..9faee61c73 100644 --- a/esmvalcore/preprocessor/_detrend.py +++ b/esmvalcore/preprocessor/_detrend.py @@ -8,8 +8,7 @@ def detrend(cube, dimension='time', method='linear'): - """ - Detrend data along a given dimension. + """Detrend data along a given dimension. Parameters ---------- diff --git a/esmvalcore/preprocessor/_mapping.py b/esmvalcore/preprocessor/_mapping.py index 28d1fefb83..a39e26e823 100644 --- a/esmvalcore/preprocessor/_mapping.py +++ b/esmvalcore/preprocessor/_mapping.py @@ -8,11 +8,10 @@ def _is_single_item(testee): - """ - Check if testee is a single item. + """Check if testee is a single item. - Return whether this is a single item, rather than an iterable. - We count string types as 'single', also. + Return whether this is a single item, rather than an iterable. We + count string types as 'single', also. """ return (isinstance(testee, str) or not isinstance(testee, collections.abc.Iterable)) @@ -64,8 +63,7 @@ def ref_to_dims_index_as_index(cube, ref): def ref_to_dims_index(cube, ref_to_slice): - """ - Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. + """Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. This method finds the indices of the dimensions in a cube that collectively correspond to the given list of :class:`iris.coords.DimCoord`. @@ -100,8 +98,7 @@ def ref_to_dims_index(cube, ref_to_slice): def get_associated_coords(cube, dimensions): - """ - Return all coords containing any of the given dimensions. + """Return all coords containing any of the given dimensions. Return all coords, dimensional and auxiliary, that contain any of the given dimensions. @@ -125,11 +122,10 @@ def get_associated_coords(cube, dimensions): def get_empty_data(shape, dtype=np.float32): - """ - Create an empty data object of the given shape. + """Create an empty data object of the given shape. - Creates an empty data object of the given shape, potentially of the lazy - kind from biggus or dask, depending on the used iris version. + Creates an empty data object of the given shape, potentially of the + lazy kind from biggus or dask, depending on the used iris version. """ data = np.empty(shape, dtype=dtype) mask = np.empty(shape, dtype=bool) @@ -137,11 +133,10 @@ def get_empty_data(shape, dtype=np.float32): def get_slice_spec(cube, ref_to_slice): - """ - Turn a slice reference into a specification for the slice. + """Turn a slice reference into a specification for the slice. - Turns a slice reference into a specification comprised of the shape as well - as the relevant dimensional and auxiliary coordinates. + Turns a slice reference into a specification comprised of the shape + as well as the relevant dimensional and auxiliary coordinates. """ slice_dims = ref_to_dims_index(cube, ref_to_slice) slice_shape = tuple(cube.shape[d] for d in slice_dims) @@ -150,8 +145,7 @@ def get_slice_spec(cube, ref_to_slice): def index_iterator(dims_to_slice, shape): - """ - Return iterator for subsets of multidimensional objects. + """Return iterator for subsets of multidimensional objects. An iterator over a multidimensional object, giving both source and destination indices. @@ -181,8 +175,7 @@ def get_slice_coords(cube): def map_slices(src, func, src_rep, dst_rep): - """ - Map slices of a cube, replacing them with different slices. + """Map slices of a cube, replacing them with different slices. This method is similar to the standard cube collapsed and aggregated_by methods, however, where they completely remove the mapped dimensions, this diff --git a/esmvalcore/preprocessor/_multimodel.py b/esmvalcore/preprocessor/_multimodel.py index d1e0d90e74..b8950c2d8e 100644 --- a/esmvalcore/preprocessor/_multimodel.py +++ b/esmvalcore/preprocessor/_multimodel.py @@ -1,11 +1,11 @@ """Statistics across cubes. -This module contains functions to compute statistics across multiple cubes or -products. +This module contains functions to compute statistics across multiple +cubes or products. -Wrapper functions separate esmvalcore internals, operating on products, from -generalized functions that operate on iris cubes. These wrappers support -grouped execution by passing a groupby keyword. +Wrapper functions separate esmvalcore internals, operating on products, +from generalized functions that operate on iris cubes. These wrappers +support grouped execution by passing a groupby keyword. """ from __future__ import annotations @@ -53,16 +53,16 @@ def _get_consistent_time_unit(cubes): def _unify_time_coordinates(cubes): """Make sure all cubes' share the same time coordinate. - This function extracts the date information from the cube and reconstructs - the time coordinate, resetting the actual dates to the 15th of the month or - 1st of July for yearly data (consistent with `regrid_time`), so that there - are no mismatches in the time arrays. + This function extracts the date information from the cube and + reconstructs the time coordinate, resetting the actual dates to the + 15th of the month or 1st of July for yearly data (consistent with + `regrid_time`), so that there are no mismatches in the time arrays. If cubes have different time units, it will reset the calendar to a the "standard" calendar with unit "days since 1850-01-01". - Might not work for (sub)daily data, because different calendars may have - different number of days in the year. + Might not work for (sub)daily data, because different calendars may + have different number of days in the year. """ t_unit = _get_consistent_time_unit(cubes) @@ -245,7 +245,6 @@ def _get_equal_coord_names_metadata(cubes, equal_coords_metadata): Note ---- Ignore coordinates whose names are not unique. - """ equal_names_metadata = {} for coord in cubes[0].coords(): @@ -361,7 +360,6 @@ def _equalise_var_metadata(cubes): If cubes have the same ``name()`` and ``units``, assign identical `standard_names`, `long_names`, and `var_names`. - """ attrs = ['standard_name', 'long_name', 'var_name'] equal_names_metadata = {} @@ -441,7 +439,6 @@ def _compute_slices(cubes): Note ---- For scalar cubes, simply return ``None``. - """ # Scalar cubes if cubes[0].shape == (): diff --git a/esmvalcore/preprocessor/_other.py b/esmvalcore/preprocessor/_other.py index 3d047a4e24..c91866ade7 100644 --- a/esmvalcore/preprocessor/_other.py +++ b/esmvalcore/preprocessor/_other.py @@ -133,7 +133,6 @@ def histogram( `longitude` is not found in cube if `weights=True`, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. - """ # Check arguments if isinstance(bins, str): @@ -248,10 +247,9 @@ def _calculate_histogram_lazy( ) -> da.Array: """Calculate histogram over data along axes (lazy version). - This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are - the dimensions of `data` not appearing in `axes` and `n_bins` is the number - of bins. - + This will return an array of shape `(x1, x2, ..., n_bins)` where + `xi` are the dimensions of `data` not appearing in `axes` and + `n_bins` is the number of bins. """ n_axes = len(along_axes) @@ -315,10 +313,9 @@ def _calculate_histogram_eager( ) -> np.ndarray: """Calculate histogram over data along axes (eager version). - This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are - the dimensions of `data` not appearing in `axes` and `n_bins` is the number - of bins. - + This will return an array of shape `(x1, x2, ..., n_bins)` where + `xi` are the dimensions of `data` not appearing in `axes` and + `n_bins` is the number of bins. """ # Create array with shape (x1, x2, ..., y) where `y` is the product of all # dimensions in `axes` and the `xi` are the remaining dimensions diff --git a/esmvalcore/preprocessor/_regrid.py b/esmvalcore/preprocessor/_regrid.py index 228bd7dc26..0e9e8aafc9 100644 --- a/esmvalcore/preprocessor/_regrid.py +++ b/esmvalcore/preprocessor/_regrid.py @@ -30,11 +30,9 @@ from esmvalcore.cmor.table import CMOR_TABLES from esmvalcore.exceptions import ESMValCoreDeprecationWarning from esmvalcore.iris_helpers import has_irregular_grid, has_unstructured_grid -from esmvalcore.preprocessor._shared import ( - get_dims_along_axes, -) from esmvalcore.preprocessor._shared import ( get_array_module, + get_dims_along_axes, preserve_float_dtype, ) from esmvalcore.preprocessor._supplementary_vars import ( diff --git a/esmvalcore/preprocessor/_regrid_esmpy.py b/esmvalcore/preprocessor/_regrid_esmpy.py index cce6dae92f..3055f82f83 100755 --- a/esmvalcore/preprocessor/_regrid_esmpy.py +++ b/esmvalcore/preprocessor/_regrid_esmpy.py @@ -10,6 +10,7 @@ except ImportError: raise exc import warnings + import iris import numpy as np from iris.cube import Cube @@ -65,7 +66,6 @@ class ESMPyRegridder: `nearest`. mask_threshold: Threshold used to regrid mask of input cube. - """ def __init__( @@ -96,7 +96,6 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. - """ # These regridders are not lazy, so load source data once. cube.data # pylint: disable=pointless-statement @@ -124,7 +123,6 @@ class _ESMPyScheme: ---------- mask_threshold: Threshold used to regrid mask of source cube. - """ _METHOD = '' @@ -162,7 +160,6 @@ def regridder(self, src_cube: Cube, tgt_cube: Cube) -> ESMPyRegridder: ------- ESMPyRegridder Regridder instance. - """ return ESMPyRegridder( src_cube, @@ -184,7 +181,6 @@ class ESMPyAreaWeighted(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. - """ _METHOD = 'area_weighted' @@ -202,7 +198,6 @@ class ESMPyLinear(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. - """ _METHOD = 'linear' @@ -220,7 +215,6 @@ class ESMPyNearest(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. - """ _METHOD = 'nearest' @@ -450,8 +444,7 @@ def get_grid_representant(cube, horizontal_only=False): def get_grid_representants(src, dst): - """ - Construct cubes representing the source and destination grid. + """Construct cubes representing the source and destination grid. This method constructs two new cubes that representant the grids, i.e. the spatial dimensions of the given cubes. diff --git a/esmvalcore/preprocessor/_regrid_unstructured.py b/esmvalcore/preprocessor/_regrid_unstructured.py index 6618c728c0..ce94d7fa68 100644 --- a/esmvalcore/preprocessor/_regrid_unstructured.py +++ b/esmvalcore/preprocessor/_regrid_unstructured.py @@ -26,10 +26,10 @@ class UnstructuredNearest(IrisUnstructuredNearest): """Unstructured nearest-neighbor regridding scheme. - This class is a wrapper around :class:`iris.analysis.UnstructuredNearest` - that removes any additional X or Y coordinates prior to regridding if - necessary. It can be used in :meth:`iris.cube.Cube.regrid`. - + This class is a wrapper around + :class:`iris.analysis.UnstructuredNearest` that removes any + additional X or Y coordinates prior to regridding if necessary. It + can be used in :meth:`iris.cube.Cube.regrid`. """ def regridder( @@ -50,7 +50,6 @@ def regridder( ------- UnstructuredNearestNeigbourRegridder Regridder instance. - """ # Unstructured nearest-neighbor regridding requires exactly one X and # one Y coordinate (latitude and longitude). Remove any X or Y @@ -79,7 +78,6 @@ class UnstructuredLinearRegridder: Cube defining the source grid. tgt_cube: Cube defining the target grid. - """ def __init__(self, src_cube: Cube, tgt_cube: Cube) -> None: @@ -127,7 +125,6 @@ def _get_weights_and_idx( The output arrays will be numpy arrays here (instead of dask) since resulting arrays are only 2D and will be computed anyway later during regridding. - """ # Make sure that source and target grid have identical units src_lat = src_lat.copy() @@ -191,7 +188,6 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. - """ if not has_unstructured_grid(cube): raise ValueError( @@ -320,7 +316,6 @@ def _interpolate(self, data: np.ndarray) -> np.ndarray: Before the interpolation, the input is extended by the data on the convex hull to consider the periodic boundary conditions of a sphere (this has also been done for the weights calculation). - """ data = self._add_convex_hull_twice(data, self._convex_hull_idx) interp_data = np.einsum( @@ -347,7 +342,6 @@ def _calculate_weights( Output shapes (M: number of target grid points) - weights: (M, 3) - indices: (M, 3) - """ tri = Delaunay(src_points) simplex = tri.find_simplex(tgt_points) @@ -373,7 +367,6 @@ class UnstructuredLinear: This will drop all cell measures, ancillary variables and aux factories, and any auxiliary coordinate that spans the dimension of the unstrucutred grid. - """ def __repr__(self) -> str: @@ -398,6 +391,5 @@ def regridder( ------- UnstructuredLinearRegridder Regridder instance. - """ return UnstructuredLinearRegridder(src_cube, tgt_cube) diff --git a/esmvalcore/preprocessor/_rolling_window.py b/esmvalcore/preprocessor/_rolling_window.py index 9e62275a45..4b0b5cdf14 100644 --- a/esmvalcore/preprocessor/_rolling_window.py +++ b/esmvalcore/preprocessor/_rolling_window.py @@ -39,7 +39,6 @@ def rolling_window_statistics( ------- iris.cube.Cube Rolling-window statistics cube. - """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) cube = cube.rolling_window(coordinate, agg, window_length, *agg_kwargs) diff --git a/esmvalcore/preprocessor/_shared.py b/esmvalcore/preprocessor/_shared.py index 67c3b89f5d..1ed78b9766 100644 --- a/esmvalcore/preprocessor/_shared.py +++ b/esmvalcore/preprocessor/_shared.py @@ -1,5 +1,4 @@ -""" -Shared functions for preprocessor. +"""Shared functions for preprocessor. Utility functions that can be used for multiple preprocessor steps """ @@ -68,7 +67,6 @@ def get_iris_aggregator( An invalid `operator` is specified, i.e., it is not found in :mod:`iris.analysis` or the returned object is not an :class:`iris.analysis.Aggregator`. - """ cap_operator = operator.upper() aggregator_kwargs = dict(operator_kwargs) @@ -138,7 +136,6 @@ def aggregator_accept_weights(aggregator: iris.analysis.Aggregator) -> bool: ------- bool ``True`` if aggregator support weights, ``False`` otherwise. - """ weighted_aggregators_cls = ( iris.analysis.WeightedAggregator, @@ -179,7 +176,6 @@ def update_weights_kwargs( ------- dict Updated keyword arguments. - """ kwargs = dict(kwargs) if aggregator_accept_weights(aggregator) and kwargs.get('weights', True): @@ -218,7 +214,6 @@ def get_normalized_cube( ------- Cube Input cube normalized with statistics cube. - """ if normalize == 'subtract': normalized_cube = cube - statistics_cube @@ -250,11 +245,10 @@ def get_normalized_cube( def preserve_float_dtype(func: Callable) -> Callable: """Preserve object's float dtype (all other dtypes are allowed to change). - This can be used as a decorator for preprocessor functions to ensure that - floating dtypes are preserved. For example, input of type float32 will - always give output of type float32, but input of type int will be allowed - to give output with any type. - + This can be used as a decorator for preprocessor functions to ensure + that floating dtypes are preserved. For example, input of type + float32 will always give output of type float32, but input of type + int will be allowed to give output with any type. """ @wraps(func) @@ -381,7 +375,6 @@ def get_time_weights(cube: Cube) -> np.ndarray | da.core.Array: Array of time weights for averaging. Returns a :class:`dask.array.Array` if the input cube has lazy data; a :class:`numpy.ndarray` otherwise. - """ time = cube.coord('time') coord_dims = cube.coord_dims('time') diff --git a/esmvalcore/preprocessor/_time.py b/esmvalcore/preprocessor/_time.py index d4dff4c1f9..5fd60d807a 100644 --- a/esmvalcore/preprocessor/_time.py +++ b/esmvalcore/preprocessor/_time.py @@ -100,7 +100,6 @@ def extract_time( ------ ValueError Time ranges are outside the cube time limits. - """ t_1 = PartialDateTime(year=int(start_year), month=int(start_month), @@ -260,7 +259,6 @@ def clip_timerange(cube: Cube, timerange: str) -> Cube: ------ ValueError Time ranges are outside the cube's time limits. - """ start_date = _parse_start_date(timerange.split('/')[0]) end_date = _parse_end_date(timerange.split('/')[1]) @@ -318,7 +316,6 @@ def extract_season(cube: Cube, season: str) -> Cube: ------ ValueError Requested season is not present in the cube. - """ season = season.upper() @@ -372,7 +369,6 @@ def extract_month(cube: Cube, month: int) -> Cube: ------ ValueError Requested month is not present in the cube. - """ if month not in range(1, 13): raise ValueError('Please provide a month number between 1 and 12.') @@ -446,7 +442,6 @@ def hourly_statistics( ------- iris.cube.Cube Hourly statistics cube. - """ if not cube.coords('hour_group'): iris.coord_categorisation.add_categorised_coord( @@ -498,7 +493,6 @@ def daily_statistics( ------- iris.cube.Cube Daily statistics cube. - """ if not cube.coords('day_of_year'): iris.coord_categorisation.add_day_of_year(cube, 'time') @@ -539,7 +533,6 @@ def monthly_statistics( ------- iris.cube.Cube Monthly statistics cube. - """ if not cube.coords('month_number'): iris.coord_categorisation.add_month_number(cube, 'time') @@ -584,7 +577,6 @@ def seasonal_statistics( ------- iris.cube.Cube Seasonal statistic cube. - """ seasons = tuple(sea.upper() for sea in seasons) @@ -631,7 +623,6 @@ def spans_full_season(cube: Cube) -> list[bool]: ------- list[bool] Truth statements if time bounds are within (month*29, month*31) - """ time = cube.coord('time') num_days = [(tt.bounds[0, 1] - tt.bounds[0, 0]) for tt in time] @@ -675,7 +666,6 @@ def annual_statistics( ------- iris.cube.Cube Annual statistics cube. - """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -717,7 +707,6 @@ def decadal_statistics( ------- iris.cube.Cube Decadal statistics cube. - """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -1036,7 +1025,6 @@ def regrid_time( NotImplementedError An invalid `frequency` is given or `calendar` is set for a non-supported frequency. - """ # Do not overwrite input cube cube = cube.copy() @@ -1220,7 +1208,6 @@ def timeseries_filter( Cube does not have time coordinate. NotImplementedError: `filter_type` is not implemented. - """ try: cube.coord('time') @@ -1295,7 +1282,6 @@ def resample_hours( `interval` is not a divisor of 24; invalid `interpolate` given; or input data does not contain any target hour (if `interpolate` is ``None``). - """ allowed_intervals = (1, 2, 3, 4, 6, 12) if interval not in allowed_intervals: @@ -1387,7 +1373,6 @@ def resample_time( ------- iris.cube.Cube Cube with the new frequency. - """ time = cube.coord('time') dates = time.units.num2date(time.points) @@ -1425,7 +1410,6 @@ def _get_lst_offset(lon_coord: Coord) -> np.ndarray: ---- This function expects longitude in degrees. Can be in [0, 360] or [-180, 180] format. - """ # Make sure that longitude is in degrees and shift it to [-180, 180] first # (do NOT overwrite input coordinate) @@ -1442,7 +1426,6 @@ def _get_lsts(time_coord: DimCoord, lon_coord: Coord) -> np.ndarray: ---- LSTs outside of the time bins given be the time coordinate bounds are put into a bin below/above the time coordinate. - """ # Pad time coordinate with 1 time step at both sides for the bins for LSTs # outside of the time coordinate @@ -1490,7 +1473,6 @@ def _get_time_index_and_mask( (LSTs) are given. E.g., for hourly data with first time point 01:00:00 UTC, LST in Berlin is already 02:00:00 (assuming no daylight saving time). Thus, for 01:00:00 LST on this day, there is no value for Berlin. - """ # Make sure that time coordinate has bounds (these are necessary for the # binning) and uses 'hours' as reference units @@ -1555,7 +1537,6 @@ def _transform_to_lst_eager( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. - """ # Apart from the time index, all other dimensions will stay the same; this # is ensured with np.ogrid @@ -1599,7 +1580,6 @@ def _transform_to_lst_lazy( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. - """ new_data = da.apply_gufunc( _transform_to_lst_eager, @@ -1630,7 +1610,6 @@ def _transform_arr_to_lst( ---- This function either calls `_transform_to_lst_eager` or `_transform_to_lst_lazy` depending on the type of input data. - """ if isinstance(data, np.ndarray): func = _transform_to_lst_eager # type: ignore @@ -1811,7 +1790,6 @@ def local_solar_time(cube: Cube) -> Cube: Input cube has multidimensional `longitude` coordinate. ValueError `time` coordinate of input cube is not monotonically increasing. - """ # Make sure that cube has valid time and longitude coordinates _check_cube_coords(cube) diff --git a/esmvalcore/preprocessor/_trend.py b/esmvalcore/preprocessor/_trend.py index c592f5196e..b81d656034 100644 --- a/esmvalcore/preprocessor/_trend.py +++ b/esmvalcore/preprocessor/_trend.py @@ -96,7 +96,6 @@ def linear_trend(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. - """ coord = cube.coord(coordinate, dim_coords=True) @@ -151,7 +150,6 @@ def linear_trend_stderr(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. - """ coord = cube.coord(coordinate, dim_coords=True) diff --git a/esmvalcore/preprocessor/_units.py b/esmvalcore/preprocessor/_units.py index 8c96f78ae1..c71fc384d6 100644 --- a/esmvalcore/preprocessor/_units.py +++ b/esmvalcore/preprocessor/_units.py @@ -112,7 +112,6 @@ def convert_units(cube, units): ------- iris.cube.Cube converted cube. - """ try: cube.convert_units(units) diff --git a/esmvalcore/preprocessor/_volume.py b/esmvalcore/preprocessor/_volume.py index 840af3214e..9705f4e4e9 100644 --- a/esmvalcore/preprocessor/_volume.py +++ b/esmvalcore/preprocessor/_volume.py @@ -66,7 +66,6 @@ def extract_volume( ------- iris.cube.Cube z-coord extracted cube. - """ if z_min > z_max: # minimum is below maximum, so switch them around @@ -124,7 +123,6 @@ def calculate_volume(cube: Cube) -> da.core.Array: ------- dask.array.core.Array Grid volumes. - """ # Load depth field and figure out which dim is which depth = cube.coord(axis='z') @@ -254,7 +252,6 @@ def volume_statistics( ------- iris.cube.Cube Collapsed cube. - """ has_cell_measure = bool(cube.cell_measures('ocean_volume')) @@ -339,7 +336,6 @@ def axis_statistics( ------- iris.cube.Cube Collapsed cube. - """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) @@ -426,7 +422,6 @@ def depth_integration(cube: Cube) -> Cube: ------- iris.cube.Cube Collapsed cube. - """ result = axis_statistics(cube, axis='z', operator='sum') result.rename('Depth_integrated_' + str(cube.name())) @@ -480,7 +475,6 @@ def extract_transect( ValueError Latitude and longitude are both floats or lists; not allowed to slice on both axes at the same time. - """ # ### coord_dim2 = False @@ -571,7 +565,6 @@ def extract_trajectory( ------ ValueError Latitude and longitude have different dimensions. - """ from iris.analysis.trajectory import interpolate diff --git a/esmvalcore/preprocessor/shapefiles/ar6.prj b/esmvalcore/preprocessor/shapefiles/ar6.prj index a30c00a55d..8f73f480ff 100644 --- a/esmvalcore/preprocessor/shapefiles/ar6.prj +++ b/esmvalcore/preprocessor/shapefiles/ar6.prj @@ -1 +1 @@ -GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] diff --git a/esmvalcore/typing.py b/esmvalcore/typing.py index 410b31f0f8..d5c60fc83e 100644 --- a/esmvalcore/typing.py +++ b/esmvalcore/typing.py @@ -17,8 +17,8 @@ NetCDFAttr = Union[str, Number, Iterable] """Type describing netCDF attributes. -`NetCDF attributes -`_ can +`NetCDF attributes`_ +can be strings, numbers or sequences. """ diff --git a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py index d988e02441..4f26feaf9e 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py @@ -27,7 +27,7 @@ def setUp(self): self.fix = Cl(None) def test_get(self): - """Test fix get""" + """Test fix get.""" fix = Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'cl') assert fix == [Cl(None), GenericFix(None)] diff --git a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py index ce6ebe0121..ba41ddae48 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py @@ -17,7 +17,7 @@ def setUp(self): self.fix = Msftmyz(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) @@ -37,7 +37,7 @@ def setUp(self): self.fix = Msftmyzba(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyzba'), [Msftmyzba(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py index 4b480ef81f..a0805f4efe 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py @@ -26,7 +26,7 @@ def setUp(self): self.fix = Sic(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sic'), [Sic(None), GenericFix(None)]) @@ -45,7 +45,7 @@ def setUp(self): self.fix = Sftlf(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sftlf'), [Sftlf(None), GenericFix(None)]) @@ -90,7 +90,7 @@ def setUp(self): self.fix = Tas(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'tas'), [Tas(None), GenericFix(None)]) @@ -147,7 +147,7 @@ def setUp(self): self.fix = Areacello(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Omon', 'areacello'), [Areacello(None), GenericFix(None)], @@ -209,7 +209,7 @@ def setUp(self): self.fix = Pr(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'pr'), [Pr(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py index c0705e58fa..0220aecb2c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py @@ -29,7 +29,7 @@ def setUp(self): self.fix = Ch4(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'ch4'), [Ch4(None), GenericFix(None)]) @@ -48,7 +48,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'co2'), [Co2(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py index 8a4fa19fd1..f2aa86d7b2 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py @@ -40,7 +40,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -62,7 +62,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'Amon', 'areacello'), [Areacello(self.vardef), @@ -106,7 +106,7 @@ def setUp(self): self.fix = Sit(self.var_info_mock) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'OImon', 'sit'), [Sit(self.var_info_mock), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py index bcda26c95b..89b62a21f9 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -39,7 +39,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'Amon', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py index d5189e84c4..d0f0c5245c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py @@ -75,7 +75,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -96,7 +96,7 @@ def setUp(self): self.fix = Usi(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'usi'), [Usi(self.vardef), @@ -118,7 +118,7 @@ def setUp(self): self.fix = Vsi(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'vsi'), [Vsi(self.vardef), @@ -140,7 +140,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py index 1897ba5c85..9fe2db7c83 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py @@ -23,7 +23,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -43,7 +43,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -64,7 +64,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py index 0e6a4fc57a..85bede7678 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py +++ b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py @@ -9,7 +9,7 @@ class TestAllVars(unittest.TestCase): """Test allvars fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'tas'), [AllVars(None), GenericFix(None)]) @@ -18,7 +18,7 @@ def test_get(self): class TestO2(unittest.TestCase): """Test o2 fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'o2'), [O2(None), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py index 1e14dfd30c..64fcbc250c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py +++ b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Tro3(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MIROC-ESM-CHEM', 'Amon', 'tro3'), [Tro3(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py index f4d39eb70b..baabbbf599 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py @@ -9,7 +9,7 @@ class TestMsftmyz(unittest.TestCase): """Test msftmyz fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MRI-ESM1', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py index b600311d5a..fc962f38b7 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py +++ b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py @@ -69,7 +69,7 @@ def test_tas(cubes_in, cubes_out): def test_get(): - """Test fix get""" + """Test fix get.""" assert Fix.get_fixes('CMIP5', 'NORESM1-ME', 'Amon', 'tas') == [ Tas(None), GenericFix(None) ] diff --git a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py index 65ca211e12..b4c1b9f7e9 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py +++ b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py @@ -2,6 +2,7 @@ import iris import numpy as np import pytest +from cf_units import Unit from esmvalcore.cmor._fixes.cmip6.gfdl_cm4 import ( Cl, @@ -15,11 +16,10 @@ Tos, Uas, ) -from esmvalcore.cmor._fixes.common import SiconcFixScalarCoord, OceanFixGrid +from esmvalcore.cmor._fixes.common import OceanFixGrid, SiconcFixScalarCoord from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info -from cf_units import Unit def test_get_cl_fix(): diff --git a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py index 63428e913c..9668681c06 100644 --- a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py @@ -4,7 +4,8 @@ from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5 import ( aladin63, - wrf381p,) + wrf381p, +) from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info diff --git a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py index c54bea04cd..f1149064a0 100644 --- a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py +++ b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py @@ -1,6 +1,6 @@ """Tests for the fixes of MIROC-MIROC5.""" -import pytest import iris +import pytest from esmvalcore.cmor._fixes.cordex.miroc_miroc5 import wrf361h from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_fix.py b/tests/integration/cmor/_fixes/test_fix.py index 1e97c62fd4..cfbbbebf31 100644 --- a/tests/integration/cmor/_fixes/test_fix.py +++ b/tests/integration/cmor/_fixes/test_fix.py @@ -10,9 +10,7 @@ from esmvalcore.cmor._fixes.cmip5.canesm2 import FgCo2 from esmvalcore.cmor._fixes.cmip5.cesm1_bgc import Gpp from esmvalcore.cmor._fixes.cmip6.cesm2 import Omon, Tos -from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import ( - Tas, -) +from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import Tas from esmvalcore.cmor._fixes.cordex.cordex_fixes import AllVars from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_native_datasets.py b/tests/integration/cmor/_fixes/test_native_datasets.py index 5399bf887e..1a732f1788 100644 --- a/tests/integration/cmor/_fixes/test_native_datasets.py +++ b/tests/integration/cmor/_fixes/test_native_datasets.py @@ -89,7 +89,6 @@ def fix(): We use `tas` as a dummy variable here, but will use monkeypatching to customize the variable information of the fix in the tests below. This will allow us to test all common cases. - """ vardef = get_var_info('CMIP6', 'Amon', 'tas') extra_facets = {} diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index fbddec7fe0..cc4237f5b7 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -43,9 +43,8 @@ def create_test_file(filename, tracking_id=None): def _get_files(root_path, facets, tracking_id): """Return dummy files. - Wildcards are only supported for `dataset` and `institute`; in this case - return files for the two "models" AAA and BBB. - + Wildcards are only supported for `dataset` and `institute`; in this + case return files for the two "models" AAA and BBB. """ if facets['dataset'] == '*': all_facets = [ @@ -141,7 +140,6 @@ def patched_failing_datafinder(tmp_path, monkeypatch): - Variable rsutcs for model AAA Otherwise, return files just like `patched_datafinder`. - """ def tracking_ids(i=0): diff --git a/tests/integration/data_finder.yml b/tests/integration/data_finder.yml index 40e0c3e821..9b90bc7da6 100644 --- a/tests/integration/data_finder.yml +++ b/tests/integration/data_finder.yml @@ -452,7 +452,7 @@ get_input_filelist: - ta_Amon_HadGEM2-ES_historical_r1i1p1*.nc found_files: - historical/Amon/ta/HadGEM2-ES/r1i1p1/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -472,7 +472,7 @@ get_input_filelist: found_files: - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_195912-198411.nc - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -593,7 +593,7 @@ get_input_filelist: found_files: - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_195001-199912.nc - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_200001-200112.nc - + - drs: NCI variable: variable_group: test diff --git a/tests/integration/preprocessor/_extract_region/test_intersect.py b/tests/integration/preprocessor/_extract_region/test_intersect.py index 41442c9c01..813576e4c6 100644 --- a/tests/integration/preprocessor/_extract_region/test_intersect.py +++ b/tests/integration/preprocessor/_extract_region/test_intersect.py @@ -1,8 +1,8 @@ -""" -Temporary test. +"""Temporary test. Remove this test and test file after iris fixes this -https://github.com/SciTools/iris/issues/5413 . +https://github.com/SciTools/iris/issues/5413 +. """ import iris import numpy as np diff --git a/tests/integration/preprocessor/_mask/__init__.py b/tests/integration/preprocessor/_mask/__init__.py index 9886ea9eed..1b1a5d625b 100644 --- a/tests/integration/preprocessor/_mask/__init__.py +++ b/tests/integration/preprocessor/_mask/__init__.py @@ -1,5 +1,4 @@ -""" -Test _mask.py +"""Test _mask.py. Integration tests for the esmvalcore.preprocessor._mask module """ diff --git a/tests/integration/preprocessor/_regrid/__init__.py b/tests/integration/preprocessor/_regrid/__init__.py index e19e118a0f..bb8eab5e54 100644 --- a/tests/integration/preprocessor/_regrid/__init__.py +++ b/tests/integration/preprocessor/_regrid/__init__.py @@ -1,4 +1 @@ -""" -Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module. - -""" +"""Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module.""" diff --git a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py index 7b4d4eb9b5..f666ff64cf 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py +++ b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py @@ -1,8 +1,5 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function.""" import unittest @@ -23,7 +20,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point""" + """Test linear interpolation when extracting a single point.""" point = extract_coordinate_points( self.cube, {'grid_latitude': 2.1, 'grid_longitude': 2.1}, @@ -66,7 +63,7 @@ def test_extract_point__single_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point""" + """Test nearest match when extracting a single point.""" point = extract_coordinate_points( self.cube, @@ -99,7 +96,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate""" + """Test linear interpolation for an array of one coordinate.""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -151,7 +148,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate""" + """Test nearest match for an array of one coordinate.""" point = extract_coordinate_points( self.cube, @@ -192,8 +189,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with - linear interpolation""" + """Test for both latitude and longitude arrays, with linear + interpolation.""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], @@ -223,7 +220,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match""" + """Test for both latitude and longitude arrays, with nearest match.""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], diff --git a/tests/integration/preprocessor/_regrid/test_extract_point.py b/tests/integration/preprocessor/_regrid/test_extract_point.py index d3d93945b9..79ec2e5685 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_point.py +++ b/tests/integration/preprocessor/_regrid/test_extract_point.py @@ -1,8 +1,5 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function.""" import unittest @@ -23,7 +20,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point""" + """Test linear interpolation when extracting a single point.""" point = extract_point(self.cube, 2.1, 2.1, scheme='linear') self.assertEqual(point.shape, (3,)) @@ -58,7 +55,7 @@ def test_extract_point__single_linear(self): assert point.data.mask.all() def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point""" + """Test nearest match when extracting a single point.""" point = extract_point(self.cube, 2.1, 2.1, scheme='nearest') self.assertEqual(point.shape, (3,)) @@ -79,7 +76,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate""" + """Test linear interpolation for an array of one coordinate.""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -121,7 +118,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate""" + """Test nearest match for an array of one coordinate.""" point = extract_point(self.cube, [1, 1.1, 1.5, 1.501, 2, 4], 2, scheme='nearest') @@ -150,8 +147,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with - linear interpolation""" + """Test for both latitude and longitude arrays, with linear + interpolation.""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='linear') self.assertEqual(point.data.shape, (3, 6, 6)) @@ -179,7 +176,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match""" + """Test for both latitude and longitude arrays, with nearest match.""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='nearest') self.assertEqual(point.data.shape, (3, 6, 6)) diff --git a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py index b4f869d171..b7a2ed0bcd 100644 --- a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py +++ b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py @@ -1,8 +1,6 @@ -""" -Integration tests for the :func: -`esmvalcore.preprocessor.regrid.get_cmor_levels` -function. +"""Integration tests for the :func: +`esmvalcore.preprocessor.regrid.get_cmor_levels` function. """ import unittest diff --git a/tests/integration/preprocessor/_regrid/test_regrid.py b/tests/integration/preprocessor/_regrid/test_regrid.py index 4e2e472681..00f35c0ad8 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid.py +++ b/tests/integration/preprocessor/_regrid/test_regrid.py @@ -1,8 +1,5 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function.""" import iris import numpy as np diff --git a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py index fee070863c..8b410771fc 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py +++ b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py @@ -1,4 +1,4 @@ -""" Integration tests for unstructured regridding.""" +"""Integration tests for unstructured regridding.""" import numpy as np import pytest diff --git a/tests/integration/preprocessor/_supplementary_vars/test_register.py b/tests/integration/preprocessor/_supplementary_vars/test_register.py index cfe6d5b7da..bf4c1677d2 100644 --- a/tests/integration/preprocessor/_supplementary_vars/test_register.py +++ b/tests/integration/preprocessor/_supplementary_vars/test_register.py @@ -28,7 +28,7 @@ def test_func(): def test_register_invalid_fails(): - """test that registering an invalid requirement fails.""" + """Test that registering an invalid requirement fails.""" with pytest.raises(NotImplementedError): @_supplementary_vars.register_supplementaries( diff --git a/tests/integration/test_citation.py b/tests/integration/test_citation.py index 339cd253a0..2bf34b4858 100644 --- a/tests/integration/test_citation.py +++ b/tests/integration/test_citation.py @@ -4,8 +4,11 @@ from prov.model import ProvDocument import esmvalcore -from esmvalcore._citation import (CMIP6_URL_STEM, ESMVALTOOL_PAPER, - _write_citation_files) +from esmvalcore._citation import ( + CMIP6_URL_STEM, + ESMVALTOOL_PAPER, + _write_citation_files, +) from esmvalcore._provenance import ESMVALTOOL_URI_PREFIX diff --git a/tests/parse_pymon.py b/tests/parse_pymon.py index e63da518cc..a9e9b21891 100644 --- a/tests/parse_pymon.py +++ b/tests/parse_pymon.py @@ -1,7 +1,7 @@ -""" -Parse and display test memory. +"""Parse and display test memory. -Uses pytest-monitor plugin from https://github.com/CFMTech/pytest-monitor +Uses pytest-monitor plugin from +https://github.com/CFMTech/pytest-monitor Lots of other metrics can be read from the file via sqlite parsing., currently just MEM_USAGE (RES memory, in MB). """ diff --git a/tests/sample_data/multimodel_statistics/test_multimodel.py b/tests/sample_data/multimodel_statistics/test_multimodel.py index 4c40d94875..b99e183cbb 100644 --- a/tests/sample_data/multimodel_statistics/test_multimodel.py +++ b/tests/sample_data/multimodel_statistics/test_multimodel.py @@ -204,7 +204,6 @@ def test_multimodel_regression_month(timeseries_cubes_month, span): """Test statistic fail due to differing input coordinates (pressure). See https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = timeseries_cubes_month name = 'timeseries_monthly' @@ -294,7 +293,6 @@ def test_multimodel_merge_error(timeseries_cubes_month, span): """Test statistic with slightly different vertical coordinates. See https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = timeseries_cubes_month msg = ( @@ -322,7 +320,6 @@ def test_multimodel_no_time_dimension(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -350,7 +347,6 @@ def test_multimodel_0d_1d_time_no_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -369,7 +365,6 @@ def test_multimodel_0d_1d_time_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -394,7 +389,6 @@ def test_multimodel_only_some_time_dimensions(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim @@ -420,7 +414,6 @@ def test_multimodel_diff_scalar_time_fail(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -442,7 +435,6 @@ def test_multimodel_diff_scalar_time_ignore(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -465,7 +457,6 @@ def test_multimodel_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): @@ -491,7 +482,6 @@ def test_multimodel_do_not_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): diff --git a/tests/unit/cmor/test_cmor_check.py b/tests/unit/cmor/test_cmor_check.py index 957136fd42..e1ba8ce9ac 100644 --- a/tests/unit/cmor/test_cmor_check.py +++ b/tests/unit/cmor/test_cmor_check.py @@ -137,7 +137,7 @@ def test_warning_fail_on_error(self): ) def test_report_debug_message(self): - """"Test report debug message function""" + """"Test report debug message function.""" checker = CMORCheck(self.cube, self.var_info) self.assertFalse(checker.has_debug_messages()) checker.report_debug_message('New debug message') @@ -270,8 +270,8 @@ def test_rank_unstructured_grid(self): self._check_cube() def test_bad_generic_level(self): - """Test check fails in metadata if generic level coord - has wrong var_name.""" + """Test check fails in metadata if generic level coord has wrong + var_name.""" depth_coord = CoordinateInfoMock('depth') depth_coord.axis = 'Z' depth_coord.generic_lev_name = 'olevel' @@ -385,26 +385,26 @@ def test_check_bad_coord_var_name_strict_flag(self): self._check_fails_in_metadata() def test_check_missing_lon_strict_flag(self): - """Test check fails for missing longitude with --cmor-check strict""" + """Test check fails for missing longitude with --cmor-check strict.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata() def test_check_missing_lat_strict_flag(self): - """Test check fails for missing latitude with --cmor-check strict""" + """Test check fails for missing latitude with --cmor-check strict.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata() def test_check_missing_time_strict_flag(self): - """Test check fails for missing time with --cmor-check strict""" + """Test check fails for missing time with --cmor-check strict.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata() def test_check_missing_coord_strict_flag(self): - """Test check fails for missing coord other than lat and lon - with --cmor-check strict""" + """Test check fails for missing coord other than lat and lon with + --cmor-check strict.""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -453,26 +453,26 @@ def test_check_bad_coord_standard_name_relaxed_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lon_relaxed_flag(self): - """Test check fails for missing longitude with --cmor-check relaxed""" + """Test check fails for missing longitude with --cmor-check relaxed.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lat_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed""" + """Test check fails for missing latitude with --cmor-check relaxed.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_time_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed""" + """Test check fails for missing latitude with --cmor-check relaxed.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_coord_relaxed_flag(self): """Test check reports warning for missing coord other than lat and lon - with --cmor-check relaxed""" + with --cmor-check relaxed.""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -535,15 +535,15 @@ def test_check_missing_lat_none_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_time_none_flag(self): - """Test check reports warning for missing time - with --cmor-check ignore""" + """Test check reports warning for missing time with --cmor-check + ignore.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_coord_none_flag(self): """Test check reports warning for missing coord other than lat, lon and - time with --cmor-check ignore""" + time with --cmor-check ignore.""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -603,11 +603,10 @@ def _check_debug_messages_on_metadata(self): self.assertTrue(checker.has_debug_messages()) def test_non_requested(self): - """ - Warning if requested values are not present. + """Warning if requested values are not present. - Check issue a warning if a values requested - for a coordinate are not correct in the metadata step + Check issue a warning if a values requested for a coordinate are + not correct in the metadata step """ coord = self.cube.coord('air_pressure') values = np.linspace(0, 40, len(coord.points)) @@ -617,11 +616,10 @@ def test_non_requested(self): self.assertTrue(checker.has_warnings()) def test_requested_str_values(self): - """ - Warning if requested values are not present. + """Warning if requested values are not present. - Check issue a warning if a values requested - for a coordinate are not correct in the metadata step + Check issue a warning if a values requested for a coordinate are + not correct in the metadata step """ region_coord = CoordinateInfoMock('basin') region_coord.standard_name = 'region' @@ -808,19 +806,19 @@ def test_bad_out_name_region_area_type(self): self._check_debug_messages_on_metadata() def test_bad_out_name_onedim_latitude(self): - """Warning if onedimensional lat has bad var_name at metadata""" + """Warning if onedimensional lat has bad var_name at metadata.""" self.var_info.table_type = 'CMIP6' self.cube.coord('latitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_onedim_longitude(self): - """Warning if onedimensional lon has bad var_name at metadata""" + """Warning if onedimensional lon has bad var_name at metadata.""" self.var_info.table_type = 'CMIP6' self.cube.coord('longitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_other(self): - """Warning if general coordinate has bad var_name at metadata""" + """Warning if general coordinate has bad var_name at metadata.""" self.var_info.table_type = 'CMIP6' self.cube.coord('time').var_name = 'bad_name' self._check_fails_in_metadata() @@ -927,8 +925,7 @@ def get_cube(self, var_info, set_time_units="days since 1850-1-1 00:00:00", frequency=None): - """ - Create a cube based on a specification. + """Create a cube based on a specification. Parameters ---------- @@ -942,7 +939,6 @@ def get_cube(self, Returns ------- iris.cube.Cube - """ coords = [] scalar_coords = [] diff --git a/tests/unit/preprocessor/_derive/test_toz.py b/tests/unit/preprocessor/_derive/test_toz.py index 262deab1e0..12dee514a5 100644 --- a/tests/unit/preprocessor/_derive/test_toz.py +++ b/tests/unit/preprocessor/_derive/test_toz.py @@ -5,6 +5,7 @@ import pytest import esmvalcore.preprocessor._derive.toz as toz + from .test_co2s import get_coord_spec, get_ps_cube diff --git a/tests/unit/preprocessor/_detrend/test_detrend.py b/tests/unit/preprocessor/_detrend/test_detrend.py index 9b53f65d51..acf9c6cbe0 100644 --- a/tests/unit/preprocessor/_detrend/test_detrend.py +++ b/tests/unit/preprocessor/_detrend/test_detrend.py @@ -4,11 +4,10 @@ import iris import iris.coords -from iris.cube import Cube import numpy as np import pytest from cf_units import Unit - +from iris.cube import Cube from numpy.testing import assert_array_almost_equal from esmvalcore.preprocessor._detrend import detrend diff --git a/tests/unit/preprocessor/_mapping/test_mapping.py b/tests/unit/preprocessor/_mapping/test_mapping.py index dc838b3a54..2af937349c 100644 --- a/tests/unit/preprocessor/_mapping/test_mapping.py +++ b/tests/unit/preprocessor/_mapping/test_mapping.py @@ -6,8 +6,11 @@ import numpy as np import tests -from esmvalcore.preprocessor._mapping import (get_empty_data, map_slices, - ref_to_dims_index) +from esmvalcore.preprocessor._mapping import ( + get_empty_data, + map_slices, + ref_to_dims_index, +) class TestHelpers(tests.Test): diff --git a/tests/unit/preprocessor/_regrid/__init__.py b/tests/unit/preprocessor/_regrid/__init__.py index 2c0e5a2f47..5774c41a41 100644 --- a/tests/unit/preprocessor/_regrid/__init__.py +++ b/tests/unit/preprocessor/_regrid/__init__.py @@ -1,9 +1,7 @@ -""" -Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module. - -""" +"""Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module.""" from typing import Literal + import iris import iris.fileformats import numpy as np @@ -11,10 +9,7 @@ def _make_vcoord(data, dtype=None): - """ - Create a synthetic test vertical coordinate. - - """ + """Create a synthetic test vertical coordinate.""" if dtype is None: dtype = np.dtype('int8') @@ -47,10 +42,7 @@ def _make_cube( dtype=None, grid: Literal['regular', 'rotated', 'mesh'] = 'regular', ): - """ - Create a 3d synthetic test cube. - - """ + """Create a 3d synthetic test cube.""" if dtype is None: dtype = np.dtype('int8') diff --git a/tests/unit/preprocessor/_regrid/test__create_cube.py b/tests/unit/preprocessor/_regrid/test__create_cube.py index e0f65eab78..cfb4434bb4 100644 --- a/tests/unit/preprocessor/_regrid/test__create_cube.py +++ b/tests/unit/preprocessor/_regrid/test__create_cube.py @@ -1,8 +1,5 @@ -""" -Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` -function. - -""" +"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` +function.""" import unittest diff --git a/tests/unit/preprocessor/_regrid/test__stock_cube.py b/tests/unit/preprocessor/_regrid/test__stock_cube.py index 8142b66ed8..8b2290f531 100644 --- a/tests/unit/preprocessor/_regrid/test__stock_cube.py +++ b/tests/unit/preprocessor/_regrid/test__stock_cube.py @@ -1,8 +1,5 @@ -""" -Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` -function. - -""" +"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` +function.""" import unittest from unittest import mock diff --git a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py index 5896f442ba..1375027263 100644 --- a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py +++ b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py @@ -1,8 +1,8 @@ """Tests for `esmvalcore.preprocessor._regrid_iris_esmf_regrid`.""" +import esmf_regrid import iris.cube import numpy as np import pytest -import esmf_regrid from esmvalcore.preprocessor.regrid_schemes import IrisESMFRegrid diff --git a/tests/unit/preprocessor/_volume/test_volume.py b/tests/unit/preprocessor/_volume/test_volume.py index d45b9bd744..1370cc5765 100644 --- a/tests/unit/preprocessor/_volume/test_volume.py +++ b/tests/unit/preprocessor/_volume/test_volume.py @@ -435,9 +435,8 @@ def test_volume_statistics(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_volume_nolevbounds(self): - """Test to take the volume weighted average of a cube with no bounds - in the z axis. - """ + """Test to take the volume weighted average of a cube with no bounds in + the z axis.""" self.assertFalse(self.grid_4d_znobounds.coord(axis='z').has_bounds()) result = volume_statistics(self.grid_4d_znobounds, 'mean') @@ -449,7 +448,7 @@ def test_volume_nolevbounds(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_calculate_volume_lazy(self): - """Test that calculate_volume returns a lazy volume + """Test that calculate_volume returns a lazy volume. The volume chunks should match those of the input cube for computational efficiency. @@ -600,7 +599,7 @@ def test_volume_statistics_2d_lat_cellarea(self): self.assertEqual(result.units, 'kg m-3') def test_volume_statistics_invalid_bounds(self): - """Test z-axis bounds is not 2 in last dimension""" + """Test z-axis bounds is not 2 in last dimension.""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_invalid_z_bounds, 'mean') @@ -611,7 +610,7 @@ def test_volume_statistics_invalid_bounds(self): ) def test_volume_statistics_invalid_units(self): - """Test z-axis units cannot be converted to m""" + """Test z-axis units cannot be converted to m.""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_4d_sigma_space, 'mean') diff --git a/tests/unit/test_dataset.py b/tests/unit/test_dataset.py index 25129dbf5d..c583252993 100644 --- a/tests/unit/test_dataset.py +++ b/tests/unit/test_dataset.py @@ -890,7 +890,8 @@ def test_from_files_with_globs(monkeypatch, session): def test_from_files_with_globs_and_missing_facets(monkeypatch, session): """Test `from_files` with wildcards and files with missing facets. - Tests a combination of files with complete facets and missing facets. + Tests a combination of files with complete facets and missing + facets. """ rootpath = Path('/path/to/data') file1 = esmvalcore.local.LocalFile( @@ -973,8 +974,8 @@ def test_from_files_with_globs_and_missing_facets(monkeypatch, session): def test_from_files_with_globs_and_automatic_missing(monkeypatch, session): """Test `from_files`. - Test with wildcards and files with missing facets that can be automatically - added. + Test with wildcards and files with missing facets that can be + automatically added. """ rootpath = Path('/path/to/data') file = esmvalcore.local.LocalFile( diff --git a/tests/unit/test_iris_io.py b/tests/unit/test_iris_io.py index 1b81c78d2f..500aa492d9 100644 --- a/tests/unit/test_iris_io.py +++ b/tests/unit/test_iris_io.py @@ -41,8 +41,7 @@ def create_regular_cube(): def test_iris_save_with_lazy_coordinate(tmp_path): - """ - Test saving a cube with fully lazy coords and data. + """Test saving a cube with fully lazy coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ @@ -56,8 +55,7 @@ def test_iris_save_with_lazy_coordinate(tmp_path): def test_iris_save_with_regular_coordinate(tmp_path): - """ - Test saving a cube with numpy array coords and data. + """Test saving a cube with numpy array coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ diff --git a/tests/unit/test_naming.py b/tests/unit/test_naming.py index 41971a60a8..1a9255c255 100644 --- a/tests/unit/test_naming.py +++ b/tests/unit/test_naming.py @@ -1,20 +1,19 @@ -"""Checks to ensure that files follow the naming convention""" +"""Checks to ensure that files follow the naming convention.""" import os import unittest class TestNaming(unittest.TestCase): - """Test naming of files and folders""" + """Test naming of files and folders.""" def setUp(self): - """Prepare tests""" + """Prepare tests.""" folder = os.path.join(__file__, '..', '..', '..') self.esmvaltool_folder = os.path.abspath(folder) def test_windows_reserved_names(self): - """ - Check that no file or folder uses a Windows reserved name + """Check that no file or folder uses a Windows reserved name. Files can not differ from a reserved name by the extension only """ @@ -37,8 +36,7 @@ def test_windows_reserved_names(self): reserved_names.isdisjoint(without_extensions), error_msg) def test_avoid_casing_collisions(self): - """ - Check that there are no names differing only in the capitalization + """Check that there are no names differing only in the capitalization. This includes folders differing from files """ @@ -52,8 +50,8 @@ def test_avoid_casing_collisions(self): 'capitalization'.format(dirpath)) def test_no_namelist(self): - """ - Check that there are no namelist references in file and folder names + """Check that there are no namelist references in file and folder + names. This will help us to avoid bad merges with stale branches """ From 5a1cda06d62fffccb805e4368b184002cbdafaf0 Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 17 Sep 2024 16:13:44 +0100 Subject: [PATCH 3/5] Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit f905f39147eb61496a0433c34280ae681fea58cb. --- .editorconfig | 1 + .github/CODEOWNERS | 1 + CITATION.cff | 2 +- NOTICE | 2 + doc/contributing.rst | 22 ++++---- doc/quickstart/install.rst | 2 +- doc/quickstart/run.rst | 2 +- doc/recipe/index.rst | 2 +- esmvalcore/_citation.py | 9 +-- esmvalcore/_main.py | 7 +-- esmvalcore/_recipe/recipe.py | 14 ++--- esmvalcore/cmor/_fixes/__init__.py | 7 ++- esmvalcore/cmor/_fixes/cesm/cesm2.py | 2 + esmvalcore/cmor/_fixes/cmip5/access1_0.py | 4 +- esmvalcore/cmor/_fixes/cmip5/access1_3.py | 2 + esmvalcore/cmor/_fixes/cmip5/bnu_esm.py | 36 +++++++++--- esmvalcore/cmor/_fixes/cmip5/canesm2.py | 5 +- esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py | 2 + esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py | 4 +- .../cmor/_fixes/cmip5/cesm1_fastchem.py | 1 + esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py | 1 + esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py | 5 +- esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py | 1 + esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py | 1 + esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py | 1 + esmvalcore/cmor/_fixes/cmip5/fio_esm.py | 10 +++- esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py | 19 +++++-- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py | 16 ++++-- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py | 21 +++++-- esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py | 1 + esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py | 1 + esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py | 5 +- esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py | 2 + esmvalcore/cmor/_fixes/cmip5/inmcm4.py | 17 ++++-- esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py | 1 + esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py | 1 + esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py | 1 + esmvalcore/cmor/_fixes/cmip5/miroc5.py | 18 ++++-- esmvalcore/cmor/_fixes/cmip5/miroc_esm.py | 12 +++- .../cmor/_fixes/cmip5/miroc_esm_chem.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py | 1 + esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py | 1 + esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py | 9 ++- esmvalcore/cmor/_fixes/cmip5/mri_esm1.py | 5 +- esmvalcore/cmor/_fixes/cmip5/noresm1_m.py | 1 + esmvalcore/cmor/_fixes/cmip5/noresm1_me.py | 2 + esmvalcore/cmor/_fixes/cmip6/access_cm2.py | 1 + esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py | 1 + esmvalcore/cmor/_fixes/cmip6/canesm5.py | 2 + esmvalcore/cmor/_fixes/cmip6/cesm2.py | 18 ++++-- esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py | 3 +- esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py | 1 + .../cmor/_fixes/cmip6/cesm2_waccm_fv2.py | 5 +- esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py | 1 + esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py | 1 + esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py | 1 + .../cmor/_fixes/cmip6/ec_earth3_veg_lr.py | 1 + esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py | 9 ++- esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py | 9 ++- esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py | 1 + .../cmor/_fixes/cmip6/hadgem3_gc31_ll.py | 1 + .../cmor/_fixes/cmip6/ipsl_cm5a2_inca.py | 1 + esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py | 5 +- .../cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py | 1 + esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py | 4 ++ esmvalcore/cmor/_fixes/cmip6/miroc6.py | 4 +- esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py | 1 + esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py | 4 +- esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py | 1 + esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py | 2 + esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py | 1 + .../cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py | 4 +- .../cordex/ichec_ec_earth/cclm4_8_17.py | 4 +- .../cordex/ichec_ec_earth/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ichec_ec_earth/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ichec_ec_earth/rca4.py | 3 +- .../_fixes/cordex/ichec_ec_earth/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/cclm4_8_17.py | 4 +- .../_fixes/cordex/miroc_miroc5/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/wrf361h.py | 2 +- .../cordex/mohc_hadgem2_es/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/mohc_hadgem2_es/hirham5.py | 1 + .../_fixes/cordex/mohc_hadgem2_es/rca4.py | 3 +- .../_fixes/cordex/mohc_hadgem2_es/remo2015.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py | 4 +- .../cordex/mpi_m_mpi_esm_lr/racmo22e.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/regcm4_6.py | 3 +- .../cordex/ncc_noresm1_m/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ncc_noresm1_m/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ncc_noresm1_m/rca4.py | 3 +- .../_fixes/cordex/ncc_noresm1_m/remo2015.py | 3 +- esmvalcore/cmor/_fixes/emac/emac.py | 3 + esmvalcore/cmor/_fixes/fix.py | 14 +++-- esmvalcore/cmor/_fixes/icon/_base_fixes.py | 15 +++-- esmvalcore/cmor/_fixes/icon/icon.py | 1 + esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py | 12 ++-- esmvalcore/cmor/_fixes/native6/era5_land.py | 11 ++-- esmvalcore/cmor/_fixes/native_datasets.py | 13 +++++ esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py | 1 + esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py | 4 +- esmvalcore/cmor/_fixes/obs4mips/ssmi.py | 1 + esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py | 5 +- esmvalcore/cmor/_fixes/shared.py | 2 + esmvalcore/cmor/_utils.py | 3 + esmvalcore/cmor/check.py | 5 ++ esmvalcore/cmor/fix.py | 3 + esmvalcore/cmor/table.py | 56 ++++++++++--------- esmvalcore/config/__init__.py | 1 + esmvalcore/config/_config_object.py | 3 + esmvalcore/config/_esgf_pyclient.py | 2 +- esmvalcore/config/_validated_config.py | 5 +- .../config/extra_facets/access-mappings.yml | 34 +++++------ esmvalcore/dataset.py | 3 +- esmvalcore/iris_helpers.py | 6 ++ esmvalcore/preprocessor/__init__.py | 4 +- esmvalcore/preprocessor/_area.py | 8 +++ esmvalcore/preprocessor/_compare_with_refs.py | 2 + esmvalcore/preprocessor/_cycles.py | 1 + esmvalcore/preprocessor/_derive/_baseclass.py | 2 + esmvalcore/preprocessor/_derive/_shared.py | 3 + esmvalcore/preprocessor/_derive/alb.py | 1 + esmvalcore/preprocessor/_derive/ctotal.py | 1 + esmvalcore/preprocessor/_derive/lvp.py | 1 + esmvalcore/preprocessor/_derive/lwp.py | 1 + esmvalcore/preprocessor/_derive/ohc.py | 6 +- esmvalcore/preprocessor/_derive/rlnst.py | 8 ++- esmvalcore/preprocessor/_derive/rlnstcs.py | 8 ++- esmvalcore/preprocessor/_derive/rlus.py | 1 + esmvalcore/preprocessor/_derive/rsnst.py | 1 + esmvalcore/preprocessor/_derive/rsnstcs.py | 1 + .../preprocessor/_derive/rsnstcsnorm.py | 10 ++-- esmvalcore/preprocessor/_derive/rsus.py | 1 + esmvalcore/preprocessor/_derive/siextent.py | 1 - esmvalcore/preprocessor/_derive/sispeed.py | 6 +- esmvalcore/preprocessor/_derive/sithick.py | 4 +- esmvalcore/preprocessor/_derive/sm.py | 1 + esmvalcore/preprocessor/_derive/toz.py | 1 + esmvalcore/preprocessor/_detrend.py | 3 +- esmvalcore/preprocessor/_mapping.py | 33 ++++++----- esmvalcore/preprocessor/_multimodel.py | 25 +++++---- esmvalcore/preprocessor/_other.py | 15 +++-- esmvalcore/preprocessor/_regrid.py | 4 +- esmvalcore/preprocessor/_regrid_esmpy.py | 11 +++- .../preprocessor/_regrid_unstructured.py | 16 ++++-- esmvalcore/preprocessor/_rolling_window.py | 1 + esmvalcore/preprocessor/_shared.py | 17 ++++-- esmvalcore/preprocessor/_time.py | 22 ++++++++ esmvalcore/preprocessor/_trend.py | 2 + esmvalcore/preprocessor/_units.py | 1 + esmvalcore/preprocessor/_volume.py | 7 +++ esmvalcore/preprocessor/shapefiles/ar6.prj | 2 +- esmvalcore/typing.py | 4 +- .../cmor/_fixes/cmip5/test_bnu_esm.py | 2 +- .../cmor/_fixes/cmip5/test_cnrm_cm5.py | 4 +- .../cmor/_fixes/cmip5/test_ec_earth.py | 10 ++-- .../cmor/_fixes/cmip5/test_fio_esm.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_cm2p1.py | 6 +- .../cmor/_fixes/cmip5/test_gfdl_cm3.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_esm2g.py | 8 +-- .../cmor/_fixes/cmip5/test_gfdl_esm2m.py | 6 +- .../cmor/_fixes/cmip5/test_hadgem2_cc.py | 4 +- .../cmor/_fixes/cmip5/test_miroc_esm_chem.py | 2 +- .../cmor/_fixes/cmip5/test_mri_esm1.py | 2 +- .../cmor/_fixes/cmip5/test_noresm1_me.py | 2 +- .../cmor/_fixes/cmip6/test_gfdl_cm4.py | 4 +- .../cordex/test_cnrm_cerfacs_cnrm_cm5.py | 3 +- .../cmor/_fixes/cordex/test_miroc_miroc5.py | 2 +- tests/integration/cmor/_fixes/test_fix.py | 4 +- .../cmor/_fixes/test_native_datasets.py | 1 + tests/integration/conftest.py | 6 +- tests/integration/data_finder.yml | 6 +- .../_extract_region/test_intersect.py | 6 +- .../preprocessor/_mask/__init__.py | 3 +- .../preprocessor/_regrid/__init__.py | 5 +- .../_regrid/test_extract_coordinate_points.py | 21 ++++--- .../_regrid/test_extract_point.py | 21 ++++--- .../_regrid/test_get_cmor_levels.py | 6 +- .../preprocessor/_regrid/test_regrid.py | 7 ++- .../_regrid/test_regrid_unstructured.py | 2 +- .../_supplementary_vars/test_register.py | 2 +- tests/integration/test_citation.py | 7 +-- tests/parse_pymon.py | 6 +- .../multimodel_statistics/test_multimodel.py | 10 ++++ tests/unit/cmor/test_cmor_check.py | 54 +++++++++--------- tests/unit/preprocessor/_derive/test_toz.py | 1 - .../preprocessor/_detrend/test_detrend.py | 3 +- .../preprocessor/_mapping/test_mapping.py | 7 +-- tests/unit/preprocessor/_regrid/__init__.py | 16 ++++-- .../preprocessor/_regrid/test__create_cube.py | 7 ++- .../preprocessor/_regrid/test__stock_cube.py | 7 ++- .../test_regrid_iris_esmf_regrid.py | 2 +- .../unit/preprocessor/_volume/test_volume.py | 11 ++-- tests/unit/test_dataset.py | 7 +-- tests/unit/test_iris_io.py | 6 +- tests/unit/test_naming.py | 16 +++--- 196 files changed, 794 insertions(+), 391 deletions(-) diff --git a/.editorconfig b/.editorconfig index ddab414f89..97c8ef6e5a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -27,3 +27,4 @@ indent_size = 2 [*.{md,Rmd}] trim_trailing_whitespace = false + diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index eba6cf5dd4..1c8122dcbe 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,3 @@ esmvalcore/cmor @jvegasbsc .github/workflows @valeriupredoi + diff --git a/CITATION.cff b/CITATION.cff index 4d3da6e4c7..51f53cfb36 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -208,7 +208,7 @@ authors: affiliation: "DLR, Germany" family-names: Cammarano given-names: Diego - - + - affiliation: "ACCESS-NRI, Australia" family-names: Yousong given-names: Zeng diff --git a/NOTICE b/NOTICE index 5e413cd5ba..5bf9f5d0cd 100644 --- a/NOTICE +++ b/NOTICE @@ -50,3 +50,5 @@ In addition to using the Software, we encourage the community to join the Softwa To join the ESMValTool Development Team, please contact Dr. Birgit Hassler (birgit.hassler@dlr.de) and Dr. Axel Lauer (axel.lauer@dlr.de). ========================================== + + diff --git a/doc/contributing.rst b/doc/contributing.rst index 658306a53b..814ab79263 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -743,15 +743,15 @@ Perform the steps listed below with two persons, to reduce the risk of error. `PyPI `__, and `readthedocs `__. -The release of ESMValCore is tied to the release of ESMValTool. +The release of ESMValCore is tied to the release of ESMValTool. The detailed steps can be found in the ESMValTool :ref:`documentation `. -To start the procedure, ESMValCore gets released as a +To start the procedure, ESMValCore gets released as a release candidate to test the recipes in ESMValTool. If bugs are found -during the testing phase of the release candidate, make as many release -candidates for ESMValCore as needed in order to fix them. +during the testing phase of the release candidate, make as many release +candidates for ESMValCore as needed in order to fix them. -To make a new release of the package, be it a release candidate or the final release, +To make a new release of the package, be it a release candidate or the final release, follow these steps: 1. Check that all tests and builds work @@ -795,13 +795,13 @@ Use the script to create create a draft of the release notes. This script uses the titles and labels of merged pull requests since the previous release. -Open a discussion to allow members of the development team to nominate pull -requests as highlights. Add the most voted pull requests as highlights at the -beginning of changelog. After the highlights section, list any backward -incompatible changes that the release may include. The +Open a discussion to allow members of the development team to nominate pull +requests as highlights. Add the most voted pull requests as highlights at the +beginning of changelog. After the highlights section, list any backward +incompatible changes that the release may include. The :ref:`backward compatibility policy`. -lists the information that should be provided by the developer of any backward -incompatible change. Make sure to also list any deprecations that the release +lists the information that should be provided by the developer of any backward +incompatible change. Make sure to also list any deprecations that the release may include, as well as a brief description on how to upgrade a deprecated feature. Review the results, and if anything needs changing, change it on GitHub and re-run the script until the changelog looks acceptable. diff --git a/doc/quickstart/install.rst b/doc/quickstart/install.rst index 804c86ed20..7ef5015fe3 100644 --- a/doc/quickstart/install.rst +++ b/doc/quickstart/install.rst @@ -201,7 +201,7 @@ Pre-installed versions on HPC clusters / other servers If you would like to use pre-installed versions on HPC clusters (currently CEDA-JASMIN and DKRZ-Levante), -and other servers (currently Met Office Linux estate), please have a look at +and other servers (currently Met Office Linux estate), please have a look at :ref:`these instructions `. diff --git a/doc/quickstart/run.rst b/doc/quickstart/run.rst index 5eca15e714..ebde6d4075 100644 --- a/doc/quickstart/run.rst +++ b/doc/quickstart/run.rst @@ -79,7 +79,7 @@ This feature is available for projects that are hosted on the ESGF, i.e. CMIP3, CMIP5, CMIP6, CORDEX, and obs4MIPs. To control the strictness of the CMOR checker and the checks during concatenation -on auxiliary coordinates, supplementary variables, and derived coordinates, +on auxiliary coordinates, supplementary variables, and derived coordinates, use the flag ``--check_level``: .. code:: bash diff --git a/doc/recipe/index.rst b/doc/recipe/index.rst index 525b0467e1..98c3f6c237 100644 --- a/doc/recipe/index.rst +++ b/doc/recipe/index.rst @@ -8,4 +8,4 @@ The recipe format Overview Preprocessor - + \ No newline at end of file diff --git a/esmvalcore/_citation.py b/esmvalcore/_citation.py index 94ff97ad15..510aa8cb42 100644 --- a/esmvalcore/_citation.py +++ b/esmvalcore/_citation.py @@ -38,7 +38,8 @@ def _write_citation_files(filename, provenance): - """Write citation information provided by the recorded provenance. + """ + Write citation information provided by the recorded provenance. Recipe and cmip6 data references are saved into one bibtex file. cmip6 data references are provided by CMIP6 data citation service. @@ -134,9 +135,9 @@ def _save_citation_info_txt(product_name, info_urls, other_info): def _extract_tags(tags): """Extract tags. - Tags are recorded as a list of strings converted to a string in - provenance. For example, a single entry in the list `tags` could be - the string "['acknow_project', 'acknow_author']". + Tags are recorded as a list of strings converted to a string in provenance. + For example, a single entry in the list `tags` could be the string + "['acknow_project', 'acknow_author']". """ pattern = re.compile(r'[\w-]+') return set(pattern.findall(str(tags))) diff --git a/esmvalcore/_main.py b/esmvalcore/_main.py index 84dc5a35b0..75c0b20c94 100755 --- a/esmvalcore/_main.py +++ b/esmvalcore/_main.py @@ -206,8 +206,8 @@ def get_config_developer(cls, overwrite=False, path=None): class Recipes(): """List, show and retrieve installed recipes. - This group contains utilities to explore and manage the recipes - available in your installation of ESMValTool. + This group contains utilities to explore and manage the recipes available + in your installation of ESMValTool. Documentation for recipes included with ESMValTool is available at https://docs.esmvaltool.org/en/latest/recipes/index.html. @@ -294,8 +294,7 @@ class ESMValTool(): multiple models, either against predecessor versions or against observations. - Documentation is available at - https://docs.esmvaltool.org. + Documentation is available at https://docs.esmvaltool.org. To report issues or ask for improvements, please visit https://github.com/ESMValGroup/ESMValTool. diff --git a/esmvalcore/_recipe/recipe.py b/esmvalcore/_recipe/recipe.py index 5633ab0e57..1f2eb63488 100644 --- a/esmvalcore/_recipe/recipe.py +++ b/esmvalcore/_recipe/recipe.py @@ -399,14 +399,12 @@ def _update_multiproduct(input_products, order, preproc_dir, step): """Return new products that are aggregated over multiple datasets. These new products will replace the original products at runtime. - Therefore, they need to have all the settings for the remaining - steps. - - The functions in _multimodel.py take output_products as function - arguments. These are the output_products created here. But since - those functions are called from the input products, the products - that are created here need to be added to their ancestors products' - settings (). + Therefore, they need to have all the settings for the remaining steps. + + The functions in _multimodel.py take output_products as function arguments. + These are the output_products created here. But since those functions are + called from the input products, the products that are created here need to + be added to their ancestors products' settings (). """ products = {p for p in input_products if step in p.settings} if not products: diff --git a/esmvalcore/cmor/_fixes/__init__.py b/esmvalcore/cmor/_fixes/__init__.py index d9e50af443..e50e749659 100644 --- a/esmvalcore/cmor/_fixes/__init__.py +++ b/esmvalcore/cmor/_fixes/__init__.py @@ -1,5 +1,6 @@ -"""Automatic fixes for input data. +""" +Automatic fixes for input data -Module to apply automatic fixes at different levels to input data for -known errors. +Module to apply automatic fixes at different levels to input data for known +errors. """ diff --git a/esmvalcore/cmor/_fixes/cesm/cesm2.py b/esmvalcore/cmor/_fixes/cesm/cesm2.py index ada216007a..5b92121555 100644 --- a/esmvalcore/cmor/_fixes/cesm/cesm2.py +++ b/esmvalcore/cmor/_fixes/cesm/cesm2.py @@ -12,6 +12,7 @@ (esmvalcore/_config/extra_facets/cesm-mappings.yml) and/or add classes to this file for variables that need more complex fixes (see esmvalcore/cmor/_fixes/emac/emac.py for examples). + """ import logging @@ -63,6 +64,7 @@ def _fix_time(self, cube): Example of monthly time coordinate after this fix (Jan. & Feb. 2000): Points: ``[2000-01-15, 2000-02-14]`` Bounds: ``[[2000-01-01, 2000-02-01], [2000-02-01, 2000-03-01]]`` + """ # Only modify time points if data contains a time dimension, is monthly # data, and does not describe point measurements. diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_0.py b/esmvalcore/cmor/_fixes/cmip5/access1_0.py index eebc2fa616..4fa4da7554 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_0.py @@ -10,7 +10,8 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong calendar 'gregorian' instead of 'proleptic_gregorian'. @@ -22,6 +23,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_3.py b/esmvalcore/cmor/_fixes/cmip5/access1_3.py index 6f581197ff..f026181660 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_3.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_3.py @@ -5,6 +5,7 @@ from ..fix import Fix from .access1_0 import Cl as BaseCl + Cl = BaseCl @@ -24,6 +25,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py index 0198d08dda..e01639a306 100644 --- a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py @@ -10,7 +10,8 @@ class Cl(ClFixHybridPressureCoord): """Fixes for cl.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -22,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -33,7 +35,8 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -45,12 +48,14 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = Unit('kg m-2 s-1') return cubes def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes cube units. @@ -62,6 +67,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 12.0 / 44.0 @@ -73,7 +79,8 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -85,12 +92,14 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = Unit('1e-9') return cubes def fix_data(self, cube): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -103,6 +112,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29.0 / 16.0 * 1.e9 @@ -114,7 +124,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -126,12 +137,14 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = Unit('1e-6') return cubes def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes cube units. @@ -143,6 +156,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29.0 / 44.0 * 1.e6 @@ -154,7 +168,8 @@ class SpCo2(Fix): """Fixes for spco2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes cube units. @@ -166,6 +181,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1.e6 @@ -177,7 +193,8 @@ class Od550Aer(Fix): """Fixes for od550aer.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Masks invalid values. @@ -189,6 +206,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ data = da.ma.masked_equal(cube.core_data(), 1.e36) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/canesm2.py b/esmvalcore/cmor/_fixes/cmip5/canesm2.py index e780f3e592..b445a4dc3a 100644 --- a/esmvalcore/cmor/_fixes/cmip5/canesm2.py +++ b/esmvalcore/cmor/_fixes/cmip5/canesm2.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -9,7 +10,8 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -21,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 12.0 / 44.0 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py index fe5dfbefa4..2e25296b8d 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py @@ -5,6 +5,7 @@ from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl @@ -23,6 +24,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ data = da.ma.masked_equal(cube.core_data(), 1.0e33) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py index ae30726e2b..4c235dfcbc 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py @@ -7,7 +7,8 @@ class Cl(Fix): """Fixes for cl.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -19,6 +20,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py index 319b96d261..d5ba1f7641 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py @@ -2,4 +2,5 @@ from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py index 86c5cbd349..818d14e4c2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py @@ -2,4 +2,5 @@ from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py index a5c5bcb017..71e6547461 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py @@ -1,3 +1,4 @@ + """Fixes for CNRM-CM5 model.""" from ..fix import Fix @@ -6,7 +7,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -17,6 +19,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1e6 diff --git a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py index 846859c6b4..4c0a5a7564 100644 --- a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py @@ -1,4 +1,5 @@ """Fixes for CSIRO-Mk3-6-0 model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py index 0067b9f172..1c2df64db0 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py @@ -23,6 +23,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py index c1b3962abd..c82151226f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py @@ -20,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py index 4935a56f92..cc9ed79421 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py @@ -1,7 +1,9 @@ + """Fixes for FIO ESM model.""" from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl @@ -9,7 +11,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -20,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29. / 44. * 1.e6 @@ -31,7 +35,8 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -42,6 +47,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29. / 16. * 1.e9 diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py index 6104efdaaf..bc1b3cf9b6 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py @@ -1,17 +1,19 @@ """Fixes for GFDL CM3 model.""" -from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars from ..fix import Fix +from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars + class AllVars(BaseAllVars): """Fixes for all variables.""" class Areacello(Fix): - """Fixes for areacello.""" + """Fixes for areacello""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong units. @@ -22,6 +24,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -32,7 +35,8 @@ class Sftof(Fix): """Fix sftof.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units. @@ -43,6 +47,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -51,10 +56,11 @@ def fix_data(self, cube): class Tos(Fix): - """Fixes for tos.""" + """Fixes for tos""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong standard_name. @@ -65,6 +71,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py index 1620f95b29..3ba4a6dd83 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py @@ -1,3 +1,4 @@ + """Fixes for GFDL ESM2G.""" import iris @@ -28,6 +29,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ _get_and_remove(cubes, 'Start time for average period') _get_and_remove(cubes, 'End time for average period') @@ -36,10 +38,11 @@ def fix_metadata(self, cubes): class Areacello(Fix): - """Fixes for areacello.""" + """Fixes for areacello""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong units. @@ -50,6 +53,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -71,6 +75,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1e6 @@ -93,6 +98,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ _get_and_remove(cubes, 'Latitude of tracer (h) points') _get_and_remove(cubes, 'Longitude of tracer (h) points') @@ -103,7 +109,8 @@ class Usi(Fix): """Fixes for usi.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes bad standard_name @@ -123,7 +130,8 @@ class Vsi(Fix): """Fixes for vsi.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes bad standard_name diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py index 0e626d80de..7722118e48 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py @@ -1,7 +1,8 @@ + """Fixes for GFDL ESM2M.""" -from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars from ..fix import Fix +from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars class AllVars(BaseAllVars): @@ -9,10 +10,11 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello.""" + """Fixes for areacello""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong units. @@ -23,6 +25,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -33,7 +36,8 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -44,6 +48,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -55,7 +60,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -66,6 +72,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1e6 @@ -77,7 +84,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong standard_name. @@ -88,6 +96,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py index 9dc63cb128..5ee8c8aff1 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py @@ -1,4 +1,5 @@ """Fixes for GISS-E2-H.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py index 3d4cd617d8..0d538e7960 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py @@ -1,4 +1,5 @@ """Fixes for GISS-E2-R.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py index e48ba4ade9..3531f78f06 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py @@ -2,6 +2,7 @@ from ..fix import Fix from .hadgem2_es import AllVars as BaseAllVars + AllVars = BaseAllVars @@ -9,7 +10,8 @@ class O2(Fix): """Fixes for o2.""" def fix_metadata(self, cubes): - """Fix standard and long names. + """ + Fix standard and long names. Parameters ---------- @@ -18,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py index 1f9e81aa86..f7360dae2b 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py @@ -19,6 +19,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: lats = cube.coords('latitude') @@ -49,6 +50,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py index d90c606b40..e89cea019d 100644 --- a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py +++ b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py @@ -4,6 +4,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -11,7 +12,8 @@ class Gpp(Fix): """Fixes for gpp.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -23,6 +25,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= -1 @@ -34,7 +37,8 @@ class Lai(Fix): """Fixes for lai.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -46,6 +50,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 0.01 @@ -57,7 +62,8 @@ class Nbp(Fix): """Fixes for nbp.""" def fix_metadata(self, cubes): - """Fix missing scalar dimension. + """ + Fix missing scalar dimension. Parameters ---------- @@ -67,6 +73,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cubes[0].standard_name = ( 'surface_net_downward_mass_flux_of_carbon_dioxide_expressed_as_' @@ -79,7 +86,8 @@ class BaresoilFrac(Fix): """Fixes for baresoilFrac.""" def fix_metadata(self, cubes): - """Fix missing scalar dimension. + """ + Fix missing scalar dimension. Parameters ---------- @@ -89,6 +97,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ typebare = iris.coords.AuxCoord( 'bare_ground', diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py index 5dfcb15ce2..894af45317 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py @@ -1,4 +1,5 @@ """Fixes for IPSL-CM5A-LR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py index 98fab8515f..893b9779c2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py @@ -1,4 +1,5 @@ """Fixes for IPSL-CM5A-MR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py index 271f48728e..03bed332d6 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py @@ -1,4 +1,5 @@ """Fixes for IPSL-CM5B-LR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc5.py b/esmvalcore/cmor/_fixes/cmip5/miroc5.py index c2e1e253a2..ec0e009402 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc5.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc5.py @@ -5,6 +5,7 @@ from ..fix import Fix from ..shared import round_coordinates + Cl = ClFixHybridPressureCoord @@ -12,7 +13,8 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -24,6 +26,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -35,7 +38,8 @@ class Snw(Fix): """Fixes for snw.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -47,6 +51,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -91,7 +96,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes mask @@ -103,6 +109,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -126,6 +133,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ return round_coordinates(cubes) @@ -138,7 +146,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_data(self, cube): - """Fix tos data. + """ + Fix tos data. Fixes mask @@ -150,6 +159,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py index de93a2bf4e..fc94bc45cc 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py @@ -15,7 +15,8 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -27,6 +28,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1000 @@ -38,7 +40,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes error in cube units @@ -50,6 +53,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = '1.0e-6' return cubes @@ -59,7 +63,8 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes error in air_pressure coordinate, sometimes called AR5PL35, and error in time coordinate. @@ -72,6 +77,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: # Fix air_pressure diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py index 400a7c0355..83d6e28f20 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py @@ -1,3 +1,4 @@ + """Fixes for MIROC ESM CHEM model.""" from ..fix import Fix @@ -6,7 +7,8 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -17,6 +19,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1000 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py index e70672c4bf..a24aebd499 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -9,7 +10,8 @@ class Pctisccp(Fix): """Fixes for pctisccp.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -21,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py index 28317e6958..92b1a6a06b 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py @@ -1,4 +1,5 @@ """Fixes for MPI-ESM-MR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py index 0a04fd0bf0..303e1b0fd1 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py @@ -1,4 +1,5 @@ """Fixes for MPI-ESM-P model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py index 55e3a20345..a21b82eb7f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py @@ -4,6 +4,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -11,7 +12,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix msftmyz data. + """ + Fix msftmyz data. Fixes mask @@ -23,6 +25,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -32,7 +35,8 @@ class ThetaO(Fix): """Fixes for thetao.""" def fix_data(self, cube): - """Fix thetao data. + """ + Fix thetao data. Fixes mask @@ -44,6 +48,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py index 8fbc47ce24..694e4cc33f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py @@ -1,3 +1,4 @@ + """Fixes for MRI-ESM1 model.""" from dask import array as da @@ -8,7 +9,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix msftmyz data. + """ + Fix msftmyz data. Fixes mask @@ -19,6 +21,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py index e52f4a2f3d..703ef054d7 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py @@ -1,4 +1,5 @@ """Fixes for NorESM1-M.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py index beb6cc3f41..08fe028419 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py @@ -20,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ return round_coordinates(cubes, 12, coord_names=['latitude']) @@ -41,5 +42,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ return round_coordinates(cubes, 12) diff --git a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py index ab5b5109d6..7627e9b3a4 100644 --- a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py @@ -18,6 +18,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py index e1688bdc58..59f09bcd28 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py @@ -1,6 +1,7 @@ """Fixes for CAMS-CSM1-0 model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/canesm5.py b/esmvalcore/cmor/_fixes/cmip6/canesm5.py index 23f004042b..d4cdbc95e1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/canesm5.py +++ b/esmvalcore/cmor/_fixes/cmip6/canesm5.py @@ -18,6 +18,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1.e-6 @@ -39,6 +40,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.0) return cube diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2.py index ea816506cc..6ded187fbb 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2.py @@ -61,6 +61,7 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. + """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix @@ -116,6 +117,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -126,8 +128,8 @@ class Prw(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """Fix latitude_bounds and longitude_bounds data type and round to 4 - d.p. + """ + Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. Parameters ---------- @@ -137,6 +139,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: for coord_name in ['latitude', 'longitude']: @@ -153,7 +156,8 @@ class Tas(Prw): """Fixes for tas.""" def fix_metadata(self, cubes): - """Add height (2m) coordinate. + """ + Add height (2m) coordinate. Fix also done for prw. Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. @@ -166,6 +170,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ super().fix_metadata(cubes) # Specific code for tas @@ -189,6 +194,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_typeland_coord(cube) @@ -209,6 +215,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_typesea_coord(cube) @@ -222,7 +229,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """Round times to 1 d.p. for monthly means. + """ + Round times to 1 d.p. for monthly means. Required to get hist-GHG and ssp245-GHG Omon tos to concatenate. @@ -234,6 +242,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) @@ -258,6 +267,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py index d6abd98fc5..0783c125fe 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py @@ -1,9 +1,10 @@ """Fixes for CESM2-FV2 model.""" -from ..common import SiconcFixScalarCoord from .cesm2 import Cl as BaseCl from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon from .cesm2 import Tas as BaseTas +from ..common import SiconcFixScalarCoord + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py index 134bf8878b..f7263a00dd 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py @@ -36,6 +36,7 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. + """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py index 7dc4e79a9e..89c55b3b10 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py @@ -1,11 +1,12 @@ """Fixes for CESM2-WACCM-FV2 model.""" -from ..common import SiconcFixScalarCoord +from .cesm2 import Tas as BaseTas from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon -from .cesm2 import Tas as BaseTas from .cesm2_waccm import Cl as BaseCl from .cesm2_waccm import Cli as BaseCli from .cesm2_waccm import Clw as BaseClw +from ..common import SiconcFixScalarCoord + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py index fc1db9d174..00983b36a7 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py +++ b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py @@ -16,6 +16,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) ps_coord = cube.coord(var_name='ps') diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py index 47c505fdd2..b5db40fc11 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py @@ -3,6 +3,7 @@ from .cnrm_cm6_1 import Cli as BaseCli from .cnrm_cm6_1 import Clw as BaseClw + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py index 23ab942fef..838ae3836c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py @@ -5,6 +5,7 @@ from .cnrm_cm6_1 import Clw as BaseClw from .cnrm_cm6_1 import Omon as BaseOmon + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py index 59bb546aac..333b4eb98b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py @@ -1,4 +1,5 @@ """Fixes for EC-Earth3-Veg-LR model.""" from ..common import OceanFixGrid + Siconc = OceanFixGrid diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py index def9a936d1..f73b16f4b8 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py @@ -26,6 +26,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) coords_to_add = { @@ -50,7 +51,8 @@ class Tas(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """Add height (2m) coordinate. + """ + Add height (2m) coordinate. Parameters ---------- @@ -60,6 +62,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) try: @@ -85,7 +88,8 @@ class Uas(Fix): """Fixes for uas.""" def fix_metadata(self, cubes): - """Add height (10m) coordinate. + """ + Add height (10m) coordinate. Parameters ---------- @@ -95,6 +99,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py index b2e421fba9..c9788eb37c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py @@ -1,7 +1,10 @@ """Fixes for GFDL-ESM4 model.""" -from ..common import OceanFixGrid, SiconcFixScalarCoord +from ..common import SiconcFixScalarCoord, OceanFixGrid from ..fix import Fix -from ..shared import add_scalar_depth_coord, fix_ocean_depth_coord +from ..shared import ( + add_scalar_depth_coord, + fix_ocean_depth_coord, +) class Fgco2(Fix): @@ -18,6 +21,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -38,6 +42,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py index 1724cce93b..054a42255f 100644 --- a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py +++ b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py @@ -1,6 +1,7 @@ """Fixes for GISS-E2-1-H model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py index 003c8f623d..99db1e2be1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridHeightCoord from .ukesm1_0_ll import AllVars as BaseAllVars + AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py index 11a25bc185..57d925e6d1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py @@ -3,6 +3,7 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon + AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py index 7e326e5948..dfd7116275 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py @@ -9,7 +9,8 @@ class AllVars(Fix): """Fixes for thetao.""" def fix_metadata(self, cubes): - """Fix cell_area coordinate. + """ + Fix cell_area coordinate. Parameters ---------- @@ -19,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) if cube.coords('latitude'): @@ -66,6 +68,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py index 2b551a8177..3a8a94b8de 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py @@ -3,6 +3,7 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon + AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py index 92a446be1c..a9b200cde6 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py @@ -38,6 +38,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ coords_to_change = { 'latitude': 'lat', @@ -99,6 +100,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): @@ -122,6 +124,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 2.0) @@ -142,6 +145,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc6.py b/esmvalcore/cmor/_fixes/cmip6/miroc6.py index e799a86577..cf1d40ca86 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc6.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc6.py @@ -15,8 +15,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """Fix latitude_bounds and longitude_bounds data type and round to 4 - d.p. + """ + Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. Parameters ---------- diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py index a5e18b302c..aa28ae13cc 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py @@ -1,6 +1,7 @@ """Fixes for MIROC-ES2L model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py index f603b9d197..201ffcca63 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py +++ b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py @@ -1,8 +1,8 @@ """Fixes for MPI-ESM1-2-XR model.""" -from .mpi_esm1_2_hr import SfcWind as BaseSfcWind -from .mpi_esm1_2_hr import Ta as BaseFix from .mpi_esm1_2_hr import Tas as BaseTas +from .mpi_esm1_2_hr import Ta as BaseFix +from .mpi_esm1_2_hr import SfcWind as BaseSfcWind class Tas(BaseTas): diff --git a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py index 04f1617200..720670b4d5 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py @@ -1,6 +1,7 @@ """Fixes for MRI-ESM2-0 model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py index 2cd1926eff..dc0aa1ccb8 100644 --- a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py +++ b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -27,6 +28,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= -1 diff --git a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py index 6d7d279d6e..8bef01c21f 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py @@ -17,6 +17,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ parent_units = 'parent_time_units' bad_value = 'days since 1850-01-01-00-00-00' diff --git a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py index 0f75e65197..1806f3f0a0 100644 --- a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by CNRM-CERFACS-CNRM-CM5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py index 19d0a2dfdc..88d2123420 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - CLMcomCCLM4817 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + CLMcomCCLM4817 as BaseFix) AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py index 9333eb9b33..2f816ba55e 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py index b79a6399a7..9f4cb7a2bc 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py @@ -1,4 +1,5 @@ """Fixes for rcm RACMO22E driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py index aad85b4848..114715a5c9 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py @@ -1,5 +1,6 @@ """Fixes for rcm RCA4 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py index 56bff0f673..c50d9a23e2 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py @@ -1,4 +1,5 @@ """Fixes for rcm REMO2015 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py index 181b42dba6..ac0460904d 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - CLMcomCCLM4817 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + CLMcomCCLM4817 as BaseFix) AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py index bcbe5356e2..fbd13bdfab 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py @@ -1,4 +1,5 @@ """Fixes for rcm REMO2015 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py index e1e691efa2..f8a69bca9b 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py @@ -1,6 +1,5 @@ """Fixes for rcm WRF361H driven by MIROC-MIROC5.""" import iris - from esmvalcore.cmor.fix import Fix @@ -21,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ fixed_cubes = iris.cube.CubeList() for cube in cubes: diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py index 45524e8654..7964a583e0 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py index 0a6a43b7b1..5dfb91f274 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py @@ -16,6 +16,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: cube.coord('latitude').attributes = {} diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py index 2ad0fe36f6..740711fcea 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py @@ -1,5 +1,6 @@ """Fixes for rcm RCA4 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py index c7f3912fb0..cea145f2d3 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py @@ -1,5 +1,6 @@ """Fixes for rcm REMO2015 driven by MOHC-HadGEM2.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py index dbad46ea88..4875edfc93 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py index ebf390b9f9..676e0dfc47 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py @@ -1,4 +1,5 @@ """Fixes for rcm RACMO22E driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py index fc54fd47e2..f863ed1712 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py @@ -1,5 +1,6 @@ """Fixes for rcm RegCM4-6 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py index 36d52de57e..1aa2d11b1b 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py index 1a924d6b04..e9e2e38734 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py @@ -1,4 +1,5 @@ """Fixes for rcm RACMO22E driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py index 3452f432ab..58d14599da 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py @@ -1,5 +1,6 @@ """Fixes for rcm RCA4 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py index 4276048585..9722263d70 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py @@ -1,4 +1,5 @@ """Fixes for rcm REMO2015 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/emac/emac.py b/esmvalcore/cmor/_fixes/emac/emac.py index 9bd961783a..99cf9ee142 100644 --- a/esmvalcore/cmor/_fixes/emac/emac.py +++ b/esmvalcore/cmor/_fixes/emac/emac.py @@ -8,6 +8,7 @@ is that ``fix_metadata`` takes all cubes (and thus all input variables of the input file) as argument while ``fix_data`` only takes one cube (the output variable) as single argument. + """ import logging @@ -46,6 +47,7 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): This fix removes the ``formula_terms`` attribute of the hybrid pressure level variables to make the corresponding coefficients appear correctly in the class:`iris.cube.CubeList` object returned by :mod:`iris.load`. + """ if 'alevel' not in self.vardef.dimensions: return filepath @@ -381,6 +383,7 @@ def fix_metadata(self, cubes): Convert geopotential Phi given by EMAC to geopotential height Z using Z = Phi / g0 (g0 is standard acceleration of gravity) + """ g0_value = constants.value('standard acceleration of gravity') g0_units = constants.unit('standard acceleration of gravity') diff --git a/esmvalcore/cmor/_fixes/fix.py b/esmvalcore/cmor/_fixes/fix.py index 2723579ef8..cf2aed42ec 100644 --- a/esmvalcore/cmor/_fixes/fix.py +++ b/esmvalcore/cmor/_fixes/fix.py @@ -61,6 +61,7 @@ def __init__( frequency: Expected frequency of the variable. If not given, use the one from the CMOR table entry of the variable. + """ self.vardef = vardef if extra_facets is None: @@ -98,6 +99,7 @@ def fix_file( Path to the corrected file. It can be different from the original filepath if a fix has been applied, but if not it should be the original filepath. + """ return filepath @@ -117,6 +119,7 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> Sequence[Cube]: ------- Iterable[iris.cube.Cube] Fixed cubes. They can be different instances. + """ return cubes @@ -144,6 +147,7 @@ def get_cube_from_list( ------- iris.cube.Cube Variable's cube. + """ if short_name is None: short_name = self.vardef.short_name @@ -166,6 +170,7 @@ def fix_data(self, cube: Cube) -> Cube: ------- iris.cube.Cube Fixed cube. It can be a difference instance. + """ return cube @@ -226,6 +231,7 @@ def get_fixes( ------- list[Fix] Fixes to apply for the given data. + """ vardef = get_var_info(project, mip, short_name) @@ -307,6 +313,7 @@ def get_fixed_filepath( ------- Path Path to the fixed file. + """ output_dir = Path(output_dir) if add_unique_suffix: @@ -334,6 +341,7 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> CubeList: ------- CubeList Fixed cubes. + """ # Make sure the this fix also works when no extra_facets are given if 'project' in self.extra_facets and 'dataset' in self.extra_facets: @@ -376,6 +384,7 @@ def fix_data(self, cube: Cube) -> Cube: ------- Cube Fixed cube. + """ return cube @@ -749,10 +758,7 @@ def _fix_coord_direction( cmor_coord: CoordinateInfo, cube_coord: Coord, ) -> tuple[Cube, Coord]: - """Fix coordinate direction (increasing vs. - - decreasing). - """ + """Fix coordinate direction (increasing vs. decreasing).""" # Skip fix for a variety of reasons if cube_coord.ndim > 1: return (cube, cube_coord) diff --git a/esmvalcore/cmor/_fixes/icon/_base_fixes.py b/esmvalcore/cmor/_fixes/icon/_base_fixes.py index ede854bc0a..c4afecc4f8 100644 --- a/esmvalcore/cmor/_fixes/icon/_base_fixes.py +++ b/esmvalcore/cmor/_fixes/icon/_base_fixes.py @@ -56,6 +56,7 @@ def _create_mesh(self, cube: Cube) -> MeshXY: neighboring cells) the number of nodes is 6 times higher with :func:`iris.mesh.MeshXY.from_coords` compared to using the information already present in the horizontal grid file. + """ horizontal_grid = self.get_horizontal_grid(cube) @@ -154,10 +155,11 @@ def _get_grid_url(self, cube): def _get_node_coords(self, horizontal_grid): """Get node coordinates from horizontal grid. - Extract node coordinates from dummy variable 'dual_area' in - horizontal grid file (in ICON jargon called 'vertex latitude' - and 'vertex longitude'), remove their bounds (not accepted by - UGRID), and adapt metadata. + Extract node coordinates from dummy variable 'dual_area' in horizontal + grid file (in ICON jargon called 'vertex latitude' and 'vertex + longitude'), remove their bounds (not accepted by UGRID), and adapt + metadata. + """ dual_area_cube = horizontal_grid.extract_cube( NameConstraint(var_name='dual_area')) @@ -234,6 +236,7 @@ def add_additional_cubes(self, cubes): ------ InputFilesNotFound A specified file does not exist. + """ facets_to_consider = [ 'zg_file', @@ -318,6 +321,7 @@ def _get_downloaded_grid(self, grid_url: str, grid_name: str) -> CubeList: In order to make this function thread-safe, the downloaded grid file is first saved to a temporary location, then copied to the actual location later. + """ grid_path = self.CACHE_DIR / grid_name @@ -398,6 +402,7 @@ def get_horizontal_grid(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. + """ if self.extra_facets.get('horizontal_grid') is not None: grid = self._get_grid_from_facet() @@ -436,6 +441,7 @@ def get_mesh(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. + """ # If specified by the user, use `horizontal_grid` facet to determine # grid name; otherwise, use the `grid_file_uri` attribute of the cube @@ -466,6 +472,7 @@ def _get_start_index(horizontal_grid): Note ---- UGRID expects this to be a int32. + """ vertex_index = horizontal_grid.extract_cube( NameConstraint(var_name='vertex_index')) diff --git a/esmvalcore/cmor/_fixes/icon/icon.py b/esmvalcore/cmor/_fixes/icon/icon.py index d714657764..707a47f20c 100644 --- a/esmvalcore/cmor/_fixes/icon/icon.py +++ b/esmvalcore/cmor/_fixes/icon/icon.py @@ -100,6 +100,7 @@ def _add_coord_from_grid_file(self, cube, coord_name): Invalid ``coord_name`` is given; input cube does not contain a single unnamed dimension that can be used to add the new coordinate. + """ # The following dict maps from desired coordinate name in output file # (dict keys) to coordinate name in grid file (dict values) diff --git a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py index 96889cd7b9..362d950f6c 100644 --- a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py +++ b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py @@ -19,8 +19,8 @@ class AllVars(Fix): def fix_file(self, filepath, output_dir, add_unique_suffix=False): """Select IPSLCM variable in filepath. - This is done only if input file is a multi-variable one. This is - diagnosed by searching in the input filepathame for the + This is done only if input file is a multi-variable one. This + is diagnosed by searching in the input filepathame for the extra_facet value for key 'group'. In such cases, it is worth to use an external tool for @@ -28,8 +28,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): up to, and including, V3.0.2), and CDO can be used, depending on extra_facets key `use_cdo` - However, we take care of ESMValTool policy re. dependencies - licence + However, we take care of ESMValTool policy re. dependencies licence + """ if "_" + self.extra_facets.get( "group", "non-sense") + ".nc" not in str(filepath): @@ -61,8 +61,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): def fix_metadata(self, cubes): """Fix metadata for any IPSLCM variable + filter out other variables. - Fix the name of the time coordinate, which is called - time_counter in the original file. + Fix the name of the time coordinate, which is called time_counter + in the original file. Remove standard_name 'time' in auxiliary time coordinates """ diff --git a/esmvalcore/cmor/_fixes/native6/era5_land.py b/esmvalcore/cmor/_fixes/native6/era5_land.py index 6c32cc6dcb..5b6fbff276 100644 --- a/esmvalcore/cmor/_fixes/native6/era5_land.py +++ b/esmvalcore/cmor/_fixes/native6/era5_land.py @@ -1,12 +1,11 @@ """Fixes for ERA5-Land.""" import logging -from esmvalcore.cmor._fixes.native6.era5 import ( - AllVars, - Evspsbl, - Evspsblpot, - Pr, -) +from esmvalcore.cmor._fixes.native6.era5 import (Pr, + Evspsbl, + Evspsblpot, + AllVars) + logger = logging.getLogger(__name__) logger.info("Load classes from era5.py") diff --git a/esmvalcore/cmor/_fixes/native_datasets.py b/esmvalcore/cmor/_fixes/native_datasets.py index b773c63966..20cfa5590f 100644 --- a/esmvalcore/cmor/_fixes/native_datasets.py +++ b/esmvalcore/cmor/_fixes/native_datasets.py @@ -29,6 +29,7 @@ def fix_scalar_coords(self, cube): cube: iris.cube.Cube Input cube for which missing scalar coordinates will be added (in-place). + """ if 'height2m' in self.vardef.dimensions: add_scalar_height_coord(cube, 2.0) @@ -46,6 +47,7 @@ def fix_var_metadata(self, cube): ---------- cube: iris.cube.Cube Input cube whose metadata is changed in-place. + """ # Fix names if self.vardef.standard_name == '': @@ -101,6 +103,7 @@ def get_cube(self, cubes, var_name=None): ------ ValueError Desired variable is not available in the input cubes. + """ if var_name is None: var_name = self.extra_facets.get('raw_name', @@ -124,6 +127,7 @@ def fix_regular_time(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. + """ if not self.vardef.has_coord_with_standard_name('time'): return @@ -144,6 +148,7 @@ def fix_regular_lat(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. + """ if not self.vardef.has_coord_with_standard_name('latitude'): return @@ -164,6 +169,7 @@ def fix_regular_lon(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. + """ if not self.vardef.has_coord_with_standard_name('longitude'): return @@ -192,6 +198,7 @@ def guess_coord_bounds(cube, coord): iris.coords.AuxCoord or iris.coords.DimCoord Coordinate with bounds. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if isinstance(coord, str): coord = cube.coord(coord) @@ -219,6 +226,7 @@ def fix_time_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed time coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('time') @@ -246,6 +254,7 @@ def fix_alt16_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed altitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('altitude') @@ -275,6 +284,7 @@ def fix_height_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed height coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('height') @@ -304,6 +314,7 @@ def fix_plev_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed air_pressure coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('air_pressure') @@ -333,6 +344,7 @@ def fix_lat_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed latitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('latitude') @@ -361,6 +373,7 @@ def fix_lon_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed longitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('longitude') diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py index eafde5e3e2..b8eab7b711 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py @@ -21,6 +21,7 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. + """ for cube in cubes: # Put information from valid_range into mask and remove the diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py index f72a498759..93ca03eaa6 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py @@ -8,7 +8,8 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Change unit of coordinate plev from hPa to Pa. @@ -21,6 +22,7 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py index dfc01ba281..cb150fe729 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py @@ -1,3 +1,4 @@ + """Fixes for SSMI model.""" from ..fix import Fix diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py index 982ab03783..2fa26842b9 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py @@ -1,3 +1,4 @@ + """Fixes for CCSM4 model.""" from iris.cube import CubeList @@ -8,7 +9,8 @@ class Prw(Fix): """Fixes for prw.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Remove error and number of observations cubes @@ -19,6 +21,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) return CubeList([cube]) diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index d3498c9b87..3ec14d05ab 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -443,6 +443,7 @@ def get_next_month(month: int, year: int) -> tuple[int, int]: ------- tuple[int, int] Next month and next year. + """ if month != 12: return month + 1, year @@ -475,6 +476,7 @@ def get_time_bounds(time: Coord, freq: str) -> np.ndarray: ------ NotImplementedError Non-supported frequency is given. + """ bounds = [] dates = time.units.num2date(time.points) diff --git a/esmvalcore/cmor/_utils.py b/esmvalcore/cmor/_utils.py index 629d6be498..be837d9c10 100644 --- a/esmvalcore/cmor/_utils.py +++ b/esmvalcore/cmor/_utils.py @@ -52,6 +52,7 @@ def _get_alternative_generic_lev_coord( ------ ValueError No valid alternative generic level coordinate present in cube. + """ alternatives_for_coord = _ALTERNATIVE_GENERIC_LEV_COORDS.get( coord_name, {} @@ -92,6 +93,7 @@ def _get_generic_lev_coord_names( Tuple of `standard_name`, `out_name`, and `name` of the generic level coordinate present in the cube. Values are ``None`` if generic level coordinate has not been found in cube. + """ standard_name = None out_name = None @@ -150,6 +152,7 @@ def _get_new_generic_level_coord( ------- CoordinateInfo New generic level coordinate. + """ new_coord = generic_level_coord.generic_lev_coords[new_coord_name] new_coord.generic_level = True diff --git a/esmvalcore/cmor/check.py b/esmvalcore/cmor/check.py index b368d6d131..09f7a6331d 100644 --- a/esmvalcore/cmor/check.py +++ b/esmvalcore/cmor/check.py @@ -164,6 +164,7 @@ def check_metadata(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. + """ if logger is not None: self._logger = logger @@ -212,6 +213,7 @@ def check_data(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. + """ if logger is not None: self._logger = logger @@ -914,6 +916,7 @@ def cmor_check_metadata( ------- iris.cube.Cube Checked cube. + """ checker = _get_cmor_checker( cmor_table, @@ -956,6 +959,7 @@ def cmor_check_data( ------- iris.cube.Cube Checked cube. + """ checker = _get_cmor_checker( cmor_table, @@ -1001,6 +1005,7 @@ def cmor_check( ------- iris.cube.Cube Checked cube. + """ cube = cmor_check_metadata( cube, diff --git a/esmvalcore/cmor/fix.py b/esmvalcore/cmor/fix.py index 8a5421e19a..d05af5ef64 100644 --- a/esmvalcore/cmor/fix.py +++ b/esmvalcore/cmor/fix.py @@ -72,6 +72,7 @@ def fix_file( ------- str or pathlib.Path Path to the fixed file. + """ # Update extra_facets with variable information given as regular arguments # to this function @@ -147,6 +148,7 @@ def fix_metadata( ------- iris.cube.CubeList Fixed cubes. + """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: @@ -267,6 +269,7 @@ def fix_data( ------- iris.cube.Cube Fixed cube. + """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: diff --git a/esmvalcore/cmor/table.py b/esmvalcore/cmor/table.py index a2a5e0a255..a0c685654a 100644 --- a/esmvalcore/cmor/table.py +++ b/esmvalcore/cmor/table.py @@ -25,7 +25,7 @@ CMORTable = Union['CMIP3Info', 'CMIP5Info', 'CMIP6Info', 'CustomInfo'] CMOR_TABLES: dict[str, CMORTable] = {} -"""Dict of str, obj: CMOR info objects.""" +"""dict of str, obj: CMOR info objects.""" _CMOR_KEYS = ( 'standard_name', @@ -102,6 +102,7 @@ def get_var_info( ------ KeyError No CMOR tables available for `project`. + """ if project not in CMOR_TABLES: raise KeyError( @@ -281,6 +282,7 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, ``None`` otherwise. + """ alt_names_list = self._get_alt_names_list(short_name) @@ -611,28 +613,28 @@ def __init__(self, table_type, short_name): super(VariableInfo, self).__init__() self.table_type = table_type self.modeling_realm = [] - """Modeling realm.""" + """Modeling realm""" self.short_name = short_name - """Short name.""" + """Short name""" self.standard_name = '' - """Standard name.""" + """Standard name""" self.long_name = '' - """Long name.""" + """Long name""" self.units = '' - """Data units.""" + """Data units""" self.valid_min = '' - """Minimum admitted value.""" + """Minimum admitted value""" self.valid_max = '' - """Maximum admitted value.""" + """Maximum admitted value""" self.frequency = '' - """Data frequency.""" + """Data frequency""" self.positive = '' - """Increasing direction.""" + """Increasing direction""" self.dimensions = [] - """List of dimensions.""" + """List of dimensions""" self.coordinates = {} - """Coordinates. + """Coordinates This is a dict with the names of the dimensions as keys and CoordinateInfo objects as values. @@ -701,6 +703,7 @@ def has_coord_with_standard_name(self, standard_name: str) -> bool: bool `True` if there is at least one coordinate with the given `standard_name`, `False` if not. + """ for coord in self.coordinates.values(): if coord.standard_name == standard_name: @@ -725,34 +728,35 @@ def __init__(self, name): self.generic_lev_coords = {} self.axis = "" - """Axis.""" + """Axis""" self.value = "" - """Coordinate value.""" + """Coordinate value""" self.standard_name = "" - """Standard name.""" + """Standard name""" self.long_name = "" - """Long name.""" + """Long name""" self.out_name = "" - """Out name. + """ + Out name This is the name of the variable in the file """ self.var_name = "" - """Short name.""" + """Short name""" self.units = "" - """Units.""" + """Units""" self.stored_direction = "" - """Direction in which the coordinate increases.""" + """Direction in which the coordinate increases""" self.requested = [] - """Values requested.""" + """Values requested""" self.valid_min = "" - """Minimum allowed value.""" + """Minimum allowed value""" self.valid_max = "" - """Maximum allowed value.""" + """Maximum allowed value""" self.must_have_bounds = "" - """Whether bounds are required on this dimension.""" + """Whether bounds are required on this dimension""" self.generic_lev_name = "" - """Generic level name.""" + """Generic level name""" def read_json(self, json_data): """Read coordinate information from json. @@ -988,6 +992,7 @@ class CustomInfo(CMIP5Info): Full path to the table or name for the table if it is present in ESMValTool repository. If ``None``, use default tables from `esmvalcore/cmor/tables/custom`. + """ def __init__(self, cmor_tables_path: Optional[str | Path] = None) -> None: @@ -1062,6 +1067,7 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, returns None if not. + """ return self.tables['custom'].get(short_name, None) diff --git a/esmvalcore/config/__init__.py b/esmvalcore/config/__init__.py index 271fa956cc..7c2b8e379c 100644 --- a/esmvalcore/config/__init__.py +++ b/esmvalcore/config/__init__.py @@ -7,6 +7,7 @@ By default, this will be loaded from the file ``~/.esmvaltool/config-user.yml``. If used within the ``esmvaltool`` program, this will respect the ``--config_file`` argument. + """ from ._config_object import CFG, Config, Session diff --git a/esmvalcore/config/_config_object.py b/esmvalcore/config/_config_object.py index 89ad3b7f69..2e53857d70 100644 --- a/esmvalcore/config/_config_object.py +++ b/esmvalcore/config/_config_object.py @@ -30,6 +30,7 @@ class Config(ValidatedConfig): Do not instantiate this class directly, but use :obj:`esmvalcore.config.CFG` instead. + """ _DEFAULT_USER_CONFIG_DIR = Path.home() / '.esmvaltool' @@ -160,6 +161,7 @@ def _get_config_user_path( _ESMVALTOOL_USER_CONFIG_FILE_ at the end of this method to make sure that subsequent calls of this method (also in suprocesses) use the correct user configuration file. + """ # (1) Try to get user configuration file from `filename` argument config_user = filename @@ -208,6 +210,7 @@ def _get_config_path_from_cli() -> None | str: ---- This only works if the script name is `esmvaltool`. Does not check if file exists. + """ if Path(sys.argv[0]).name != 'esmvaltool': return None diff --git a/esmvalcore/config/_esgf_pyclient.py b/esmvalcore/config/_esgf_pyclient.py index 5f4b1aab48..51152344c4 100644 --- a/esmvalcore/config/_esgf_pyclient.py +++ b/esmvalcore/config/_esgf_pyclient.py @@ -1,4 +1,4 @@ -"""Esgf-pyclient configuration. +"""esgf-pyclient configuration. The configuration is read from the file ~/.esmvaltool/esgf-pyclient.yml. """ diff --git a/esmvalcore/config/_validated_config.py b/esmvalcore/config/_validated_config.py index dcc3e2ca36..27048397a7 100644 --- a/esmvalcore/config/_validated_config.py +++ b/esmvalcore/config/_validated_config.py @@ -49,9 +49,8 @@ class ValidatedConfig(MutableMapping): _warn_if_missing: tuple[tuple[str, str], ...] = () """Handle missing options. - Each sub-tuple in the tuple consists of an option for which a - warning is emitted and a string with more information for the user - on that option. + Each sub-tuple in the tuple consists of an option for which a warning is + emitted and a string with more information for the user on that option. """ # validate values on the way in diff --git a/esmvalcore/config/extra_facets/access-mappings.yml b/esmvalcore/config/extra_facets/access-mappings.yml index 14c75f07b0..9d4eb0621b 100644 --- a/esmvalcore/config/extra_facets/access-mappings.yml +++ b/esmvalcore/config/extra_facets/access-mappings.yml @@ -7,23 +7,23 @@ ACCESS-ESM1-5: '*': - + tas: raw_name: fld_s03i236 modeling_realm: atm - + pr: raw_name: fld_s05i216 modeling_realm: atm - + ps: raw_name: fld_s00i409 modeling_realm: atm - + clt: raw_name: fld_s02i204 modeling_realm: atm - + psl: raw_name: fld_s16i222 modeling_realm: atm @@ -31,7 +31,7 @@ ACCESS-ESM1-5: hus: raw_name: fld_s30i205 modeling_realm: atm - + zg: raw_name: fld_s30i207 modeling_realm: atm @@ -39,30 +39,30 @@ ACCESS-ESM1-5: va: raw_name: fld_s30i202 modeling_realm: atm - + ua: raw_name: fld_s30i201 modeling_realm: atm - + ta: raw_name: fld_s30i204 modeling_realm: atm - + rlus: - raw_name: - - fld_s02i207 - - fld_s02i201 - - fld_s03i332 + raw_name: + - fld_s02i207 + - fld_s02i201 + - fld_s03i332 - fld_s02i205 modeling_realm: atm - + rlds: raw_name: fld_s02i207 modeling_realm: atm rsus: - raw_name: + raw_name: - fld_s01i235 - - fld_s01i201 + - fld_s01i201 modeling_realm: atm - + diff --git a/esmvalcore/dataset.py b/esmvalcore/dataset.py index 07f07bc915..d4bd665aa6 100644 --- a/esmvalcore/dataset.py +++ b/esmvalcore/dataset.py @@ -188,8 +188,7 @@ def _file_to_dataset( def _get_available_datasets(self) -> Iterator[Dataset]: """Yield datasets based on the available files. - This function requires that self.facets['mip'] is not a glob - pattern. + This function requires that self.facets['mip'] is not a glob pattern. """ dataset_template = self.copy() dataset_template.supplementaries = [] diff --git a/esmvalcore/iris_helpers.py b/esmvalcore/iris_helpers.py index b2a9f3183c..eb9a96461e 100644 --- a/esmvalcore/iris_helpers.py +++ b/esmvalcore/iris_helpers.py @@ -39,6 +39,7 @@ def add_leading_dim_to_cube(cube, dim_coord): ------ CoordinateMultiDimError ``dim_coord`` is not 1D. + """ # Only 1D dim_coords are supported if dim_coord.ndim > 1: @@ -133,6 +134,7 @@ def merge_cube_attributes( Input cubes whose attributes will be modified in-place. delimiter: Delimiter that is used to concatenate non-identical attributes. + """ if len(cubes) <= 1: return @@ -252,6 +254,7 @@ def rechunk_cube( ------- Cube Rechunked cube. This will always be a copy of the input cube. + """ cube = cube.copy() # do not modify input cube @@ -286,6 +289,7 @@ def has_regular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has a regular grid, else ``False``. + """ try: lat = cube.coord('latitude') @@ -314,6 +318,7 @@ def has_irregular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an irregular grid, else ``False``. + """ try: lat = cube.coord('latitude') @@ -340,6 +345,7 @@ def has_unstructured_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an unstructured grid, else ``False``. + """ try: lat = cube.coord('latitude') diff --git a/esmvalcore/preprocessor/__init__.py b/esmvalcore/preprocessor/__init__.py index b44dada778..3800fb1413 100644 --- a/esmvalcore/preprocessor/__init__.py +++ b/esmvalcore/preprocessor/__init__.py @@ -206,7 +206,9 @@ ] DEFAULT_ORDER = tuple(__all__) -"""By default, preprocessor functions are applied in this order.""" +""" +By default, preprocessor functions are applied in this order. +""" # The order of initial and final steps cannot be configured INITIAL_STEPS = DEFAULT_ORDER[:DEFAULT_ORDER.index( diff --git a/esmvalcore/preprocessor/_area.py b/esmvalcore/preprocessor/_area.py index 78ff33f3a5..dd2f9b4b4b 100644 --- a/esmvalcore/preprocessor/_area.py +++ b/esmvalcore/preprocessor/_area.py @@ -70,6 +70,7 @@ def extract_region( ------- iris.cube.Cube Smaller cube. + """ # first examine if any cell_measures are present cell_measures = cube.cell_measures() @@ -225,6 +226,7 @@ def zonal_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. + """ if cube.coord('longitude').points.ndim >= 2: raise ValueError( @@ -273,6 +275,7 @@ def meridional_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. + """ if cube.coord('latitude').points.ndim >= 2: raise ValueError( @@ -335,6 +338,7 @@ def area_statistics( iris.exceptions.CoordinateMultiDimError Cube has irregular or unstructured grid but supplementary variable `cell_area` is not available. + """ has_cell_measure = bool(cube.cell_measures('cell_area')) @@ -379,6 +383,7 @@ def extract_named_regions(cube: Cube, regions: str | Iterable[str]) -> Cube: regions is not list or tuple or set. ValueError region not included in cube. + """ # Make sure regions is a list of strings if isinstance(regions, str): @@ -594,6 +599,7 @@ def _get_bounds( ------- lat_min, lon_min, lat_max, lon_max Coordinates deliminating bounding box for shape ids. + """ all_bounds = np.vstack( [fiona.bounds(geom) for geom in geometries.values()] @@ -648,6 +654,7 @@ def fix_coordinate_ordering(cube: Cube) -> Cube: ------- iris.cube.Cube Cube with dimensions transposed to standard order + """ try: time_dim = cube.coord_dims('time') @@ -771,6 +778,7 @@ def extract_shape( See Also -------- extract_region: Extract a region from a cube. + """ shapefile = _update_shapefile_path(shapefile) with fiona.open(shapefile) as geometries: diff --git a/esmvalcore/preprocessor/_compare_with_refs.py b/esmvalcore/preprocessor/_compare_with_refs.py index 0228a5eddc..1634fc1752 100644 --- a/esmvalcore/preprocessor/_compare_with_refs.py +++ b/esmvalcore/preprocessor/_compare_with_refs.py @@ -102,6 +102,7 @@ def bias( true`` if ``reference=None``; ``reference=None`` and the input products are given as iterable of :class:`~iris.cube.Cube` objects; ``bias_type`` is not one of ``'absolute'`` or ``'relative'``. + """ ref_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) @@ -318,6 +319,7 @@ def distance_metric( `longitude` is not found in cube if a weighted metric shall be calculated, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. + """ reference_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) diff --git a/esmvalcore/preprocessor/_cycles.py b/esmvalcore/preprocessor/_cycles.py index 90e1284684..017d6ed71b 100644 --- a/esmvalcore/preprocessor/_cycles.py +++ b/esmvalcore/preprocessor/_cycles.py @@ -41,6 +41,7 @@ def amplitude(cube, coords): iris.exceptions.CoordinateNotFoundError A coordinate is not found in ``cube`` and cannot be added via :mod:`iris.coord_categorisation`. + """ if isinstance(coords, str): coords = [coords] diff --git a/esmvalcore/preprocessor/_derive/_baseclass.py b/esmvalcore/preprocessor/_derive/_baseclass.py index c2076b1542..ba9325bfdd 100644 --- a/esmvalcore/preprocessor/_derive/_baseclass.py +++ b/esmvalcore/preprocessor/_derive/_baseclass.py @@ -30,6 +30,7 @@ def required(project): ------- list of dict List of variable metadata. + """ @staticmethod @@ -57,4 +58,5 @@ def calculate(cubes): NotImplementedError If the desired variable derivation is not implemented, i.e. if this method is called from this base class and not a child class. + """ diff --git a/esmvalcore/preprocessor/_derive/_shared.py b/esmvalcore/preprocessor/_derive/_shared.py index dfe620b58e..e6d07011f1 100644 --- a/esmvalcore/preprocessor/_derive/_shared.py +++ b/esmvalcore/preprocessor/_derive/_shared.py @@ -61,6 +61,7 @@ def column_average(cube, hus_cube, zg_cube, ps_cube): ------- iris.cube.Cube Column-averaged mole fraction of a gas. + """ # Convert units of data hus_cube.convert_units('1') @@ -123,6 +124,7 @@ def pressure_level_widths(cube, ps_cube, top_limit=0.0): ------- iris.cube.Cube Cube of same shape as ``cube`` containing pressure level widths. + """ pressure_array = _create_pressure_array(cube, ps_cube, top_limit) @@ -170,6 +172,7 @@ def _get_pressure_level_widths(array, air_pressure_axis=1): For a 1D array with pressure level columns, return a 1D array with pressure level widths. + """ array = np.copy(array) if np.any(np.diff(array, axis=air_pressure_axis) > 0.0): diff --git a/esmvalcore/preprocessor/_derive/alb.py b/esmvalcore/preprocessor/_derive/alb.py index dcc45362b8..b0036077ad 100644 --- a/esmvalcore/preprocessor/_derive/alb.py +++ b/esmvalcore/preprocessor/_derive/alb.py @@ -2,6 +2,7 @@ authors: - crez_ba + """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/ctotal.py b/esmvalcore/preprocessor/_derive/ctotal.py index 45cd2610da..18bef27071 100644 --- a/esmvalcore/preprocessor/_derive/ctotal.py +++ b/esmvalcore/preprocessor/_derive/ctotal.py @@ -1,6 +1,7 @@ """Derivation of variable `ctotal`.""" import iris + from iris import Constraint from ._baseclass import DerivedVariableBase diff --git a/esmvalcore/preprocessor/_derive/lvp.py b/esmvalcore/preprocessor/_derive/lvp.py index ad9db3f299..0faf0779c4 100644 --- a/esmvalcore/preprocessor/_derive/lvp.py +++ b/esmvalcore/preprocessor/_derive/lvp.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/lwp.py b/esmvalcore/preprocessor/_derive/lwp.py index 4c79322496..067126d5e9 100644 --- a/esmvalcore/preprocessor/_derive/lwp.py +++ b/esmvalcore/preprocessor/_derive/lwp.py @@ -33,6 +33,7 @@ def calculate(cubes): ---- Some datasets output the variable `clwvi` which only contains `lwp`. In these cases, the input `clwvi` cube is just returned. + """ # CMIP5 and CMIP6 names are slightly different, so use # variable name instead to extract cubes diff --git a/esmvalcore/preprocessor/_derive/ohc.py b/esmvalcore/preprocessor/_derive/ohc.py index e9f1f52e67..d8d374b312 100644 --- a/esmvalcore/preprocessor/_derive/ohc.py +++ b/esmvalcore/preprocessor/_derive/ohc.py @@ -1,8 +1,9 @@ """Derivation of variable `ohc`.""" import iris -from cf_units import Unit from iris import Constraint +from cf_units import Unit + from ._baseclass import DerivedVariableBase RHO_CP = iris.coords.AuxCoord(4.09169e+6, units=Unit('kg m-3 J kg-1 K-1')) @@ -37,7 +38,8 @@ def required(project): @staticmethod def calculate(cubes): - """Compute ocean heat content. + """ + Compute ocean heat content. Use c_p*rho_0= 4.09169e+6 J m-3 K-1 (Kuhlbrodt et al., 2015, Clim. Dyn.) diff --git a/esmvalcore/preprocessor/_derive/rlnst.py b/esmvalcore/preprocessor/_derive/rlnst.py index dcf1c643c9..4eecd9b90d 100644 --- a/esmvalcore/preprocessor/_derive/rlnst.py +++ b/esmvalcore/preprocessor/_derive/rlnst.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint @@ -29,10 +30,11 @@ def required(project): @staticmethod def calculate(cubes): - """Compute variable `rlnst`. + """ + Compute variable `rlnst`. - Compute Net Atmospheric Longwave Cooling to surface and outer - space. + Compute Net Atmospheric Longwave Cooling + to surface and outer space. """ rlds_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air')) diff --git a/esmvalcore/preprocessor/_derive/rlnstcs.py b/esmvalcore/preprocessor/_derive/rlnstcs.py index a1b39128fe..10613216a9 100644 --- a/esmvalcore/preprocessor/_derive/rlnstcs.py +++ b/esmvalcore/preprocessor/_derive/rlnstcs.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint @@ -29,10 +30,11 @@ def required(project): @staticmethod def calculate(cubes): - """Compute variable `rlnstcs`. + """ + Compute variable `rlnstcs`. - Compute Net Atmospheric Longwave Cooling to surface and outer - space assuming clear sky. + Compute Net Atmospheric Longwave Cooling + to surface and outer space assuming clear sky. """ rldscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rlus.py b/esmvalcore/preprocessor/_derive/rlus.py index 928b7d296a..4d536c29ad 100644 --- a/esmvalcore/preprocessor/_derive/rlus.py +++ b/esmvalcore/preprocessor/_derive/rlus.py @@ -2,6 +2,7 @@ authors: - lukas_brunner + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnst.py b/esmvalcore/preprocessor/_derive/rsnst.py index 80b6d7abf0..e2a2a53b21 100644 --- a/esmvalcore/preprocessor/_derive/rsnst.py +++ b/esmvalcore/preprocessor/_derive/rsnst.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcs.py b/esmvalcore/preprocessor/_derive/rsnstcs.py index 6a4271c649..976be64003 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcs.py +++ b/esmvalcore/preprocessor/_derive/rsnstcs.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py index 590a4bdd57..a6445bbb64 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py +++ b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from cf_units import Unit from iris import Constraint @@ -33,11 +34,12 @@ def required(project): @staticmethod def calculate(cubes): - """Compute `rsnstcs`. + """ + Compute `rsnstcs`. - Compute Heating from Shortwave Absorption assuming clear sky - normalized by the incoming shortwave flux at the top of the - atmosphere. + Compute Heating from Shortwave Absorption + assuming clear sky normalized by + the incoming shortwave flux at the top of the atmosphere. """ rsdscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_shortwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rsus.py b/esmvalcore/preprocessor/_derive/rsus.py index cd3a6ad4dd..326d063c26 100644 --- a/esmvalcore/preprocessor/_derive/rsus.py +++ b/esmvalcore/preprocessor/_derive/rsus.py @@ -2,6 +2,7 @@ authors: - lukas_brunner + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/siextent.py b/esmvalcore/preprocessor/_derive/siextent.py index 2e2bee96bb..eee25e5a98 100644 --- a/esmvalcore/preprocessor/_derive/siextent.py +++ b/esmvalcore/preprocessor/_derive/siextent.py @@ -6,7 +6,6 @@ from iris import Constraint from esmvalcore.exceptions import RecipeError - from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) diff --git a/esmvalcore/preprocessor/_derive/sispeed.py b/esmvalcore/preprocessor/_derive/sispeed.py index b28aa06214..168b2e5525 100644 --- a/esmvalcore/preprocessor/_derive/sispeed.py +++ b/esmvalcore/preprocessor/_derive/sispeed.py @@ -1,10 +1,10 @@ """Derivation of variable `sispeed`.""" import logging - from iris import Constraint from .._regrid import regrid + from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) @@ -24,7 +24,8 @@ def required(project): @staticmethod def calculate(cubes): - """Compute sispeed module from velocity components siu and siv. + """ + Compute sispeed module from velocity components siu and siv. Arguments --------- @@ -33,6 +34,7 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. + """ siu = cubes.extract_cube(Constraint(name='sea_ice_x_velocity')) siv = cubes.extract_cube(Constraint(name='sea_ice_y_velocity')) diff --git a/esmvalcore/preprocessor/_derive/sithick.py b/esmvalcore/preprocessor/_derive/sithick.py index b28fa2881b..ad80709d8f 100644 --- a/esmvalcore/preprocessor/_derive/sithick.py +++ b/esmvalcore/preprocessor/_derive/sithick.py @@ -20,7 +20,8 @@ def required(project): @staticmethod def calculate(cubes): - """Compute sea ice thickness from volume and concentration. + """ + Compute sea ice thickness from volume and concentration. In CMIP5, `sit` is called `sea_ice_thickness` but it is not real thickness. It is ice volume per area unit. In CMIP6, it is called @@ -33,6 +34,7 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. + """ sivol = cubes.extract_cube(Constraint(name='sea_ice_thickness')) siconc = cubes.extract_cube(Constraint(name='sea_ice_area_fraction')) diff --git a/esmvalcore/preprocessor/_derive/sm.py b/esmvalcore/preprocessor/_derive/sm.py index efc3810d65..deb3526dfd 100644 --- a/esmvalcore/preprocessor/_derive/sm.py +++ b/esmvalcore/preprocessor/_derive/sm.py @@ -25,6 +25,7 @@ def calculate(cubes): Convert moisture content of soil layer (kg/m2) into volumetric soil moisture (m3/m3), assuming density of water 998.2 kg/m2 (at temperature 20 deg C). + """ mrsos_cube = cubes.extract_cube(NameConstraint(var_name='mrsos')) diff --git a/esmvalcore/preprocessor/_derive/toz.py b/esmvalcore/preprocessor/_derive/toz.py index 62514d4ca3..32fd9e8334 100644 --- a/esmvalcore/preprocessor/_derive/toz.py +++ b/esmvalcore/preprocessor/_derive/toz.py @@ -39,6 +39,7 @@ def calculate(cubes): ---- The surface pressure is used as a lower integration bound. A fixed upper integration bound of 0 Pa is used. + """ tro3_cube = cubes.extract_cube( iris.Constraint(name='mole_fraction_of_ozone_in_air')) diff --git a/esmvalcore/preprocessor/_detrend.py b/esmvalcore/preprocessor/_detrend.py index 9faee61c73..5bc0ce6fc8 100644 --- a/esmvalcore/preprocessor/_detrend.py +++ b/esmvalcore/preprocessor/_detrend.py @@ -8,7 +8,8 @@ def detrend(cube, dimension='time', method='linear'): - """Detrend data along a given dimension. + """ + Detrend data along a given dimension. Parameters ---------- diff --git a/esmvalcore/preprocessor/_mapping.py b/esmvalcore/preprocessor/_mapping.py index a39e26e823..28d1fefb83 100644 --- a/esmvalcore/preprocessor/_mapping.py +++ b/esmvalcore/preprocessor/_mapping.py @@ -8,10 +8,11 @@ def _is_single_item(testee): - """Check if testee is a single item. + """ + Check if testee is a single item. - Return whether this is a single item, rather than an iterable. We - count string types as 'single', also. + Return whether this is a single item, rather than an iterable. + We count string types as 'single', also. """ return (isinstance(testee, str) or not isinstance(testee, collections.abc.Iterable)) @@ -63,7 +64,8 @@ def ref_to_dims_index_as_index(cube, ref): def ref_to_dims_index(cube, ref_to_slice): - """Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. + """ + Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. This method finds the indices of the dimensions in a cube that collectively correspond to the given list of :class:`iris.coords.DimCoord`. @@ -98,7 +100,8 @@ def ref_to_dims_index(cube, ref_to_slice): def get_associated_coords(cube, dimensions): - """Return all coords containing any of the given dimensions. + """ + Return all coords containing any of the given dimensions. Return all coords, dimensional and auxiliary, that contain any of the given dimensions. @@ -122,10 +125,11 @@ def get_associated_coords(cube, dimensions): def get_empty_data(shape, dtype=np.float32): - """Create an empty data object of the given shape. + """ + Create an empty data object of the given shape. - Creates an empty data object of the given shape, potentially of the - lazy kind from biggus or dask, depending on the used iris version. + Creates an empty data object of the given shape, potentially of the lazy + kind from biggus or dask, depending on the used iris version. """ data = np.empty(shape, dtype=dtype) mask = np.empty(shape, dtype=bool) @@ -133,10 +137,11 @@ def get_empty_data(shape, dtype=np.float32): def get_slice_spec(cube, ref_to_slice): - """Turn a slice reference into a specification for the slice. + """ + Turn a slice reference into a specification for the slice. - Turns a slice reference into a specification comprised of the shape - as well as the relevant dimensional and auxiliary coordinates. + Turns a slice reference into a specification comprised of the shape as well + as the relevant dimensional and auxiliary coordinates. """ slice_dims = ref_to_dims_index(cube, ref_to_slice) slice_shape = tuple(cube.shape[d] for d in slice_dims) @@ -145,7 +150,8 @@ def get_slice_spec(cube, ref_to_slice): def index_iterator(dims_to_slice, shape): - """Return iterator for subsets of multidimensional objects. + """ + Return iterator for subsets of multidimensional objects. An iterator over a multidimensional object, giving both source and destination indices. @@ -175,7 +181,8 @@ def get_slice_coords(cube): def map_slices(src, func, src_rep, dst_rep): - """Map slices of a cube, replacing them with different slices. + """ + Map slices of a cube, replacing them with different slices. This method is similar to the standard cube collapsed and aggregated_by methods, however, where they completely remove the mapped dimensions, this diff --git a/esmvalcore/preprocessor/_multimodel.py b/esmvalcore/preprocessor/_multimodel.py index b8950c2d8e..d1e0d90e74 100644 --- a/esmvalcore/preprocessor/_multimodel.py +++ b/esmvalcore/preprocessor/_multimodel.py @@ -1,11 +1,11 @@ """Statistics across cubes. -This module contains functions to compute statistics across multiple -cubes or products. +This module contains functions to compute statistics across multiple cubes or +products. -Wrapper functions separate esmvalcore internals, operating on products, -from generalized functions that operate on iris cubes. These wrappers -support grouped execution by passing a groupby keyword. +Wrapper functions separate esmvalcore internals, operating on products, from +generalized functions that operate on iris cubes. These wrappers support +grouped execution by passing a groupby keyword. """ from __future__ import annotations @@ -53,16 +53,16 @@ def _get_consistent_time_unit(cubes): def _unify_time_coordinates(cubes): """Make sure all cubes' share the same time coordinate. - This function extracts the date information from the cube and - reconstructs the time coordinate, resetting the actual dates to the - 15th of the month or 1st of July for yearly data (consistent with - `regrid_time`), so that there are no mismatches in the time arrays. + This function extracts the date information from the cube and reconstructs + the time coordinate, resetting the actual dates to the 15th of the month or + 1st of July for yearly data (consistent with `regrid_time`), so that there + are no mismatches in the time arrays. If cubes have different time units, it will reset the calendar to a the "standard" calendar with unit "days since 1850-01-01". - Might not work for (sub)daily data, because different calendars may - have different number of days in the year. + Might not work for (sub)daily data, because different calendars may have + different number of days in the year. """ t_unit = _get_consistent_time_unit(cubes) @@ -245,6 +245,7 @@ def _get_equal_coord_names_metadata(cubes, equal_coords_metadata): Note ---- Ignore coordinates whose names are not unique. + """ equal_names_metadata = {} for coord in cubes[0].coords(): @@ -360,6 +361,7 @@ def _equalise_var_metadata(cubes): If cubes have the same ``name()`` and ``units``, assign identical `standard_names`, `long_names`, and `var_names`. + """ attrs = ['standard_name', 'long_name', 'var_name'] equal_names_metadata = {} @@ -439,6 +441,7 @@ def _compute_slices(cubes): Note ---- For scalar cubes, simply return ``None``. + """ # Scalar cubes if cubes[0].shape == (): diff --git a/esmvalcore/preprocessor/_other.py b/esmvalcore/preprocessor/_other.py index c91866ade7..3d047a4e24 100644 --- a/esmvalcore/preprocessor/_other.py +++ b/esmvalcore/preprocessor/_other.py @@ -133,6 +133,7 @@ def histogram( `longitude` is not found in cube if `weights=True`, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. + """ # Check arguments if isinstance(bins, str): @@ -247,9 +248,10 @@ def _calculate_histogram_lazy( ) -> da.Array: """Calculate histogram over data along axes (lazy version). - This will return an array of shape `(x1, x2, ..., n_bins)` where - `xi` are the dimensions of `data` not appearing in `axes` and - `n_bins` is the number of bins. + This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are + the dimensions of `data` not appearing in `axes` and `n_bins` is the number + of bins. + """ n_axes = len(along_axes) @@ -313,9 +315,10 @@ def _calculate_histogram_eager( ) -> np.ndarray: """Calculate histogram over data along axes (eager version). - This will return an array of shape `(x1, x2, ..., n_bins)` where - `xi` are the dimensions of `data` not appearing in `axes` and - `n_bins` is the number of bins. + This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are + the dimensions of `data` not appearing in `axes` and `n_bins` is the number + of bins. + """ # Create array with shape (x1, x2, ..., y) where `y` is the product of all # dimensions in `axes` and the `xi` are the remaining dimensions diff --git a/esmvalcore/preprocessor/_regrid.py b/esmvalcore/preprocessor/_regrid.py index 0e9e8aafc9..228bd7dc26 100644 --- a/esmvalcore/preprocessor/_regrid.py +++ b/esmvalcore/preprocessor/_regrid.py @@ -31,8 +31,10 @@ from esmvalcore.exceptions import ESMValCoreDeprecationWarning from esmvalcore.iris_helpers import has_irregular_grid, has_unstructured_grid from esmvalcore.preprocessor._shared import ( - get_array_module, get_dims_along_axes, +) +from esmvalcore.preprocessor._shared import ( + get_array_module, preserve_float_dtype, ) from esmvalcore.preprocessor._supplementary_vars import ( diff --git a/esmvalcore/preprocessor/_regrid_esmpy.py b/esmvalcore/preprocessor/_regrid_esmpy.py index 3055f82f83..cce6dae92f 100755 --- a/esmvalcore/preprocessor/_regrid_esmpy.py +++ b/esmvalcore/preprocessor/_regrid_esmpy.py @@ -10,7 +10,6 @@ except ImportError: raise exc import warnings - import iris import numpy as np from iris.cube import Cube @@ -66,6 +65,7 @@ class ESMPyRegridder: `nearest`. mask_threshold: Threshold used to regrid mask of input cube. + """ def __init__( @@ -96,6 +96,7 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. + """ # These regridders are not lazy, so load source data once. cube.data # pylint: disable=pointless-statement @@ -123,6 +124,7 @@ class _ESMPyScheme: ---------- mask_threshold: Threshold used to regrid mask of source cube. + """ _METHOD = '' @@ -160,6 +162,7 @@ def regridder(self, src_cube: Cube, tgt_cube: Cube) -> ESMPyRegridder: ------- ESMPyRegridder Regridder instance. + """ return ESMPyRegridder( src_cube, @@ -181,6 +184,7 @@ class ESMPyAreaWeighted(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. + """ _METHOD = 'area_weighted' @@ -198,6 +202,7 @@ class ESMPyLinear(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. + """ _METHOD = 'linear' @@ -215,6 +220,7 @@ class ESMPyNearest(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. + """ _METHOD = 'nearest' @@ -444,7 +450,8 @@ def get_grid_representant(cube, horizontal_only=False): def get_grid_representants(src, dst): - """Construct cubes representing the source and destination grid. + """ + Construct cubes representing the source and destination grid. This method constructs two new cubes that representant the grids, i.e. the spatial dimensions of the given cubes. diff --git a/esmvalcore/preprocessor/_regrid_unstructured.py b/esmvalcore/preprocessor/_regrid_unstructured.py index ce94d7fa68..6618c728c0 100644 --- a/esmvalcore/preprocessor/_regrid_unstructured.py +++ b/esmvalcore/preprocessor/_regrid_unstructured.py @@ -26,10 +26,10 @@ class UnstructuredNearest(IrisUnstructuredNearest): """Unstructured nearest-neighbor regridding scheme. - This class is a wrapper around - :class:`iris.analysis.UnstructuredNearest` that removes any - additional X or Y coordinates prior to regridding if necessary. It - can be used in :meth:`iris.cube.Cube.regrid`. + This class is a wrapper around :class:`iris.analysis.UnstructuredNearest` + that removes any additional X or Y coordinates prior to regridding if + necessary. It can be used in :meth:`iris.cube.Cube.regrid`. + """ def regridder( @@ -50,6 +50,7 @@ def regridder( ------- UnstructuredNearestNeigbourRegridder Regridder instance. + """ # Unstructured nearest-neighbor regridding requires exactly one X and # one Y coordinate (latitude and longitude). Remove any X or Y @@ -78,6 +79,7 @@ class UnstructuredLinearRegridder: Cube defining the source grid. tgt_cube: Cube defining the target grid. + """ def __init__(self, src_cube: Cube, tgt_cube: Cube) -> None: @@ -125,6 +127,7 @@ def _get_weights_and_idx( The output arrays will be numpy arrays here (instead of dask) since resulting arrays are only 2D and will be computed anyway later during regridding. + """ # Make sure that source and target grid have identical units src_lat = src_lat.copy() @@ -188,6 +191,7 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. + """ if not has_unstructured_grid(cube): raise ValueError( @@ -316,6 +320,7 @@ def _interpolate(self, data: np.ndarray) -> np.ndarray: Before the interpolation, the input is extended by the data on the convex hull to consider the periodic boundary conditions of a sphere (this has also been done for the weights calculation). + """ data = self._add_convex_hull_twice(data, self._convex_hull_idx) interp_data = np.einsum( @@ -342,6 +347,7 @@ def _calculate_weights( Output shapes (M: number of target grid points) - weights: (M, 3) - indices: (M, 3) + """ tri = Delaunay(src_points) simplex = tri.find_simplex(tgt_points) @@ -367,6 +373,7 @@ class UnstructuredLinear: This will drop all cell measures, ancillary variables and aux factories, and any auxiliary coordinate that spans the dimension of the unstrucutred grid. + """ def __repr__(self) -> str: @@ -391,5 +398,6 @@ def regridder( ------- UnstructuredLinearRegridder Regridder instance. + """ return UnstructuredLinearRegridder(src_cube, tgt_cube) diff --git a/esmvalcore/preprocessor/_rolling_window.py b/esmvalcore/preprocessor/_rolling_window.py index 4b0b5cdf14..9e62275a45 100644 --- a/esmvalcore/preprocessor/_rolling_window.py +++ b/esmvalcore/preprocessor/_rolling_window.py @@ -39,6 +39,7 @@ def rolling_window_statistics( ------- iris.cube.Cube Rolling-window statistics cube. + """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) cube = cube.rolling_window(coordinate, agg, window_length, *agg_kwargs) diff --git a/esmvalcore/preprocessor/_shared.py b/esmvalcore/preprocessor/_shared.py index 1ed78b9766..67c3b89f5d 100644 --- a/esmvalcore/preprocessor/_shared.py +++ b/esmvalcore/preprocessor/_shared.py @@ -1,4 +1,5 @@ -"""Shared functions for preprocessor. +""" +Shared functions for preprocessor. Utility functions that can be used for multiple preprocessor steps """ @@ -67,6 +68,7 @@ def get_iris_aggregator( An invalid `operator` is specified, i.e., it is not found in :mod:`iris.analysis` or the returned object is not an :class:`iris.analysis.Aggregator`. + """ cap_operator = operator.upper() aggregator_kwargs = dict(operator_kwargs) @@ -136,6 +138,7 @@ def aggregator_accept_weights(aggregator: iris.analysis.Aggregator) -> bool: ------- bool ``True`` if aggregator support weights, ``False`` otherwise. + """ weighted_aggregators_cls = ( iris.analysis.WeightedAggregator, @@ -176,6 +179,7 @@ def update_weights_kwargs( ------- dict Updated keyword arguments. + """ kwargs = dict(kwargs) if aggregator_accept_weights(aggregator) and kwargs.get('weights', True): @@ -214,6 +218,7 @@ def get_normalized_cube( ------- Cube Input cube normalized with statistics cube. + """ if normalize == 'subtract': normalized_cube = cube - statistics_cube @@ -245,10 +250,11 @@ def get_normalized_cube( def preserve_float_dtype(func: Callable) -> Callable: """Preserve object's float dtype (all other dtypes are allowed to change). - This can be used as a decorator for preprocessor functions to ensure - that floating dtypes are preserved. For example, input of type - float32 will always give output of type float32, but input of type - int will be allowed to give output with any type. + This can be used as a decorator for preprocessor functions to ensure that + floating dtypes are preserved. For example, input of type float32 will + always give output of type float32, but input of type int will be allowed + to give output with any type. + """ @wraps(func) @@ -375,6 +381,7 @@ def get_time_weights(cube: Cube) -> np.ndarray | da.core.Array: Array of time weights for averaging. Returns a :class:`dask.array.Array` if the input cube has lazy data; a :class:`numpy.ndarray` otherwise. + """ time = cube.coord('time') coord_dims = cube.coord_dims('time') diff --git a/esmvalcore/preprocessor/_time.py b/esmvalcore/preprocessor/_time.py index 5fd60d807a..d4dff4c1f9 100644 --- a/esmvalcore/preprocessor/_time.py +++ b/esmvalcore/preprocessor/_time.py @@ -100,6 +100,7 @@ def extract_time( ------ ValueError Time ranges are outside the cube time limits. + """ t_1 = PartialDateTime(year=int(start_year), month=int(start_month), @@ -259,6 +260,7 @@ def clip_timerange(cube: Cube, timerange: str) -> Cube: ------ ValueError Time ranges are outside the cube's time limits. + """ start_date = _parse_start_date(timerange.split('/')[0]) end_date = _parse_end_date(timerange.split('/')[1]) @@ -316,6 +318,7 @@ def extract_season(cube: Cube, season: str) -> Cube: ------ ValueError Requested season is not present in the cube. + """ season = season.upper() @@ -369,6 +372,7 @@ def extract_month(cube: Cube, month: int) -> Cube: ------ ValueError Requested month is not present in the cube. + """ if month not in range(1, 13): raise ValueError('Please provide a month number between 1 and 12.') @@ -442,6 +446,7 @@ def hourly_statistics( ------- iris.cube.Cube Hourly statistics cube. + """ if not cube.coords('hour_group'): iris.coord_categorisation.add_categorised_coord( @@ -493,6 +498,7 @@ def daily_statistics( ------- iris.cube.Cube Daily statistics cube. + """ if not cube.coords('day_of_year'): iris.coord_categorisation.add_day_of_year(cube, 'time') @@ -533,6 +539,7 @@ def monthly_statistics( ------- iris.cube.Cube Monthly statistics cube. + """ if not cube.coords('month_number'): iris.coord_categorisation.add_month_number(cube, 'time') @@ -577,6 +584,7 @@ def seasonal_statistics( ------- iris.cube.Cube Seasonal statistic cube. + """ seasons = tuple(sea.upper() for sea in seasons) @@ -623,6 +631,7 @@ def spans_full_season(cube: Cube) -> list[bool]: ------- list[bool] Truth statements if time bounds are within (month*29, month*31) + """ time = cube.coord('time') num_days = [(tt.bounds[0, 1] - tt.bounds[0, 0]) for tt in time] @@ -666,6 +675,7 @@ def annual_statistics( ------- iris.cube.Cube Annual statistics cube. + """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -707,6 +717,7 @@ def decadal_statistics( ------- iris.cube.Cube Decadal statistics cube. + """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -1025,6 +1036,7 @@ def regrid_time( NotImplementedError An invalid `frequency` is given or `calendar` is set for a non-supported frequency. + """ # Do not overwrite input cube cube = cube.copy() @@ -1208,6 +1220,7 @@ def timeseries_filter( Cube does not have time coordinate. NotImplementedError: `filter_type` is not implemented. + """ try: cube.coord('time') @@ -1282,6 +1295,7 @@ def resample_hours( `interval` is not a divisor of 24; invalid `interpolate` given; or input data does not contain any target hour (if `interpolate` is ``None``). + """ allowed_intervals = (1, 2, 3, 4, 6, 12) if interval not in allowed_intervals: @@ -1373,6 +1387,7 @@ def resample_time( ------- iris.cube.Cube Cube with the new frequency. + """ time = cube.coord('time') dates = time.units.num2date(time.points) @@ -1410,6 +1425,7 @@ def _get_lst_offset(lon_coord: Coord) -> np.ndarray: ---- This function expects longitude in degrees. Can be in [0, 360] or [-180, 180] format. + """ # Make sure that longitude is in degrees and shift it to [-180, 180] first # (do NOT overwrite input coordinate) @@ -1426,6 +1442,7 @@ def _get_lsts(time_coord: DimCoord, lon_coord: Coord) -> np.ndarray: ---- LSTs outside of the time bins given be the time coordinate bounds are put into a bin below/above the time coordinate. + """ # Pad time coordinate with 1 time step at both sides for the bins for LSTs # outside of the time coordinate @@ -1473,6 +1490,7 @@ def _get_time_index_and_mask( (LSTs) are given. E.g., for hourly data with first time point 01:00:00 UTC, LST in Berlin is already 02:00:00 (assuming no daylight saving time). Thus, for 01:00:00 LST on this day, there is no value for Berlin. + """ # Make sure that time coordinate has bounds (these are necessary for the # binning) and uses 'hours' as reference units @@ -1537,6 +1555,7 @@ def _transform_to_lst_eager( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. + """ # Apart from the time index, all other dimensions will stay the same; this # is ensured with np.ogrid @@ -1580,6 +1599,7 @@ def _transform_to_lst_lazy( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. + """ new_data = da.apply_gufunc( _transform_to_lst_eager, @@ -1610,6 +1630,7 @@ def _transform_arr_to_lst( ---- This function either calls `_transform_to_lst_eager` or `_transform_to_lst_lazy` depending on the type of input data. + """ if isinstance(data, np.ndarray): func = _transform_to_lst_eager # type: ignore @@ -1790,6 +1811,7 @@ def local_solar_time(cube: Cube) -> Cube: Input cube has multidimensional `longitude` coordinate. ValueError `time` coordinate of input cube is not monotonically increasing. + """ # Make sure that cube has valid time and longitude coordinates _check_cube_coords(cube) diff --git a/esmvalcore/preprocessor/_trend.py b/esmvalcore/preprocessor/_trend.py index b81d656034..c592f5196e 100644 --- a/esmvalcore/preprocessor/_trend.py +++ b/esmvalcore/preprocessor/_trend.py @@ -96,6 +96,7 @@ def linear_trend(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. + """ coord = cube.coord(coordinate, dim_coords=True) @@ -150,6 +151,7 @@ def linear_trend_stderr(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. + """ coord = cube.coord(coordinate, dim_coords=True) diff --git a/esmvalcore/preprocessor/_units.py b/esmvalcore/preprocessor/_units.py index c71fc384d6..8c96f78ae1 100644 --- a/esmvalcore/preprocessor/_units.py +++ b/esmvalcore/preprocessor/_units.py @@ -112,6 +112,7 @@ def convert_units(cube, units): ------- iris.cube.Cube converted cube. + """ try: cube.convert_units(units) diff --git a/esmvalcore/preprocessor/_volume.py b/esmvalcore/preprocessor/_volume.py index 9705f4e4e9..840af3214e 100644 --- a/esmvalcore/preprocessor/_volume.py +++ b/esmvalcore/preprocessor/_volume.py @@ -66,6 +66,7 @@ def extract_volume( ------- iris.cube.Cube z-coord extracted cube. + """ if z_min > z_max: # minimum is below maximum, so switch them around @@ -123,6 +124,7 @@ def calculate_volume(cube: Cube) -> da.core.Array: ------- dask.array.core.Array Grid volumes. + """ # Load depth field and figure out which dim is which depth = cube.coord(axis='z') @@ -252,6 +254,7 @@ def volume_statistics( ------- iris.cube.Cube Collapsed cube. + """ has_cell_measure = bool(cube.cell_measures('ocean_volume')) @@ -336,6 +339,7 @@ def axis_statistics( ------- iris.cube.Cube Collapsed cube. + """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) @@ -422,6 +426,7 @@ def depth_integration(cube: Cube) -> Cube: ------- iris.cube.Cube Collapsed cube. + """ result = axis_statistics(cube, axis='z', operator='sum') result.rename('Depth_integrated_' + str(cube.name())) @@ -475,6 +480,7 @@ def extract_transect( ValueError Latitude and longitude are both floats or lists; not allowed to slice on both axes at the same time. + """ # ### coord_dim2 = False @@ -565,6 +571,7 @@ def extract_trajectory( ------ ValueError Latitude and longitude have different dimensions. + """ from iris.analysis.trajectory import interpolate diff --git a/esmvalcore/preprocessor/shapefiles/ar6.prj b/esmvalcore/preprocessor/shapefiles/ar6.prj index 8f73f480ff..a30c00a55d 100644 --- a/esmvalcore/preprocessor/shapefiles/ar6.prj +++ b/esmvalcore/preprocessor/shapefiles/ar6.prj @@ -1 +1 @@ -GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/esmvalcore/typing.py b/esmvalcore/typing.py index d5c60fc83e..410b31f0f8 100644 --- a/esmvalcore/typing.py +++ b/esmvalcore/typing.py @@ -17,8 +17,8 @@ NetCDFAttr = Union[str, Number, Iterable] """Type describing netCDF attributes. -`NetCDF attributes`_ -can +`NetCDF attributes +`_ can be strings, numbers or sequences. """ diff --git a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py index 4f26feaf9e..d988e02441 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py @@ -27,7 +27,7 @@ def setUp(self): self.fix = Cl(None) def test_get(self): - """Test fix get.""" + """Test fix get""" fix = Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'cl') assert fix == [Cl(None), GenericFix(None)] diff --git a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py index ba41ddae48..ce6ebe0121 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py @@ -17,7 +17,7 @@ def setUp(self): self.fix = Msftmyz(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) @@ -37,7 +37,7 @@ def setUp(self): self.fix = Msftmyzba(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyzba'), [Msftmyzba(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py index a0805f4efe..4b480ef81f 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py @@ -26,7 +26,7 @@ def setUp(self): self.fix = Sic(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sic'), [Sic(None), GenericFix(None)]) @@ -45,7 +45,7 @@ def setUp(self): self.fix = Sftlf(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sftlf'), [Sftlf(None), GenericFix(None)]) @@ -90,7 +90,7 @@ def setUp(self): self.fix = Tas(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'tas'), [Tas(None), GenericFix(None)]) @@ -147,7 +147,7 @@ def setUp(self): self.fix = Areacello(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Omon', 'areacello'), [Areacello(None), GenericFix(None)], @@ -209,7 +209,7 @@ def setUp(self): self.fix = Pr(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'pr'), [Pr(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py index 0220aecb2c..c0705e58fa 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py @@ -29,7 +29,7 @@ def setUp(self): self.fix = Ch4(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'ch4'), [Ch4(None), GenericFix(None)]) @@ -48,7 +48,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'co2'), [Co2(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py index f2aa86d7b2..8a4fa19fd1 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py @@ -40,7 +40,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -62,7 +62,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'Amon', 'areacello'), [Areacello(self.vardef), @@ -106,7 +106,7 @@ def setUp(self): self.fix = Sit(self.var_info_mock) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'OImon', 'sit'), [Sit(self.var_info_mock), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py index 89b62a21f9..bcda26c95b 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -39,7 +39,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'Amon', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py index d0f0c5245c..d5189e84c4 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py @@ -75,7 +75,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -96,7 +96,7 @@ def setUp(self): self.fix = Usi(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'usi'), [Usi(self.vardef), @@ -118,7 +118,7 @@ def setUp(self): self.fix = Vsi(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'vsi'), [Vsi(self.vardef), @@ -140,7 +140,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py index 9fe2db7c83..1897ba5c85 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py @@ -23,7 +23,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -43,7 +43,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -64,7 +64,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py index 85bede7678..0e6a4fc57a 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py +++ b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py @@ -9,7 +9,7 @@ class TestAllVars(unittest.TestCase): """Test allvars fixes.""" def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'tas'), [AllVars(None), GenericFix(None)]) @@ -18,7 +18,7 @@ def test_get(self): class TestO2(unittest.TestCase): """Test o2 fixes.""" def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'o2'), [O2(None), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py index 64fcbc250c..1e14dfd30c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py +++ b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Tro3(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MIROC-ESM-CHEM', 'Amon', 'tro3'), [Tro3(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py index baabbbf599..f4d39eb70b 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py @@ -9,7 +9,7 @@ class TestMsftmyz(unittest.TestCase): """Test msftmyz fixes.""" def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MRI-ESM1', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py index fc962f38b7..b600311d5a 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py +++ b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py @@ -69,7 +69,7 @@ def test_tas(cubes_in, cubes_out): def test_get(): - """Test fix get.""" + """Test fix get""" assert Fix.get_fixes('CMIP5', 'NORESM1-ME', 'Amon', 'tas') == [ Tas(None), GenericFix(None) ] diff --git a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py index b4c1b9f7e9..65ca211e12 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py +++ b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py @@ -2,7 +2,6 @@ import iris import numpy as np import pytest -from cf_units import Unit from esmvalcore.cmor._fixes.cmip6.gfdl_cm4 import ( Cl, @@ -16,10 +15,11 @@ Tos, Uas, ) -from esmvalcore.cmor._fixes.common import OceanFixGrid, SiconcFixScalarCoord +from esmvalcore.cmor._fixes.common import SiconcFixScalarCoord, OceanFixGrid from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info +from cf_units import Unit def test_get_cl_fix(): diff --git a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py index 9668681c06..63428e913c 100644 --- a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py @@ -4,8 +4,7 @@ from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5 import ( aladin63, - wrf381p, -) + wrf381p,) from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info diff --git a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py index f1149064a0..c54bea04cd 100644 --- a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py +++ b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py @@ -1,6 +1,6 @@ """Tests for the fixes of MIROC-MIROC5.""" -import iris import pytest +import iris from esmvalcore.cmor._fixes.cordex.miroc_miroc5 import wrf361h from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_fix.py b/tests/integration/cmor/_fixes/test_fix.py index cfbbbebf31..1e97c62fd4 100644 --- a/tests/integration/cmor/_fixes/test_fix.py +++ b/tests/integration/cmor/_fixes/test_fix.py @@ -10,7 +10,9 @@ from esmvalcore.cmor._fixes.cmip5.canesm2 import FgCo2 from esmvalcore.cmor._fixes.cmip5.cesm1_bgc import Gpp from esmvalcore.cmor._fixes.cmip6.cesm2 import Omon, Tos -from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import Tas +from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import ( + Tas, +) from esmvalcore.cmor._fixes.cordex.cordex_fixes import AllVars from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_native_datasets.py b/tests/integration/cmor/_fixes/test_native_datasets.py index 1a732f1788..5399bf887e 100644 --- a/tests/integration/cmor/_fixes/test_native_datasets.py +++ b/tests/integration/cmor/_fixes/test_native_datasets.py @@ -89,6 +89,7 @@ def fix(): We use `tas` as a dummy variable here, but will use monkeypatching to customize the variable information of the fix in the tests below. This will allow us to test all common cases. + """ vardef = get_var_info('CMIP6', 'Amon', 'tas') extra_facets = {} diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index cc4237f5b7..fbddec7fe0 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -43,8 +43,9 @@ def create_test_file(filename, tracking_id=None): def _get_files(root_path, facets, tracking_id): """Return dummy files. - Wildcards are only supported for `dataset` and `institute`; in this - case return files for the two "models" AAA and BBB. + Wildcards are only supported for `dataset` and `institute`; in this case + return files for the two "models" AAA and BBB. + """ if facets['dataset'] == '*': all_facets = [ @@ -140,6 +141,7 @@ def patched_failing_datafinder(tmp_path, monkeypatch): - Variable rsutcs for model AAA Otherwise, return files just like `patched_datafinder`. + """ def tracking_ids(i=0): diff --git a/tests/integration/data_finder.yml b/tests/integration/data_finder.yml index 9b90bc7da6..40e0c3e821 100644 --- a/tests/integration/data_finder.yml +++ b/tests/integration/data_finder.yml @@ -452,7 +452,7 @@ get_input_filelist: - ta_Amon_HadGEM2-ES_historical_r1i1p1*.nc found_files: - historical/Amon/ta/HadGEM2-ES/r1i1p1/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -472,7 +472,7 @@ get_input_filelist: found_files: - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_195912-198411.nc - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -593,7 +593,7 @@ get_input_filelist: found_files: - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_195001-199912.nc - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_200001-200112.nc - + - drs: NCI variable: variable_group: test diff --git a/tests/integration/preprocessor/_extract_region/test_intersect.py b/tests/integration/preprocessor/_extract_region/test_intersect.py index 813576e4c6..41442c9c01 100644 --- a/tests/integration/preprocessor/_extract_region/test_intersect.py +++ b/tests/integration/preprocessor/_extract_region/test_intersect.py @@ -1,8 +1,8 @@ -"""Temporary test. +""" +Temporary test. Remove this test and test file after iris fixes this -https://github.com/SciTools/iris/issues/5413 -. +https://github.com/SciTools/iris/issues/5413 . """ import iris import numpy as np diff --git a/tests/integration/preprocessor/_mask/__init__.py b/tests/integration/preprocessor/_mask/__init__.py index 1b1a5d625b..9886ea9eed 100644 --- a/tests/integration/preprocessor/_mask/__init__.py +++ b/tests/integration/preprocessor/_mask/__init__.py @@ -1,4 +1,5 @@ -"""Test _mask.py. +""" +Test _mask.py Integration tests for the esmvalcore.preprocessor._mask module """ diff --git a/tests/integration/preprocessor/_regrid/__init__.py b/tests/integration/preprocessor/_regrid/__init__.py index bb8eab5e54..e19e118a0f 100644 --- a/tests/integration/preprocessor/_regrid/__init__.py +++ b/tests/integration/preprocessor/_regrid/__init__.py @@ -1 +1,4 @@ -"""Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module.""" +""" +Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module. + +""" diff --git a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py index f666ff64cf..7b4d4eb9b5 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py +++ b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py @@ -1,5 +1,8 @@ -"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function.""" +""" +Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function. + +""" import unittest @@ -20,7 +23,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point.""" + """Test linear interpolation when extracting a single point""" point = extract_coordinate_points( self.cube, {'grid_latitude': 2.1, 'grid_longitude': 2.1}, @@ -63,7 +66,7 @@ def test_extract_point__single_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point.""" + """Test nearest match when extracting a single point""" point = extract_coordinate_points( self.cube, @@ -96,7 +99,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate.""" + """Test linear interpolation for an array of one coordinate""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -148,7 +151,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate.""" + """Test nearest match for an array of one coordinate""" point = extract_coordinate_points( self.cube, @@ -189,8 +192,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with linear - interpolation.""" + """Test for both latitude and longitude arrays, with + linear interpolation""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], @@ -220,7 +223,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match.""" + """Test for both latitude and longitude arrays, with nearest match""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], diff --git a/tests/integration/preprocessor/_regrid/test_extract_point.py b/tests/integration/preprocessor/_regrid/test_extract_point.py index 79ec2e5685..d3d93945b9 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_point.py +++ b/tests/integration/preprocessor/_regrid/test_extract_point.py @@ -1,5 +1,8 @@ -"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function.""" +""" +Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function. + +""" import unittest @@ -20,7 +23,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point.""" + """Test linear interpolation when extracting a single point""" point = extract_point(self.cube, 2.1, 2.1, scheme='linear') self.assertEqual(point.shape, (3,)) @@ -55,7 +58,7 @@ def test_extract_point__single_linear(self): assert point.data.mask.all() def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point.""" + """Test nearest match when extracting a single point""" point = extract_point(self.cube, 2.1, 2.1, scheme='nearest') self.assertEqual(point.shape, (3,)) @@ -76,7 +79,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate.""" + """Test linear interpolation for an array of one coordinate""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -118,7 +121,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate.""" + """Test nearest match for an array of one coordinate""" point = extract_point(self.cube, [1, 1.1, 1.5, 1.501, 2, 4], 2, scheme='nearest') @@ -147,8 +150,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with linear - interpolation.""" + """Test for both latitude and longitude arrays, with + linear interpolation""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='linear') self.assertEqual(point.data.shape, (3, 6, 6)) @@ -176,7 +179,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match.""" + """Test for both latitude and longitude arrays, with nearest match""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='nearest') self.assertEqual(point.data.shape, (3, 6, 6)) diff --git a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py index b7a2ed0bcd..b4f869d171 100644 --- a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py +++ b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py @@ -1,6 +1,8 @@ -"""Integration tests for the :func: +""" +Integration tests for the :func: +`esmvalcore.preprocessor.regrid.get_cmor_levels` +function. -`esmvalcore.preprocessor.regrid.get_cmor_levels` function. """ import unittest diff --git a/tests/integration/preprocessor/_regrid/test_regrid.py b/tests/integration/preprocessor/_regrid/test_regrid.py index 00f35c0ad8..4e2e472681 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid.py +++ b/tests/integration/preprocessor/_regrid/test_regrid.py @@ -1,5 +1,8 @@ -"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function.""" +""" +Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function. + +""" import iris import numpy as np diff --git a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py index 8b410771fc..fee070863c 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py +++ b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py @@ -1,4 +1,4 @@ -"""Integration tests for unstructured regridding.""" +""" Integration tests for unstructured regridding.""" import numpy as np import pytest diff --git a/tests/integration/preprocessor/_supplementary_vars/test_register.py b/tests/integration/preprocessor/_supplementary_vars/test_register.py index bf4c1677d2..cfe6d5b7da 100644 --- a/tests/integration/preprocessor/_supplementary_vars/test_register.py +++ b/tests/integration/preprocessor/_supplementary_vars/test_register.py @@ -28,7 +28,7 @@ def test_func(): def test_register_invalid_fails(): - """Test that registering an invalid requirement fails.""" + """test that registering an invalid requirement fails.""" with pytest.raises(NotImplementedError): @_supplementary_vars.register_supplementaries( diff --git a/tests/integration/test_citation.py b/tests/integration/test_citation.py index 2bf34b4858..339cd253a0 100644 --- a/tests/integration/test_citation.py +++ b/tests/integration/test_citation.py @@ -4,11 +4,8 @@ from prov.model import ProvDocument import esmvalcore -from esmvalcore._citation import ( - CMIP6_URL_STEM, - ESMVALTOOL_PAPER, - _write_citation_files, -) +from esmvalcore._citation import (CMIP6_URL_STEM, ESMVALTOOL_PAPER, + _write_citation_files) from esmvalcore._provenance import ESMVALTOOL_URI_PREFIX diff --git a/tests/parse_pymon.py b/tests/parse_pymon.py index a9e9b21891..e63da518cc 100644 --- a/tests/parse_pymon.py +++ b/tests/parse_pymon.py @@ -1,7 +1,7 @@ -"""Parse and display test memory. +""" +Parse and display test memory. -Uses pytest-monitor plugin from -https://github.com/CFMTech/pytest-monitor +Uses pytest-monitor plugin from https://github.com/CFMTech/pytest-monitor Lots of other metrics can be read from the file via sqlite parsing., currently just MEM_USAGE (RES memory, in MB). """ diff --git a/tests/sample_data/multimodel_statistics/test_multimodel.py b/tests/sample_data/multimodel_statistics/test_multimodel.py index b99e183cbb..4c40d94875 100644 --- a/tests/sample_data/multimodel_statistics/test_multimodel.py +++ b/tests/sample_data/multimodel_statistics/test_multimodel.py @@ -204,6 +204,7 @@ def test_multimodel_regression_month(timeseries_cubes_month, span): """Test statistic fail due to differing input coordinates (pressure). See https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = timeseries_cubes_month name = 'timeseries_monthly' @@ -293,6 +294,7 @@ def test_multimodel_merge_error(timeseries_cubes_month, span): """Test statistic with slightly different vertical coordinates. See https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = timeseries_cubes_month msg = ( @@ -320,6 +322,7 @@ def test_multimodel_no_time_dimension(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -347,6 +350,7 @@ def test_multimodel_0d_1d_time_no_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -365,6 +369,7 @@ def test_multimodel_0d_1d_time_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -389,6 +394,7 @@ def test_multimodel_only_some_time_dimensions(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim @@ -414,6 +420,7 @@ def test_multimodel_diff_scalar_time_fail(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -435,6 +442,7 @@ def test_multimodel_diff_scalar_time_ignore(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -457,6 +465,7 @@ def test_multimodel_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): @@ -482,6 +491,7 @@ def test_multimodel_do_not_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): diff --git a/tests/unit/cmor/test_cmor_check.py b/tests/unit/cmor/test_cmor_check.py index e1ba8ce9ac..957136fd42 100644 --- a/tests/unit/cmor/test_cmor_check.py +++ b/tests/unit/cmor/test_cmor_check.py @@ -137,7 +137,7 @@ def test_warning_fail_on_error(self): ) def test_report_debug_message(self): - """"Test report debug message function.""" + """"Test report debug message function""" checker = CMORCheck(self.cube, self.var_info) self.assertFalse(checker.has_debug_messages()) checker.report_debug_message('New debug message') @@ -270,8 +270,8 @@ def test_rank_unstructured_grid(self): self._check_cube() def test_bad_generic_level(self): - """Test check fails in metadata if generic level coord has wrong - var_name.""" + """Test check fails in metadata if generic level coord + has wrong var_name.""" depth_coord = CoordinateInfoMock('depth') depth_coord.axis = 'Z' depth_coord.generic_lev_name = 'olevel' @@ -385,26 +385,26 @@ def test_check_bad_coord_var_name_strict_flag(self): self._check_fails_in_metadata() def test_check_missing_lon_strict_flag(self): - """Test check fails for missing longitude with --cmor-check strict.""" + """Test check fails for missing longitude with --cmor-check strict""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata() def test_check_missing_lat_strict_flag(self): - """Test check fails for missing latitude with --cmor-check strict.""" + """Test check fails for missing latitude with --cmor-check strict""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata() def test_check_missing_time_strict_flag(self): - """Test check fails for missing time with --cmor-check strict.""" + """Test check fails for missing time with --cmor-check strict""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata() def test_check_missing_coord_strict_flag(self): - """Test check fails for missing coord other than lat and lon with - --cmor-check strict.""" + """Test check fails for missing coord other than lat and lon + with --cmor-check strict""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -453,26 +453,26 @@ def test_check_bad_coord_standard_name_relaxed_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lon_relaxed_flag(self): - """Test check fails for missing longitude with --cmor-check relaxed.""" + """Test check fails for missing longitude with --cmor-check relaxed""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lat_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed.""" + """Test check fails for missing latitude with --cmor-check relaxed""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_time_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed.""" + """Test check fails for missing latitude with --cmor-check relaxed""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_coord_relaxed_flag(self): """Test check reports warning for missing coord other than lat and lon - with --cmor-check relaxed.""" + with --cmor-check relaxed""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -535,15 +535,15 @@ def test_check_missing_lat_none_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_time_none_flag(self): - """Test check reports warning for missing time with --cmor-check - ignore.""" + """Test check reports warning for missing time + with --cmor-check ignore""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_coord_none_flag(self): """Test check reports warning for missing coord other than lat, lon and - time with --cmor-check ignore.""" + time with --cmor-check ignore""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -603,10 +603,11 @@ def _check_debug_messages_on_metadata(self): self.assertTrue(checker.has_debug_messages()) def test_non_requested(self): - """Warning if requested values are not present. + """ + Warning if requested values are not present. - Check issue a warning if a values requested for a coordinate are - not correct in the metadata step + Check issue a warning if a values requested + for a coordinate are not correct in the metadata step """ coord = self.cube.coord('air_pressure') values = np.linspace(0, 40, len(coord.points)) @@ -616,10 +617,11 @@ def test_non_requested(self): self.assertTrue(checker.has_warnings()) def test_requested_str_values(self): - """Warning if requested values are not present. + """ + Warning if requested values are not present. - Check issue a warning if a values requested for a coordinate are - not correct in the metadata step + Check issue a warning if a values requested + for a coordinate are not correct in the metadata step """ region_coord = CoordinateInfoMock('basin') region_coord.standard_name = 'region' @@ -806,19 +808,19 @@ def test_bad_out_name_region_area_type(self): self._check_debug_messages_on_metadata() def test_bad_out_name_onedim_latitude(self): - """Warning if onedimensional lat has bad var_name at metadata.""" + """Warning if onedimensional lat has bad var_name at metadata""" self.var_info.table_type = 'CMIP6' self.cube.coord('latitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_onedim_longitude(self): - """Warning if onedimensional lon has bad var_name at metadata.""" + """Warning if onedimensional lon has bad var_name at metadata""" self.var_info.table_type = 'CMIP6' self.cube.coord('longitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_other(self): - """Warning if general coordinate has bad var_name at metadata.""" + """Warning if general coordinate has bad var_name at metadata""" self.var_info.table_type = 'CMIP6' self.cube.coord('time').var_name = 'bad_name' self._check_fails_in_metadata() @@ -925,7 +927,8 @@ def get_cube(self, var_info, set_time_units="days since 1850-1-1 00:00:00", frequency=None): - """Create a cube based on a specification. + """ + Create a cube based on a specification. Parameters ---------- @@ -939,6 +942,7 @@ def get_cube(self, Returns ------- iris.cube.Cube + """ coords = [] scalar_coords = [] diff --git a/tests/unit/preprocessor/_derive/test_toz.py b/tests/unit/preprocessor/_derive/test_toz.py index 12dee514a5..262deab1e0 100644 --- a/tests/unit/preprocessor/_derive/test_toz.py +++ b/tests/unit/preprocessor/_derive/test_toz.py @@ -5,7 +5,6 @@ import pytest import esmvalcore.preprocessor._derive.toz as toz - from .test_co2s import get_coord_spec, get_ps_cube diff --git a/tests/unit/preprocessor/_detrend/test_detrend.py b/tests/unit/preprocessor/_detrend/test_detrend.py index acf9c6cbe0..9b53f65d51 100644 --- a/tests/unit/preprocessor/_detrend/test_detrend.py +++ b/tests/unit/preprocessor/_detrend/test_detrend.py @@ -4,10 +4,11 @@ import iris import iris.coords +from iris.cube import Cube import numpy as np import pytest from cf_units import Unit -from iris.cube import Cube + from numpy.testing import assert_array_almost_equal from esmvalcore.preprocessor._detrend import detrend diff --git a/tests/unit/preprocessor/_mapping/test_mapping.py b/tests/unit/preprocessor/_mapping/test_mapping.py index 2af937349c..dc838b3a54 100644 --- a/tests/unit/preprocessor/_mapping/test_mapping.py +++ b/tests/unit/preprocessor/_mapping/test_mapping.py @@ -6,11 +6,8 @@ import numpy as np import tests -from esmvalcore.preprocessor._mapping import ( - get_empty_data, - map_slices, - ref_to_dims_index, -) +from esmvalcore.preprocessor._mapping import (get_empty_data, map_slices, + ref_to_dims_index) class TestHelpers(tests.Test): diff --git a/tests/unit/preprocessor/_regrid/__init__.py b/tests/unit/preprocessor/_regrid/__init__.py index 5774c41a41..2c0e5a2f47 100644 --- a/tests/unit/preprocessor/_regrid/__init__.py +++ b/tests/unit/preprocessor/_regrid/__init__.py @@ -1,7 +1,9 @@ -"""Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module.""" +""" +Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module. -from typing import Literal +""" +from typing import Literal import iris import iris.fileformats import numpy as np @@ -9,7 +11,10 @@ def _make_vcoord(data, dtype=None): - """Create a synthetic test vertical coordinate.""" + """ + Create a synthetic test vertical coordinate. + + """ if dtype is None: dtype = np.dtype('int8') @@ -42,7 +47,10 @@ def _make_cube( dtype=None, grid: Literal['regular', 'rotated', 'mesh'] = 'regular', ): - """Create a 3d synthetic test cube.""" + """ + Create a 3d synthetic test cube. + + """ if dtype is None: dtype = np.dtype('int8') diff --git a/tests/unit/preprocessor/_regrid/test__create_cube.py b/tests/unit/preprocessor/_regrid/test__create_cube.py index cfb4434bb4..e0f65eab78 100644 --- a/tests/unit/preprocessor/_regrid/test__create_cube.py +++ b/tests/unit/preprocessor/_regrid/test__create_cube.py @@ -1,5 +1,8 @@ -"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` -function.""" +""" +Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` +function. + +""" import unittest diff --git a/tests/unit/preprocessor/_regrid/test__stock_cube.py b/tests/unit/preprocessor/_regrid/test__stock_cube.py index 8b2290f531..8142b66ed8 100644 --- a/tests/unit/preprocessor/_regrid/test__stock_cube.py +++ b/tests/unit/preprocessor/_regrid/test__stock_cube.py @@ -1,5 +1,8 @@ -"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` -function.""" +""" +Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` +function. + +""" import unittest from unittest import mock diff --git a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py index 1375027263..5896f442ba 100644 --- a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py +++ b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py @@ -1,8 +1,8 @@ """Tests for `esmvalcore.preprocessor._regrid_iris_esmf_regrid`.""" -import esmf_regrid import iris.cube import numpy as np import pytest +import esmf_regrid from esmvalcore.preprocessor.regrid_schemes import IrisESMFRegrid diff --git a/tests/unit/preprocessor/_volume/test_volume.py b/tests/unit/preprocessor/_volume/test_volume.py index 1370cc5765..d45b9bd744 100644 --- a/tests/unit/preprocessor/_volume/test_volume.py +++ b/tests/unit/preprocessor/_volume/test_volume.py @@ -435,8 +435,9 @@ def test_volume_statistics(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_volume_nolevbounds(self): - """Test to take the volume weighted average of a cube with no bounds in - the z axis.""" + """Test to take the volume weighted average of a cube with no bounds + in the z axis. + """ self.assertFalse(self.grid_4d_znobounds.coord(axis='z').has_bounds()) result = volume_statistics(self.grid_4d_znobounds, 'mean') @@ -448,7 +449,7 @@ def test_volume_nolevbounds(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_calculate_volume_lazy(self): - """Test that calculate_volume returns a lazy volume. + """Test that calculate_volume returns a lazy volume The volume chunks should match those of the input cube for computational efficiency. @@ -599,7 +600,7 @@ def test_volume_statistics_2d_lat_cellarea(self): self.assertEqual(result.units, 'kg m-3') def test_volume_statistics_invalid_bounds(self): - """Test z-axis bounds is not 2 in last dimension.""" + """Test z-axis bounds is not 2 in last dimension""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_invalid_z_bounds, 'mean') @@ -610,7 +611,7 @@ def test_volume_statistics_invalid_bounds(self): ) def test_volume_statistics_invalid_units(self): - """Test z-axis units cannot be converted to m.""" + """Test z-axis units cannot be converted to m""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_4d_sigma_space, 'mean') diff --git a/tests/unit/test_dataset.py b/tests/unit/test_dataset.py index c583252993..25129dbf5d 100644 --- a/tests/unit/test_dataset.py +++ b/tests/unit/test_dataset.py @@ -890,8 +890,7 @@ def test_from_files_with_globs(monkeypatch, session): def test_from_files_with_globs_and_missing_facets(monkeypatch, session): """Test `from_files` with wildcards and files with missing facets. - Tests a combination of files with complete facets and missing - facets. + Tests a combination of files with complete facets and missing facets. """ rootpath = Path('/path/to/data') file1 = esmvalcore.local.LocalFile( @@ -974,8 +973,8 @@ def test_from_files_with_globs_and_missing_facets(monkeypatch, session): def test_from_files_with_globs_and_automatic_missing(monkeypatch, session): """Test `from_files`. - Test with wildcards and files with missing facets that can be - automatically added. + Test with wildcards and files with missing facets that can be automatically + added. """ rootpath = Path('/path/to/data') file = esmvalcore.local.LocalFile( diff --git a/tests/unit/test_iris_io.py b/tests/unit/test_iris_io.py index 500aa492d9..1b81c78d2f 100644 --- a/tests/unit/test_iris_io.py +++ b/tests/unit/test_iris_io.py @@ -41,7 +41,8 @@ def create_regular_cube(): def test_iris_save_with_lazy_coordinate(tmp_path): - """Test saving a cube with fully lazy coords and data. + """ + Test saving a cube with fully lazy coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ @@ -55,7 +56,8 @@ def test_iris_save_with_lazy_coordinate(tmp_path): def test_iris_save_with_regular_coordinate(tmp_path): - """Test saving a cube with numpy array coords and data. + """ + Test saving a cube with numpy array coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ diff --git a/tests/unit/test_naming.py b/tests/unit/test_naming.py index 1a9255c255..41971a60a8 100644 --- a/tests/unit/test_naming.py +++ b/tests/unit/test_naming.py @@ -1,19 +1,20 @@ -"""Checks to ensure that files follow the naming convention.""" +"""Checks to ensure that files follow the naming convention""" import os import unittest class TestNaming(unittest.TestCase): - """Test naming of files and folders.""" + """Test naming of files and folders""" def setUp(self): - """Prepare tests.""" + """Prepare tests""" folder = os.path.join(__file__, '..', '..', '..') self.esmvaltool_folder = os.path.abspath(folder) def test_windows_reserved_names(self): - """Check that no file or folder uses a Windows reserved name. + """ + Check that no file or folder uses a Windows reserved name Files can not differ from a reserved name by the extension only """ @@ -36,7 +37,8 @@ def test_windows_reserved_names(self): reserved_names.isdisjoint(without_extensions), error_msg) def test_avoid_casing_collisions(self): - """Check that there are no names differing only in the capitalization. + """ + Check that there are no names differing only in the capitalization This includes folders differing from files """ @@ -50,8 +52,8 @@ def test_avoid_casing_collisions(self): 'capitalization'.format(dirpath)) def test_no_namelist(self): - """Check that there are no namelist references in file and folder - names. + """ + Check that there are no namelist references in file and folder names This will help us to avoid bad merges with stale branches """ From 7196f1674d9a8b67190601c9875f38856bbd6885 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:14:56 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .editorconfig | 1 - .github/CODEOWNERS | 1 - CITATION.cff | 2 +- NOTICE | 2 - doc/contributing.rst | 22 ++++---- doc/quickstart/install.rst | 2 +- doc/quickstart/run.rst | 2 +- doc/recipe/index.rst | 2 +- esmvalcore/_citation.py | 9 ++- esmvalcore/_main.py | 7 ++- esmvalcore/_recipe/recipe.py | 14 +++-- esmvalcore/cmor/_fixes/__init__.py | 7 +-- esmvalcore/cmor/_fixes/cesm/cesm2.py | 2 - esmvalcore/cmor/_fixes/cmip5/access1_0.py | 4 +- esmvalcore/cmor/_fixes/cmip5/access1_3.py | 2 - esmvalcore/cmor/_fixes/cmip5/bnu_esm.py | 36 +++--------- esmvalcore/cmor/_fixes/cmip5/canesm2.py | 5 +- esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py | 2 - esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py | 4 +- .../cmor/_fixes/cmip5/cesm1_fastchem.py | 1 - esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py | 1 - esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py | 5 +- esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py | 1 - esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py | 1 - esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py | 1 - esmvalcore/cmor/_fixes/cmip5/fio_esm.py | 10 +--- esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py | 19 ++----- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py | 16 ++---- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py | 21 ++----- esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py | 1 - esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py | 1 - esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py | 5 +- esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py | 2 - esmvalcore/cmor/_fixes/cmip5/inmcm4.py | 17 ++---- esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py | 1 - esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py | 1 - esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py | 1 - esmvalcore/cmor/_fixes/cmip5/miroc5.py | 18 ++---- esmvalcore/cmor/_fixes/cmip5/miroc_esm.py | 12 +--- .../cmor/_fixes/cmip5/miroc_esm_chem.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py | 1 - esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py | 1 - esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py | 9 +-- esmvalcore/cmor/_fixes/cmip5/mri_esm1.py | 5 +- esmvalcore/cmor/_fixes/cmip5/noresm1_m.py | 1 - esmvalcore/cmor/_fixes/cmip5/noresm1_me.py | 2 - esmvalcore/cmor/_fixes/cmip6/access_cm2.py | 1 - esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py | 1 - esmvalcore/cmor/_fixes/cmip6/canesm5.py | 2 - esmvalcore/cmor/_fixes/cmip6/cesm2.py | 18 ++---- esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py | 3 +- esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py | 1 - .../cmor/_fixes/cmip6/cesm2_waccm_fv2.py | 5 +- esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py | 1 - esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py | 1 - esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py | 1 - .../cmor/_fixes/cmip6/ec_earth3_veg_lr.py | 1 - esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py | 9 +-- esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py | 9 +-- esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py | 1 - .../cmor/_fixes/cmip6/hadgem3_gc31_ll.py | 1 - .../cmor/_fixes/cmip6/ipsl_cm5a2_inca.py | 1 - esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py | 5 +- .../cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py | 1 - esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py | 4 -- esmvalcore/cmor/_fixes/cmip6/miroc6.py | 4 +- esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py | 1 - esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py | 4 +- esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py | 1 - esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py | 2 - esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py | 1 - .../cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py | 4 +- .../cordex/ichec_ec_earth/cclm4_8_17.py | 4 +- .../cordex/ichec_ec_earth/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ichec_ec_earth/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ichec_ec_earth/rca4.py | 3 +- .../_fixes/cordex/ichec_ec_earth/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/cclm4_8_17.py | 4 +- .../_fixes/cordex/miroc_miroc5/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/wrf361h.py | 2 +- .../cordex/mohc_hadgem2_es/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/mohc_hadgem2_es/hirham5.py | 1 - .../_fixes/cordex/mohc_hadgem2_es/rca4.py | 3 +- .../_fixes/cordex/mohc_hadgem2_es/remo2015.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py | 4 +- .../cordex/mpi_m_mpi_esm_lr/racmo22e.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/regcm4_6.py | 3 +- .../cordex/ncc_noresm1_m/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ncc_noresm1_m/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ncc_noresm1_m/rca4.py | 3 +- .../_fixes/cordex/ncc_noresm1_m/remo2015.py | 3 +- esmvalcore/cmor/_fixes/emac/emac.py | 3 - esmvalcore/cmor/_fixes/fix.py | 14 ++--- esmvalcore/cmor/_fixes/icon/_base_fixes.py | 15 ++--- esmvalcore/cmor/_fixes/icon/icon.py | 1 - esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py | 12 ++-- esmvalcore/cmor/_fixes/native6/era5_land.py | 11 ++-- esmvalcore/cmor/_fixes/native_datasets.py | 13 ----- esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py | 1 - esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py | 4 +- esmvalcore/cmor/_fixes/obs4mips/ssmi.py | 1 - esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py | 5 +- esmvalcore/cmor/_fixes/shared.py | 2 - esmvalcore/cmor/_utils.py | 3 - esmvalcore/cmor/check.py | 5 -- esmvalcore/cmor/fix.py | 3 - esmvalcore/cmor/table.py | 56 +++++++++---------- esmvalcore/config/__init__.py | 1 - esmvalcore/config/_config_object.py | 3 - esmvalcore/config/_esgf_pyclient.py | 2 +- esmvalcore/config/_validated_config.py | 5 +- .../config/extra_facets/access-mappings.yml | 34 +++++------ esmvalcore/dataset.py | 3 +- esmvalcore/iris_helpers.py | 6 -- esmvalcore/preprocessor/__init__.py | 4 +- esmvalcore/preprocessor/_area.py | 8 --- esmvalcore/preprocessor/_compare_with_refs.py | 2 - esmvalcore/preprocessor/_cycles.py | 1 - esmvalcore/preprocessor/_derive/_baseclass.py | 2 - esmvalcore/preprocessor/_derive/_shared.py | 3 - esmvalcore/preprocessor/_derive/alb.py | 1 - esmvalcore/preprocessor/_derive/ctotal.py | 1 - esmvalcore/preprocessor/_derive/lvp.py | 1 - esmvalcore/preprocessor/_derive/lwp.py | 1 - esmvalcore/preprocessor/_derive/ohc.py | 6 +- esmvalcore/preprocessor/_derive/rlnst.py | 8 +-- esmvalcore/preprocessor/_derive/rlnstcs.py | 8 +-- esmvalcore/preprocessor/_derive/rlus.py | 1 - esmvalcore/preprocessor/_derive/rsnst.py | 1 - esmvalcore/preprocessor/_derive/rsnstcs.py | 1 - .../preprocessor/_derive/rsnstcsnorm.py | 10 ++-- esmvalcore/preprocessor/_derive/rsus.py | 1 - esmvalcore/preprocessor/_derive/siextent.py | 1 + esmvalcore/preprocessor/_derive/sispeed.py | 6 +- esmvalcore/preprocessor/_derive/sithick.py | 4 +- esmvalcore/preprocessor/_derive/sm.py | 1 - esmvalcore/preprocessor/_derive/toz.py | 1 - esmvalcore/preprocessor/_detrend.py | 3 +- esmvalcore/preprocessor/_mapping.py | 33 +++++------ esmvalcore/preprocessor/_multimodel.py | 25 ++++----- esmvalcore/preprocessor/_other.py | 15 ++--- esmvalcore/preprocessor/_regrid.py | 4 +- esmvalcore/preprocessor/_regrid_esmpy.py | 11 +--- .../preprocessor/_regrid_unstructured.py | 16 ++---- esmvalcore/preprocessor/_rolling_window.py | 1 - esmvalcore/preprocessor/_shared.py | 17 ++---- esmvalcore/preprocessor/_time.py | 22 -------- esmvalcore/preprocessor/_trend.py | 2 - esmvalcore/preprocessor/_units.py | 1 - esmvalcore/preprocessor/_volume.py | 7 --- esmvalcore/preprocessor/shapefiles/ar6.prj | 2 +- esmvalcore/typing.py | 4 +- .../cmor/_fixes/cmip5/test_bnu_esm.py | 2 +- .../cmor/_fixes/cmip5/test_cnrm_cm5.py | 4 +- .../cmor/_fixes/cmip5/test_ec_earth.py | 10 ++-- .../cmor/_fixes/cmip5/test_fio_esm.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_cm2p1.py | 6 +- .../cmor/_fixes/cmip5/test_gfdl_cm3.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_esm2g.py | 8 +-- .../cmor/_fixes/cmip5/test_gfdl_esm2m.py | 6 +- .../cmor/_fixes/cmip5/test_hadgem2_cc.py | 4 +- .../cmor/_fixes/cmip5/test_miroc_esm_chem.py | 2 +- .../cmor/_fixes/cmip5/test_mri_esm1.py | 2 +- .../cmor/_fixes/cmip5/test_noresm1_me.py | 2 +- .../cmor/_fixes/cmip6/test_gfdl_cm4.py | 4 +- .../cordex/test_cnrm_cerfacs_cnrm_cm5.py | 3 +- .../cmor/_fixes/cordex/test_miroc_miroc5.py | 2 +- tests/integration/cmor/_fixes/test_fix.py | 4 +- .../cmor/_fixes/test_native_datasets.py | 1 - tests/integration/conftest.py | 6 +- tests/integration/data_finder.yml | 6 +- .../_extract_region/test_intersect.py | 6 +- .../preprocessor/_mask/__init__.py | 3 +- .../preprocessor/_regrid/__init__.py | 5 +- .../_regrid/test_extract_coordinate_points.py | 21 +++---- .../_regrid/test_extract_point.py | 21 +++---- .../_regrid/test_get_cmor_levels.py | 6 +- .../preprocessor/_regrid/test_regrid.py | 7 +-- .../_regrid/test_regrid_unstructured.py | 2 +- .../_supplementary_vars/test_register.py | 2 +- tests/integration/test_citation.py | 7 ++- tests/parse_pymon.py | 6 +- .../multimodel_statistics/test_multimodel.py | 10 ---- tests/unit/cmor/test_cmor_check.py | 54 +++++++++--------- tests/unit/preprocessor/_derive/test_toz.py | 1 + .../preprocessor/_detrend/test_detrend.py | 3 +- .../preprocessor/_mapping/test_mapping.py | 7 ++- tests/unit/preprocessor/_regrid/__init__.py | 16 ++---- .../preprocessor/_regrid/test__create_cube.py | 7 +-- .../preprocessor/_regrid/test__stock_cube.py | 7 +-- .../test_regrid_iris_esmf_regrid.py | 2 +- .../unit/preprocessor/_volume/test_volume.py | 11 ++-- tests/unit/test_dataset.py | 7 ++- tests/unit/test_iris_io.py | 6 +- tests/unit/test_naming.py | 16 +++--- 196 files changed, 391 insertions(+), 794 deletions(-) diff --git a/.editorconfig b/.editorconfig index 97c8ef6e5a..ddab414f89 100644 --- a/.editorconfig +++ b/.editorconfig @@ -27,4 +27,3 @@ indent_size = 2 [*.{md,Rmd}] trim_trailing_whitespace = false - diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1c8122dcbe..eba6cf5dd4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,2 @@ esmvalcore/cmor @jvegasbsc .github/workflows @valeriupredoi - diff --git a/CITATION.cff b/CITATION.cff index 51f53cfb36..4d3da6e4c7 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -208,7 +208,7 @@ authors: affiliation: "DLR, Germany" family-names: Cammarano given-names: Diego - - + - affiliation: "ACCESS-NRI, Australia" family-names: Yousong given-names: Zeng diff --git a/NOTICE b/NOTICE index 5bf9f5d0cd..5e413cd5ba 100644 --- a/NOTICE +++ b/NOTICE @@ -50,5 +50,3 @@ In addition to using the Software, we encourage the community to join the Softwa To join the ESMValTool Development Team, please contact Dr. Birgit Hassler (birgit.hassler@dlr.de) and Dr. Axel Lauer (axel.lauer@dlr.de). ========================================== - - diff --git a/doc/contributing.rst b/doc/contributing.rst index 814ab79263..658306a53b 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -743,15 +743,15 @@ Perform the steps listed below with two persons, to reduce the risk of error. `PyPI `__, and `readthedocs `__. -The release of ESMValCore is tied to the release of ESMValTool. +The release of ESMValCore is tied to the release of ESMValTool. The detailed steps can be found in the ESMValTool :ref:`documentation `. -To start the procedure, ESMValCore gets released as a +To start the procedure, ESMValCore gets released as a release candidate to test the recipes in ESMValTool. If bugs are found -during the testing phase of the release candidate, make as many release -candidates for ESMValCore as needed in order to fix them. +during the testing phase of the release candidate, make as many release +candidates for ESMValCore as needed in order to fix them. -To make a new release of the package, be it a release candidate or the final release, +To make a new release of the package, be it a release candidate or the final release, follow these steps: 1. Check that all tests and builds work @@ -795,13 +795,13 @@ Use the script to create create a draft of the release notes. This script uses the titles and labels of merged pull requests since the previous release. -Open a discussion to allow members of the development team to nominate pull -requests as highlights. Add the most voted pull requests as highlights at the -beginning of changelog. After the highlights section, list any backward -incompatible changes that the release may include. The +Open a discussion to allow members of the development team to nominate pull +requests as highlights. Add the most voted pull requests as highlights at the +beginning of changelog. After the highlights section, list any backward +incompatible changes that the release may include. The :ref:`backward compatibility policy`. -lists the information that should be provided by the developer of any backward -incompatible change. Make sure to also list any deprecations that the release +lists the information that should be provided by the developer of any backward +incompatible change. Make sure to also list any deprecations that the release may include, as well as a brief description on how to upgrade a deprecated feature. Review the results, and if anything needs changing, change it on GitHub and re-run the script until the changelog looks acceptable. diff --git a/doc/quickstart/install.rst b/doc/quickstart/install.rst index 7ef5015fe3..804c86ed20 100644 --- a/doc/quickstart/install.rst +++ b/doc/quickstart/install.rst @@ -201,7 +201,7 @@ Pre-installed versions on HPC clusters / other servers If you would like to use pre-installed versions on HPC clusters (currently CEDA-JASMIN and DKRZ-Levante), -and other servers (currently Met Office Linux estate), please have a look at +and other servers (currently Met Office Linux estate), please have a look at :ref:`these instructions `. diff --git a/doc/quickstart/run.rst b/doc/quickstart/run.rst index ebde6d4075..5eca15e714 100644 --- a/doc/quickstart/run.rst +++ b/doc/quickstart/run.rst @@ -79,7 +79,7 @@ This feature is available for projects that are hosted on the ESGF, i.e. CMIP3, CMIP5, CMIP6, CORDEX, and obs4MIPs. To control the strictness of the CMOR checker and the checks during concatenation -on auxiliary coordinates, supplementary variables, and derived coordinates, +on auxiliary coordinates, supplementary variables, and derived coordinates, use the flag ``--check_level``: .. code:: bash diff --git a/doc/recipe/index.rst b/doc/recipe/index.rst index 98c3f6c237..525b0467e1 100644 --- a/doc/recipe/index.rst +++ b/doc/recipe/index.rst @@ -8,4 +8,4 @@ The recipe format Overview Preprocessor - \ No newline at end of file + diff --git a/esmvalcore/_citation.py b/esmvalcore/_citation.py index 510aa8cb42..94ff97ad15 100644 --- a/esmvalcore/_citation.py +++ b/esmvalcore/_citation.py @@ -38,8 +38,7 @@ def _write_citation_files(filename, provenance): - """ - Write citation information provided by the recorded provenance. + """Write citation information provided by the recorded provenance. Recipe and cmip6 data references are saved into one bibtex file. cmip6 data references are provided by CMIP6 data citation service. @@ -135,9 +134,9 @@ def _save_citation_info_txt(product_name, info_urls, other_info): def _extract_tags(tags): """Extract tags. - Tags are recorded as a list of strings converted to a string in provenance. - For example, a single entry in the list `tags` could be the string - "['acknow_project', 'acknow_author']". + Tags are recorded as a list of strings converted to a string in + provenance. For example, a single entry in the list `tags` could be + the string "['acknow_project', 'acknow_author']". """ pattern = re.compile(r'[\w-]+') return set(pattern.findall(str(tags))) diff --git a/esmvalcore/_main.py b/esmvalcore/_main.py index 75c0b20c94..84dc5a35b0 100755 --- a/esmvalcore/_main.py +++ b/esmvalcore/_main.py @@ -206,8 +206,8 @@ def get_config_developer(cls, overwrite=False, path=None): class Recipes(): """List, show and retrieve installed recipes. - This group contains utilities to explore and manage the recipes available - in your installation of ESMValTool. + This group contains utilities to explore and manage the recipes + available in your installation of ESMValTool. Documentation for recipes included with ESMValTool is available at https://docs.esmvaltool.org/en/latest/recipes/index.html. @@ -294,7 +294,8 @@ class ESMValTool(): multiple models, either against predecessor versions or against observations. - Documentation is available at https://docs.esmvaltool.org. + Documentation is available at + https://docs.esmvaltool.org. To report issues or ask for improvements, please visit https://github.com/ESMValGroup/ESMValTool. diff --git a/esmvalcore/_recipe/recipe.py b/esmvalcore/_recipe/recipe.py index 1f2eb63488..5633ab0e57 100644 --- a/esmvalcore/_recipe/recipe.py +++ b/esmvalcore/_recipe/recipe.py @@ -399,12 +399,14 @@ def _update_multiproduct(input_products, order, preproc_dir, step): """Return new products that are aggregated over multiple datasets. These new products will replace the original products at runtime. - Therefore, they need to have all the settings for the remaining steps. - - The functions in _multimodel.py take output_products as function arguments. - These are the output_products created here. But since those functions are - called from the input products, the products that are created here need to - be added to their ancestors products' settings (). + Therefore, they need to have all the settings for the remaining + steps. + + The functions in _multimodel.py take output_products as function + arguments. These are the output_products created here. But since + those functions are called from the input products, the products + that are created here need to be added to their ancestors products' + settings (). """ products = {p for p in input_products if step in p.settings} if not products: diff --git a/esmvalcore/cmor/_fixes/__init__.py b/esmvalcore/cmor/_fixes/__init__.py index e50e749659..d9e50af443 100644 --- a/esmvalcore/cmor/_fixes/__init__.py +++ b/esmvalcore/cmor/_fixes/__init__.py @@ -1,6 +1,5 @@ -""" -Automatic fixes for input data +"""Automatic fixes for input data. -Module to apply automatic fixes at different levels to input data for known -errors. +Module to apply automatic fixes at different levels to input data for +known errors. """ diff --git a/esmvalcore/cmor/_fixes/cesm/cesm2.py b/esmvalcore/cmor/_fixes/cesm/cesm2.py index 5b92121555..ada216007a 100644 --- a/esmvalcore/cmor/_fixes/cesm/cesm2.py +++ b/esmvalcore/cmor/_fixes/cesm/cesm2.py @@ -12,7 +12,6 @@ (esmvalcore/_config/extra_facets/cesm-mappings.yml) and/or add classes to this file for variables that need more complex fixes (see esmvalcore/cmor/_fixes/emac/emac.py for examples). - """ import logging @@ -64,7 +63,6 @@ def _fix_time(self, cube): Example of monthly time coordinate after this fix (Jan. & Feb. 2000): Points: ``[2000-01-15, 2000-02-14]`` Bounds: ``[[2000-01-01, 2000-02-01], [2000-02-01, 2000-03-01]]`` - """ # Only modify time points if data contains a time dimension, is monthly # data, and does not describe point measurements. diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_0.py b/esmvalcore/cmor/_fixes/cmip5/access1_0.py index 4fa4da7554..eebc2fa616 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_0.py @@ -10,8 +10,7 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong calendar 'gregorian' instead of 'proleptic_gregorian'. @@ -23,7 +22,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_3.py b/esmvalcore/cmor/_fixes/cmip5/access1_3.py index f026181660..6f581197ff 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_3.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_3.py @@ -5,7 +5,6 @@ from ..fix import Fix from .access1_0 import Cl as BaseCl - Cl = BaseCl @@ -25,7 +24,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py index e01639a306..0198d08dda 100644 --- a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py @@ -10,8 +10,7 @@ class Cl(ClFixHybridPressureCoord): """Fixes for cl.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +22,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -35,8 +33,7 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -48,14 +45,12 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = Unit('kg m-2 s-1') return cubes def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes cube units. @@ -67,7 +62,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 12.0 / 44.0 @@ -79,8 +73,7 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -92,14 +85,12 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = Unit('1e-9') return cubes def fix_data(self, cube): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -112,7 +103,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29.0 / 16.0 * 1.e9 @@ -124,8 +114,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes cube units. @@ -137,14 +126,12 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = Unit('1e-6') return cubes def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes cube units. @@ -156,7 +143,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29.0 / 44.0 * 1.e6 @@ -168,8 +154,7 @@ class SpCo2(Fix): """Fixes for spco2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes cube units. @@ -181,7 +166,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1.e6 @@ -193,8 +177,7 @@ class Od550Aer(Fix): """Fixes for od550aer.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Masks invalid values. @@ -206,7 +189,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ data = da.ma.masked_equal(cube.core_data(), 1.e36) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/canesm2.py b/esmvalcore/cmor/_fixes/cmip5/canesm2.py index b445a4dc3a..e780f3e592 100644 --- a/esmvalcore/cmor/_fixes/cmip5/canesm2.py +++ b/esmvalcore/cmor/_fixes/cmip5/canesm2.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -10,8 +9,7 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +21,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 12.0 / 44.0 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py index 2e25296b8d..fe5dfbefa4 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py @@ -5,7 +5,6 @@ from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl @@ -24,7 +23,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ data = da.ma.masked_equal(cube.core_data(), 1.0e33) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py index 4c235dfcbc..ae30726e2b 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py @@ -7,8 +7,7 @@ class Cl(Fix): """Fixes for cl.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -20,7 +19,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py index d5ba1f7641..319b96d261 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py @@ -2,5 +2,4 @@ from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py index 818d14e4c2..86c5cbd349 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py @@ -2,5 +2,4 @@ from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py index 71e6547461..a5c5bcb017 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py @@ -1,4 +1,3 @@ - """Fixes for CNRM-CM5 model.""" from ..fix import Fix @@ -7,8 +6,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -19,7 +17,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1e6 diff --git a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py index 4c0a5a7564..846859c6b4 100644 --- a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py @@ -1,5 +1,4 @@ """Fixes for CSIRO-Mk3-6-0 model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py index 1c2df64db0..0067b9f172 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py @@ -23,7 +23,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py index c82151226f..c1b3962abd 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py @@ -20,7 +20,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py index cc9ed79421..4935a56f92 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py @@ -1,9 +1,7 @@ - """Fixes for FIO ESM model.""" from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl - Cl = BaseCl @@ -11,8 +9,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +20,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29. / 44. * 1.e6 @@ -35,8 +31,7 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -47,7 +42,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 29. / 16. * 1.e9 diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py index bc1b3cf9b6..6104efdaaf 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py @@ -1,7 +1,6 @@ """Fixes for GFDL CM3 model.""" -from ..fix import Fix - from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars +from ..fix import Fix class AllVars(BaseAllVars): @@ -9,11 +8,10 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong units. @@ -24,7 +22,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -35,8 +32,7 @@ class Sftof(Fix): """Fix sftof.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units. @@ -47,7 +43,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -56,11 +51,10 @@ def fix_data(self, cube): class Tos(Fix): - """Fixes for tos""" + """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong standard_name. @@ -71,7 +65,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py index 3ba4a6dd83..1620f95b29 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py @@ -1,4 +1,3 @@ - """Fixes for GFDL ESM2G.""" import iris @@ -29,7 +28,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ _get_and_remove(cubes, 'Start time for average period') _get_and_remove(cubes, 'End time for average period') @@ -38,11 +36,10 @@ def fix_metadata(self, cubes): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong units. @@ -53,7 +50,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -75,7 +71,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1e6 @@ -98,7 +93,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ _get_and_remove(cubes, 'Latitude of tracer (h) points') _get_and_remove(cubes, 'Longitude of tracer (h) points') @@ -109,8 +103,7 @@ class Usi(Fix): """Fixes for usi.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes bad standard_name @@ -130,8 +123,7 @@ class Vsi(Fix): """Fixes for vsi.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes bad standard_name diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py index 7722118e48..0e626d80de 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py @@ -1,8 +1,7 @@ - """Fixes for GFDL ESM2M.""" -from ..fix import Fix from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars +from ..fix import Fix class AllVars(BaseAllVars): @@ -10,11 +9,10 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello""" + """Fixes for areacello.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong units. @@ -25,7 +23,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -36,8 +33,7 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -48,7 +44,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -60,8 +55,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -72,7 +66,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1e6 @@ -84,8 +77,7 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes wrong standard_name. @@ -96,7 +88,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py index 5ee8c8aff1..9dc63cb128 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py @@ -1,5 +1,4 @@ """Fixes for GISS-E2-H.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py index 0d538e7960..3d4cd617d8 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py @@ -1,5 +1,4 @@ """Fixes for GISS-E2-R.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py index 3531f78f06..e48ba4ade9 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py @@ -2,7 +2,6 @@ from ..fix import Fix from .hadgem2_es import AllVars as BaseAllVars - AllVars = BaseAllVars @@ -10,8 +9,7 @@ class O2(Fix): """Fixes for o2.""" def fix_metadata(self, cubes): - """ - Fix standard and long names. + """Fix standard and long names. Parameters ---------- @@ -20,7 +18,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py index f7360dae2b..1f9e81aa86 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py @@ -19,7 +19,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: lats = cube.coords('latitude') @@ -50,7 +49,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py index e89cea019d..d90c606b40 100644 --- a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py +++ b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py @@ -4,7 +4,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -12,8 +11,7 @@ class Gpp(Fix): """Fixes for gpp.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -25,7 +23,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= -1 @@ -37,8 +34,7 @@ class Lai(Fix): """Fixes for lai.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -50,7 +46,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 0.01 @@ -62,8 +57,7 @@ class Nbp(Fix): """Fixes for nbp.""" def fix_metadata(self, cubes): - """ - Fix missing scalar dimension. + """Fix missing scalar dimension. Parameters ---------- @@ -73,7 +67,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cubes[0].standard_name = ( 'surface_net_downward_mass_flux_of_carbon_dioxide_expressed_as_' @@ -86,8 +79,7 @@ class BaresoilFrac(Fix): """Fixes for baresoilFrac.""" def fix_metadata(self, cubes): - """ - Fix missing scalar dimension. + """Fix missing scalar dimension. Parameters ---------- @@ -97,7 +89,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ typebare = iris.coords.AuxCoord( 'bare_ground', diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py index 894af45317..5dfcb15ce2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py @@ -1,5 +1,4 @@ """Fixes for IPSL-CM5A-LR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py index 893b9779c2..98fab8515f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py @@ -1,5 +1,4 @@ """Fixes for IPSL-CM5A-MR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py index 03bed332d6..271f48728e 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py @@ -1,5 +1,4 @@ """Fixes for IPSL-CM5B-LR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc5.py b/esmvalcore/cmor/_fixes/cmip5/miroc5.py index ec0e009402..c2e1e253a2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc5.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc5.py @@ -5,7 +5,6 @@ from ..fix import Fix from ..shared import round_coordinates - Cl = ClFixHybridPressureCoord @@ -13,8 +12,7 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -26,7 +24,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -38,8 +35,7 @@ class Snw(Fix): """Fixes for snw.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -51,7 +47,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 @@ -96,8 +91,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes mask @@ -109,7 +103,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -133,7 +126,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ return round_coordinates(cubes) @@ -146,8 +138,7 @@ class Tos(Fix): """Fixes for tos.""" def fix_data(self, cube): - """ - Fix tos data. + """Fix tos data. Fixes mask @@ -159,7 +150,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py index fc94bc45cc..de93a2bf4e 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py @@ -15,8 +15,7 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -28,7 +27,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1000 @@ -40,8 +38,7 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes error in cube units @@ -53,7 +50,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ self.get_cube_from_list(cubes).units = '1.0e-6' return cubes @@ -63,8 +59,7 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Fixes error in air_pressure coordinate, sometimes called AR5PL35, and error in time coordinate. @@ -77,7 +72,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: # Fix air_pressure diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py index 83d6e28f20..400a7c0355 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py @@ -1,4 +1,3 @@ - """Fixes for MIROC ESM CHEM model.""" from ..fix import Fix @@ -7,8 +6,7 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -19,7 +17,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1000 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py index a24aebd499..e70672c4bf 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -10,8 +9,7 @@ class Pctisccp(Fix): """Fixes for pctisccp.""" def fix_data(self, cube): - """ - Fix data. + """Fix data. Fixes discrepancy between declared units and real units @@ -23,7 +21,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py index 92b1a6a06b..28317e6958 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py @@ -1,5 +1,4 @@ """Fixes for MPI-ESM-MR model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py index 303e1b0fd1..0a04fd0bf0 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py @@ -1,5 +1,4 @@ """Fixes for MPI-ESM-P model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py index a21b82eb7f..55e3a20345 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py @@ -4,7 +4,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -12,8 +11,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix msftmyz data. + """Fix msftmyz data. Fixes mask @@ -25,7 +23,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -35,8 +32,7 @@ class ThetaO(Fix): """Fixes for thetao.""" def fix_data(self, cube): - """ - Fix thetao data. + """Fix thetao data. Fixes mask @@ -48,7 +44,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py index 694e4cc33f..8fbc47ce24 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py @@ -1,4 +1,3 @@ - """Fixes for MRI-ESM1 model.""" from dask import array as da @@ -9,8 +8,7 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """ - Fix msftmyz data. + """Fix msftmyz data. Fixes mask @@ -21,7 +19,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py index 703ef054d7..e52f4a2f3d 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py @@ -1,5 +1,4 @@ """Fixes for NorESM1-M.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py index 08fe028419..beb6cc3f41 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py @@ -20,7 +20,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ return round_coordinates(cubes, 12, coord_names=['latitude']) @@ -42,6 +41,5 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ return round_coordinates(cubes, 12) diff --git a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py index 7627e9b3a4..ab5b5109d6 100644 --- a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py @@ -18,7 +18,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py index 59f09bcd28..e1688bdc58 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py @@ -1,7 +1,6 @@ """Fixes for CAMS-CSM1-0 model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/canesm5.py b/esmvalcore/cmor/_fixes/cmip6/canesm5.py index d4cdbc95e1..23f004042b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/canesm5.py +++ b/esmvalcore/cmor/_fixes/cmip6/canesm5.py @@ -18,7 +18,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= 1.e-6 @@ -40,7 +39,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ cube.data = da.ma.masked_equal(cube.core_data(), 0.0) return cube diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2.py index 6ded187fbb..ea816506cc 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2.py @@ -61,7 +61,6 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. - """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix @@ -117,7 +116,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -128,8 +126,8 @@ class Prw(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """ - Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. + """Fix latitude_bounds and longitude_bounds data type and round to 4 + d.p. Parameters ---------- @@ -139,7 +137,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: for coord_name in ['latitude', 'longitude']: @@ -156,8 +153,7 @@ class Tas(Prw): """Fixes for tas.""" def fix_metadata(self, cubes): - """ - Add height (2m) coordinate. + """Add height (2m) coordinate. Fix also done for prw. Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. @@ -170,7 +166,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ super().fix_metadata(cubes) # Specific code for tas @@ -194,7 +189,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_typeland_coord(cube) @@ -215,7 +209,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_typesea_coord(cube) @@ -229,8 +222,7 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Round times to 1 d.p. for monthly means. + """Round times to 1 d.p. for monthly means. Required to get hist-GHG and ssp245-GHG Omon tos to concatenate. @@ -242,7 +234,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) @@ -267,7 +258,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py index 0783c125fe..d6abd98fc5 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py @@ -1,10 +1,9 @@ """Fixes for CESM2-FV2 model.""" +from ..common import SiconcFixScalarCoord from .cesm2 import Cl as BaseCl from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon from .cesm2 import Tas as BaseTas -from ..common import SiconcFixScalarCoord - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py index f7263a00dd..134bf8878b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py @@ -36,7 +36,6 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. - """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py index 89c55b3b10..7dc4e79a9e 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py @@ -1,12 +1,11 @@ """Fixes for CESM2-WACCM-FV2 model.""" -from .cesm2 import Tas as BaseTas +from ..common import SiconcFixScalarCoord from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon +from .cesm2 import Tas as BaseTas from .cesm2_waccm import Cl as BaseCl from .cesm2_waccm import Cli as BaseCli from .cesm2_waccm import Clw as BaseClw -from ..common import SiconcFixScalarCoord - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py index 00983b36a7..fc1db9d174 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py +++ b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py @@ -16,7 +16,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) ps_coord = cube.coord(var_name='ps') diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py index b5db40fc11..47c505fdd2 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py @@ -3,7 +3,6 @@ from .cnrm_cm6_1 import Cli as BaseCli from .cnrm_cm6_1 import Clw as BaseClw - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py index 838ae3836c..23ab942fef 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py @@ -5,7 +5,6 @@ from .cnrm_cm6_1 import Clw as BaseClw from .cnrm_cm6_1 import Omon as BaseOmon - Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py index 333b4eb98b..59bb546aac 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py @@ -1,5 +1,4 @@ """Fixes for EC-Earth3-Veg-LR model.""" from ..common import OceanFixGrid - Siconc = OceanFixGrid diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py index f73b16f4b8..def9a936d1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py @@ -26,7 +26,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) coords_to_add = { @@ -51,8 +50,7 @@ class Tas(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """ - Add height (2m) coordinate. + """Add height (2m) coordinate. Parameters ---------- @@ -62,7 +60,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) try: @@ -88,8 +85,7 @@ class Uas(Fix): """Fixes for uas.""" def fix_metadata(self, cubes): - """ - Add height (10m) coordinate. + """Add height (10m) coordinate. Parameters ---------- @@ -99,7 +95,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py index c9788eb37c..b2e421fba9 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py @@ -1,10 +1,7 @@ """Fixes for GFDL-ESM4 model.""" -from ..common import SiconcFixScalarCoord, OceanFixGrid +from ..common import OceanFixGrid, SiconcFixScalarCoord from ..fix import Fix -from ..shared import ( - add_scalar_depth_coord, - fix_ocean_depth_coord, -) +from ..shared import add_scalar_depth_coord, fix_ocean_depth_coord class Fgco2(Fix): @@ -21,7 +18,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -42,7 +38,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py index 054a42255f..1724cce93b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py +++ b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py @@ -1,7 +1,6 @@ """Fixes for GISS-E2-1-H model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py index 99db1e2be1..003c8f623d 100644 --- a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridHeightCoord from .ukesm1_0_ll import AllVars as BaseAllVars - AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py index 57d925e6d1..11a25bc185 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py @@ -3,7 +3,6 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon - AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py index dfd7116275..7e326e5948 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py @@ -9,8 +9,7 @@ class AllVars(Fix): """Fixes for thetao.""" def fix_metadata(self, cubes): - """ - Fix cell_area coordinate. + """Fix cell_area coordinate. Parameters ---------- @@ -20,7 +19,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) if cube.coords('latitude'): @@ -68,7 +66,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py index 3a8a94b8de..2b551a8177 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py @@ -3,7 +3,6 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon - AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py index a9b200cde6..92a446be1c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py @@ -38,7 +38,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ coords_to_change = { 'latitude': 'lat', @@ -100,7 +99,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: if cube.coords(axis='Z'): @@ -124,7 +122,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 2.0) @@ -145,7 +142,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc6.py b/esmvalcore/cmor/_fixes/cmip6/miroc6.py index cf1d40ca86..e799a86577 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc6.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc6.py @@ -15,8 +15,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """ - Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. + """Fix latitude_bounds and longitude_bounds data type and round to 4 + d.p. Parameters ---------- diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py index aa28ae13cc..a5e18b302c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py @@ -1,7 +1,6 @@ """Fixes for MIROC-ES2L model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py index 201ffcca63..f603b9d197 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py +++ b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py @@ -1,8 +1,8 @@ """Fixes for MPI-ESM1-2-XR model.""" -from .mpi_esm1_2_hr import Tas as BaseTas -from .mpi_esm1_2_hr import Ta as BaseFix from .mpi_esm1_2_hr import SfcWind as BaseSfcWind +from .mpi_esm1_2_hr import Ta as BaseFix +from .mpi_esm1_2_hr import Tas as BaseTas class Tas(BaseTas): diff --git a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py index 720670b4d5..04f1617200 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py @@ -1,7 +1,6 @@ """Fixes for MRI-ESM2-0 model.""" from ..common import ClFixHybridPressureCoord - Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py index dc0aa1ccb8..2cd1926eff 100644 --- a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py +++ b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py @@ -2,7 +2,6 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix - Cl = ClFixHybridPressureCoord @@ -28,7 +27,6 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube - """ metadata = cube.metadata cube *= -1 diff --git a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py index 8bef01c21f..6d7d279d6e 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py @@ -17,7 +17,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ parent_units = 'parent_time_units' bad_value = 'days since 1850-01-01-00-00-00' diff --git a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py index 1806f3f0a0..0f75e65197 100644 --- a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by CNRM-CERFACS-CNRM-CM5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py index 88d2123420..19d0a2dfdc 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - CLMcomCCLM4817 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + CLMcomCCLM4817 as BaseFix AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py index 2f816ba55e..9333eb9b33 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py index 9f4cb7a2bc..b79a6399a7 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py @@ -1,5 +1,4 @@ """Fixes for rcm RACMO22E driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py index 114715a5c9..aad85b4848 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py @@ -1,6 +1,5 @@ """Fixes for rcm RCA4 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py index c50d9a23e2..56bff0f673 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py @@ -1,5 +1,4 @@ """Fixes for rcm REMO2015 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py index ac0460904d..181b42dba6 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - CLMcomCCLM4817 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + CLMcomCCLM4817 as BaseFix AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py index fbd13bdfab..bcbe5356e2 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py @@ -1,5 +1,4 @@ """Fixes for rcm REMO2015 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py index f8a69bca9b..e1e691efa2 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py @@ -1,5 +1,6 @@ """Fixes for rcm WRF361H driven by MIROC-MIROC5.""" import iris + from esmvalcore.cmor.fix import Fix @@ -20,7 +21,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ fixed_cubes = iris.cube.CubeList() for cube in cubes: diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py index 7964a583e0..45524e8654 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py index 5dfb91f274..0a6a43b7b1 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py @@ -16,7 +16,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList - """ for cube in cubes: cube.coord('latitude').attributes = {} diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py index 740711fcea..2ad0fe36f6 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py @@ -1,6 +1,5 @@ """Fixes for rcm RCA4 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py index cea145f2d3..c7f3912fb0 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py @@ -1,6 +1,5 @@ """Fixes for rcm REMO2015 driven by MOHC-HadGEM2.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py index 4875edfc93..dbad46ea88 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py index 676e0dfc47..ebf390b9f9 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py @@ -1,5 +1,4 @@ """Fixes for rcm RACMO22E driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py index f863ed1712..fc54fd47e2 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py @@ -1,6 +1,5 @@ """Fixes for rcm RegCM4-6 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py index 1aa2d11b1b..36d52de57e 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - MOHCHadREM3GA705 as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ + MOHCHadREM3GA705 as BaseFix Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py index e9e2e38734..1a924d6b04 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py @@ -1,5 +1,4 @@ """Fixes for rcm RACMO22E driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py index 58d14599da..3452f432ab 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py @@ -1,6 +1,5 @@ """Fixes for rcm RCA4 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py index 9722263d70..4276048585 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py @@ -1,5 +1,4 @@ """Fixes for rcm REMO2015 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( - TimeLongName as BaseFix) +from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/emac/emac.py b/esmvalcore/cmor/_fixes/emac/emac.py index 99cf9ee142..9bd961783a 100644 --- a/esmvalcore/cmor/_fixes/emac/emac.py +++ b/esmvalcore/cmor/_fixes/emac/emac.py @@ -8,7 +8,6 @@ is that ``fix_metadata`` takes all cubes (and thus all input variables of the input file) as argument while ``fix_data`` only takes one cube (the output variable) as single argument. - """ import logging @@ -47,7 +46,6 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): This fix removes the ``formula_terms`` attribute of the hybrid pressure level variables to make the corresponding coefficients appear correctly in the class:`iris.cube.CubeList` object returned by :mod:`iris.load`. - """ if 'alevel' not in self.vardef.dimensions: return filepath @@ -383,7 +381,6 @@ def fix_metadata(self, cubes): Convert geopotential Phi given by EMAC to geopotential height Z using Z = Phi / g0 (g0 is standard acceleration of gravity) - """ g0_value = constants.value('standard acceleration of gravity') g0_units = constants.unit('standard acceleration of gravity') diff --git a/esmvalcore/cmor/_fixes/fix.py b/esmvalcore/cmor/_fixes/fix.py index cf2aed42ec..2723579ef8 100644 --- a/esmvalcore/cmor/_fixes/fix.py +++ b/esmvalcore/cmor/_fixes/fix.py @@ -61,7 +61,6 @@ def __init__( frequency: Expected frequency of the variable. If not given, use the one from the CMOR table entry of the variable. - """ self.vardef = vardef if extra_facets is None: @@ -99,7 +98,6 @@ def fix_file( Path to the corrected file. It can be different from the original filepath if a fix has been applied, but if not it should be the original filepath. - """ return filepath @@ -119,7 +117,6 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> Sequence[Cube]: ------- Iterable[iris.cube.Cube] Fixed cubes. They can be different instances. - """ return cubes @@ -147,7 +144,6 @@ def get_cube_from_list( ------- iris.cube.Cube Variable's cube. - """ if short_name is None: short_name = self.vardef.short_name @@ -170,7 +166,6 @@ def fix_data(self, cube: Cube) -> Cube: ------- iris.cube.Cube Fixed cube. It can be a difference instance. - """ return cube @@ -231,7 +226,6 @@ def get_fixes( ------- list[Fix] Fixes to apply for the given data. - """ vardef = get_var_info(project, mip, short_name) @@ -313,7 +307,6 @@ def get_fixed_filepath( ------- Path Path to the fixed file. - """ output_dir = Path(output_dir) if add_unique_suffix: @@ -341,7 +334,6 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> CubeList: ------- CubeList Fixed cubes. - """ # Make sure the this fix also works when no extra_facets are given if 'project' in self.extra_facets and 'dataset' in self.extra_facets: @@ -384,7 +376,6 @@ def fix_data(self, cube: Cube) -> Cube: ------- Cube Fixed cube. - """ return cube @@ -758,7 +749,10 @@ def _fix_coord_direction( cmor_coord: CoordinateInfo, cube_coord: Coord, ) -> tuple[Cube, Coord]: - """Fix coordinate direction (increasing vs. decreasing).""" + """Fix coordinate direction (increasing vs. + + decreasing). + """ # Skip fix for a variety of reasons if cube_coord.ndim > 1: return (cube, cube_coord) diff --git a/esmvalcore/cmor/_fixes/icon/_base_fixes.py b/esmvalcore/cmor/_fixes/icon/_base_fixes.py index c4afecc4f8..ede854bc0a 100644 --- a/esmvalcore/cmor/_fixes/icon/_base_fixes.py +++ b/esmvalcore/cmor/_fixes/icon/_base_fixes.py @@ -56,7 +56,6 @@ def _create_mesh(self, cube: Cube) -> MeshXY: neighboring cells) the number of nodes is 6 times higher with :func:`iris.mesh.MeshXY.from_coords` compared to using the information already present in the horizontal grid file. - """ horizontal_grid = self.get_horizontal_grid(cube) @@ -155,11 +154,10 @@ def _get_grid_url(self, cube): def _get_node_coords(self, horizontal_grid): """Get node coordinates from horizontal grid. - Extract node coordinates from dummy variable 'dual_area' in horizontal - grid file (in ICON jargon called 'vertex latitude' and 'vertex - longitude'), remove their bounds (not accepted by UGRID), and adapt - metadata. - + Extract node coordinates from dummy variable 'dual_area' in + horizontal grid file (in ICON jargon called 'vertex latitude' + and 'vertex longitude'), remove their bounds (not accepted by + UGRID), and adapt metadata. """ dual_area_cube = horizontal_grid.extract_cube( NameConstraint(var_name='dual_area')) @@ -236,7 +234,6 @@ def add_additional_cubes(self, cubes): ------ InputFilesNotFound A specified file does not exist. - """ facets_to_consider = [ 'zg_file', @@ -321,7 +318,6 @@ def _get_downloaded_grid(self, grid_url: str, grid_name: str) -> CubeList: In order to make this function thread-safe, the downloaded grid file is first saved to a temporary location, then copied to the actual location later. - """ grid_path = self.CACHE_DIR / grid_name @@ -402,7 +398,6 @@ def get_horizontal_grid(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. - """ if self.extra_facets.get('horizontal_grid') is not None: grid = self._get_grid_from_facet() @@ -441,7 +436,6 @@ def get_mesh(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. - """ # If specified by the user, use `horizontal_grid` facet to determine # grid name; otherwise, use the `grid_file_uri` attribute of the cube @@ -472,7 +466,6 @@ def _get_start_index(horizontal_grid): Note ---- UGRID expects this to be a int32. - """ vertex_index = horizontal_grid.extract_cube( NameConstraint(var_name='vertex_index')) diff --git a/esmvalcore/cmor/_fixes/icon/icon.py b/esmvalcore/cmor/_fixes/icon/icon.py index 707a47f20c..d714657764 100644 --- a/esmvalcore/cmor/_fixes/icon/icon.py +++ b/esmvalcore/cmor/_fixes/icon/icon.py @@ -100,7 +100,6 @@ def _add_coord_from_grid_file(self, cube, coord_name): Invalid ``coord_name`` is given; input cube does not contain a single unnamed dimension that can be used to add the new coordinate. - """ # The following dict maps from desired coordinate name in output file # (dict keys) to coordinate name in grid file (dict values) diff --git a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py index 362d950f6c..96889cd7b9 100644 --- a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py +++ b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py @@ -19,8 +19,8 @@ class AllVars(Fix): def fix_file(self, filepath, output_dir, add_unique_suffix=False): """Select IPSLCM variable in filepath. - This is done only if input file is a multi-variable one. This - is diagnosed by searching in the input filepathame for the + This is done only if input file is a multi-variable one. This is + diagnosed by searching in the input filepathame for the extra_facet value for key 'group'. In such cases, it is worth to use an external tool for @@ -28,8 +28,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): up to, and including, V3.0.2), and CDO can be used, depending on extra_facets key `use_cdo` - However, we take care of ESMValTool policy re. dependencies licence - + However, we take care of ESMValTool policy re. dependencies + licence """ if "_" + self.extra_facets.get( "group", "non-sense") + ".nc" not in str(filepath): @@ -61,8 +61,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): def fix_metadata(self, cubes): """Fix metadata for any IPSLCM variable + filter out other variables. - Fix the name of the time coordinate, which is called time_counter - in the original file. + Fix the name of the time coordinate, which is called + time_counter in the original file. Remove standard_name 'time' in auxiliary time coordinates """ diff --git a/esmvalcore/cmor/_fixes/native6/era5_land.py b/esmvalcore/cmor/_fixes/native6/era5_land.py index 5b6fbff276..6c32cc6dcb 100644 --- a/esmvalcore/cmor/_fixes/native6/era5_land.py +++ b/esmvalcore/cmor/_fixes/native6/era5_land.py @@ -1,11 +1,12 @@ """Fixes for ERA5-Land.""" import logging -from esmvalcore.cmor._fixes.native6.era5 import (Pr, - Evspsbl, - Evspsblpot, - AllVars) - +from esmvalcore.cmor._fixes.native6.era5 import ( + AllVars, + Evspsbl, + Evspsblpot, + Pr, +) logger = logging.getLogger(__name__) logger.info("Load classes from era5.py") diff --git a/esmvalcore/cmor/_fixes/native_datasets.py b/esmvalcore/cmor/_fixes/native_datasets.py index 20cfa5590f..b773c63966 100644 --- a/esmvalcore/cmor/_fixes/native_datasets.py +++ b/esmvalcore/cmor/_fixes/native_datasets.py @@ -29,7 +29,6 @@ def fix_scalar_coords(self, cube): cube: iris.cube.Cube Input cube for which missing scalar coordinates will be added (in-place). - """ if 'height2m' in self.vardef.dimensions: add_scalar_height_coord(cube, 2.0) @@ -47,7 +46,6 @@ def fix_var_metadata(self, cube): ---------- cube: iris.cube.Cube Input cube whose metadata is changed in-place. - """ # Fix names if self.vardef.standard_name == '': @@ -103,7 +101,6 @@ def get_cube(self, cubes, var_name=None): ------ ValueError Desired variable is not available in the input cubes. - """ if var_name is None: var_name = self.extra_facets.get('raw_name', @@ -127,7 +124,6 @@ def fix_regular_time(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. - """ if not self.vardef.has_coord_with_standard_name('time'): return @@ -148,7 +144,6 @@ def fix_regular_lat(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. - """ if not self.vardef.has_coord_with_standard_name('latitude'): return @@ -169,7 +164,6 @@ def fix_regular_lon(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. - """ if not self.vardef.has_coord_with_standard_name('longitude'): return @@ -198,7 +192,6 @@ def guess_coord_bounds(cube, coord): iris.coords.AuxCoord or iris.coords.DimCoord Coordinate with bounds. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if isinstance(coord, str): coord = cube.coord(coord) @@ -226,7 +219,6 @@ def fix_time_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed time coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('time') @@ -254,7 +246,6 @@ def fix_alt16_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed altitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('altitude') @@ -284,7 +275,6 @@ def fix_height_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed height coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('height') @@ -314,7 +304,6 @@ def fix_plev_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed air_pressure coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('air_pressure') @@ -344,7 +333,6 @@ def fix_lat_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed latitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('latitude') @@ -373,7 +361,6 @@ def fix_lon_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed longitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. - """ if coord is None: coord = cube.coord('longitude') diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py index b8eab7b711..eafde5e3e2 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py @@ -21,7 +21,6 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. - """ for cube in cubes: # Put information from valid_range into mask and remove the diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py index 93ca03eaa6..f72a498759 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py @@ -8,8 +8,7 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Change unit of coordinate plev from hPa to Pa. @@ -22,7 +21,6 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. - """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py index cb150fe729..dfc01ba281 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py @@ -1,4 +1,3 @@ - """Fixes for SSMI model.""" from ..fix import Fix diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py index 2fa26842b9..982ab03783 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py @@ -1,4 +1,3 @@ - """Fixes for CCSM4 model.""" from iris.cube import CubeList @@ -9,8 +8,7 @@ class Prw(Fix): """Fixes for prw.""" def fix_metadata(self, cubes): - """ - Fix metadata. + """Fix metadata. Remove error and number of observations cubes @@ -21,7 +19,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube - """ cube = self.get_cube_from_list(cubes) return CubeList([cube]) diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index 3ec14d05ab..d3498c9b87 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -443,7 +443,6 @@ def get_next_month(month: int, year: int) -> tuple[int, int]: ------- tuple[int, int] Next month and next year. - """ if month != 12: return month + 1, year @@ -476,7 +475,6 @@ def get_time_bounds(time: Coord, freq: str) -> np.ndarray: ------ NotImplementedError Non-supported frequency is given. - """ bounds = [] dates = time.units.num2date(time.points) diff --git a/esmvalcore/cmor/_utils.py b/esmvalcore/cmor/_utils.py index be837d9c10..629d6be498 100644 --- a/esmvalcore/cmor/_utils.py +++ b/esmvalcore/cmor/_utils.py @@ -52,7 +52,6 @@ def _get_alternative_generic_lev_coord( ------ ValueError No valid alternative generic level coordinate present in cube. - """ alternatives_for_coord = _ALTERNATIVE_GENERIC_LEV_COORDS.get( coord_name, {} @@ -93,7 +92,6 @@ def _get_generic_lev_coord_names( Tuple of `standard_name`, `out_name`, and `name` of the generic level coordinate present in the cube. Values are ``None`` if generic level coordinate has not been found in cube. - """ standard_name = None out_name = None @@ -152,7 +150,6 @@ def _get_new_generic_level_coord( ------- CoordinateInfo New generic level coordinate. - """ new_coord = generic_level_coord.generic_lev_coords[new_coord_name] new_coord.generic_level = True diff --git a/esmvalcore/cmor/check.py b/esmvalcore/cmor/check.py index 09f7a6331d..b368d6d131 100644 --- a/esmvalcore/cmor/check.py +++ b/esmvalcore/cmor/check.py @@ -164,7 +164,6 @@ def check_metadata(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. - """ if logger is not None: self._logger = logger @@ -213,7 +212,6 @@ def check_data(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. - """ if logger is not None: self._logger = logger @@ -916,7 +914,6 @@ def cmor_check_metadata( ------- iris.cube.Cube Checked cube. - """ checker = _get_cmor_checker( cmor_table, @@ -959,7 +956,6 @@ def cmor_check_data( ------- iris.cube.Cube Checked cube. - """ checker = _get_cmor_checker( cmor_table, @@ -1005,7 +1001,6 @@ def cmor_check( ------- iris.cube.Cube Checked cube. - """ cube = cmor_check_metadata( cube, diff --git a/esmvalcore/cmor/fix.py b/esmvalcore/cmor/fix.py index d05af5ef64..8a5421e19a 100644 --- a/esmvalcore/cmor/fix.py +++ b/esmvalcore/cmor/fix.py @@ -72,7 +72,6 @@ def fix_file( ------- str or pathlib.Path Path to the fixed file. - """ # Update extra_facets with variable information given as regular arguments # to this function @@ -148,7 +147,6 @@ def fix_metadata( ------- iris.cube.CubeList Fixed cubes. - """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: @@ -269,7 +267,6 @@ def fix_data( ------- iris.cube.Cube Fixed cube. - """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: diff --git a/esmvalcore/cmor/table.py b/esmvalcore/cmor/table.py index a0c685654a..a2a5e0a255 100644 --- a/esmvalcore/cmor/table.py +++ b/esmvalcore/cmor/table.py @@ -25,7 +25,7 @@ CMORTable = Union['CMIP3Info', 'CMIP5Info', 'CMIP6Info', 'CustomInfo'] CMOR_TABLES: dict[str, CMORTable] = {} -"""dict of str, obj: CMOR info objects.""" +"""Dict of str, obj: CMOR info objects.""" _CMOR_KEYS = ( 'standard_name', @@ -102,7 +102,6 @@ def get_var_info( ------ KeyError No CMOR tables available for `project`. - """ if project not in CMOR_TABLES: raise KeyError( @@ -282,7 +281,6 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, ``None`` otherwise. - """ alt_names_list = self._get_alt_names_list(short_name) @@ -613,28 +611,28 @@ def __init__(self, table_type, short_name): super(VariableInfo, self).__init__() self.table_type = table_type self.modeling_realm = [] - """Modeling realm""" + """Modeling realm.""" self.short_name = short_name - """Short name""" + """Short name.""" self.standard_name = '' - """Standard name""" + """Standard name.""" self.long_name = '' - """Long name""" + """Long name.""" self.units = '' - """Data units""" + """Data units.""" self.valid_min = '' - """Minimum admitted value""" + """Minimum admitted value.""" self.valid_max = '' - """Maximum admitted value""" + """Maximum admitted value.""" self.frequency = '' - """Data frequency""" + """Data frequency.""" self.positive = '' - """Increasing direction""" + """Increasing direction.""" self.dimensions = [] - """List of dimensions""" + """List of dimensions.""" self.coordinates = {} - """Coordinates + """Coordinates. This is a dict with the names of the dimensions as keys and CoordinateInfo objects as values. @@ -703,7 +701,6 @@ def has_coord_with_standard_name(self, standard_name: str) -> bool: bool `True` if there is at least one coordinate with the given `standard_name`, `False` if not. - """ for coord in self.coordinates.values(): if coord.standard_name == standard_name: @@ -728,35 +725,34 @@ def __init__(self, name): self.generic_lev_coords = {} self.axis = "" - """Axis""" + """Axis.""" self.value = "" - """Coordinate value""" + """Coordinate value.""" self.standard_name = "" - """Standard name""" + """Standard name.""" self.long_name = "" - """Long name""" + """Long name.""" self.out_name = "" - """ - Out name + """Out name. This is the name of the variable in the file """ self.var_name = "" - """Short name""" + """Short name.""" self.units = "" - """Units""" + """Units.""" self.stored_direction = "" - """Direction in which the coordinate increases""" + """Direction in which the coordinate increases.""" self.requested = [] - """Values requested""" + """Values requested.""" self.valid_min = "" - """Minimum allowed value""" + """Minimum allowed value.""" self.valid_max = "" - """Maximum allowed value""" + """Maximum allowed value.""" self.must_have_bounds = "" - """Whether bounds are required on this dimension""" + """Whether bounds are required on this dimension.""" self.generic_lev_name = "" - """Generic level name""" + """Generic level name.""" def read_json(self, json_data): """Read coordinate information from json. @@ -992,7 +988,6 @@ class CustomInfo(CMIP5Info): Full path to the table or name for the table if it is present in ESMValTool repository. If ``None``, use default tables from `esmvalcore/cmor/tables/custom`. - """ def __init__(self, cmor_tables_path: Optional[str | Path] = None) -> None: @@ -1067,7 +1062,6 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, returns None if not. - """ return self.tables['custom'].get(short_name, None) diff --git a/esmvalcore/config/__init__.py b/esmvalcore/config/__init__.py index 7c2b8e379c..271fa956cc 100644 --- a/esmvalcore/config/__init__.py +++ b/esmvalcore/config/__init__.py @@ -7,7 +7,6 @@ By default, this will be loaded from the file ``~/.esmvaltool/config-user.yml``. If used within the ``esmvaltool`` program, this will respect the ``--config_file`` argument. - """ from ._config_object import CFG, Config, Session diff --git a/esmvalcore/config/_config_object.py b/esmvalcore/config/_config_object.py index 2e53857d70..89ad3b7f69 100644 --- a/esmvalcore/config/_config_object.py +++ b/esmvalcore/config/_config_object.py @@ -30,7 +30,6 @@ class Config(ValidatedConfig): Do not instantiate this class directly, but use :obj:`esmvalcore.config.CFG` instead. - """ _DEFAULT_USER_CONFIG_DIR = Path.home() / '.esmvaltool' @@ -161,7 +160,6 @@ def _get_config_user_path( _ESMVALTOOL_USER_CONFIG_FILE_ at the end of this method to make sure that subsequent calls of this method (also in suprocesses) use the correct user configuration file. - """ # (1) Try to get user configuration file from `filename` argument config_user = filename @@ -210,7 +208,6 @@ def _get_config_path_from_cli() -> None | str: ---- This only works if the script name is `esmvaltool`. Does not check if file exists. - """ if Path(sys.argv[0]).name != 'esmvaltool': return None diff --git a/esmvalcore/config/_esgf_pyclient.py b/esmvalcore/config/_esgf_pyclient.py index 51152344c4..5f4b1aab48 100644 --- a/esmvalcore/config/_esgf_pyclient.py +++ b/esmvalcore/config/_esgf_pyclient.py @@ -1,4 +1,4 @@ -"""esgf-pyclient configuration. +"""Esgf-pyclient configuration. The configuration is read from the file ~/.esmvaltool/esgf-pyclient.yml. """ diff --git a/esmvalcore/config/_validated_config.py b/esmvalcore/config/_validated_config.py index 27048397a7..dcc3e2ca36 100644 --- a/esmvalcore/config/_validated_config.py +++ b/esmvalcore/config/_validated_config.py @@ -49,8 +49,9 @@ class ValidatedConfig(MutableMapping): _warn_if_missing: tuple[tuple[str, str], ...] = () """Handle missing options. - Each sub-tuple in the tuple consists of an option for which a warning is - emitted and a string with more information for the user on that option. + Each sub-tuple in the tuple consists of an option for which a + warning is emitted and a string with more information for the user + on that option. """ # validate values on the way in diff --git a/esmvalcore/config/extra_facets/access-mappings.yml b/esmvalcore/config/extra_facets/access-mappings.yml index 9d4eb0621b..14c75f07b0 100644 --- a/esmvalcore/config/extra_facets/access-mappings.yml +++ b/esmvalcore/config/extra_facets/access-mappings.yml @@ -7,23 +7,23 @@ ACCESS-ESM1-5: '*': - + tas: raw_name: fld_s03i236 modeling_realm: atm - + pr: raw_name: fld_s05i216 modeling_realm: atm - + ps: raw_name: fld_s00i409 modeling_realm: atm - + clt: raw_name: fld_s02i204 modeling_realm: atm - + psl: raw_name: fld_s16i222 modeling_realm: atm @@ -31,7 +31,7 @@ ACCESS-ESM1-5: hus: raw_name: fld_s30i205 modeling_realm: atm - + zg: raw_name: fld_s30i207 modeling_realm: atm @@ -39,30 +39,30 @@ ACCESS-ESM1-5: va: raw_name: fld_s30i202 modeling_realm: atm - + ua: raw_name: fld_s30i201 modeling_realm: atm - + ta: raw_name: fld_s30i204 modeling_realm: atm - + rlus: - raw_name: - - fld_s02i207 - - fld_s02i201 - - fld_s03i332 + raw_name: + - fld_s02i207 + - fld_s02i201 + - fld_s03i332 - fld_s02i205 modeling_realm: atm - + rlds: raw_name: fld_s02i207 modeling_realm: atm rsus: - raw_name: + raw_name: - fld_s01i235 - - fld_s01i201 + - fld_s01i201 modeling_realm: atm - + diff --git a/esmvalcore/dataset.py b/esmvalcore/dataset.py index d4bd665aa6..07f07bc915 100644 --- a/esmvalcore/dataset.py +++ b/esmvalcore/dataset.py @@ -188,7 +188,8 @@ def _file_to_dataset( def _get_available_datasets(self) -> Iterator[Dataset]: """Yield datasets based on the available files. - This function requires that self.facets['mip'] is not a glob pattern. + This function requires that self.facets['mip'] is not a glob + pattern. """ dataset_template = self.copy() dataset_template.supplementaries = [] diff --git a/esmvalcore/iris_helpers.py b/esmvalcore/iris_helpers.py index eb9a96461e..b2a9f3183c 100644 --- a/esmvalcore/iris_helpers.py +++ b/esmvalcore/iris_helpers.py @@ -39,7 +39,6 @@ def add_leading_dim_to_cube(cube, dim_coord): ------ CoordinateMultiDimError ``dim_coord`` is not 1D. - """ # Only 1D dim_coords are supported if dim_coord.ndim > 1: @@ -134,7 +133,6 @@ def merge_cube_attributes( Input cubes whose attributes will be modified in-place. delimiter: Delimiter that is used to concatenate non-identical attributes. - """ if len(cubes) <= 1: return @@ -254,7 +252,6 @@ def rechunk_cube( ------- Cube Rechunked cube. This will always be a copy of the input cube. - """ cube = cube.copy() # do not modify input cube @@ -289,7 +286,6 @@ def has_regular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has a regular grid, else ``False``. - """ try: lat = cube.coord('latitude') @@ -318,7 +314,6 @@ def has_irregular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an irregular grid, else ``False``. - """ try: lat = cube.coord('latitude') @@ -345,7 +340,6 @@ def has_unstructured_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an unstructured grid, else ``False``. - """ try: lat = cube.coord('latitude') diff --git a/esmvalcore/preprocessor/__init__.py b/esmvalcore/preprocessor/__init__.py index 3800fb1413..b44dada778 100644 --- a/esmvalcore/preprocessor/__init__.py +++ b/esmvalcore/preprocessor/__init__.py @@ -206,9 +206,7 @@ ] DEFAULT_ORDER = tuple(__all__) -""" -By default, preprocessor functions are applied in this order. -""" +"""By default, preprocessor functions are applied in this order.""" # The order of initial and final steps cannot be configured INITIAL_STEPS = DEFAULT_ORDER[:DEFAULT_ORDER.index( diff --git a/esmvalcore/preprocessor/_area.py b/esmvalcore/preprocessor/_area.py index dd2f9b4b4b..78ff33f3a5 100644 --- a/esmvalcore/preprocessor/_area.py +++ b/esmvalcore/preprocessor/_area.py @@ -70,7 +70,6 @@ def extract_region( ------- iris.cube.Cube Smaller cube. - """ # first examine if any cell_measures are present cell_measures = cube.cell_measures() @@ -226,7 +225,6 @@ def zonal_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. - """ if cube.coord('longitude').points.ndim >= 2: raise ValueError( @@ -275,7 +273,6 @@ def meridional_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. - """ if cube.coord('latitude').points.ndim >= 2: raise ValueError( @@ -338,7 +335,6 @@ def area_statistics( iris.exceptions.CoordinateMultiDimError Cube has irregular or unstructured grid but supplementary variable `cell_area` is not available. - """ has_cell_measure = bool(cube.cell_measures('cell_area')) @@ -383,7 +379,6 @@ def extract_named_regions(cube: Cube, regions: str | Iterable[str]) -> Cube: regions is not list or tuple or set. ValueError region not included in cube. - """ # Make sure regions is a list of strings if isinstance(regions, str): @@ -599,7 +594,6 @@ def _get_bounds( ------- lat_min, lon_min, lat_max, lon_max Coordinates deliminating bounding box for shape ids. - """ all_bounds = np.vstack( [fiona.bounds(geom) for geom in geometries.values()] @@ -654,7 +648,6 @@ def fix_coordinate_ordering(cube: Cube) -> Cube: ------- iris.cube.Cube Cube with dimensions transposed to standard order - """ try: time_dim = cube.coord_dims('time') @@ -778,7 +771,6 @@ def extract_shape( See Also -------- extract_region: Extract a region from a cube. - """ shapefile = _update_shapefile_path(shapefile) with fiona.open(shapefile) as geometries: diff --git a/esmvalcore/preprocessor/_compare_with_refs.py b/esmvalcore/preprocessor/_compare_with_refs.py index 1634fc1752..0228a5eddc 100644 --- a/esmvalcore/preprocessor/_compare_with_refs.py +++ b/esmvalcore/preprocessor/_compare_with_refs.py @@ -102,7 +102,6 @@ def bias( true`` if ``reference=None``; ``reference=None`` and the input products are given as iterable of :class:`~iris.cube.Cube` objects; ``bias_type`` is not one of ``'absolute'`` or ``'relative'``. - """ ref_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) @@ -319,7 +318,6 @@ def distance_metric( `longitude` is not found in cube if a weighted metric shall be calculated, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. - """ reference_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) diff --git a/esmvalcore/preprocessor/_cycles.py b/esmvalcore/preprocessor/_cycles.py index 017d6ed71b..90e1284684 100644 --- a/esmvalcore/preprocessor/_cycles.py +++ b/esmvalcore/preprocessor/_cycles.py @@ -41,7 +41,6 @@ def amplitude(cube, coords): iris.exceptions.CoordinateNotFoundError A coordinate is not found in ``cube`` and cannot be added via :mod:`iris.coord_categorisation`. - """ if isinstance(coords, str): coords = [coords] diff --git a/esmvalcore/preprocessor/_derive/_baseclass.py b/esmvalcore/preprocessor/_derive/_baseclass.py index ba9325bfdd..c2076b1542 100644 --- a/esmvalcore/preprocessor/_derive/_baseclass.py +++ b/esmvalcore/preprocessor/_derive/_baseclass.py @@ -30,7 +30,6 @@ def required(project): ------- list of dict List of variable metadata. - """ @staticmethod @@ -58,5 +57,4 @@ def calculate(cubes): NotImplementedError If the desired variable derivation is not implemented, i.e. if this method is called from this base class and not a child class. - """ diff --git a/esmvalcore/preprocessor/_derive/_shared.py b/esmvalcore/preprocessor/_derive/_shared.py index e6d07011f1..dfe620b58e 100644 --- a/esmvalcore/preprocessor/_derive/_shared.py +++ b/esmvalcore/preprocessor/_derive/_shared.py @@ -61,7 +61,6 @@ def column_average(cube, hus_cube, zg_cube, ps_cube): ------- iris.cube.Cube Column-averaged mole fraction of a gas. - """ # Convert units of data hus_cube.convert_units('1') @@ -124,7 +123,6 @@ def pressure_level_widths(cube, ps_cube, top_limit=0.0): ------- iris.cube.Cube Cube of same shape as ``cube`` containing pressure level widths. - """ pressure_array = _create_pressure_array(cube, ps_cube, top_limit) @@ -172,7 +170,6 @@ def _get_pressure_level_widths(array, air_pressure_axis=1): For a 1D array with pressure level columns, return a 1D array with pressure level widths. - """ array = np.copy(array) if np.any(np.diff(array, axis=air_pressure_axis) > 0.0): diff --git a/esmvalcore/preprocessor/_derive/alb.py b/esmvalcore/preprocessor/_derive/alb.py index b0036077ad..dcc45362b8 100644 --- a/esmvalcore/preprocessor/_derive/alb.py +++ b/esmvalcore/preprocessor/_derive/alb.py @@ -2,7 +2,6 @@ authors: - crez_ba - """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/ctotal.py b/esmvalcore/preprocessor/_derive/ctotal.py index 18bef27071..45cd2610da 100644 --- a/esmvalcore/preprocessor/_derive/ctotal.py +++ b/esmvalcore/preprocessor/_derive/ctotal.py @@ -1,7 +1,6 @@ """Derivation of variable `ctotal`.""" import iris - from iris import Constraint from ._baseclass import DerivedVariableBase diff --git a/esmvalcore/preprocessor/_derive/lvp.py b/esmvalcore/preprocessor/_derive/lvp.py index 0faf0779c4..ad9db3f299 100644 --- a/esmvalcore/preprocessor/_derive/lvp.py +++ b/esmvalcore/preprocessor/_derive/lvp.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/lwp.py b/esmvalcore/preprocessor/_derive/lwp.py index 067126d5e9..4c79322496 100644 --- a/esmvalcore/preprocessor/_derive/lwp.py +++ b/esmvalcore/preprocessor/_derive/lwp.py @@ -33,7 +33,6 @@ def calculate(cubes): ---- Some datasets output the variable `clwvi` which only contains `lwp`. In these cases, the input `clwvi` cube is just returned. - """ # CMIP5 and CMIP6 names are slightly different, so use # variable name instead to extract cubes diff --git a/esmvalcore/preprocessor/_derive/ohc.py b/esmvalcore/preprocessor/_derive/ohc.py index d8d374b312..e9f1f52e67 100644 --- a/esmvalcore/preprocessor/_derive/ohc.py +++ b/esmvalcore/preprocessor/_derive/ohc.py @@ -1,8 +1,7 @@ """Derivation of variable `ohc`.""" import iris -from iris import Constraint - from cf_units import Unit +from iris import Constraint from ._baseclass import DerivedVariableBase @@ -38,8 +37,7 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute ocean heat content. + """Compute ocean heat content. Use c_p*rho_0= 4.09169e+6 J m-3 K-1 (Kuhlbrodt et al., 2015, Clim. Dyn.) diff --git a/esmvalcore/preprocessor/_derive/rlnst.py b/esmvalcore/preprocessor/_derive/rlnst.py index 4eecd9b90d..dcf1c643c9 100644 --- a/esmvalcore/preprocessor/_derive/rlnst.py +++ b/esmvalcore/preprocessor/_derive/rlnst.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint @@ -30,11 +29,10 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute variable `rlnst`. + """Compute variable `rlnst`. - Compute Net Atmospheric Longwave Cooling - to surface and outer space. + Compute Net Atmospheric Longwave Cooling to surface and outer + space. """ rlds_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air')) diff --git a/esmvalcore/preprocessor/_derive/rlnstcs.py b/esmvalcore/preprocessor/_derive/rlnstcs.py index 10613216a9..a1b39128fe 100644 --- a/esmvalcore/preprocessor/_derive/rlnstcs.py +++ b/esmvalcore/preprocessor/_derive/rlnstcs.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint @@ -30,11 +29,10 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute variable `rlnstcs`. + """Compute variable `rlnstcs`. - Compute Net Atmospheric Longwave Cooling - to surface and outer space assuming clear sky. + Compute Net Atmospheric Longwave Cooling to surface and outer + space assuming clear sky. """ rldscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rlus.py b/esmvalcore/preprocessor/_derive/rlus.py index 4d536c29ad..928b7d296a 100644 --- a/esmvalcore/preprocessor/_derive/rlus.py +++ b/esmvalcore/preprocessor/_derive/rlus.py @@ -2,7 +2,6 @@ authors: - lukas_brunner - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnst.py b/esmvalcore/preprocessor/_derive/rsnst.py index e2a2a53b21..80b6d7abf0 100644 --- a/esmvalcore/preprocessor/_derive/rsnst.py +++ b/esmvalcore/preprocessor/_derive/rsnst.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcs.py b/esmvalcore/preprocessor/_derive/rsnstcs.py index 976be64003..6a4271c649 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcs.py +++ b/esmvalcore/preprocessor/_derive/rsnstcs.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py index a6445bbb64..590a4bdd57 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py +++ b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py @@ -2,7 +2,6 @@ authors: - weig_ka - """ from cf_units import Unit from iris import Constraint @@ -34,12 +33,11 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute `rsnstcs`. + """Compute `rsnstcs`. - Compute Heating from Shortwave Absorption - assuming clear sky normalized by - the incoming shortwave flux at the top of the atmosphere. + Compute Heating from Shortwave Absorption assuming clear sky + normalized by the incoming shortwave flux at the top of the + atmosphere. """ rsdscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_shortwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rsus.py b/esmvalcore/preprocessor/_derive/rsus.py index 326d063c26..cd3a6ad4dd 100644 --- a/esmvalcore/preprocessor/_derive/rsus.py +++ b/esmvalcore/preprocessor/_derive/rsus.py @@ -2,7 +2,6 @@ authors: - lukas_brunner - """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/siextent.py b/esmvalcore/preprocessor/_derive/siextent.py index eee25e5a98..2e2bee96bb 100644 --- a/esmvalcore/preprocessor/_derive/siextent.py +++ b/esmvalcore/preprocessor/_derive/siextent.py @@ -6,6 +6,7 @@ from iris import Constraint from esmvalcore.exceptions import RecipeError + from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) diff --git a/esmvalcore/preprocessor/_derive/sispeed.py b/esmvalcore/preprocessor/_derive/sispeed.py index 168b2e5525..b28aa06214 100644 --- a/esmvalcore/preprocessor/_derive/sispeed.py +++ b/esmvalcore/preprocessor/_derive/sispeed.py @@ -1,10 +1,10 @@ """Derivation of variable `sispeed`.""" import logging + from iris import Constraint from .._regrid import regrid - from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) @@ -24,8 +24,7 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute sispeed module from velocity components siu and siv. + """Compute sispeed module from velocity components siu and siv. Arguments --------- @@ -34,7 +33,6 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. - """ siu = cubes.extract_cube(Constraint(name='sea_ice_x_velocity')) siv = cubes.extract_cube(Constraint(name='sea_ice_y_velocity')) diff --git a/esmvalcore/preprocessor/_derive/sithick.py b/esmvalcore/preprocessor/_derive/sithick.py index ad80709d8f..b28fa2881b 100644 --- a/esmvalcore/preprocessor/_derive/sithick.py +++ b/esmvalcore/preprocessor/_derive/sithick.py @@ -20,8 +20,7 @@ def required(project): @staticmethod def calculate(cubes): - """ - Compute sea ice thickness from volume and concentration. + """Compute sea ice thickness from volume and concentration. In CMIP5, `sit` is called `sea_ice_thickness` but it is not real thickness. It is ice volume per area unit. In CMIP6, it is called @@ -34,7 +33,6 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. - """ sivol = cubes.extract_cube(Constraint(name='sea_ice_thickness')) siconc = cubes.extract_cube(Constraint(name='sea_ice_area_fraction')) diff --git a/esmvalcore/preprocessor/_derive/sm.py b/esmvalcore/preprocessor/_derive/sm.py index deb3526dfd..efc3810d65 100644 --- a/esmvalcore/preprocessor/_derive/sm.py +++ b/esmvalcore/preprocessor/_derive/sm.py @@ -25,7 +25,6 @@ def calculate(cubes): Convert moisture content of soil layer (kg/m2) into volumetric soil moisture (m3/m3), assuming density of water 998.2 kg/m2 (at temperature 20 deg C). - """ mrsos_cube = cubes.extract_cube(NameConstraint(var_name='mrsos')) diff --git a/esmvalcore/preprocessor/_derive/toz.py b/esmvalcore/preprocessor/_derive/toz.py index 32fd9e8334..62514d4ca3 100644 --- a/esmvalcore/preprocessor/_derive/toz.py +++ b/esmvalcore/preprocessor/_derive/toz.py @@ -39,7 +39,6 @@ def calculate(cubes): ---- The surface pressure is used as a lower integration bound. A fixed upper integration bound of 0 Pa is used. - """ tro3_cube = cubes.extract_cube( iris.Constraint(name='mole_fraction_of_ozone_in_air')) diff --git a/esmvalcore/preprocessor/_detrend.py b/esmvalcore/preprocessor/_detrend.py index 5bc0ce6fc8..9faee61c73 100644 --- a/esmvalcore/preprocessor/_detrend.py +++ b/esmvalcore/preprocessor/_detrend.py @@ -8,8 +8,7 @@ def detrend(cube, dimension='time', method='linear'): - """ - Detrend data along a given dimension. + """Detrend data along a given dimension. Parameters ---------- diff --git a/esmvalcore/preprocessor/_mapping.py b/esmvalcore/preprocessor/_mapping.py index 28d1fefb83..a39e26e823 100644 --- a/esmvalcore/preprocessor/_mapping.py +++ b/esmvalcore/preprocessor/_mapping.py @@ -8,11 +8,10 @@ def _is_single_item(testee): - """ - Check if testee is a single item. + """Check if testee is a single item. - Return whether this is a single item, rather than an iterable. - We count string types as 'single', also. + Return whether this is a single item, rather than an iterable. We + count string types as 'single', also. """ return (isinstance(testee, str) or not isinstance(testee, collections.abc.Iterable)) @@ -64,8 +63,7 @@ def ref_to_dims_index_as_index(cube, ref): def ref_to_dims_index(cube, ref_to_slice): - """ - Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. + """Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. This method finds the indices of the dimensions in a cube that collectively correspond to the given list of :class:`iris.coords.DimCoord`. @@ -100,8 +98,7 @@ def ref_to_dims_index(cube, ref_to_slice): def get_associated_coords(cube, dimensions): - """ - Return all coords containing any of the given dimensions. + """Return all coords containing any of the given dimensions. Return all coords, dimensional and auxiliary, that contain any of the given dimensions. @@ -125,11 +122,10 @@ def get_associated_coords(cube, dimensions): def get_empty_data(shape, dtype=np.float32): - """ - Create an empty data object of the given shape. + """Create an empty data object of the given shape. - Creates an empty data object of the given shape, potentially of the lazy - kind from biggus or dask, depending on the used iris version. + Creates an empty data object of the given shape, potentially of the + lazy kind from biggus or dask, depending on the used iris version. """ data = np.empty(shape, dtype=dtype) mask = np.empty(shape, dtype=bool) @@ -137,11 +133,10 @@ def get_empty_data(shape, dtype=np.float32): def get_slice_spec(cube, ref_to_slice): - """ - Turn a slice reference into a specification for the slice. + """Turn a slice reference into a specification for the slice. - Turns a slice reference into a specification comprised of the shape as well - as the relevant dimensional and auxiliary coordinates. + Turns a slice reference into a specification comprised of the shape + as well as the relevant dimensional and auxiliary coordinates. """ slice_dims = ref_to_dims_index(cube, ref_to_slice) slice_shape = tuple(cube.shape[d] for d in slice_dims) @@ -150,8 +145,7 @@ def get_slice_spec(cube, ref_to_slice): def index_iterator(dims_to_slice, shape): - """ - Return iterator for subsets of multidimensional objects. + """Return iterator for subsets of multidimensional objects. An iterator over a multidimensional object, giving both source and destination indices. @@ -181,8 +175,7 @@ def get_slice_coords(cube): def map_slices(src, func, src_rep, dst_rep): - """ - Map slices of a cube, replacing them with different slices. + """Map slices of a cube, replacing them with different slices. This method is similar to the standard cube collapsed and aggregated_by methods, however, where they completely remove the mapped dimensions, this diff --git a/esmvalcore/preprocessor/_multimodel.py b/esmvalcore/preprocessor/_multimodel.py index d1e0d90e74..b8950c2d8e 100644 --- a/esmvalcore/preprocessor/_multimodel.py +++ b/esmvalcore/preprocessor/_multimodel.py @@ -1,11 +1,11 @@ """Statistics across cubes. -This module contains functions to compute statistics across multiple cubes or -products. +This module contains functions to compute statistics across multiple +cubes or products. -Wrapper functions separate esmvalcore internals, operating on products, from -generalized functions that operate on iris cubes. These wrappers support -grouped execution by passing a groupby keyword. +Wrapper functions separate esmvalcore internals, operating on products, +from generalized functions that operate on iris cubes. These wrappers +support grouped execution by passing a groupby keyword. """ from __future__ import annotations @@ -53,16 +53,16 @@ def _get_consistent_time_unit(cubes): def _unify_time_coordinates(cubes): """Make sure all cubes' share the same time coordinate. - This function extracts the date information from the cube and reconstructs - the time coordinate, resetting the actual dates to the 15th of the month or - 1st of July for yearly data (consistent with `regrid_time`), so that there - are no mismatches in the time arrays. + This function extracts the date information from the cube and + reconstructs the time coordinate, resetting the actual dates to the + 15th of the month or 1st of July for yearly data (consistent with + `regrid_time`), so that there are no mismatches in the time arrays. If cubes have different time units, it will reset the calendar to a the "standard" calendar with unit "days since 1850-01-01". - Might not work for (sub)daily data, because different calendars may have - different number of days in the year. + Might not work for (sub)daily data, because different calendars may + have different number of days in the year. """ t_unit = _get_consistent_time_unit(cubes) @@ -245,7 +245,6 @@ def _get_equal_coord_names_metadata(cubes, equal_coords_metadata): Note ---- Ignore coordinates whose names are not unique. - """ equal_names_metadata = {} for coord in cubes[0].coords(): @@ -361,7 +360,6 @@ def _equalise_var_metadata(cubes): If cubes have the same ``name()`` and ``units``, assign identical `standard_names`, `long_names`, and `var_names`. - """ attrs = ['standard_name', 'long_name', 'var_name'] equal_names_metadata = {} @@ -441,7 +439,6 @@ def _compute_slices(cubes): Note ---- For scalar cubes, simply return ``None``. - """ # Scalar cubes if cubes[0].shape == (): diff --git a/esmvalcore/preprocessor/_other.py b/esmvalcore/preprocessor/_other.py index 3d047a4e24..c91866ade7 100644 --- a/esmvalcore/preprocessor/_other.py +++ b/esmvalcore/preprocessor/_other.py @@ -133,7 +133,6 @@ def histogram( `longitude` is not found in cube if `weights=True`, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. - """ # Check arguments if isinstance(bins, str): @@ -248,10 +247,9 @@ def _calculate_histogram_lazy( ) -> da.Array: """Calculate histogram over data along axes (lazy version). - This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are - the dimensions of `data` not appearing in `axes` and `n_bins` is the number - of bins. - + This will return an array of shape `(x1, x2, ..., n_bins)` where + `xi` are the dimensions of `data` not appearing in `axes` and + `n_bins` is the number of bins. """ n_axes = len(along_axes) @@ -315,10 +313,9 @@ def _calculate_histogram_eager( ) -> np.ndarray: """Calculate histogram over data along axes (eager version). - This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are - the dimensions of `data` not appearing in `axes` and `n_bins` is the number - of bins. - + This will return an array of shape `(x1, x2, ..., n_bins)` where + `xi` are the dimensions of `data` not appearing in `axes` and + `n_bins` is the number of bins. """ # Create array with shape (x1, x2, ..., y) where `y` is the product of all # dimensions in `axes` and the `xi` are the remaining dimensions diff --git a/esmvalcore/preprocessor/_regrid.py b/esmvalcore/preprocessor/_regrid.py index 228bd7dc26..0e9e8aafc9 100644 --- a/esmvalcore/preprocessor/_regrid.py +++ b/esmvalcore/preprocessor/_regrid.py @@ -30,11 +30,9 @@ from esmvalcore.cmor.table import CMOR_TABLES from esmvalcore.exceptions import ESMValCoreDeprecationWarning from esmvalcore.iris_helpers import has_irregular_grid, has_unstructured_grid -from esmvalcore.preprocessor._shared import ( - get_dims_along_axes, -) from esmvalcore.preprocessor._shared import ( get_array_module, + get_dims_along_axes, preserve_float_dtype, ) from esmvalcore.preprocessor._supplementary_vars import ( diff --git a/esmvalcore/preprocessor/_regrid_esmpy.py b/esmvalcore/preprocessor/_regrid_esmpy.py index cce6dae92f..3055f82f83 100755 --- a/esmvalcore/preprocessor/_regrid_esmpy.py +++ b/esmvalcore/preprocessor/_regrid_esmpy.py @@ -10,6 +10,7 @@ except ImportError: raise exc import warnings + import iris import numpy as np from iris.cube import Cube @@ -65,7 +66,6 @@ class ESMPyRegridder: `nearest`. mask_threshold: Threshold used to regrid mask of input cube. - """ def __init__( @@ -96,7 +96,6 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. - """ # These regridders are not lazy, so load source data once. cube.data # pylint: disable=pointless-statement @@ -124,7 +123,6 @@ class _ESMPyScheme: ---------- mask_threshold: Threshold used to regrid mask of source cube. - """ _METHOD = '' @@ -162,7 +160,6 @@ def regridder(self, src_cube: Cube, tgt_cube: Cube) -> ESMPyRegridder: ------- ESMPyRegridder Regridder instance. - """ return ESMPyRegridder( src_cube, @@ -184,7 +181,6 @@ class ESMPyAreaWeighted(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. - """ _METHOD = 'area_weighted' @@ -202,7 +198,6 @@ class ESMPyLinear(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. - """ _METHOD = 'linear' @@ -220,7 +215,6 @@ class ESMPyNearest(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. - """ _METHOD = 'nearest' @@ -450,8 +444,7 @@ def get_grid_representant(cube, horizontal_only=False): def get_grid_representants(src, dst): - """ - Construct cubes representing the source and destination grid. + """Construct cubes representing the source and destination grid. This method constructs two new cubes that representant the grids, i.e. the spatial dimensions of the given cubes. diff --git a/esmvalcore/preprocessor/_regrid_unstructured.py b/esmvalcore/preprocessor/_regrid_unstructured.py index 6618c728c0..ce94d7fa68 100644 --- a/esmvalcore/preprocessor/_regrid_unstructured.py +++ b/esmvalcore/preprocessor/_regrid_unstructured.py @@ -26,10 +26,10 @@ class UnstructuredNearest(IrisUnstructuredNearest): """Unstructured nearest-neighbor regridding scheme. - This class is a wrapper around :class:`iris.analysis.UnstructuredNearest` - that removes any additional X or Y coordinates prior to regridding if - necessary. It can be used in :meth:`iris.cube.Cube.regrid`. - + This class is a wrapper around + :class:`iris.analysis.UnstructuredNearest` that removes any + additional X or Y coordinates prior to regridding if necessary. It + can be used in :meth:`iris.cube.Cube.regrid`. """ def regridder( @@ -50,7 +50,6 @@ def regridder( ------- UnstructuredNearestNeigbourRegridder Regridder instance. - """ # Unstructured nearest-neighbor regridding requires exactly one X and # one Y coordinate (latitude and longitude). Remove any X or Y @@ -79,7 +78,6 @@ class UnstructuredLinearRegridder: Cube defining the source grid. tgt_cube: Cube defining the target grid. - """ def __init__(self, src_cube: Cube, tgt_cube: Cube) -> None: @@ -127,7 +125,6 @@ def _get_weights_and_idx( The output arrays will be numpy arrays here (instead of dask) since resulting arrays are only 2D and will be computed anyway later during regridding. - """ # Make sure that source and target grid have identical units src_lat = src_lat.copy() @@ -191,7 +188,6 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. - """ if not has_unstructured_grid(cube): raise ValueError( @@ -320,7 +316,6 @@ def _interpolate(self, data: np.ndarray) -> np.ndarray: Before the interpolation, the input is extended by the data on the convex hull to consider the periodic boundary conditions of a sphere (this has also been done for the weights calculation). - """ data = self._add_convex_hull_twice(data, self._convex_hull_idx) interp_data = np.einsum( @@ -347,7 +342,6 @@ def _calculate_weights( Output shapes (M: number of target grid points) - weights: (M, 3) - indices: (M, 3) - """ tri = Delaunay(src_points) simplex = tri.find_simplex(tgt_points) @@ -373,7 +367,6 @@ class UnstructuredLinear: This will drop all cell measures, ancillary variables and aux factories, and any auxiliary coordinate that spans the dimension of the unstrucutred grid. - """ def __repr__(self) -> str: @@ -398,6 +391,5 @@ def regridder( ------- UnstructuredLinearRegridder Regridder instance. - """ return UnstructuredLinearRegridder(src_cube, tgt_cube) diff --git a/esmvalcore/preprocessor/_rolling_window.py b/esmvalcore/preprocessor/_rolling_window.py index 9e62275a45..4b0b5cdf14 100644 --- a/esmvalcore/preprocessor/_rolling_window.py +++ b/esmvalcore/preprocessor/_rolling_window.py @@ -39,7 +39,6 @@ def rolling_window_statistics( ------- iris.cube.Cube Rolling-window statistics cube. - """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) cube = cube.rolling_window(coordinate, agg, window_length, *agg_kwargs) diff --git a/esmvalcore/preprocessor/_shared.py b/esmvalcore/preprocessor/_shared.py index 67c3b89f5d..1ed78b9766 100644 --- a/esmvalcore/preprocessor/_shared.py +++ b/esmvalcore/preprocessor/_shared.py @@ -1,5 +1,4 @@ -""" -Shared functions for preprocessor. +"""Shared functions for preprocessor. Utility functions that can be used for multiple preprocessor steps """ @@ -68,7 +67,6 @@ def get_iris_aggregator( An invalid `operator` is specified, i.e., it is not found in :mod:`iris.analysis` or the returned object is not an :class:`iris.analysis.Aggregator`. - """ cap_operator = operator.upper() aggregator_kwargs = dict(operator_kwargs) @@ -138,7 +136,6 @@ def aggregator_accept_weights(aggregator: iris.analysis.Aggregator) -> bool: ------- bool ``True`` if aggregator support weights, ``False`` otherwise. - """ weighted_aggregators_cls = ( iris.analysis.WeightedAggregator, @@ -179,7 +176,6 @@ def update_weights_kwargs( ------- dict Updated keyword arguments. - """ kwargs = dict(kwargs) if aggregator_accept_weights(aggregator) and kwargs.get('weights', True): @@ -218,7 +214,6 @@ def get_normalized_cube( ------- Cube Input cube normalized with statistics cube. - """ if normalize == 'subtract': normalized_cube = cube - statistics_cube @@ -250,11 +245,10 @@ def get_normalized_cube( def preserve_float_dtype(func: Callable) -> Callable: """Preserve object's float dtype (all other dtypes are allowed to change). - This can be used as a decorator for preprocessor functions to ensure that - floating dtypes are preserved. For example, input of type float32 will - always give output of type float32, but input of type int will be allowed - to give output with any type. - + This can be used as a decorator for preprocessor functions to ensure + that floating dtypes are preserved. For example, input of type + float32 will always give output of type float32, but input of type + int will be allowed to give output with any type. """ @wraps(func) @@ -381,7 +375,6 @@ def get_time_weights(cube: Cube) -> np.ndarray | da.core.Array: Array of time weights for averaging. Returns a :class:`dask.array.Array` if the input cube has lazy data; a :class:`numpy.ndarray` otherwise. - """ time = cube.coord('time') coord_dims = cube.coord_dims('time') diff --git a/esmvalcore/preprocessor/_time.py b/esmvalcore/preprocessor/_time.py index d4dff4c1f9..5fd60d807a 100644 --- a/esmvalcore/preprocessor/_time.py +++ b/esmvalcore/preprocessor/_time.py @@ -100,7 +100,6 @@ def extract_time( ------ ValueError Time ranges are outside the cube time limits. - """ t_1 = PartialDateTime(year=int(start_year), month=int(start_month), @@ -260,7 +259,6 @@ def clip_timerange(cube: Cube, timerange: str) -> Cube: ------ ValueError Time ranges are outside the cube's time limits. - """ start_date = _parse_start_date(timerange.split('/')[0]) end_date = _parse_end_date(timerange.split('/')[1]) @@ -318,7 +316,6 @@ def extract_season(cube: Cube, season: str) -> Cube: ------ ValueError Requested season is not present in the cube. - """ season = season.upper() @@ -372,7 +369,6 @@ def extract_month(cube: Cube, month: int) -> Cube: ------ ValueError Requested month is not present in the cube. - """ if month not in range(1, 13): raise ValueError('Please provide a month number between 1 and 12.') @@ -446,7 +442,6 @@ def hourly_statistics( ------- iris.cube.Cube Hourly statistics cube. - """ if not cube.coords('hour_group'): iris.coord_categorisation.add_categorised_coord( @@ -498,7 +493,6 @@ def daily_statistics( ------- iris.cube.Cube Daily statistics cube. - """ if not cube.coords('day_of_year'): iris.coord_categorisation.add_day_of_year(cube, 'time') @@ -539,7 +533,6 @@ def monthly_statistics( ------- iris.cube.Cube Monthly statistics cube. - """ if not cube.coords('month_number'): iris.coord_categorisation.add_month_number(cube, 'time') @@ -584,7 +577,6 @@ def seasonal_statistics( ------- iris.cube.Cube Seasonal statistic cube. - """ seasons = tuple(sea.upper() for sea in seasons) @@ -631,7 +623,6 @@ def spans_full_season(cube: Cube) -> list[bool]: ------- list[bool] Truth statements if time bounds are within (month*29, month*31) - """ time = cube.coord('time') num_days = [(tt.bounds[0, 1] - tt.bounds[0, 0]) for tt in time] @@ -675,7 +666,6 @@ def annual_statistics( ------- iris.cube.Cube Annual statistics cube. - """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -717,7 +707,6 @@ def decadal_statistics( ------- iris.cube.Cube Decadal statistics cube. - """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -1036,7 +1025,6 @@ def regrid_time( NotImplementedError An invalid `frequency` is given or `calendar` is set for a non-supported frequency. - """ # Do not overwrite input cube cube = cube.copy() @@ -1220,7 +1208,6 @@ def timeseries_filter( Cube does not have time coordinate. NotImplementedError: `filter_type` is not implemented. - """ try: cube.coord('time') @@ -1295,7 +1282,6 @@ def resample_hours( `interval` is not a divisor of 24; invalid `interpolate` given; or input data does not contain any target hour (if `interpolate` is ``None``). - """ allowed_intervals = (1, 2, 3, 4, 6, 12) if interval not in allowed_intervals: @@ -1387,7 +1373,6 @@ def resample_time( ------- iris.cube.Cube Cube with the new frequency. - """ time = cube.coord('time') dates = time.units.num2date(time.points) @@ -1425,7 +1410,6 @@ def _get_lst_offset(lon_coord: Coord) -> np.ndarray: ---- This function expects longitude in degrees. Can be in [0, 360] or [-180, 180] format. - """ # Make sure that longitude is in degrees and shift it to [-180, 180] first # (do NOT overwrite input coordinate) @@ -1442,7 +1426,6 @@ def _get_lsts(time_coord: DimCoord, lon_coord: Coord) -> np.ndarray: ---- LSTs outside of the time bins given be the time coordinate bounds are put into a bin below/above the time coordinate. - """ # Pad time coordinate with 1 time step at both sides for the bins for LSTs # outside of the time coordinate @@ -1490,7 +1473,6 @@ def _get_time_index_and_mask( (LSTs) are given. E.g., for hourly data with first time point 01:00:00 UTC, LST in Berlin is already 02:00:00 (assuming no daylight saving time). Thus, for 01:00:00 LST on this day, there is no value for Berlin. - """ # Make sure that time coordinate has bounds (these are necessary for the # binning) and uses 'hours' as reference units @@ -1555,7 +1537,6 @@ def _transform_to_lst_eager( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. - """ # Apart from the time index, all other dimensions will stay the same; this # is ensured with np.ogrid @@ -1599,7 +1580,6 @@ def _transform_to_lst_lazy( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. - """ new_data = da.apply_gufunc( _transform_to_lst_eager, @@ -1630,7 +1610,6 @@ def _transform_arr_to_lst( ---- This function either calls `_transform_to_lst_eager` or `_transform_to_lst_lazy` depending on the type of input data. - """ if isinstance(data, np.ndarray): func = _transform_to_lst_eager # type: ignore @@ -1811,7 +1790,6 @@ def local_solar_time(cube: Cube) -> Cube: Input cube has multidimensional `longitude` coordinate. ValueError `time` coordinate of input cube is not monotonically increasing. - """ # Make sure that cube has valid time and longitude coordinates _check_cube_coords(cube) diff --git a/esmvalcore/preprocessor/_trend.py b/esmvalcore/preprocessor/_trend.py index c592f5196e..b81d656034 100644 --- a/esmvalcore/preprocessor/_trend.py +++ b/esmvalcore/preprocessor/_trend.py @@ -96,7 +96,6 @@ def linear_trend(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. - """ coord = cube.coord(coordinate, dim_coords=True) @@ -151,7 +150,6 @@ def linear_trend_stderr(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. - """ coord = cube.coord(coordinate, dim_coords=True) diff --git a/esmvalcore/preprocessor/_units.py b/esmvalcore/preprocessor/_units.py index 8c96f78ae1..c71fc384d6 100644 --- a/esmvalcore/preprocessor/_units.py +++ b/esmvalcore/preprocessor/_units.py @@ -112,7 +112,6 @@ def convert_units(cube, units): ------- iris.cube.Cube converted cube. - """ try: cube.convert_units(units) diff --git a/esmvalcore/preprocessor/_volume.py b/esmvalcore/preprocessor/_volume.py index 840af3214e..9705f4e4e9 100644 --- a/esmvalcore/preprocessor/_volume.py +++ b/esmvalcore/preprocessor/_volume.py @@ -66,7 +66,6 @@ def extract_volume( ------- iris.cube.Cube z-coord extracted cube. - """ if z_min > z_max: # minimum is below maximum, so switch them around @@ -124,7 +123,6 @@ def calculate_volume(cube: Cube) -> da.core.Array: ------- dask.array.core.Array Grid volumes. - """ # Load depth field and figure out which dim is which depth = cube.coord(axis='z') @@ -254,7 +252,6 @@ def volume_statistics( ------- iris.cube.Cube Collapsed cube. - """ has_cell_measure = bool(cube.cell_measures('ocean_volume')) @@ -339,7 +336,6 @@ def axis_statistics( ------- iris.cube.Cube Collapsed cube. - """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) @@ -426,7 +422,6 @@ def depth_integration(cube: Cube) -> Cube: ------- iris.cube.Cube Collapsed cube. - """ result = axis_statistics(cube, axis='z', operator='sum') result.rename('Depth_integrated_' + str(cube.name())) @@ -480,7 +475,6 @@ def extract_transect( ValueError Latitude and longitude are both floats or lists; not allowed to slice on both axes at the same time. - """ # ### coord_dim2 = False @@ -571,7 +565,6 @@ def extract_trajectory( ------ ValueError Latitude and longitude have different dimensions. - """ from iris.analysis.trajectory import interpolate diff --git a/esmvalcore/preprocessor/shapefiles/ar6.prj b/esmvalcore/preprocessor/shapefiles/ar6.prj index a30c00a55d..8f73f480ff 100644 --- a/esmvalcore/preprocessor/shapefiles/ar6.prj +++ b/esmvalcore/preprocessor/shapefiles/ar6.prj @@ -1 +1 @@ -GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] diff --git a/esmvalcore/typing.py b/esmvalcore/typing.py index 410b31f0f8..d5c60fc83e 100644 --- a/esmvalcore/typing.py +++ b/esmvalcore/typing.py @@ -17,8 +17,8 @@ NetCDFAttr = Union[str, Number, Iterable] """Type describing netCDF attributes. -`NetCDF attributes -`_ can +`NetCDF attributes`_ +can be strings, numbers or sequences. """ diff --git a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py index d988e02441..4f26feaf9e 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py @@ -27,7 +27,7 @@ def setUp(self): self.fix = Cl(None) def test_get(self): - """Test fix get""" + """Test fix get.""" fix = Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'cl') assert fix == [Cl(None), GenericFix(None)] diff --git a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py index ce6ebe0121..ba41ddae48 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py @@ -17,7 +17,7 @@ def setUp(self): self.fix = Msftmyz(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) @@ -37,7 +37,7 @@ def setUp(self): self.fix = Msftmyzba(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyzba'), [Msftmyzba(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py index 4b480ef81f..a0805f4efe 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py @@ -26,7 +26,7 @@ def setUp(self): self.fix = Sic(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sic'), [Sic(None), GenericFix(None)]) @@ -45,7 +45,7 @@ def setUp(self): self.fix = Sftlf(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sftlf'), [Sftlf(None), GenericFix(None)]) @@ -90,7 +90,7 @@ def setUp(self): self.fix = Tas(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'tas'), [Tas(None), GenericFix(None)]) @@ -147,7 +147,7 @@ def setUp(self): self.fix = Areacello(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Omon', 'areacello'), [Areacello(None), GenericFix(None)], @@ -209,7 +209,7 @@ def setUp(self): self.fix = Pr(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'pr'), [Pr(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py index c0705e58fa..0220aecb2c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py @@ -29,7 +29,7 @@ def setUp(self): self.fix = Ch4(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'ch4'), [Ch4(None), GenericFix(None)]) @@ -48,7 +48,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'co2'), [Co2(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py index 8a4fa19fd1..f2aa86d7b2 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py @@ -40,7 +40,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -62,7 +62,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'Amon', 'areacello'), [Areacello(self.vardef), @@ -106,7 +106,7 @@ def setUp(self): self.fix = Sit(self.var_info_mock) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'OImon', 'sit'), [Sit(self.var_info_mock), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py index bcda26c95b..89b62a21f9 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -39,7 +39,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'Amon', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py index d5189e84c4..d0f0c5245c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py @@ -75,7 +75,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -96,7 +96,7 @@ def setUp(self): self.fix = Usi(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'usi'), [Usi(self.vardef), @@ -118,7 +118,7 @@ def setUp(self): self.fix = Vsi(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'vsi'), [Vsi(self.vardef), @@ -140,7 +140,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py index 1897ba5c85..9fe2db7c83 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py @@ -23,7 +23,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -43,7 +43,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -64,7 +64,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py index 0e6a4fc57a..85bede7678 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py +++ b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py @@ -9,7 +9,7 @@ class TestAllVars(unittest.TestCase): """Test allvars fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'tas'), [AllVars(None), GenericFix(None)]) @@ -18,7 +18,7 @@ def test_get(self): class TestO2(unittest.TestCase): """Test o2 fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'o2'), [O2(None), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py index 1e14dfd30c..64fcbc250c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py +++ b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Tro3(None) def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MIROC-ESM-CHEM', 'Amon', 'tro3'), [Tro3(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py index f4d39eb70b..baabbbf599 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py @@ -9,7 +9,7 @@ class TestMsftmyz(unittest.TestCase): """Test msftmyz fixes.""" def test_get(self): - """Test fix get""" + """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MRI-ESM1', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py index b600311d5a..fc962f38b7 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py +++ b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py @@ -69,7 +69,7 @@ def test_tas(cubes_in, cubes_out): def test_get(): - """Test fix get""" + """Test fix get.""" assert Fix.get_fixes('CMIP5', 'NORESM1-ME', 'Amon', 'tas') == [ Tas(None), GenericFix(None) ] diff --git a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py index 65ca211e12..b4c1b9f7e9 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py +++ b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py @@ -2,6 +2,7 @@ import iris import numpy as np import pytest +from cf_units import Unit from esmvalcore.cmor._fixes.cmip6.gfdl_cm4 import ( Cl, @@ -15,11 +16,10 @@ Tos, Uas, ) -from esmvalcore.cmor._fixes.common import SiconcFixScalarCoord, OceanFixGrid +from esmvalcore.cmor._fixes.common import OceanFixGrid, SiconcFixScalarCoord from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info -from cf_units import Unit def test_get_cl_fix(): diff --git a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py index 63428e913c..9668681c06 100644 --- a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py @@ -4,7 +4,8 @@ from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5 import ( aladin63, - wrf381p,) + wrf381p, +) from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info diff --git a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py index c54bea04cd..f1149064a0 100644 --- a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py +++ b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py @@ -1,6 +1,6 @@ """Tests for the fixes of MIROC-MIROC5.""" -import pytest import iris +import pytest from esmvalcore.cmor._fixes.cordex.miroc_miroc5 import wrf361h from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_fix.py b/tests/integration/cmor/_fixes/test_fix.py index 1e97c62fd4..cfbbbebf31 100644 --- a/tests/integration/cmor/_fixes/test_fix.py +++ b/tests/integration/cmor/_fixes/test_fix.py @@ -10,9 +10,7 @@ from esmvalcore.cmor._fixes.cmip5.canesm2 import FgCo2 from esmvalcore.cmor._fixes.cmip5.cesm1_bgc import Gpp from esmvalcore.cmor._fixes.cmip6.cesm2 import Omon, Tos -from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import ( - Tas, -) +from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import Tas from esmvalcore.cmor._fixes.cordex.cordex_fixes import AllVars from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_native_datasets.py b/tests/integration/cmor/_fixes/test_native_datasets.py index 5399bf887e..1a732f1788 100644 --- a/tests/integration/cmor/_fixes/test_native_datasets.py +++ b/tests/integration/cmor/_fixes/test_native_datasets.py @@ -89,7 +89,6 @@ def fix(): We use `tas` as a dummy variable here, but will use monkeypatching to customize the variable information of the fix in the tests below. This will allow us to test all common cases. - """ vardef = get_var_info('CMIP6', 'Amon', 'tas') extra_facets = {} diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index fbddec7fe0..cc4237f5b7 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -43,9 +43,8 @@ def create_test_file(filename, tracking_id=None): def _get_files(root_path, facets, tracking_id): """Return dummy files. - Wildcards are only supported for `dataset` and `institute`; in this case - return files for the two "models" AAA and BBB. - + Wildcards are only supported for `dataset` and `institute`; in this + case return files for the two "models" AAA and BBB. """ if facets['dataset'] == '*': all_facets = [ @@ -141,7 +140,6 @@ def patched_failing_datafinder(tmp_path, monkeypatch): - Variable rsutcs for model AAA Otherwise, return files just like `patched_datafinder`. - """ def tracking_ids(i=0): diff --git a/tests/integration/data_finder.yml b/tests/integration/data_finder.yml index 40e0c3e821..9b90bc7da6 100644 --- a/tests/integration/data_finder.yml +++ b/tests/integration/data_finder.yml @@ -452,7 +452,7 @@ get_input_filelist: - ta_Amon_HadGEM2-ES_historical_r1i1p1*.nc found_files: - historical/Amon/ta/HadGEM2-ES/r1i1p1/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -472,7 +472,7 @@ get_input_filelist: found_files: - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_195912-198411.nc - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -593,7 +593,7 @@ get_input_filelist: found_files: - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_195001-199912.nc - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_200001-200112.nc - + - drs: NCI variable: variable_group: test diff --git a/tests/integration/preprocessor/_extract_region/test_intersect.py b/tests/integration/preprocessor/_extract_region/test_intersect.py index 41442c9c01..813576e4c6 100644 --- a/tests/integration/preprocessor/_extract_region/test_intersect.py +++ b/tests/integration/preprocessor/_extract_region/test_intersect.py @@ -1,8 +1,8 @@ -""" -Temporary test. +"""Temporary test. Remove this test and test file after iris fixes this -https://github.com/SciTools/iris/issues/5413 . +https://github.com/SciTools/iris/issues/5413 +. """ import iris import numpy as np diff --git a/tests/integration/preprocessor/_mask/__init__.py b/tests/integration/preprocessor/_mask/__init__.py index 9886ea9eed..1b1a5d625b 100644 --- a/tests/integration/preprocessor/_mask/__init__.py +++ b/tests/integration/preprocessor/_mask/__init__.py @@ -1,5 +1,4 @@ -""" -Test _mask.py +"""Test _mask.py. Integration tests for the esmvalcore.preprocessor._mask module """ diff --git a/tests/integration/preprocessor/_regrid/__init__.py b/tests/integration/preprocessor/_regrid/__init__.py index e19e118a0f..bb8eab5e54 100644 --- a/tests/integration/preprocessor/_regrid/__init__.py +++ b/tests/integration/preprocessor/_regrid/__init__.py @@ -1,4 +1 @@ -""" -Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module. - -""" +"""Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module.""" diff --git a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py index 7b4d4eb9b5..f666ff64cf 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py +++ b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py @@ -1,8 +1,5 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function.""" import unittest @@ -23,7 +20,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point""" + """Test linear interpolation when extracting a single point.""" point = extract_coordinate_points( self.cube, {'grid_latitude': 2.1, 'grid_longitude': 2.1}, @@ -66,7 +63,7 @@ def test_extract_point__single_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point""" + """Test nearest match when extracting a single point.""" point = extract_coordinate_points( self.cube, @@ -99,7 +96,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate""" + """Test linear interpolation for an array of one coordinate.""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -151,7 +148,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate""" + """Test nearest match for an array of one coordinate.""" point = extract_coordinate_points( self.cube, @@ -192,8 +189,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with - linear interpolation""" + """Test for both latitude and longitude arrays, with linear + interpolation.""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], @@ -223,7 +220,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match""" + """Test for both latitude and longitude arrays, with nearest match.""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], diff --git a/tests/integration/preprocessor/_regrid/test_extract_point.py b/tests/integration/preprocessor/_regrid/test_extract_point.py index d3d93945b9..79ec2e5685 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_point.py +++ b/tests/integration/preprocessor/_regrid/test_extract_point.py @@ -1,8 +1,5 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function.""" import unittest @@ -23,7 +20,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point""" + """Test linear interpolation when extracting a single point.""" point = extract_point(self.cube, 2.1, 2.1, scheme='linear') self.assertEqual(point.shape, (3,)) @@ -58,7 +55,7 @@ def test_extract_point__single_linear(self): assert point.data.mask.all() def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point""" + """Test nearest match when extracting a single point.""" point = extract_point(self.cube, 2.1, 2.1, scheme='nearest') self.assertEqual(point.shape, (3,)) @@ -79,7 +76,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate""" + """Test linear interpolation for an array of one coordinate.""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -121,7 +118,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate""" + """Test nearest match for an array of one coordinate.""" point = extract_point(self.cube, [1, 1.1, 1.5, 1.501, 2, 4], 2, scheme='nearest') @@ -150,8 +147,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with - linear interpolation""" + """Test for both latitude and longitude arrays, with linear + interpolation.""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='linear') self.assertEqual(point.data.shape, (3, 6, 6)) @@ -179,7 +176,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match""" + """Test for both latitude and longitude arrays, with nearest match.""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='nearest') self.assertEqual(point.data.shape, (3, 6, 6)) diff --git a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py index b4f869d171..b7a2ed0bcd 100644 --- a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py +++ b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py @@ -1,8 +1,6 @@ -""" -Integration tests for the :func: -`esmvalcore.preprocessor.regrid.get_cmor_levels` -function. +"""Integration tests for the :func: +`esmvalcore.preprocessor.regrid.get_cmor_levels` function. """ import unittest diff --git a/tests/integration/preprocessor/_regrid/test_regrid.py b/tests/integration/preprocessor/_regrid/test_regrid.py index 4e2e472681..00f35c0ad8 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid.py +++ b/tests/integration/preprocessor/_regrid/test_regrid.py @@ -1,8 +1,5 @@ -""" -Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function. - -""" +"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function.""" import iris import numpy as np diff --git a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py index fee070863c..8b410771fc 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py +++ b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py @@ -1,4 +1,4 @@ -""" Integration tests for unstructured regridding.""" +"""Integration tests for unstructured regridding.""" import numpy as np import pytest diff --git a/tests/integration/preprocessor/_supplementary_vars/test_register.py b/tests/integration/preprocessor/_supplementary_vars/test_register.py index cfe6d5b7da..bf4c1677d2 100644 --- a/tests/integration/preprocessor/_supplementary_vars/test_register.py +++ b/tests/integration/preprocessor/_supplementary_vars/test_register.py @@ -28,7 +28,7 @@ def test_func(): def test_register_invalid_fails(): - """test that registering an invalid requirement fails.""" + """Test that registering an invalid requirement fails.""" with pytest.raises(NotImplementedError): @_supplementary_vars.register_supplementaries( diff --git a/tests/integration/test_citation.py b/tests/integration/test_citation.py index 339cd253a0..2bf34b4858 100644 --- a/tests/integration/test_citation.py +++ b/tests/integration/test_citation.py @@ -4,8 +4,11 @@ from prov.model import ProvDocument import esmvalcore -from esmvalcore._citation import (CMIP6_URL_STEM, ESMVALTOOL_PAPER, - _write_citation_files) +from esmvalcore._citation import ( + CMIP6_URL_STEM, + ESMVALTOOL_PAPER, + _write_citation_files, +) from esmvalcore._provenance import ESMVALTOOL_URI_PREFIX diff --git a/tests/parse_pymon.py b/tests/parse_pymon.py index e63da518cc..a9e9b21891 100644 --- a/tests/parse_pymon.py +++ b/tests/parse_pymon.py @@ -1,7 +1,7 @@ -""" -Parse and display test memory. +"""Parse and display test memory. -Uses pytest-monitor plugin from https://github.com/CFMTech/pytest-monitor +Uses pytest-monitor plugin from +https://github.com/CFMTech/pytest-monitor Lots of other metrics can be read from the file via sqlite parsing., currently just MEM_USAGE (RES memory, in MB). """ diff --git a/tests/sample_data/multimodel_statistics/test_multimodel.py b/tests/sample_data/multimodel_statistics/test_multimodel.py index 4c40d94875..b99e183cbb 100644 --- a/tests/sample_data/multimodel_statistics/test_multimodel.py +++ b/tests/sample_data/multimodel_statistics/test_multimodel.py @@ -204,7 +204,6 @@ def test_multimodel_regression_month(timeseries_cubes_month, span): """Test statistic fail due to differing input coordinates (pressure). See https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = timeseries_cubes_month name = 'timeseries_monthly' @@ -294,7 +293,6 @@ def test_multimodel_merge_error(timeseries_cubes_month, span): """Test statistic with slightly different vertical coordinates. See https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = timeseries_cubes_month msg = ( @@ -322,7 +320,6 @@ def test_multimodel_no_time_dimension(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -350,7 +347,6 @@ def test_multimodel_0d_1d_time_no_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -369,7 +365,6 @@ def test_multimodel_0d_1d_time_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -394,7 +389,6 @@ def test_multimodel_only_some_time_dimensions(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim @@ -420,7 +414,6 @@ def test_multimodel_diff_scalar_time_fail(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -442,7 +435,6 @@ def test_multimodel_diff_scalar_time_ignore(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -465,7 +457,6 @@ def test_multimodel_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): @@ -491,7 +482,6 @@ def test_multimodel_do_not_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. - """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): diff --git a/tests/unit/cmor/test_cmor_check.py b/tests/unit/cmor/test_cmor_check.py index 957136fd42..e1ba8ce9ac 100644 --- a/tests/unit/cmor/test_cmor_check.py +++ b/tests/unit/cmor/test_cmor_check.py @@ -137,7 +137,7 @@ def test_warning_fail_on_error(self): ) def test_report_debug_message(self): - """"Test report debug message function""" + """"Test report debug message function.""" checker = CMORCheck(self.cube, self.var_info) self.assertFalse(checker.has_debug_messages()) checker.report_debug_message('New debug message') @@ -270,8 +270,8 @@ def test_rank_unstructured_grid(self): self._check_cube() def test_bad_generic_level(self): - """Test check fails in metadata if generic level coord - has wrong var_name.""" + """Test check fails in metadata if generic level coord has wrong + var_name.""" depth_coord = CoordinateInfoMock('depth') depth_coord.axis = 'Z' depth_coord.generic_lev_name = 'olevel' @@ -385,26 +385,26 @@ def test_check_bad_coord_var_name_strict_flag(self): self._check_fails_in_metadata() def test_check_missing_lon_strict_flag(self): - """Test check fails for missing longitude with --cmor-check strict""" + """Test check fails for missing longitude with --cmor-check strict.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata() def test_check_missing_lat_strict_flag(self): - """Test check fails for missing latitude with --cmor-check strict""" + """Test check fails for missing latitude with --cmor-check strict.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata() def test_check_missing_time_strict_flag(self): - """Test check fails for missing time with --cmor-check strict""" + """Test check fails for missing time with --cmor-check strict.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata() def test_check_missing_coord_strict_flag(self): - """Test check fails for missing coord other than lat and lon - with --cmor-check strict""" + """Test check fails for missing coord other than lat and lon with + --cmor-check strict.""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -453,26 +453,26 @@ def test_check_bad_coord_standard_name_relaxed_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lon_relaxed_flag(self): - """Test check fails for missing longitude with --cmor-check relaxed""" + """Test check fails for missing longitude with --cmor-check relaxed.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lat_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed""" + """Test check fails for missing latitude with --cmor-check relaxed.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_time_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed""" + """Test check fails for missing latitude with --cmor-check relaxed.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_coord_relaxed_flag(self): """Test check reports warning for missing coord other than lat and lon - with --cmor-check relaxed""" + with --cmor-check relaxed.""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -535,15 +535,15 @@ def test_check_missing_lat_none_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_time_none_flag(self): - """Test check reports warning for missing time - with --cmor-check ignore""" + """Test check reports warning for missing time with --cmor-check + ignore.""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_coord_none_flag(self): """Test check reports warning for missing coord other than lat, lon and - time with --cmor-check ignore""" + time with --cmor-check ignore.""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -603,11 +603,10 @@ def _check_debug_messages_on_metadata(self): self.assertTrue(checker.has_debug_messages()) def test_non_requested(self): - """ - Warning if requested values are not present. + """Warning if requested values are not present. - Check issue a warning if a values requested - for a coordinate are not correct in the metadata step + Check issue a warning if a values requested for a coordinate are + not correct in the metadata step """ coord = self.cube.coord('air_pressure') values = np.linspace(0, 40, len(coord.points)) @@ -617,11 +616,10 @@ def test_non_requested(self): self.assertTrue(checker.has_warnings()) def test_requested_str_values(self): - """ - Warning if requested values are not present. + """Warning if requested values are not present. - Check issue a warning if a values requested - for a coordinate are not correct in the metadata step + Check issue a warning if a values requested for a coordinate are + not correct in the metadata step """ region_coord = CoordinateInfoMock('basin') region_coord.standard_name = 'region' @@ -808,19 +806,19 @@ def test_bad_out_name_region_area_type(self): self._check_debug_messages_on_metadata() def test_bad_out_name_onedim_latitude(self): - """Warning if onedimensional lat has bad var_name at metadata""" + """Warning if onedimensional lat has bad var_name at metadata.""" self.var_info.table_type = 'CMIP6' self.cube.coord('latitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_onedim_longitude(self): - """Warning if onedimensional lon has bad var_name at metadata""" + """Warning if onedimensional lon has bad var_name at metadata.""" self.var_info.table_type = 'CMIP6' self.cube.coord('longitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_other(self): - """Warning if general coordinate has bad var_name at metadata""" + """Warning if general coordinate has bad var_name at metadata.""" self.var_info.table_type = 'CMIP6' self.cube.coord('time').var_name = 'bad_name' self._check_fails_in_metadata() @@ -927,8 +925,7 @@ def get_cube(self, var_info, set_time_units="days since 1850-1-1 00:00:00", frequency=None): - """ - Create a cube based on a specification. + """Create a cube based on a specification. Parameters ---------- @@ -942,7 +939,6 @@ def get_cube(self, Returns ------- iris.cube.Cube - """ coords = [] scalar_coords = [] diff --git a/tests/unit/preprocessor/_derive/test_toz.py b/tests/unit/preprocessor/_derive/test_toz.py index 262deab1e0..12dee514a5 100644 --- a/tests/unit/preprocessor/_derive/test_toz.py +++ b/tests/unit/preprocessor/_derive/test_toz.py @@ -5,6 +5,7 @@ import pytest import esmvalcore.preprocessor._derive.toz as toz + from .test_co2s import get_coord_spec, get_ps_cube diff --git a/tests/unit/preprocessor/_detrend/test_detrend.py b/tests/unit/preprocessor/_detrend/test_detrend.py index 9b53f65d51..acf9c6cbe0 100644 --- a/tests/unit/preprocessor/_detrend/test_detrend.py +++ b/tests/unit/preprocessor/_detrend/test_detrend.py @@ -4,11 +4,10 @@ import iris import iris.coords -from iris.cube import Cube import numpy as np import pytest from cf_units import Unit - +from iris.cube import Cube from numpy.testing import assert_array_almost_equal from esmvalcore.preprocessor._detrend import detrend diff --git a/tests/unit/preprocessor/_mapping/test_mapping.py b/tests/unit/preprocessor/_mapping/test_mapping.py index dc838b3a54..2af937349c 100644 --- a/tests/unit/preprocessor/_mapping/test_mapping.py +++ b/tests/unit/preprocessor/_mapping/test_mapping.py @@ -6,8 +6,11 @@ import numpy as np import tests -from esmvalcore.preprocessor._mapping import (get_empty_data, map_slices, - ref_to_dims_index) +from esmvalcore.preprocessor._mapping import ( + get_empty_data, + map_slices, + ref_to_dims_index, +) class TestHelpers(tests.Test): diff --git a/tests/unit/preprocessor/_regrid/__init__.py b/tests/unit/preprocessor/_regrid/__init__.py index 2c0e5a2f47..5774c41a41 100644 --- a/tests/unit/preprocessor/_regrid/__init__.py +++ b/tests/unit/preprocessor/_regrid/__init__.py @@ -1,9 +1,7 @@ -""" -Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module. - -""" +"""Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module.""" from typing import Literal + import iris import iris.fileformats import numpy as np @@ -11,10 +9,7 @@ def _make_vcoord(data, dtype=None): - """ - Create a synthetic test vertical coordinate. - - """ + """Create a synthetic test vertical coordinate.""" if dtype is None: dtype = np.dtype('int8') @@ -47,10 +42,7 @@ def _make_cube( dtype=None, grid: Literal['regular', 'rotated', 'mesh'] = 'regular', ): - """ - Create a 3d synthetic test cube. - - """ + """Create a 3d synthetic test cube.""" if dtype is None: dtype = np.dtype('int8') diff --git a/tests/unit/preprocessor/_regrid/test__create_cube.py b/tests/unit/preprocessor/_regrid/test__create_cube.py index e0f65eab78..cfb4434bb4 100644 --- a/tests/unit/preprocessor/_regrid/test__create_cube.py +++ b/tests/unit/preprocessor/_regrid/test__create_cube.py @@ -1,8 +1,5 @@ -""" -Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` -function. - -""" +"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` +function.""" import unittest diff --git a/tests/unit/preprocessor/_regrid/test__stock_cube.py b/tests/unit/preprocessor/_regrid/test__stock_cube.py index 8142b66ed8..8b2290f531 100644 --- a/tests/unit/preprocessor/_regrid/test__stock_cube.py +++ b/tests/unit/preprocessor/_regrid/test__stock_cube.py @@ -1,8 +1,5 @@ -""" -Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` -function. - -""" +"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` +function.""" import unittest from unittest import mock diff --git a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py index 5896f442ba..1375027263 100644 --- a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py +++ b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py @@ -1,8 +1,8 @@ """Tests for `esmvalcore.preprocessor._regrid_iris_esmf_regrid`.""" +import esmf_regrid import iris.cube import numpy as np import pytest -import esmf_regrid from esmvalcore.preprocessor.regrid_schemes import IrisESMFRegrid diff --git a/tests/unit/preprocessor/_volume/test_volume.py b/tests/unit/preprocessor/_volume/test_volume.py index d45b9bd744..1370cc5765 100644 --- a/tests/unit/preprocessor/_volume/test_volume.py +++ b/tests/unit/preprocessor/_volume/test_volume.py @@ -435,9 +435,8 @@ def test_volume_statistics(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_volume_nolevbounds(self): - """Test to take the volume weighted average of a cube with no bounds - in the z axis. - """ + """Test to take the volume weighted average of a cube with no bounds in + the z axis.""" self.assertFalse(self.grid_4d_znobounds.coord(axis='z').has_bounds()) result = volume_statistics(self.grid_4d_znobounds, 'mean') @@ -449,7 +448,7 @@ def test_volume_nolevbounds(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_calculate_volume_lazy(self): - """Test that calculate_volume returns a lazy volume + """Test that calculate_volume returns a lazy volume. The volume chunks should match those of the input cube for computational efficiency. @@ -600,7 +599,7 @@ def test_volume_statistics_2d_lat_cellarea(self): self.assertEqual(result.units, 'kg m-3') def test_volume_statistics_invalid_bounds(self): - """Test z-axis bounds is not 2 in last dimension""" + """Test z-axis bounds is not 2 in last dimension.""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_invalid_z_bounds, 'mean') @@ -611,7 +610,7 @@ def test_volume_statistics_invalid_bounds(self): ) def test_volume_statistics_invalid_units(self): - """Test z-axis units cannot be converted to m""" + """Test z-axis units cannot be converted to m.""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_4d_sigma_space, 'mean') diff --git a/tests/unit/test_dataset.py b/tests/unit/test_dataset.py index 25129dbf5d..c583252993 100644 --- a/tests/unit/test_dataset.py +++ b/tests/unit/test_dataset.py @@ -890,7 +890,8 @@ def test_from_files_with_globs(monkeypatch, session): def test_from_files_with_globs_and_missing_facets(monkeypatch, session): """Test `from_files` with wildcards and files with missing facets. - Tests a combination of files with complete facets and missing facets. + Tests a combination of files with complete facets and missing + facets. """ rootpath = Path('/path/to/data') file1 = esmvalcore.local.LocalFile( @@ -973,8 +974,8 @@ def test_from_files_with_globs_and_missing_facets(monkeypatch, session): def test_from_files_with_globs_and_automatic_missing(monkeypatch, session): """Test `from_files`. - Test with wildcards and files with missing facets that can be automatically - added. + Test with wildcards and files with missing facets that can be + automatically added. """ rootpath = Path('/path/to/data') file = esmvalcore.local.LocalFile( diff --git a/tests/unit/test_iris_io.py b/tests/unit/test_iris_io.py index 1b81c78d2f..500aa492d9 100644 --- a/tests/unit/test_iris_io.py +++ b/tests/unit/test_iris_io.py @@ -41,8 +41,7 @@ def create_regular_cube(): def test_iris_save_with_lazy_coordinate(tmp_path): - """ - Test saving a cube with fully lazy coords and data. + """Test saving a cube with fully lazy coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ @@ -56,8 +55,7 @@ def test_iris_save_with_lazy_coordinate(tmp_path): def test_iris_save_with_regular_coordinate(tmp_path): - """ - Test saving a cube with numpy array coords and data. + """Test saving a cube with numpy array coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ diff --git a/tests/unit/test_naming.py b/tests/unit/test_naming.py index 41971a60a8..1a9255c255 100644 --- a/tests/unit/test_naming.py +++ b/tests/unit/test_naming.py @@ -1,20 +1,19 @@ -"""Checks to ensure that files follow the naming convention""" +"""Checks to ensure that files follow the naming convention.""" import os import unittest class TestNaming(unittest.TestCase): - """Test naming of files and folders""" + """Test naming of files and folders.""" def setUp(self): - """Prepare tests""" + """Prepare tests.""" folder = os.path.join(__file__, '..', '..', '..') self.esmvaltool_folder = os.path.abspath(folder) def test_windows_reserved_names(self): - """ - Check that no file or folder uses a Windows reserved name + """Check that no file or folder uses a Windows reserved name. Files can not differ from a reserved name by the extension only """ @@ -37,8 +36,7 @@ def test_windows_reserved_names(self): reserved_names.isdisjoint(without_extensions), error_msg) def test_avoid_casing_collisions(self): - """ - Check that there are no names differing only in the capitalization + """Check that there are no names differing only in the capitalization. This includes folders differing from files """ @@ -52,8 +50,8 @@ def test_avoid_casing_collisions(self): 'capitalization'.format(dirpath)) def test_no_namelist(self): - """ - Check that there are no namelist references in file and folder names + """Check that there are no namelist references in file and folder + names. This will help us to avoid bad merges with stale branches """ From 294d17f1817e2af37d71c4c574801877b8d9d6ad Mon Sep 17 00:00:00 2001 From: Valeriu Predoi Date: Tue, 17 Sep 2024 16:20:33 +0100 Subject: [PATCH 5/5] Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit 7196f1674d9a8b67190601c9875f38856bbd6885. --- .editorconfig | 1 + .github/CODEOWNERS | 1 + CITATION.cff | 2 +- NOTICE | 2 + doc/contributing.rst | 22 ++++---- doc/quickstart/install.rst | 2 +- doc/quickstart/run.rst | 2 +- doc/recipe/index.rst | 2 +- esmvalcore/_citation.py | 9 +-- esmvalcore/_main.py | 7 +-- esmvalcore/_recipe/recipe.py | 14 ++--- esmvalcore/cmor/_fixes/__init__.py | 7 ++- esmvalcore/cmor/_fixes/cesm/cesm2.py | 2 + esmvalcore/cmor/_fixes/cmip5/access1_0.py | 4 +- esmvalcore/cmor/_fixes/cmip5/access1_3.py | 2 + esmvalcore/cmor/_fixes/cmip5/bnu_esm.py | 36 +++++++++--- esmvalcore/cmor/_fixes/cmip5/canesm2.py | 5 +- esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py | 2 + esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py | 4 +- .../cmor/_fixes/cmip5/cesm1_fastchem.py | 1 + esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py | 1 + esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py | 5 +- esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py | 1 + esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py | 1 + esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py | 1 + esmvalcore/cmor/_fixes/cmip5/fio_esm.py | 10 +++- esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py | 19 +++++-- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py | 16 ++++-- esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py | 21 +++++-- esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py | 1 + esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py | 1 + esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py | 5 +- esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py | 2 + esmvalcore/cmor/_fixes/cmip5/inmcm4.py | 17 ++++-- esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py | 1 + esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py | 1 + esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py | 1 + esmvalcore/cmor/_fixes/cmip5/miroc5.py | 18 ++++-- esmvalcore/cmor/_fixes/cmip5/miroc_esm.py | 12 +++- .../cmor/_fixes/cmip5/miroc_esm_chem.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py | 5 +- esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py | 1 + esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py | 1 + esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py | 9 ++- esmvalcore/cmor/_fixes/cmip5/mri_esm1.py | 5 +- esmvalcore/cmor/_fixes/cmip5/noresm1_m.py | 1 + esmvalcore/cmor/_fixes/cmip5/noresm1_me.py | 2 + esmvalcore/cmor/_fixes/cmip6/access_cm2.py | 1 + esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py | 1 + esmvalcore/cmor/_fixes/cmip6/canesm5.py | 2 + esmvalcore/cmor/_fixes/cmip6/cesm2.py | 18 ++++-- esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py | 3 +- esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py | 1 + .../cmor/_fixes/cmip6/cesm2_waccm_fv2.py | 5 +- esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py | 1 + esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py | 1 + esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py | 1 + .../cmor/_fixes/cmip6/ec_earth3_veg_lr.py | 1 + esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py | 9 ++- esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py | 9 ++- esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py | 1 + .../cmor/_fixes/cmip6/hadgem3_gc31_ll.py | 1 + .../cmor/_fixes/cmip6/ipsl_cm5a2_inca.py | 1 + esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py | 5 +- .../cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py | 1 + esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py | 4 ++ esmvalcore/cmor/_fixes/cmip6/miroc6.py | 4 +- esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py | 1 + esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py | 4 +- esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py | 1 + esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py | 2 + esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py | 1 + .../cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py | 4 +- .../cordex/ichec_ec_earth/cclm4_8_17.py | 4 +- .../cordex/ichec_ec_earth/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ichec_ec_earth/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ichec_ec_earth/rca4.py | 3 +- .../_fixes/cordex/ichec_ec_earth/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/cclm4_8_17.py | 4 +- .../_fixes/cordex/miroc_miroc5/remo2015.py | 3 +- .../_fixes/cordex/miroc_miroc5/wrf361h.py | 2 +- .../cordex/mohc_hadgem2_es/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/mohc_hadgem2_es/hirham5.py | 1 + .../_fixes/cordex/mohc_hadgem2_es/rca4.py | 3 +- .../_fixes/cordex/mohc_hadgem2_es/remo2015.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py | 4 +- .../cordex/mpi_m_mpi_esm_lr/racmo22e.py | 3 +- .../cordex/mpi_m_mpi_esm_lr/regcm4_6.py | 3 +- .../cordex/ncc_noresm1_m/hadrem3_ga7_05.py | 4 +- .../_fixes/cordex/ncc_noresm1_m/racmo22e.py | 3 +- .../cmor/_fixes/cordex/ncc_noresm1_m/rca4.py | 3 +- .../_fixes/cordex/ncc_noresm1_m/remo2015.py | 3 +- esmvalcore/cmor/_fixes/emac/emac.py | 3 + esmvalcore/cmor/_fixes/fix.py | 14 +++-- esmvalcore/cmor/_fixes/icon/_base_fixes.py | 15 +++-- esmvalcore/cmor/_fixes/icon/icon.py | 1 + esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py | 12 ++-- esmvalcore/cmor/_fixes/native6/era5_land.py | 11 ++-- esmvalcore/cmor/_fixes/native_datasets.py | 13 +++++ esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py | 1 + esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py | 4 +- esmvalcore/cmor/_fixes/obs4mips/ssmi.py | 1 + esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py | 5 +- esmvalcore/cmor/_fixes/shared.py | 2 + esmvalcore/cmor/_utils.py | 3 + esmvalcore/cmor/check.py | 5 ++ esmvalcore/cmor/fix.py | 3 + esmvalcore/cmor/table.py | 56 ++++++++++--------- esmvalcore/config/__init__.py | 1 + esmvalcore/config/_config_object.py | 3 + esmvalcore/config/_esgf_pyclient.py | 2 +- esmvalcore/config/_validated_config.py | 5 +- .../config/extra_facets/access-mappings.yml | 34 +++++------ esmvalcore/dataset.py | 3 +- esmvalcore/iris_helpers.py | 6 ++ esmvalcore/preprocessor/__init__.py | 4 +- esmvalcore/preprocessor/_area.py | 8 +++ esmvalcore/preprocessor/_compare_with_refs.py | 2 + esmvalcore/preprocessor/_cycles.py | 1 + esmvalcore/preprocessor/_derive/_baseclass.py | 2 + esmvalcore/preprocessor/_derive/_shared.py | 3 + esmvalcore/preprocessor/_derive/alb.py | 1 + esmvalcore/preprocessor/_derive/ctotal.py | 1 + esmvalcore/preprocessor/_derive/lvp.py | 1 + esmvalcore/preprocessor/_derive/lwp.py | 1 + esmvalcore/preprocessor/_derive/ohc.py | 6 +- esmvalcore/preprocessor/_derive/rlnst.py | 8 ++- esmvalcore/preprocessor/_derive/rlnstcs.py | 8 ++- esmvalcore/preprocessor/_derive/rlus.py | 1 + esmvalcore/preprocessor/_derive/rsnst.py | 1 + esmvalcore/preprocessor/_derive/rsnstcs.py | 1 + .../preprocessor/_derive/rsnstcsnorm.py | 10 ++-- esmvalcore/preprocessor/_derive/rsus.py | 1 + esmvalcore/preprocessor/_derive/siextent.py | 1 - esmvalcore/preprocessor/_derive/sispeed.py | 6 +- esmvalcore/preprocessor/_derive/sithick.py | 4 +- esmvalcore/preprocessor/_derive/sm.py | 1 + esmvalcore/preprocessor/_derive/toz.py | 1 + esmvalcore/preprocessor/_detrend.py | 3 +- esmvalcore/preprocessor/_mapping.py | 33 ++++++----- esmvalcore/preprocessor/_multimodel.py | 25 +++++---- esmvalcore/preprocessor/_other.py | 15 +++-- esmvalcore/preprocessor/_regrid.py | 4 +- esmvalcore/preprocessor/_regrid_esmpy.py | 11 +++- .../preprocessor/_regrid_unstructured.py | 16 ++++-- esmvalcore/preprocessor/_rolling_window.py | 1 + esmvalcore/preprocessor/_shared.py | 17 ++++-- esmvalcore/preprocessor/_time.py | 22 ++++++++ esmvalcore/preprocessor/_trend.py | 2 + esmvalcore/preprocessor/_units.py | 1 + esmvalcore/preprocessor/_volume.py | 7 +++ esmvalcore/preprocessor/shapefiles/ar6.prj | 2 +- esmvalcore/typing.py | 4 +- .../cmor/_fixes/cmip5/test_bnu_esm.py | 2 +- .../cmor/_fixes/cmip5/test_cnrm_cm5.py | 4 +- .../cmor/_fixes/cmip5/test_ec_earth.py | 10 ++-- .../cmor/_fixes/cmip5/test_fio_esm.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_cm2p1.py | 6 +- .../cmor/_fixes/cmip5/test_gfdl_cm3.py | 4 +- .../cmor/_fixes/cmip5/test_gfdl_esm2g.py | 8 +-- .../cmor/_fixes/cmip5/test_gfdl_esm2m.py | 6 +- .../cmor/_fixes/cmip5/test_hadgem2_cc.py | 4 +- .../cmor/_fixes/cmip5/test_miroc_esm_chem.py | 2 +- .../cmor/_fixes/cmip5/test_mri_esm1.py | 2 +- .../cmor/_fixes/cmip5/test_noresm1_me.py | 2 +- .../cmor/_fixes/cmip6/test_gfdl_cm4.py | 4 +- .../cordex/test_cnrm_cerfacs_cnrm_cm5.py | 3 +- .../cmor/_fixes/cordex/test_miroc_miroc5.py | 2 +- tests/integration/cmor/_fixes/test_fix.py | 4 +- .../cmor/_fixes/test_native_datasets.py | 1 + tests/integration/conftest.py | 6 +- tests/integration/data_finder.yml | 6 +- .../_extract_region/test_intersect.py | 6 +- .../preprocessor/_mask/__init__.py | 3 +- .../preprocessor/_regrid/__init__.py | 5 +- .../_regrid/test_extract_coordinate_points.py | 21 ++++--- .../_regrid/test_extract_point.py | 21 ++++--- .../_regrid/test_get_cmor_levels.py | 6 +- .../preprocessor/_regrid/test_regrid.py | 7 ++- .../_regrid/test_regrid_unstructured.py | 2 +- .../_supplementary_vars/test_register.py | 2 +- tests/integration/test_citation.py | 7 +-- tests/parse_pymon.py | 6 +- .../multimodel_statistics/test_multimodel.py | 10 ++++ tests/unit/cmor/test_cmor_check.py | 54 +++++++++--------- tests/unit/preprocessor/_derive/test_toz.py | 1 - .../preprocessor/_detrend/test_detrend.py | 3 +- .../preprocessor/_mapping/test_mapping.py | 7 +-- tests/unit/preprocessor/_regrid/__init__.py | 16 ++++-- .../preprocessor/_regrid/test__create_cube.py | 7 ++- .../preprocessor/_regrid/test__stock_cube.py | 7 ++- .../test_regrid_iris_esmf_regrid.py | 2 +- .../unit/preprocessor/_volume/test_volume.py | 11 ++-- tests/unit/test_dataset.py | 7 +-- tests/unit/test_iris_io.py | 6 +- tests/unit/test_naming.py | 16 +++--- 196 files changed, 794 insertions(+), 391 deletions(-) diff --git a/.editorconfig b/.editorconfig index ddab414f89..97c8ef6e5a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -27,3 +27,4 @@ indent_size = 2 [*.{md,Rmd}] trim_trailing_whitespace = false + diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index eba6cf5dd4..1c8122dcbe 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,3 @@ esmvalcore/cmor @jvegasbsc .github/workflows @valeriupredoi + diff --git a/CITATION.cff b/CITATION.cff index 4d3da6e4c7..51f53cfb36 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -208,7 +208,7 @@ authors: affiliation: "DLR, Germany" family-names: Cammarano given-names: Diego - - + - affiliation: "ACCESS-NRI, Australia" family-names: Yousong given-names: Zeng diff --git a/NOTICE b/NOTICE index 5e413cd5ba..5bf9f5d0cd 100644 --- a/NOTICE +++ b/NOTICE @@ -50,3 +50,5 @@ In addition to using the Software, we encourage the community to join the Softwa To join the ESMValTool Development Team, please contact Dr. Birgit Hassler (birgit.hassler@dlr.de) and Dr. Axel Lauer (axel.lauer@dlr.de). ========================================== + + diff --git a/doc/contributing.rst b/doc/contributing.rst index 658306a53b..814ab79263 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -743,15 +743,15 @@ Perform the steps listed below with two persons, to reduce the risk of error. `PyPI `__, and `readthedocs `__. -The release of ESMValCore is tied to the release of ESMValTool. +The release of ESMValCore is tied to the release of ESMValTool. The detailed steps can be found in the ESMValTool :ref:`documentation `. -To start the procedure, ESMValCore gets released as a +To start the procedure, ESMValCore gets released as a release candidate to test the recipes in ESMValTool. If bugs are found -during the testing phase of the release candidate, make as many release -candidates for ESMValCore as needed in order to fix them. +during the testing phase of the release candidate, make as many release +candidates for ESMValCore as needed in order to fix them. -To make a new release of the package, be it a release candidate or the final release, +To make a new release of the package, be it a release candidate or the final release, follow these steps: 1. Check that all tests and builds work @@ -795,13 +795,13 @@ Use the script to create create a draft of the release notes. This script uses the titles and labels of merged pull requests since the previous release. -Open a discussion to allow members of the development team to nominate pull -requests as highlights. Add the most voted pull requests as highlights at the -beginning of changelog. After the highlights section, list any backward -incompatible changes that the release may include. The +Open a discussion to allow members of the development team to nominate pull +requests as highlights. Add the most voted pull requests as highlights at the +beginning of changelog. After the highlights section, list any backward +incompatible changes that the release may include. The :ref:`backward compatibility policy`. -lists the information that should be provided by the developer of any backward -incompatible change. Make sure to also list any deprecations that the release +lists the information that should be provided by the developer of any backward +incompatible change. Make sure to also list any deprecations that the release may include, as well as a brief description on how to upgrade a deprecated feature. Review the results, and if anything needs changing, change it on GitHub and re-run the script until the changelog looks acceptable. diff --git a/doc/quickstart/install.rst b/doc/quickstart/install.rst index 804c86ed20..7ef5015fe3 100644 --- a/doc/quickstart/install.rst +++ b/doc/quickstart/install.rst @@ -201,7 +201,7 @@ Pre-installed versions on HPC clusters / other servers If you would like to use pre-installed versions on HPC clusters (currently CEDA-JASMIN and DKRZ-Levante), -and other servers (currently Met Office Linux estate), please have a look at +and other servers (currently Met Office Linux estate), please have a look at :ref:`these instructions `. diff --git a/doc/quickstart/run.rst b/doc/quickstart/run.rst index 5eca15e714..ebde6d4075 100644 --- a/doc/quickstart/run.rst +++ b/doc/quickstart/run.rst @@ -79,7 +79,7 @@ This feature is available for projects that are hosted on the ESGF, i.e. CMIP3, CMIP5, CMIP6, CORDEX, and obs4MIPs. To control the strictness of the CMOR checker and the checks during concatenation -on auxiliary coordinates, supplementary variables, and derived coordinates, +on auxiliary coordinates, supplementary variables, and derived coordinates, use the flag ``--check_level``: .. code:: bash diff --git a/doc/recipe/index.rst b/doc/recipe/index.rst index 525b0467e1..98c3f6c237 100644 --- a/doc/recipe/index.rst +++ b/doc/recipe/index.rst @@ -8,4 +8,4 @@ The recipe format Overview Preprocessor - + \ No newline at end of file diff --git a/esmvalcore/_citation.py b/esmvalcore/_citation.py index 94ff97ad15..510aa8cb42 100644 --- a/esmvalcore/_citation.py +++ b/esmvalcore/_citation.py @@ -38,7 +38,8 @@ def _write_citation_files(filename, provenance): - """Write citation information provided by the recorded provenance. + """ + Write citation information provided by the recorded provenance. Recipe and cmip6 data references are saved into one bibtex file. cmip6 data references are provided by CMIP6 data citation service. @@ -134,9 +135,9 @@ def _save_citation_info_txt(product_name, info_urls, other_info): def _extract_tags(tags): """Extract tags. - Tags are recorded as a list of strings converted to a string in - provenance. For example, a single entry in the list `tags` could be - the string "['acknow_project', 'acknow_author']". + Tags are recorded as a list of strings converted to a string in provenance. + For example, a single entry in the list `tags` could be the string + "['acknow_project', 'acknow_author']". """ pattern = re.compile(r'[\w-]+') return set(pattern.findall(str(tags))) diff --git a/esmvalcore/_main.py b/esmvalcore/_main.py index 84dc5a35b0..75c0b20c94 100755 --- a/esmvalcore/_main.py +++ b/esmvalcore/_main.py @@ -206,8 +206,8 @@ def get_config_developer(cls, overwrite=False, path=None): class Recipes(): """List, show and retrieve installed recipes. - This group contains utilities to explore and manage the recipes - available in your installation of ESMValTool. + This group contains utilities to explore and manage the recipes available + in your installation of ESMValTool. Documentation for recipes included with ESMValTool is available at https://docs.esmvaltool.org/en/latest/recipes/index.html. @@ -294,8 +294,7 @@ class ESMValTool(): multiple models, either against predecessor versions or against observations. - Documentation is available at - https://docs.esmvaltool.org. + Documentation is available at https://docs.esmvaltool.org. To report issues or ask for improvements, please visit https://github.com/ESMValGroup/ESMValTool. diff --git a/esmvalcore/_recipe/recipe.py b/esmvalcore/_recipe/recipe.py index 5633ab0e57..1f2eb63488 100644 --- a/esmvalcore/_recipe/recipe.py +++ b/esmvalcore/_recipe/recipe.py @@ -399,14 +399,12 @@ def _update_multiproduct(input_products, order, preproc_dir, step): """Return new products that are aggregated over multiple datasets. These new products will replace the original products at runtime. - Therefore, they need to have all the settings for the remaining - steps. - - The functions in _multimodel.py take output_products as function - arguments. These are the output_products created here. But since - those functions are called from the input products, the products - that are created here need to be added to their ancestors products' - settings (). + Therefore, they need to have all the settings for the remaining steps. + + The functions in _multimodel.py take output_products as function arguments. + These are the output_products created here. But since those functions are + called from the input products, the products that are created here need to + be added to their ancestors products' settings (). """ products = {p for p in input_products if step in p.settings} if not products: diff --git a/esmvalcore/cmor/_fixes/__init__.py b/esmvalcore/cmor/_fixes/__init__.py index d9e50af443..e50e749659 100644 --- a/esmvalcore/cmor/_fixes/__init__.py +++ b/esmvalcore/cmor/_fixes/__init__.py @@ -1,5 +1,6 @@ -"""Automatic fixes for input data. +""" +Automatic fixes for input data -Module to apply automatic fixes at different levels to input data for -known errors. +Module to apply automatic fixes at different levels to input data for known +errors. """ diff --git a/esmvalcore/cmor/_fixes/cesm/cesm2.py b/esmvalcore/cmor/_fixes/cesm/cesm2.py index ada216007a..5b92121555 100644 --- a/esmvalcore/cmor/_fixes/cesm/cesm2.py +++ b/esmvalcore/cmor/_fixes/cesm/cesm2.py @@ -12,6 +12,7 @@ (esmvalcore/_config/extra_facets/cesm-mappings.yml) and/or add classes to this file for variables that need more complex fixes (see esmvalcore/cmor/_fixes/emac/emac.py for examples). + """ import logging @@ -63,6 +64,7 @@ def _fix_time(self, cube): Example of monthly time coordinate after this fix (Jan. & Feb. 2000): Points: ``[2000-01-15, 2000-02-14]`` Bounds: ``[[2000-01-01, 2000-02-01], [2000-02-01, 2000-03-01]]`` + """ # Only modify time points if data contains a time dimension, is monthly # data, and does not describe point measurements. diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_0.py b/esmvalcore/cmor/_fixes/cmip5/access1_0.py index eebc2fa616..4fa4da7554 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_0.py @@ -10,7 +10,8 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong calendar 'gregorian' instead of 'proleptic_gregorian'. @@ -22,6 +23,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/access1_3.py b/esmvalcore/cmor/_fixes/cmip5/access1_3.py index 6f581197ff..f026181660 100644 --- a/esmvalcore/cmor/_fixes/cmip5/access1_3.py +++ b/esmvalcore/cmor/_fixes/cmip5/access1_3.py @@ -5,6 +5,7 @@ from ..fix import Fix from .access1_0 import Cl as BaseCl + Cl = BaseCl @@ -24,6 +25,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py index 0198d08dda..e01639a306 100644 --- a/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/bnu_esm.py @@ -10,7 +10,8 @@ class Cl(ClFixHybridPressureCoord): """Fixes for cl.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -22,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -33,7 +35,8 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -45,12 +48,14 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = Unit('kg m-2 s-1') return cubes def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes cube units. @@ -62,6 +67,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 12.0 / 44.0 @@ -73,7 +79,8 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -85,12 +92,14 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = Unit('1e-9') return cubes def fix_data(self, cube): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -103,6 +112,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29.0 / 16.0 * 1.e9 @@ -114,7 +124,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes cube units. @@ -126,12 +137,14 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = Unit('1e-6') return cubes def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes cube units. @@ -143,6 +156,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29.0 / 44.0 * 1.e6 @@ -154,7 +168,8 @@ class SpCo2(Fix): """Fixes for spco2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes cube units. @@ -166,6 +181,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1.e6 @@ -177,7 +193,8 @@ class Od550Aer(Fix): """Fixes for od550aer.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Masks invalid values. @@ -189,6 +206,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ data = da.ma.masked_equal(cube.core_data(), 1.e36) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/canesm2.py b/esmvalcore/cmor/_fixes/cmip5/canesm2.py index e780f3e592..b445a4dc3a 100644 --- a/esmvalcore/cmor/_fixes/cmip5/canesm2.py +++ b/esmvalcore/cmor/_fixes/cmip5/canesm2.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -9,7 +10,8 @@ class FgCo2(Fix): """Fixes for fgco2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -21,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 12.0 / 44.0 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py index fe5dfbefa4..2e25296b8d 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_bgc.py @@ -5,6 +5,7 @@ from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl @@ -23,6 +24,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ data = da.ma.masked_equal(cube.core_data(), 1.0e33) return cube.copy(data) diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py index ae30726e2b..4c235dfcbc 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_cam5.py @@ -7,7 +7,8 @@ class Cl(Fix): """Fixes for cl.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -19,6 +20,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py index 319b96d261..d5ba1f7641 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_fastchem.py @@ -2,4 +2,5 @@ from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py index 86c5cbd349..818d14e4c2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip5/cesm1_waccm.py @@ -2,4 +2,5 @@ from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py index a5c5bcb017..71e6547461 100644 --- a/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py +++ b/esmvalcore/cmor/_fixes/cmip5/cnrm_cm5.py @@ -1,3 +1,4 @@ + """Fixes for CNRM-CM5 model.""" from ..fix import Fix @@ -6,7 +7,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -17,6 +19,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1e6 diff --git a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py index 846859c6b4..4c0a5a7564 100644 --- a/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py +++ b/esmvalcore/cmor/_fixes/cmip5/csiro_mk3_6_0.py @@ -1,4 +1,5 @@ """Fixes for CSIRO-Mk3-6-0 model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py index 0067b9f172..1c2df64db0 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_g2.py @@ -23,6 +23,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py index c1b3962abd..c82151226f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py +++ b/esmvalcore/cmor/_fixes/cmip5/fgoals_s2.py @@ -20,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py index 4935a56f92..cc9ed79421 100644 --- a/esmvalcore/cmor/_fixes/cmip5/fio_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/fio_esm.py @@ -1,7 +1,9 @@ + """Fixes for FIO ESM model.""" from ..fix import Fix from .cesm1_cam5 import Cl as BaseCl + Cl = BaseCl @@ -9,7 +11,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -20,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29. / 44. * 1.e6 @@ -31,7 +35,8 @@ class Ch4(Fix): """Fixes for ch4.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -42,6 +47,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 29. / 16. * 1.e9 diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py index 6104efdaaf..bc1b3cf9b6 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_cm3.py @@ -1,17 +1,19 @@ """Fixes for GFDL CM3 model.""" -from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars from ..fix import Fix +from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars + class AllVars(BaseAllVars): """Fixes for all variables.""" class Areacello(Fix): - """Fixes for areacello.""" + """Fixes for areacello""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong units. @@ -22,6 +24,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -32,7 +35,8 @@ class Sftof(Fix): """Fix sftof.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units. @@ -43,6 +47,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -51,10 +56,11 @@ def fix_data(self, cube): class Tos(Fix): - """Fixes for tos.""" + """Fixes for tos""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong standard_name. @@ -65,6 +71,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py index 1620f95b29..3ba4a6dd83 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2g.py @@ -1,3 +1,4 @@ + """Fixes for GFDL ESM2G.""" import iris @@ -28,6 +29,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ _get_and_remove(cubes, 'Start time for average period') _get_and_remove(cubes, 'End time for average period') @@ -36,10 +38,11 @@ def fix_metadata(self, cubes): class Areacello(Fix): - """Fixes for areacello.""" + """Fixes for areacello""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong units. @@ -50,6 +53,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -71,6 +75,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1e6 @@ -93,6 +98,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ _get_and_remove(cubes, 'Latitude of tracer (h) points') _get_and_remove(cubes, 'Longitude of tracer (h) points') @@ -103,7 +109,8 @@ class Usi(Fix): """Fixes for usi.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes bad standard_name @@ -123,7 +130,8 @@ class Vsi(Fix): """Fixes for vsi.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes bad standard_name diff --git a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py index 0e626d80de..7722118e48 100644 --- a/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py +++ b/esmvalcore/cmor/_fixes/cmip5/gfdl_esm2m.py @@ -1,7 +1,8 @@ + """Fixes for GFDL ESM2M.""" -from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars from ..fix import Fix +from ..cmip5.gfdl_esm2g import AllVars as BaseAllVars class AllVars(BaseAllVars): @@ -9,10 +10,11 @@ class AllVars(BaseAllVars): class Areacello(Fix): - """Fixes for areacello.""" + """Fixes for areacello""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong units. @@ -23,6 +25,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.units = 'm2' @@ -33,7 +36,8 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -44,6 +48,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -55,7 +60,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -66,6 +72,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1e6 @@ -77,7 +84,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes wrong standard_name. @@ -88,6 +96,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) cube.standard_name = 'sea_surface_temperature' diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py index 9dc63cb128..5ee8c8aff1 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_h.py @@ -1,4 +1,5 @@ """Fixes for GISS-E2-H.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py index 3d4cd617d8..0d538e7960 100644 --- a/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py +++ b/esmvalcore/cmor/_fixes/cmip5/giss_e2_r.py @@ -1,4 +1,5 @@ """Fixes for GISS-E2-R.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py index e48ba4ade9..3531f78f06 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_cc.py @@ -2,6 +2,7 @@ from ..fix import Fix from .hadgem2_es import AllVars as BaseAllVars + AllVars = BaseAllVars @@ -9,7 +10,8 @@ class O2(Fix): """Fixes for o2.""" def fix_metadata(self, cubes): - """Fix standard and long names. + """ + Fix standard and long names. Parameters ---------- @@ -18,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py index 1f9e81aa86..f7360dae2b 100644 --- a/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py +++ b/esmvalcore/cmor/_fixes/cmip5/hadgem2_es.py @@ -19,6 +19,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: lats = cube.coords('latitude') @@ -49,6 +50,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ std = 'mole_concentration_of_dissolved_molecular_oxygen_in_sea_water' long_name = 'Dissolved Oxygen Concentration' diff --git a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py index d90c606b40..e89cea019d 100644 --- a/esmvalcore/cmor/_fixes/cmip5/inmcm4.py +++ b/esmvalcore/cmor/_fixes/cmip5/inmcm4.py @@ -4,6 +4,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -11,7 +12,8 @@ class Gpp(Fix): """Fixes for gpp.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -23,6 +25,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= -1 @@ -34,7 +37,8 @@ class Lai(Fix): """Fixes for lai.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -46,6 +50,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 0.01 @@ -57,7 +62,8 @@ class Nbp(Fix): """Fixes for nbp.""" def fix_metadata(self, cubes): - """Fix missing scalar dimension. + """ + Fix missing scalar dimension. Parameters ---------- @@ -67,6 +73,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cubes[0].standard_name = ( 'surface_net_downward_mass_flux_of_carbon_dioxide_expressed_as_' @@ -79,7 +86,8 @@ class BaresoilFrac(Fix): """Fixes for baresoilFrac.""" def fix_metadata(self, cubes): - """Fix missing scalar dimension. + """ + Fix missing scalar dimension. Parameters ---------- @@ -89,6 +97,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ typebare = iris.coords.AuxCoord( 'bare_ground', diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py index 5dfcb15ce2..894af45317 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_lr.py @@ -1,4 +1,5 @@ """Fixes for IPSL-CM5A-LR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py index 98fab8515f..893b9779c2 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5a_mr.py @@ -1,4 +1,5 @@ """Fixes for IPSL-CM5A-MR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py index 271f48728e..03bed332d6 100644 --- a/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/ipsl_cm5b_lr.py @@ -1,4 +1,5 @@ """Fixes for IPSL-CM5B-LR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc5.py b/esmvalcore/cmor/_fixes/cmip5/miroc5.py index c2e1e253a2..ec0e009402 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc5.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc5.py @@ -5,6 +5,7 @@ from ..fix import Fix from ..shared import round_coordinates + Cl = ClFixHybridPressureCoord @@ -12,7 +13,8 @@ class Sftof(Fix): """Fixes for sftof.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -24,6 +26,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -35,7 +38,8 @@ class Snw(Fix): """Fixes for snw.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -47,6 +51,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 @@ -91,7 +96,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes mask @@ -103,6 +109,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -126,6 +133,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ return round_coordinates(cubes) @@ -138,7 +146,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_data(self, cube): - """Fix tos data. + """ + Fix tos data. Fixes mask @@ -150,6 +159,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py index de93a2bf4e..fc94bc45cc 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm.py @@ -15,7 +15,8 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -27,6 +28,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1000 @@ -38,7 +40,8 @@ class Co2(Fix): """Fixes for co2.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes error in cube units @@ -50,6 +53,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ self.get_cube_from_list(cubes).units = '1.0e-6' return cubes @@ -59,7 +63,8 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Fixes error in air_pressure coordinate, sometimes called AR5PL35, and error in time coordinate. @@ -72,6 +77,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: # Fix air_pressure diff --git a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py index 400a7c0355..83d6e28f20 100644 --- a/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py +++ b/esmvalcore/cmor/_fixes/cmip5/miroc_esm_chem.py @@ -1,3 +1,4 @@ + """Fixes for MIROC ESM CHEM model.""" from ..fix import Fix @@ -6,7 +7,8 @@ class Tro3(Fix): """Fixes for tro3.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -17,6 +19,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1000 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py index e70672c4bf..a24aebd499 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_lr.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -9,7 +10,8 @@ class Pctisccp(Fix): """Fixes for pctisccp.""" def fix_data(self, cube): - """Fix data. + """ + Fix data. Fixes discrepancy between declared units and real units @@ -21,6 +23,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 100 diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py index 28317e6958..92b1a6a06b 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_mr.py @@ -1,4 +1,5 @@ """Fixes for MPI-ESM-MR model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py index 0a04fd0bf0..303e1b0fd1 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py +++ b/esmvalcore/cmor/_fixes/cmip5/mpi_esm_p.py @@ -1,4 +1,5 @@ """Fixes for MPI-ESM-P model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py index 55e3a20345..a21b82eb7f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_cgcm3.py @@ -4,6 +4,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -11,7 +12,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix msftmyz data. + """ + Fix msftmyz data. Fixes mask @@ -23,6 +25,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube @@ -32,7 +35,8 @@ class ThetaO(Fix): """Fixes for thetao.""" def fix_data(self, cube): - """Fix thetao data. + """ + Fix thetao data. Fixes mask @@ -44,6 +48,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py index 8fbc47ce24..694e4cc33f 100644 --- a/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py +++ b/esmvalcore/cmor/_fixes/cmip5/mri_esm1.py @@ -1,3 +1,4 @@ + """Fixes for MRI-ESM1 model.""" from dask import array as da @@ -8,7 +9,8 @@ class Msftmyz(Fix): """Fixes for msftmyz.""" def fix_data(self, cube): - """Fix msftmyz data. + """ + Fix msftmyz data. Fixes mask @@ -19,6 +21,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.) return cube diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py index e52f4a2f3d..703ef054d7 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_m.py @@ -1,4 +1,5 @@ """Fixes for NorESM1-M.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py index beb6cc3f41..08fe028419 100644 --- a/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py +++ b/esmvalcore/cmor/_fixes/cmip5/noresm1_me.py @@ -20,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ return round_coordinates(cubes, 12, coord_names=['latitude']) @@ -41,5 +42,6 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ return round_coordinates(cubes, 12) diff --git a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py index ab5b5109d6..7627e9b3a4 100644 --- a/esmvalcore/cmor/_fixes/cmip6/access_cm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/access_cm2.py @@ -18,6 +18,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py index e1688bdc58..59f09bcd28 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/cams_csm1_0.py @@ -1,6 +1,7 @@ """Fixes for CAMS-CSM1-0 model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/canesm5.py b/esmvalcore/cmor/_fixes/cmip6/canesm5.py index 23f004042b..d4cdbc95e1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/canesm5.py +++ b/esmvalcore/cmor/_fixes/cmip6/canesm5.py @@ -18,6 +18,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= 1.e-6 @@ -39,6 +40,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ cube.data = da.ma.masked_equal(cube.core_data(), 0.0) return cube diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2.py index ea816506cc..6ded187fbb 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2.py @@ -61,6 +61,7 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. + """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix @@ -116,6 +117,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -126,8 +128,8 @@ class Prw(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """Fix latitude_bounds and longitude_bounds data type and round to 4 - d.p. + """ + Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. Parameters ---------- @@ -137,6 +139,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: for coord_name in ['latitude', 'longitude']: @@ -153,7 +156,8 @@ class Tas(Prw): """Fixes for tas.""" def fix_metadata(self, cubes): - """Add height (2m) coordinate. + """ + Add height (2m) coordinate. Fix also done for prw. Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. @@ -166,6 +170,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ super().fix_metadata(cubes) # Specific code for tas @@ -189,6 +194,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_typeland_coord(cube) @@ -209,6 +215,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_typesea_coord(cube) @@ -222,7 +229,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """Round times to 1 d.p. for monthly means. + """ + Round times to 1 d.p. for monthly means. Required to get hist-GHG and ssp245-GHG Omon tos to concatenate. @@ -234,6 +242,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) @@ -258,6 +267,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py index d6abd98fc5..0783c125fe 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_fv2.py @@ -1,9 +1,10 @@ """Fixes for CESM2-FV2 model.""" -from ..common import SiconcFixScalarCoord from .cesm2 import Cl as BaseCl from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon from .cesm2 import Tas as BaseTas +from ..common import SiconcFixScalarCoord + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py index 134bf8878b..f7263a00dd 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm.py @@ -36,6 +36,7 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): ------- str Path to the fixed file. + """ new_path = self._fix_formula_terms( filepath, output_dir, add_unique_suffix=add_unique_suffix diff --git a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py index 7dc4e79a9e..89c55b3b10 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py +++ b/esmvalcore/cmor/_fixes/cmip6/cesm2_waccm_fv2.py @@ -1,11 +1,12 @@ """Fixes for CESM2-WACCM-FV2 model.""" -from ..common import SiconcFixScalarCoord +from .cesm2 import Tas as BaseTas from .cesm2 import Fgco2 as BaseFgco2 from .cesm2 import Omon as BaseOmon -from .cesm2 import Tas as BaseTas from .cesm2_waccm import Cl as BaseCl from .cesm2_waccm import Cli as BaseCli from .cesm2_waccm import Clw as BaseClw +from ..common import SiconcFixScalarCoord + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py index fc1db9d174..00983b36a7 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py +++ b/esmvalcore/cmor/_fixes/cmip6/cmcc_cm2_sr5.py @@ -16,6 +16,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) ps_coord = cube.coord(var_name='ps') diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py index 47c505fdd2..b5db40fc11 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_cm6_1_hr.py @@ -3,6 +3,7 @@ from .cnrm_cm6_1 import Cli as BaseCli from .cnrm_cm6_1 import Clw as BaseClw + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py index 23ab942fef..838ae3836c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py +++ b/esmvalcore/cmor/_fixes/cmip6/cnrm_esm2_1.py @@ -5,6 +5,7 @@ from .cnrm_cm6_1 import Clw as BaseClw from .cnrm_cm6_1 import Omon as BaseOmon + Cl = BaseCl diff --git a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py index 59bb546aac..333b4eb98b 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ec_earth3_veg_lr.py @@ -1,4 +1,5 @@ """Fixes for EC-Earth3-Veg-LR model.""" from ..common import OceanFixGrid + Siconc = OceanFixGrid diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py index def9a936d1..f73b16f4b8 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_cm4.py @@ -26,6 +26,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) coords_to_add = { @@ -50,7 +51,8 @@ class Tas(Fix): """Fixes for tas.""" def fix_metadata(self, cubes): - """Add height (2m) coordinate. + """ + Add height (2m) coordinate. Parameters ---------- @@ -60,6 +62,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) try: @@ -85,7 +88,8 @@ class Uas(Fix): """Fixes for uas.""" def fix_metadata(self, cubes): - """Add height (10m) coordinate. + """ + Add height (10m) coordinate. Parameters ---------- @@ -95,6 +99,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py index b2e421fba9..c9788eb37c 100644 --- a/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py +++ b/esmvalcore/cmor/_fixes/cmip6/gfdl_esm4.py @@ -1,7 +1,10 @@ """Fixes for GFDL-ESM4 model.""" -from ..common import OceanFixGrid, SiconcFixScalarCoord +from ..common import SiconcFixScalarCoord, OceanFixGrid from ..fix import Fix -from ..shared import add_scalar_depth_coord, fix_ocean_depth_coord +from ..shared import ( + add_scalar_depth_coord, + fix_ocean_depth_coord, +) class Fgco2(Fix): @@ -18,6 +21,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_depth_coord(cube) @@ -38,6 +42,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py index 1724cce93b..054a42255f 100644 --- a/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py +++ b/esmvalcore/cmor/_fixes/cmip6/giss_e2_1_h.py @@ -1,6 +1,7 @@ """Fixes for GISS-E2-1-H model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py index 003c8f623d..99db1e2be1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/hadgem3_gc31_ll.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridHeightCoord from .ukesm1_0_ll import AllVars as BaseAllVars + AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py index 11a25bc185..57d925e6d1 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm5a2_inca.py @@ -3,6 +3,7 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon + AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py index 7e326e5948..dfd7116275 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr.py @@ -9,7 +9,8 @@ class AllVars(Fix): """Fixes for thetao.""" def fix_metadata(self, cubes): - """Fix cell_area coordinate. + """ + Fix cell_area coordinate. Parameters ---------- @@ -19,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) if cube.coords('latitude'): @@ -66,6 +68,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): diff --git a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py index 2b551a8177..3a8a94b8de 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py +++ b/esmvalcore/cmor/_fixes/cmip6/ipsl_cm6a_lr_inca.py @@ -3,6 +3,7 @@ from .ipsl_cm6a_lr import Clcalipso as BaseClcalipso from .ipsl_cm6a_lr import Omon as BaseOmon + AllVars = BaseAllVars diff --git a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py index 92a446be1c..a9b200cde6 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mcm_ua_1_0.py @@ -38,6 +38,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ coords_to_change = { 'latitude': 'lat', @@ -99,6 +100,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: if cube.coords(axis='Z'): @@ -122,6 +124,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 2.0) @@ -142,6 +145,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ cube = self.get_cube_from_list(cubes) add_scalar_height_coord(cube, 10.0) diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc6.py b/esmvalcore/cmor/_fixes/cmip6/miroc6.py index e799a86577..cf1d40ca86 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc6.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc6.py @@ -15,8 +15,8 @@ class Tos(Fix): """Fixes for tos.""" def fix_metadata(self, cubes): - """Fix latitude_bounds and longitude_bounds data type and round to 4 - d.p. + """ + Fix latitude_bounds and longitude_bounds data type and round to 4 d.p. Parameters ---------- diff --git a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py index a5e18b302c..aa28ae13cc 100644 --- a/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py +++ b/esmvalcore/cmor/_fixes/cmip6/miroc_es2l.py @@ -1,6 +1,7 @@ """Fixes for MIROC-ES2L model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py index f603b9d197..201ffcca63 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py +++ b/esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py @@ -1,8 +1,8 @@ """Fixes for MPI-ESM1-2-XR model.""" -from .mpi_esm1_2_hr import SfcWind as BaseSfcWind -from .mpi_esm1_2_hr import Ta as BaseFix from .mpi_esm1_2_hr import Tas as BaseTas +from .mpi_esm1_2_hr import Ta as BaseFix +from .mpi_esm1_2_hr import SfcWind as BaseSfcWind class Tas(BaseTas): diff --git a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py index 04f1617200..720670b4d5 100644 --- a/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py +++ b/esmvalcore/cmor/_fixes/cmip6/mri_esm2_0.py @@ -1,6 +1,7 @@ """Fixes for MRI-ESM2-0 model.""" from ..common import ClFixHybridPressureCoord + Cl = ClFixHybridPressureCoord diff --git a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py index 2cd1926eff..dc0aa1ccb8 100644 --- a/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py +++ b/esmvalcore/cmor/_fixes/cmip6/sam0_unicon.py @@ -2,6 +2,7 @@ from ..common import ClFixHybridPressureCoord from ..fix import Fix + Cl = ClFixHybridPressureCoord @@ -27,6 +28,7 @@ def fix_data(self, cube): Returns ------- iris.cube.Cube + """ metadata = cube.metadata cube *= -1 diff --git a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py index 6d7d279d6e..8bef01c21f 100644 --- a/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py +++ b/esmvalcore/cmor/_fixes/cmip6/ukesm1_0_ll.py @@ -17,6 +17,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ parent_units = 'parent_time_units' bad_value = 'days since 1850-01-01-00-00-00' diff --git a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py index 0f75e65197..1806f3f0a0 100644 --- a/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/cnrm_cerfacs_cnrm_cm5/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by CNRM-CERFACS-CNRM-CM5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py index 19d0a2dfdc..88d2123420 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - CLMcomCCLM4817 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + CLMcomCCLM4817 as BaseFix) AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py index 9333eb9b33..2f816ba55e 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py index b79a6399a7..9f4cb7a2bc 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/racmo22e.py @@ -1,4 +1,5 @@ """Fixes for rcm RACMO22E driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py index aad85b4848..114715a5c9 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/rca4.py @@ -1,5 +1,6 @@ """Fixes for rcm RCA4 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py index 56bff0f673..c50d9a23e2 100644 --- a/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ichec_ec_earth/remo2015.py @@ -1,4 +1,5 @@ """Fixes for rcm REMO2015 driven by ICHEC-EC-EARTH.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py index 181b42dba6..ac0460904d 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/cclm4_8_17.py @@ -1,5 +1,5 @@ """Fixes for rcm CCLM4-8-17 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - CLMcomCCLM4817 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + CLMcomCCLM4817 as BaseFix) AllVars = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py index bcbe5356e2..fbd13bdfab 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/remo2015.py @@ -1,4 +1,5 @@ """Fixes for rcm REMO2015 driven by MIROC-MIROC5.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py index e1e691efa2..f8a69bca9b 100644 --- a/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py +++ b/esmvalcore/cmor/_fixes/cordex/miroc_miroc5/wrf361h.py @@ -1,6 +1,5 @@ """Fixes for rcm WRF361H driven by MIROC-MIROC5.""" import iris - from esmvalcore.cmor.fix import Fix @@ -21,6 +20,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ fixed_cubes = iris.cube.CubeList() for cube in cubes: diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py index 45524e8654..7964a583e0 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py index 0a6a43b7b1..5dfb91f274 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/hirham5.py @@ -16,6 +16,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.CubeList + """ for cube in cubes: cube.coord('latitude').attributes = {} diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py index 2ad0fe36f6..740711fcea 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/rca4.py @@ -1,5 +1,6 @@ """Fixes for rcm RCA4 driven by MOHC-HadGEM2-ES.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py index c7f3912fb0..cea145f2d3 100644 --- a/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/mohc_hadgem2_es/remo2015.py @@ -1,5 +1,6 @@ """Fixes for rcm REMO2015 driven by MOHC-HadGEM2.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py index dbad46ea88..4875edfc93 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py index ebf390b9f9..676e0dfc47 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/racmo22e.py @@ -1,4 +1,5 @@ """Fixes for rcm RACMO22E driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py index fc54fd47e2..f863ed1712 100644 --- a/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py +++ b/esmvalcore/cmor/_fixes/cordex/mpi_m_mpi_esm_lr/regcm4_6.py @@ -1,5 +1,6 @@ """Fixes for rcm RegCM4-6 driven by MPI-M-MPI-ESM-LR.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py index 36d52de57e..1aa2d11b1b 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/hadrem3_ga7_05.py @@ -1,6 +1,6 @@ """Fixes for rcm HadREM3-GA7-05 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import \ - MOHCHadREM3GA705 as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + MOHCHadREM3GA705 as BaseFix) Tas = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py index 1a924d6b04..e9e2e38734 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/racmo22e.py @@ -1,4 +1,5 @@ """Fixes for rcm RACMO22E driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py index 3452f432ab..58d14599da 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/rca4.py @@ -1,5 +1,6 @@ """Fixes for rcm RCA4 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py index 4276048585..9722263d70 100644 --- a/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py +++ b/esmvalcore/cmor/_fixes/cordex/ncc_noresm1_m/remo2015.py @@ -1,4 +1,5 @@ """Fixes for rcm REMO2015 driven by NCC-NorESM1-M.""" -from esmvalcore.cmor._fixes.cordex.cordex_fixes import TimeLongName as BaseFix +from esmvalcore.cmor._fixes.cordex.cordex_fixes import ( + TimeLongName as BaseFix) Pr = BaseFix diff --git a/esmvalcore/cmor/_fixes/emac/emac.py b/esmvalcore/cmor/_fixes/emac/emac.py index 9bd961783a..99cf9ee142 100644 --- a/esmvalcore/cmor/_fixes/emac/emac.py +++ b/esmvalcore/cmor/_fixes/emac/emac.py @@ -8,6 +8,7 @@ is that ``fix_metadata`` takes all cubes (and thus all input variables of the input file) as argument while ``fix_data`` only takes one cube (the output variable) as single argument. + """ import logging @@ -46,6 +47,7 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): This fix removes the ``formula_terms`` attribute of the hybrid pressure level variables to make the corresponding coefficients appear correctly in the class:`iris.cube.CubeList` object returned by :mod:`iris.load`. + """ if 'alevel' not in self.vardef.dimensions: return filepath @@ -381,6 +383,7 @@ def fix_metadata(self, cubes): Convert geopotential Phi given by EMAC to geopotential height Z using Z = Phi / g0 (g0 is standard acceleration of gravity) + """ g0_value = constants.value('standard acceleration of gravity') g0_units = constants.unit('standard acceleration of gravity') diff --git a/esmvalcore/cmor/_fixes/fix.py b/esmvalcore/cmor/_fixes/fix.py index 2723579ef8..cf2aed42ec 100644 --- a/esmvalcore/cmor/_fixes/fix.py +++ b/esmvalcore/cmor/_fixes/fix.py @@ -61,6 +61,7 @@ def __init__( frequency: Expected frequency of the variable. If not given, use the one from the CMOR table entry of the variable. + """ self.vardef = vardef if extra_facets is None: @@ -98,6 +99,7 @@ def fix_file( Path to the corrected file. It can be different from the original filepath if a fix has been applied, but if not it should be the original filepath. + """ return filepath @@ -117,6 +119,7 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> Sequence[Cube]: ------- Iterable[iris.cube.Cube] Fixed cubes. They can be different instances. + """ return cubes @@ -144,6 +147,7 @@ def get_cube_from_list( ------- iris.cube.Cube Variable's cube. + """ if short_name is None: short_name = self.vardef.short_name @@ -166,6 +170,7 @@ def fix_data(self, cube: Cube) -> Cube: ------- iris.cube.Cube Fixed cube. It can be a difference instance. + """ return cube @@ -226,6 +231,7 @@ def get_fixes( ------- list[Fix] Fixes to apply for the given data. + """ vardef = get_var_info(project, mip, short_name) @@ -307,6 +313,7 @@ def get_fixed_filepath( ------- Path Path to the fixed file. + """ output_dir = Path(output_dir) if add_unique_suffix: @@ -334,6 +341,7 @@ def fix_metadata(self, cubes: Sequence[Cube]) -> CubeList: ------- CubeList Fixed cubes. + """ # Make sure the this fix also works when no extra_facets are given if 'project' in self.extra_facets and 'dataset' in self.extra_facets: @@ -376,6 +384,7 @@ def fix_data(self, cube: Cube) -> Cube: ------- Cube Fixed cube. + """ return cube @@ -749,10 +758,7 @@ def _fix_coord_direction( cmor_coord: CoordinateInfo, cube_coord: Coord, ) -> tuple[Cube, Coord]: - """Fix coordinate direction (increasing vs. - - decreasing). - """ + """Fix coordinate direction (increasing vs. decreasing).""" # Skip fix for a variety of reasons if cube_coord.ndim > 1: return (cube, cube_coord) diff --git a/esmvalcore/cmor/_fixes/icon/_base_fixes.py b/esmvalcore/cmor/_fixes/icon/_base_fixes.py index ede854bc0a..c4afecc4f8 100644 --- a/esmvalcore/cmor/_fixes/icon/_base_fixes.py +++ b/esmvalcore/cmor/_fixes/icon/_base_fixes.py @@ -56,6 +56,7 @@ def _create_mesh(self, cube: Cube) -> MeshXY: neighboring cells) the number of nodes is 6 times higher with :func:`iris.mesh.MeshXY.from_coords` compared to using the information already present in the horizontal grid file. + """ horizontal_grid = self.get_horizontal_grid(cube) @@ -154,10 +155,11 @@ def _get_grid_url(self, cube): def _get_node_coords(self, horizontal_grid): """Get node coordinates from horizontal grid. - Extract node coordinates from dummy variable 'dual_area' in - horizontal grid file (in ICON jargon called 'vertex latitude' - and 'vertex longitude'), remove their bounds (not accepted by - UGRID), and adapt metadata. + Extract node coordinates from dummy variable 'dual_area' in horizontal + grid file (in ICON jargon called 'vertex latitude' and 'vertex + longitude'), remove their bounds (not accepted by UGRID), and adapt + metadata. + """ dual_area_cube = horizontal_grid.extract_cube( NameConstraint(var_name='dual_area')) @@ -234,6 +236,7 @@ def add_additional_cubes(self, cubes): ------ InputFilesNotFound A specified file does not exist. + """ facets_to_consider = [ 'zg_file', @@ -318,6 +321,7 @@ def _get_downloaded_grid(self, grid_url: str, grid_name: str) -> CubeList: In order to make this function thread-safe, the downloaded grid file is first saved to a temporary location, then copied to the actual location later. + """ grid_path = self.CACHE_DIR / grid_name @@ -398,6 +402,7 @@ def get_horizontal_grid(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. + """ if self.extra_facets.get('horizontal_grid') is not None: grid = self._get_grid_from_facet() @@ -436,6 +441,7 @@ def get_mesh(self, cube): Input cube does not contain the necessary attribute `grid_file_uri` that specifies the download location of the ICON horizontal grid file. + """ # If specified by the user, use `horizontal_grid` facet to determine # grid name; otherwise, use the `grid_file_uri` attribute of the cube @@ -466,6 +472,7 @@ def _get_start_index(horizontal_grid): Note ---- UGRID expects this to be a int32. + """ vertex_index = horizontal_grid.extract_cube( NameConstraint(var_name='vertex_index')) diff --git a/esmvalcore/cmor/_fixes/icon/icon.py b/esmvalcore/cmor/_fixes/icon/icon.py index d714657764..707a47f20c 100644 --- a/esmvalcore/cmor/_fixes/icon/icon.py +++ b/esmvalcore/cmor/_fixes/icon/icon.py @@ -100,6 +100,7 @@ def _add_coord_from_grid_file(self, cube, coord_name): Invalid ``coord_name`` is given; input cube does not contain a single unnamed dimension that can be used to add the new coordinate. + """ # The following dict maps from desired coordinate name in output file # (dict keys) to coordinate name in grid file (dict values) diff --git a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py index 96889cd7b9..362d950f6c 100644 --- a/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py +++ b/esmvalcore/cmor/_fixes/ipslcm/ipsl_cm6.py @@ -19,8 +19,8 @@ class AllVars(Fix): def fix_file(self, filepath, output_dir, add_unique_suffix=False): """Select IPSLCM variable in filepath. - This is done only if input file is a multi-variable one. This is - diagnosed by searching in the input filepathame for the + This is done only if input file is a multi-variable one. This + is diagnosed by searching in the input filepathame for the extra_facet value for key 'group'. In such cases, it is worth to use an external tool for @@ -28,8 +28,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): up to, and including, V3.0.2), and CDO can be used, depending on extra_facets key `use_cdo` - However, we take care of ESMValTool policy re. dependencies - licence + However, we take care of ESMValTool policy re. dependencies licence + """ if "_" + self.extra_facets.get( "group", "non-sense") + ".nc" not in str(filepath): @@ -61,8 +61,8 @@ def fix_file(self, filepath, output_dir, add_unique_suffix=False): def fix_metadata(self, cubes): """Fix metadata for any IPSLCM variable + filter out other variables. - Fix the name of the time coordinate, which is called - time_counter in the original file. + Fix the name of the time coordinate, which is called time_counter + in the original file. Remove standard_name 'time' in auxiliary time coordinates """ diff --git a/esmvalcore/cmor/_fixes/native6/era5_land.py b/esmvalcore/cmor/_fixes/native6/era5_land.py index 6c32cc6dcb..5b6fbff276 100644 --- a/esmvalcore/cmor/_fixes/native6/era5_land.py +++ b/esmvalcore/cmor/_fixes/native6/era5_land.py @@ -1,12 +1,11 @@ """Fixes for ERA5-Land.""" import logging -from esmvalcore.cmor._fixes.native6.era5 import ( - AllVars, - Evspsbl, - Evspsblpot, - Pr, -) +from esmvalcore.cmor._fixes.native6.era5 import (Pr, + Evspsbl, + Evspsblpot, + AllVars) + logger = logging.getLogger(__name__) logger.info("Load classes from era5.py") diff --git a/esmvalcore/cmor/_fixes/native_datasets.py b/esmvalcore/cmor/_fixes/native_datasets.py index b773c63966..20cfa5590f 100644 --- a/esmvalcore/cmor/_fixes/native_datasets.py +++ b/esmvalcore/cmor/_fixes/native_datasets.py @@ -29,6 +29,7 @@ def fix_scalar_coords(self, cube): cube: iris.cube.Cube Input cube for which missing scalar coordinates will be added (in-place). + """ if 'height2m' in self.vardef.dimensions: add_scalar_height_coord(cube, 2.0) @@ -46,6 +47,7 @@ def fix_var_metadata(self, cube): ---------- cube: iris.cube.Cube Input cube whose metadata is changed in-place. + """ # Fix names if self.vardef.standard_name == '': @@ -101,6 +103,7 @@ def get_cube(self, cubes, var_name=None): ------ ValueError Desired variable is not available in the input cubes. + """ if var_name is None: var_name = self.extra_facets.get('raw_name', @@ -124,6 +127,7 @@ def fix_regular_time(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. + """ if not self.vardef.has_coord_with_standard_name('time'): return @@ -144,6 +148,7 @@ def fix_regular_lat(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. + """ if not self.vardef.has_coord_with_standard_name('latitude'): return @@ -164,6 +169,7 @@ def fix_regular_lon(self, cube, coord=None, guess_bounds=True): guess_bounds: bool, optional (default: True) If ``True``, try to guess bounds. If ``False``, do not try to guess bounds. + """ if not self.vardef.has_coord_with_standard_name('longitude'): return @@ -192,6 +198,7 @@ def guess_coord_bounds(cube, coord): iris.coords.AuxCoord or iris.coords.DimCoord Coordinate with bounds. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if isinstance(coord, str): coord = cube.coord(coord) @@ -219,6 +226,7 @@ def fix_time_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed time coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('time') @@ -246,6 +254,7 @@ def fix_alt16_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed altitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('altitude') @@ -275,6 +284,7 @@ def fix_height_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed height coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('height') @@ -304,6 +314,7 @@ def fix_plev_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed air_pressure coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('air_pressure') @@ -333,6 +344,7 @@ def fix_lat_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed latitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('latitude') @@ -361,6 +373,7 @@ def fix_lon_metadata(cube, coord=None): iris.coords.AuxCoord or iris.coords.DimCoord Fixed longitude coordinate. The coordinate is altered in-place; it is just returned out of convenience for easy access. + """ if coord is None: coord = cube.coord('longitude') diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py index eafde5e3e2..b8eab7b711 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_0.py @@ -21,6 +21,7 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. + """ for cube in cubes: # Put information from valid_range into mask and remove the diff --git a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py index f72a498759..93ca03eaa6 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py +++ b/esmvalcore/cmor/_fixes/obs4mips/airs_2_1.py @@ -8,7 +8,8 @@ class AllVars(Fix): """Common fixes to all vars.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Change unit of coordinate plev from hPa to Pa. @@ -21,6 +22,7 @@ def fix_metadata(self, cubes): ------- iris.cube.CubeList Fixed cubes. + """ for cube in cubes: try: diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py index dfc01ba281..cb150fe729 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi.py @@ -1,3 +1,4 @@ + """Fixes for SSMI model.""" from ..fix import Fix diff --git a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py index 982ab03783..2fa26842b9 100644 --- a/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py +++ b/esmvalcore/cmor/_fixes/obs4mips/ssmi_meris.py @@ -1,3 +1,4 @@ + """Fixes for CCSM4 model.""" from iris.cube import CubeList @@ -8,7 +9,8 @@ class Prw(Fix): """Fixes for prw.""" def fix_metadata(self, cubes): - """Fix metadata. + """ + Fix metadata. Remove error and number of observations cubes @@ -19,6 +21,7 @@ def fix_metadata(self, cubes): Returns ------- iris.cube.Cube + """ cube = self.get_cube_from_list(cubes) return CubeList([cube]) diff --git a/esmvalcore/cmor/_fixes/shared.py b/esmvalcore/cmor/_fixes/shared.py index d3498c9b87..3ec14d05ab 100644 --- a/esmvalcore/cmor/_fixes/shared.py +++ b/esmvalcore/cmor/_fixes/shared.py @@ -443,6 +443,7 @@ def get_next_month(month: int, year: int) -> tuple[int, int]: ------- tuple[int, int] Next month and next year. + """ if month != 12: return month + 1, year @@ -475,6 +476,7 @@ def get_time_bounds(time: Coord, freq: str) -> np.ndarray: ------ NotImplementedError Non-supported frequency is given. + """ bounds = [] dates = time.units.num2date(time.points) diff --git a/esmvalcore/cmor/_utils.py b/esmvalcore/cmor/_utils.py index 629d6be498..be837d9c10 100644 --- a/esmvalcore/cmor/_utils.py +++ b/esmvalcore/cmor/_utils.py @@ -52,6 +52,7 @@ def _get_alternative_generic_lev_coord( ------ ValueError No valid alternative generic level coordinate present in cube. + """ alternatives_for_coord = _ALTERNATIVE_GENERIC_LEV_COORDS.get( coord_name, {} @@ -92,6 +93,7 @@ def _get_generic_lev_coord_names( Tuple of `standard_name`, `out_name`, and `name` of the generic level coordinate present in the cube. Values are ``None`` if generic level coordinate has not been found in cube. + """ standard_name = None out_name = None @@ -150,6 +152,7 @@ def _get_new_generic_level_coord( ------- CoordinateInfo New generic level coordinate. + """ new_coord = generic_level_coord.generic_lev_coords[new_coord_name] new_coord.generic_level = True diff --git a/esmvalcore/cmor/check.py b/esmvalcore/cmor/check.py index b368d6d131..09f7a6331d 100644 --- a/esmvalcore/cmor/check.py +++ b/esmvalcore/cmor/check.py @@ -164,6 +164,7 @@ def check_metadata(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. + """ if logger is not None: self._logger = logger @@ -212,6 +213,7 @@ def check_data(self, logger: Optional[logging.Logger] = None) -> Cube: If errors are found. If fail_on_error attribute is set to True, raises as soon as an error is detected. If set to False, it perform all checks and then raises. + """ if logger is not None: self._logger = logger @@ -914,6 +916,7 @@ def cmor_check_metadata( ------- iris.cube.Cube Checked cube. + """ checker = _get_cmor_checker( cmor_table, @@ -956,6 +959,7 @@ def cmor_check_data( ------- iris.cube.Cube Checked cube. + """ checker = _get_cmor_checker( cmor_table, @@ -1001,6 +1005,7 @@ def cmor_check( ------- iris.cube.Cube Checked cube. + """ cube = cmor_check_metadata( cube, diff --git a/esmvalcore/cmor/fix.py b/esmvalcore/cmor/fix.py index 8a5421e19a..d05af5ef64 100644 --- a/esmvalcore/cmor/fix.py +++ b/esmvalcore/cmor/fix.py @@ -72,6 +72,7 @@ def fix_file( ------- str or pathlib.Path Path to the fixed file. + """ # Update extra_facets with variable information given as regular arguments # to this function @@ -147,6 +148,7 @@ def fix_metadata( ------- iris.cube.CubeList Fixed cubes. + """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: @@ -267,6 +269,7 @@ def fix_data( ------- iris.cube.Cube Fixed cube. + """ # Deprecate CMOR checks (remove in v2.12) if check_level != CheckLevels.DEFAULT: diff --git a/esmvalcore/cmor/table.py b/esmvalcore/cmor/table.py index a2a5e0a255..a0c685654a 100644 --- a/esmvalcore/cmor/table.py +++ b/esmvalcore/cmor/table.py @@ -25,7 +25,7 @@ CMORTable = Union['CMIP3Info', 'CMIP5Info', 'CMIP6Info', 'CustomInfo'] CMOR_TABLES: dict[str, CMORTable] = {} -"""Dict of str, obj: CMOR info objects.""" +"""dict of str, obj: CMOR info objects.""" _CMOR_KEYS = ( 'standard_name', @@ -102,6 +102,7 @@ def get_var_info( ------ KeyError No CMOR tables available for `project`. + """ if project not in CMOR_TABLES: raise KeyError( @@ -281,6 +282,7 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, ``None`` otherwise. + """ alt_names_list = self._get_alt_names_list(short_name) @@ -611,28 +613,28 @@ def __init__(self, table_type, short_name): super(VariableInfo, self).__init__() self.table_type = table_type self.modeling_realm = [] - """Modeling realm.""" + """Modeling realm""" self.short_name = short_name - """Short name.""" + """Short name""" self.standard_name = '' - """Standard name.""" + """Standard name""" self.long_name = '' - """Long name.""" + """Long name""" self.units = '' - """Data units.""" + """Data units""" self.valid_min = '' - """Minimum admitted value.""" + """Minimum admitted value""" self.valid_max = '' - """Maximum admitted value.""" + """Maximum admitted value""" self.frequency = '' - """Data frequency.""" + """Data frequency""" self.positive = '' - """Increasing direction.""" + """Increasing direction""" self.dimensions = [] - """List of dimensions.""" + """List of dimensions""" self.coordinates = {} - """Coordinates. + """Coordinates This is a dict with the names of the dimensions as keys and CoordinateInfo objects as values. @@ -701,6 +703,7 @@ def has_coord_with_standard_name(self, standard_name: str) -> bool: bool `True` if there is at least one coordinate with the given `standard_name`, `False` if not. + """ for coord in self.coordinates.values(): if coord.standard_name == standard_name: @@ -725,34 +728,35 @@ def __init__(self, name): self.generic_lev_coords = {} self.axis = "" - """Axis.""" + """Axis""" self.value = "" - """Coordinate value.""" + """Coordinate value""" self.standard_name = "" - """Standard name.""" + """Standard name""" self.long_name = "" - """Long name.""" + """Long name""" self.out_name = "" - """Out name. + """ + Out name This is the name of the variable in the file """ self.var_name = "" - """Short name.""" + """Short name""" self.units = "" - """Units.""" + """Units""" self.stored_direction = "" - """Direction in which the coordinate increases.""" + """Direction in which the coordinate increases""" self.requested = [] - """Values requested.""" + """Values requested""" self.valid_min = "" - """Minimum allowed value.""" + """Minimum allowed value""" self.valid_max = "" - """Maximum allowed value.""" + """Maximum allowed value""" self.must_have_bounds = "" - """Whether bounds are required on this dimension.""" + """Whether bounds are required on this dimension""" self.generic_lev_name = "" - """Generic level name.""" + """Generic level name""" def read_json(self, json_data): """Read coordinate information from json. @@ -988,6 +992,7 @@ class CustomInfo(CMIP5Info): Full path to the table or name for the table if it is present in ESMValTool repository. If ``None``, use default tables from `esmvalcore/cmor/tables/custom`. + """ def __init__(self, cmor_tables_path: Optional[str | Path] = None) -> None: @@ -1062,6 +1067,7 @@ def get_variable( VariableInfo | None `VariableInfo` object for the requested variable if found, returns None if not. + """ return self.tables['custom'].get(short_name, None) diff --git a/esmvalcore/config/__init__.py b/esmvalcore/config/__init__.py index 271fa956cc..7c2b8e379c 100644 --- a/esmvalcore/config/__init__.py +++ b/esmvalcore/config/__init__.py @@ -7,6 +7,7 @@ By default, this will be loaded from the file ``~/.esmvaltool/config-user.yml``. If used within the ``esmvaltool`` program, this will respect the ``--config_file`` argument. + """ from ._config_object import CFG, Config, Session diff --git a/esmvalcore/config/_config_object.py b/esmvalcore/config/_config_object.py index 89ad3b7f69..2e53857d70 100644 --- a/esmvalcore/config/_config_object.py +++ b/esmvalcore/config/_config_object.py @@ -30,6 +30,7 @@ class Config(ValidatedConfig): Do not instantiate this class directly, but use :obj:`esmvalcore.config.CFG` instead. + """ _DEFAULT_USER_CONFIG_DIR = Path.home() / '.esmvaltool' @@ -160,6 +161,7 @@ def _get_config_user_path( _ESMVALTOOL_USER_CONFIG_FILE_ at the end of this method to make sure that subsequent calls of this method (also in suprocesses) use the correct user configuration file. + """ # (1) Try to get user configuration file from `filename` argument config_user = filename @@ -208,6 +210,7 @@ def _get_config_path_from_cli() -> None | str: ---- This only works if the script name is `esmvaltool`. Does not check if file exists. + """ if Path(sys.argv[0]).name != 'esmvaltool': return None diff --git a/esmvalcore/config/_esgf_pyclient.py b/esmvalcore/config/_esgf_pyclient.py index 5f4b1aab48..51152344c4 100644 --- a/esmvalcore/config/_esgf_pyclient.py +++ b/esmvalcore/config/_esgf_pyclient.py @@ -1,4 +1,4 @@ -"""Esgf-pyclient configuration. +"""esgf-pyclient configuration. The configuration is read from the file ~/.esmvaltool/esgf-pyclient.yml. """ diff --git a/esmvalcore/config/_validated_config.py b/esmvalcore/config/_validated_config.py index dcc3e2ca36..27048397a7 100644 --- a/esmvalcore/config/_validated_config.py +++ b/esmvalcore/config/_validated_config.py @@ -49,9 +49,8 @@ class ValidatedConfig(MutableMapping): _warn_if_missing: tuple[tuple[str, str], ...] = () """Handle missing options. - Each sub-tuple in the tuple consists of an option for which a - warning is emitted and a string with more information for the user - on that option. + Each sub-tuple in the tuple consists of an option for which a warning is + emitted and a string with more information for the user on that option. """ # validate values on the way in diff --git a/esmvalcore/config/extra_facets/access-mappings.yml b/esmvalcore/config/extra_facets/access-mappings.yml index 14c75f07b0..9d4eb0621b 100644 --- a/esmvalcore/config/extra_facets/access-mappings.yml +++ b/esmvalcore/config/extra_facets/access-mappings.yml @@ -7,23 +7,23 @@ ACCESS-ESM1-5: '*': - + tas: raw_name: fld_s03i236 modeling_realm: atm - + pr: raw_name: fld_s05i216 modeling_realm: atm - + ps: raw_name: fld_s00i409 modeling_realm: atm - + clt: raw_name: fld_s02i204 modeling_realm: atm - + psl: raw_name: fld_s16i222 modeling_realm: atm @@ -31,7 +31,7 @@ ACCESS-ESM1-5: hus: raw_name: fld_s30i205 modeling_realm: atm - + zg: raw_name: fld_s30i207 modeling_realm: atm @@ -39,30 +39,30 @@ ACCESS-ESM1-5: va: raw_name: fld_s30i202 modeling_realm: atm - + ua: raw_name: fld_s30i201 modeling_realm: atm - + ta: raw_name: fld_s30i204 modeling_realm: atm - + rlus: - raw_name: - - fld_s02i207 - - fld_s02i201 - - fld_s03i332 + raw_name: + - fld_s02i207 + - fld_s02i201 + - fld_s03i332 - fld_s02i205 modeling_realm: atm - + rlds: raw_name: fld_s02i207 modeling_realm: atm rsus: - raw_name: + raw_name: - fld_s01i235 - - fld_s01i201 + - fld_s01i201 modeling_realm: atm - + diff --git a/esmvalcore/dataset.py b/esmvalcore/dataset.py index 07f07bc915..d4bd665aa6 100644 --- a/esmvalcore/dataset.py +++ b/esmvalcore/dataset.py @@ -188,8 +188,7 @@ def _file_to_dataset( def _get_available_datasets(self) -> Iterator[Dataset]: """Yield datasets based on the available files. - This function requires that self.facets['mip'] is not a glob - pattern. + This function requires that self.facets['mip'] is not a glob pattern. """ dataset_template = self.copy() dataset_template.supplementaries = [] diff --git a/esmvalcore/iris_helpers.py b/esmvalcore/iris_helpers.py index b2a9f3183c..eb9a96461e 100644 --- a/esmvalcore/iris_helpers.py +++ b/esmvalcore/iris_helpers.py @@ -39,6 +39,7 @@ def add_leading_dim_to_cube(cube, dim_coord): ------ CoordinateMultiDimError ``dim_coord`` is not 1D. + """ # Only 1D dim_coords are supported if dim_coord.ndim > 1: @@ -133,6 +134,7 @@ def merge_cube_attributes( Input cubes whose attributes will be modified in-place. delimiter: Delimiter that is used to concatenate non-identical attributes. + """ if len(cubes) <= 1: return @@ -252,6 +254,7 @@ def rechunk_cube( ------- Cube Rechunked cube. This will always be a copy of the input cube. + """ cube = cube.copy() # do not modify input cube @@ -286,6 +289,7 @@ def has_regular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has a regular grid, else ``False``. + """ try: lat = cube.coord('latitude') @@ -314,6 +318,7 @@ def has_irregular_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an irregular grid, else ``False``. + """ try: lat = cube.coord('latitude') @@ -340,6 +345,7 @@ def has_unstructured_grid(cube: Cube) -> bool: ------- bool ``True`` if input cube has an unstructured grid, else ``False``. + """ try: lat = cube.coord('latitude') diff --git a/esmvalcore/preprocessor/__init__.py b/esmvalcore/preprocessor/__init__.py index b44dada778..3800fb1413 100644 --- a/esmvalcore/preprocessor/__init__.py +++ b/esmvalcore/preprocessor/__init__.py @@ -206,7 +206,9 @@ ] DEFAULT_ORDER = tuple(__all__) -"""By default, preprocessor functions are applied in this order.""" +""" +By default, preprocessor functions are applied in this order. +""" # The order of initial and final steps cannot be configured INITIAL_STEPS = DEFAULT_ORDER[:DEFAULT_ORDER.index( diff --git a/esmvalcore/preprocessor/_area.py b/esmvalcore/preprocessor/_area.py index 78ff33f3a5..dd2f9b4b4b 100644 --- a/esmvalcore/preprocessor/_area.py +++ b/esmvalcore/preprocessor/_area.py @@ -70,6 +70,7 @@ def extract_region( ------- iris.cube.Cube Smaller cube. + """ # first examine if any cell_measures are present cell_measures = cube.cell_measures() @@ -225,6 +226,7 @@ def zonal_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. + """ if cube.coord('longitude').points.ndim >= 2: raise ValueError( @@ -273,6 +275,7 @@ def meridional_statistics( ValueError Error raised if computation on irregular grids is attempted. Zonal statistics not yet implemented for irregular grids. + """ if cube.coord('latitude').points.ndim >= 2: raise ValueError( @@ -335,6 +338,7 @@ def area_statistics( iris.exceptions.CoordinateMultiDimError Cube has irregular or unstructured grid but supplementary variable `cell_area` is not available. + """ has_cell_measure = bool(cube.cell_measures('cell_area')) @@ -379,6 +383,7 @@ def extract_named_regions(cube: Cube, regions: str | Iterable[str]) -> Cube: regions is not list or tuple or set. ValueError region not included in cube. + """ # Make sure regions is a list of strings if isinstance(regions, str): @@ -594,6 +599,7 @@ def _get_bounds( ------- lat_min, lon_min, lat_max, lon_max Coordinates deliminating bounding box for shape ids. + """ all_bounds = np.vstack( [fiona.bounds(geom) for geom in geometries.values()] @@ -648,6 +654,7 @@ def fix_coordinate_ordering(cube: Cube) -> Cube: ------- iris.cube.Cube Cube with dimensions transposed to standard order + """ try: time_dim = cube.coord_dims('time') @@ -771,6 +778,7 @@ def extract_shape( See Also -------- extract_region: Extract a region from a cube. + """ shapefile = _update_shapefile_path(shapefile) with fiona.open(shapefile) as geometries: diff --git a/esmvalcore/preprocessor/_compare_with_refs.py b/esmvalcore/preprocessor/_compare_with_refs.py index 0228a5eddc..1634fc1752 100644 --- a/esmvalcore/preprocessor/_compare_with_refs.py +++ b/esmvalcore/preprocessor/_compare_with_refs.py @@ -102,6 +102,7 @@ def bias( true`` if ``reference=None``; ``reference=None`` and the input products are given as iterable of :class:`~iris.cube.Cube` objects; ``bias_type`` is not one of ``'absolute'`` or ``'relative'``. + """ ref_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) @@ -318,6 +319,7 @@ def distance_metric( `longitude` is not found in cube if a weighted metric shall be calculated, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. + """ reference_product = None all_cubes_given = all(isinstance(p, Cube) for p in products) diff --git a/esmvalcore/preprocessor/_cycles.py b/esmvalcore/preprocessor/_cycles.py index 90e1284684..017d6ed71b 100644 --- a/esmvalcore/preprocessor/_cycles.py +++ b/esmvalcore/preprocessor/_cycles.py @@ -41,6 +41,7 @@ def amplitude(cube, coords): iris.exceptions.CoordinateNotFoundError A coordinate is not found in ``cube`` and cannot be added via :mod:`iris.coord_categorisation`. + """ if isinstance(coords, str): coords = [coords] diff --git a/esmvalcore/preprocessor/_derive/_baseclass.py b/esmvalcore/preprocessor/_derive/_baseclass.py index c2076b1542..ba9325bfdd 100644 --- a/esmvalcore/preprocessor/_derive/_baseclass.py +++ b/esmvalcore/preprocessor/_derive/_baseclass.py @@ -30,6 +30,7 @@ def required(project): ------- list of dict List of variable metadata. + """ @staticmethod @@ -57,4 +58,5 @@ def calculate(cubes): NotImplementedError If the desired variable derivation is not implemented, i.e. if this method is called from this base class and not a child class. + """ diff --git a/esmvalcore/preprocessor/_derive/_shared.py b/esmvalcore/preprocessor/_derive/_shared.py index dfe620b58e..e6d07011f1 100644 --- a/esmvalcore/preprocessor/_derive/_shared.py +++ b/esmvalcore/preprocessor/_derive/_shared.py @@ -61,6 +61,7 @@ def column_average(cube, hus_cube, zg_cube, ps_cube): ------- iris.cube.Cube Column-averaged mole fraction of a gas. + """ # Convert units of data hus_cube.convert_units('1') @@ -123,6 +124,7 @@ def pressure_level_widths(cube, ps_cube, top_limit=0.0): ------- iris.cube.Cube Cube of same shape as ``cube`` containing pressure level widths. + """ pressure_array = _create_pressure_array(cube, ps_cube, top_limit) @@ -170,6 +172,7 @@ def _get_pressure_level_widths(array, air_pressure_axis=1): For a 1D array with pressure level columns, return a 1D array with pressure level widths. + """ array = np.copy(array) if np.any(np.diff(array, axis=air_pressure_axis) > 0.0): diff --git a/esmvalcore/preprocessor/_derive/alb.py b/esmvalcore/preprocessor/_derive/alb.py index dcc45362b8..b0036077ad 100644 --- a/esmvalcore/preprocessor/_derive/alb.py +++ b/esmvalcore/preprocessor/_derive/alb.py @@ -2,6 +2,7 @@ authors: - crez_ba + """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/ctotal.py b/esmvalcore/preprocessor/_derive/ctotal.py index 45cd2610da..18bef27071 100644 --- a/esmvalcore/preprocessor/_derive/ctotal.py +++ b/esmvalcore/preprocessor/_derive/ctotal.py @@ -1,6 +1,7 @@ """Derivation of variable `ctotal`.""" import iris + from iris import Constraint from ._baseclass import DerivedVariableBase diff --git a/esmvalcore/preprocessor/_derive/lvp.py b/esmvalcore/preprocessor/_derive/lvp.py index ad9db3f299..0faf0779c4 100644 --- a/esmvalcore/preprocessor/_derive/lvp.py +++ b/esmvalcore/preprocessor/_derive/lvp.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import NameConstraint diff --git a/esmvalcore/preprocessor/_derive/lwp.py b/esmvalcore/preprocessor/_derive/lwp.py index 4c79322496..067126d5e9 100644 --- a/esmvalcore/preprocessor/_derive/lwp.py +++ b/esmvalcore/preprocessor/_derive/lwp.py @@ -33,6 +33,7 @@ def calculate(cubes): ---- Some datasets output the variable `clwvi` which only contains `lwp`. In these cases, the input `clwvi` cube is just returned. + """ # CMIP5 and CMIP6 names are slightly different, so use # variable name instead to extract cubes diff --git a/esmvalcore/preprocessor/_derive/ohc.py b/esmvalcore/preprocessor/_derive/ohc.py index e9f1f52e67..d8d374b312 100644 --- a/esmvalcore/preprocessor/_derive/ohc.py +++ b/esmvalcore/preprocessor/_derive/ohc.py @@ -1,8 +1,9 @@ """Derivation of variable `ohc`.""" import iris -from cf_units import Unit from iris import Constraint +from cf_units import Unit + from ._baseclass import DerivedVariableBase RHO_CP = iris.coords.AuxCoord(4.09169e+6, units=Unit('kg m-3 J kg-1 K-1')) @@ -37,7 +38,8 @@ def required(project): @staticmethod def calculate(cubes): - """Compute ocean heat content. + """ + Compute ocean heat content. Use c_p*rho_0= 4.09169e+6 J m-3 K-1 (Kuhlbrodt et al., 2015, Clim. Dyn.) diff --git a/esmvalcore/preprocessor/_derive/rlnst.py b/esmvalcore/preprocessor/_derive/rlnst.py index dcf1c643c9..4eecd9b90d 100644 --- a/esmvalcore/preprocessor/_derive/rlnst.py +++ b/esmvalcore/preprocessor/_derive/rlnst.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint @@ -29,10 +30,11 @@ def required(project): @staticmethod def calculate(cubes): - """Compute variable `rlnst`. + """ + Compute variable `rlnst`. - Compute Net Atmospheric Longwave Cooling to surface and outer - space. + Compute Net Atmospheric Longwave Cooling + to surface and outer space. """ rlds_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air')) diff --git a/esmvalcore/preprocessor/_derive/rlnstcs.py b/esmvalcore/preprocessor/_derive/rlnstcs.py index a1b39128fe..10613216a9 100644 --- a/esmvalcore/preprocessor/_derive/rlnstcs.py +++ b/esmvalcore/preprocessor/_derive/rlnstcs.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint @@ -29,10 +30,11 @@ def required(project): @staticmethod def calculate(cubes): - """Compute variable `rlnstcs`. + """ + Compute variable `rlnstcs`. - Compute Net Atmospheric Longwave Cooling to surface and outer - space assuming clear sky. + Compute Net Atmospheric Longwave Cooling + to surface and outer space assuming clear sky. """ rldscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_longwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rlus.py b/esmvalcore/preprocessor/_derive/rlus.py index 928b7d296a..4d536c29ad 100644 --- a/esmvalcore/preprocessor/_derive/rlus.py +++ b/esmvalcore/preprocessor/_derive/rlus.py @@ -2,6 +2,7 @@ authors: - lukas_brunner + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnst.py b/esmvalcore/preprocessor/_derive/rsnst.py index 80b6d7abf0..e2a2a53b21 100644 --- a/esmvalcore/preprocessor/_derive/rsnst.py +++ b/esmvalcore/preprocessor/_derive/rsnst.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcs.py b/esmvalcore/preprocessor/_derive/rsnstcs.py index 6a4271c649..976be64003 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcs.py +++ b/esmvalcore/preprocessor/_derive/rsnstcs.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py index 590a4bdd57..a6445bbb64 100644 --- a/esmvalcore/preprocessor/_derive/rsnstcsnorm.py +++ b/esmvalcore/preprocessor/_derive/rsnstcsnorm.py @@ -2,6 +2,7 @@ authors: - weig_ka + """ from cf_units import Unit from iris import Constraint @@ -33,11 +34,12 @@ def required(project): @staticmethod def calculate(cubes): - """Compute `rsnstcs`. + """ + Compute `rsnstcs`. - Compute Heating from Shortwave Absorption assuming clear sky - normalized by the incoming shortwave flux at the top of the - atmosphere. + Compute Heating from Shortwave Absorption + assuming clear sky normalized by + the incoming shortwave flux at the top of the atmosphere. """ rsdscs_cube = cubes.extract_cube( Constraint(name='surface_downwelling_shortwave_flux_in_air_' + diff --git a/esmvalcore/preprocessor/_derive/rsus.py b/esmvalcore/preprocessor/_derive/rsus.py index cd3a6ad4dd..326d063c26 100644 --- a/esmvalcore/preprocessor/_derive/rsus.py +++ b/esmvalcore/preprocessor/_derive/rsus.py @@ -2,6 +2,7 @@ authors: - lukas_brunner + """ from iris import Constraint diff --git a/esmvalcore/preprocessor/_derive/siextent.py b/esmvalcore/preprocessor/_derive/siextent.py index 2e2bee96bb..eee25e5a98 100644 --- a/esmvalcore/preprocessor/_derive/siextent.py +++ b/esmvalcore/preprocessor/_derive/siextent.py @@ -6,7 +6,6 @@ from iris import Constraint from esmvalcore.exceptions import RecipeError - from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) diff --git a/esmvalcore/preprocessor/_derive/sispeed.py b/esmvalcore/preprocessor/_derive/sispeed.py index b28aa06214..168b2e5525 100644 --- a/esmvalcore/preprocessor/_derive/sispeed.py +++ b/esmvalcore/preprocessor/_derive/sispeed.py @@ -1,10 +1,10 @@ """Derivation of variable `sispeed`.""" import logging - from iris import Constraint from .._regrid import regrid + from ._baseclass import DerivedVariableBase logger = logging.getLogger(__name__) @@ -24,7 +24,8 @@ def required(project): @staticmethod def calculate(cubes): - """Compute sispeed module from velocity components siu and siv. + """ + Compute sispeed module from velocity components siu and siv. Arguments --------- @@ -33,6 +34,7 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. + """ siu = cubes.extract_cube(Constraint(name='sea_ice_x_velocity')) siv = cubes.extract_cube(Constraint(name='sea_ice_y_velocity')) diff --git a/esmvalcore/preprocessor/_derive/sithick.py b/esmvalcore/preprocessor/_derive/sithick.py index b28fa2881b..ad80709d8f 100644 --- a/esmvalcore/preprocessor/_derive/sithick.py +++ b/esmvalcore/preprocessor/_derive/sithick.py @@ -20,7 +20,8 @@ def required(project): @staticmethod def calculate(cubes): - """Compute sea ice thickness from volume and concentration. + """ + Compute sea ice thickness from volume and concentration. In CMIP5, `sit` is called `sea_ice_thickness` but it is not real thickness. It is ice volume per area unit. In CMIP6, it is called @@ -33,6 +34,7 @@ def calculate(cubes): Returns ------- Cube containing sea ice speed. + """ sivol = cubes.extract_cube(Constraint(name='sea_ice_thickness')) siconc = cubes.extract_cube(Constraint(name='sea_ice_area_fraction')) diff --git a/esmvalcore/preprocessor/_derive/sm.py b/esmvalcore/preprocessor/_derive/sm.py index efc3810d65..deb3526dfd 100644 --- a/esmvalcore/preprocessor/_derive/sm.py +++ b/esmvalcore/preprocessor/_derive/sm.py @@ -25,6 +25,7 @@ def calculate(cubes): Convert moisture content of soil layer (kg/m2) into volumetric soil moisture (m3/m3), assuming density of water 998.2 kg/m2 (at temperature 20 deg C). + """ mrsos_cube = cubes.extract_cube(NameConstraint(var_name='mrsos')) diff --git a/esmvalcore/preprocessor/_derive/toz.py b/esmvalcore/preprocessor/_derive/toz.py index 62514d4ca3..32fd9e8334 100644 --- a/esmvalcore/preprocessor/_derive/toz.py +++ b/esmvalcore/preprocessor/_derive/toz.py @@ -39,6 +39,7 @@ def calculate(cubes): ---- The surface pressure is used as a lower integration bound. A fixed upper integration bound of 0 Pa is used. + """ tro3_cube = cubes.extract_cube( iris.Constraint(name='mole_fraction_of_ozone_in_air')) diff --git a/esmvalcore/preprocessor/_detrend.py b/esmvalcore/preprocessor/_detrend.py index 9faee61c73..5bc0ce6fc8 100644 --- a/esmvalcore/preprocessor/_detrend.py +++ b/esmvalcore/preprocessor/_detrend.py @@ -8,7 +8,8 @@ def detrend(cube, dimension='time', method='linear'): - """Detrend data along a given dimension. + """ + Detrend data along a given dimension. Parameters ---------- diff --git a/esmvalcore/preprocessor/_mapping.py b/esmvalcore/preprocessor/_mapping.py index a39e26e823..28d1fefb83 100644 --- a/esmvalcore/preprocessor/_mapping.py +++ b/esmvalcore/preprocessor/_mapping.py @@ -8,10 +8,11 @@ def _is_single_item(testee): - """Check if testee is a single item. + """ + Check if testee is a single item. - Return whether this is a single item, rather than an iterable. We - count string types as 'single', also. + Return whether this is a single item, rather than an iterable. + We count string types as 'single', also. """ return (isinstance(testee, str) or not isinstance(testee, collections.abc.Iterable)) @@ -63,7 +64,8 @@ def ref_to_dims_index_as_index(cube, ref): def ref_to_dims_index(cube, ref_to_slice): - """Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. + """ + Map a list of :class:`iris.coords.DimCoord` to a tuple of indices. This method finds the indices of the dimensions in a cube that collectively correspond to the given list of :class:`iris.coords.DimCoord`. @@ -98,7 +100,8 @@ def ref_to_dims_index(cube, ref_to_slice): def get_associated_coords(cube, dimensions): - """Return all coords containing any of the given dimensions. + """ + Return all coords containing any of the given dimensions. Return all coords, dimensional and auxiliary, that contain any of the given dimensions. @@ -122,10 +125,11 @@ def get_associated_coords(cube, dimensions): def get_empty_data(shape, dtype=np.float32): - """Create an empty data object of the given shape. + """ + Create an empty data object of the given shape. - Creates an empty data object of the given shape, potentially of the - lazy kind from biggus or dask, depending on the used iris version. + Creates an empty data object of the given shape, potentially of the lazy + kind from biggus or dask, depending on the used iris version. """ data = np.empty(shape, dtype=dtype) mask = np.empty(shape, dtype=bool) @@ -133,10 +137,11 @@ def get_empty_data(shape, dtype=np.float32): def get_slice_spec(cube, ref_to_slice): - """Turn a slice reference into a specification for the slice. + """ + Turn a slice reference into a specification for the slice. - Turns a slice reference into a specification comprised of the shape - as well as the relevant dimensional and auxiliary coordinates. + Turns a slice reference into a specification comprised of the shape as well + as the relevant dimensional and auxiliary coordinates. """ slice_dims = ref_to_dims_index(cube, ref_to_slice) slice_shape = tuple(cube.shape[d] for d in slice_dims) @@ -145,7 +150,8 @@ def get_slice_spec(cube, ref_to_slice): def index_iterator(dims_to_slice, shape): - """Return iterator for subsets of multidimensional objects. + """ + Return iterator for subsets of multidimensional objects. An iterator over a multidimensional object, giving both source and destination indices. @@ -175,7 +181,8 @@ def get_slice_coords(cube): def map_slices(src, func, src_rep, dst_rep): - """Map slices of a cube, replacing them with different slices. + """ + Map slices of a cube, replacing them with different slices. This method is similar to the standard cube collapsed and aggregated_by methods, however, where they completely remove the mapped dimensions, this diff --git a/esmvalcore/preprocessor/_multimodel.py b/esmvalcore/preprocessor/_multimodel.py index b8950c2d8e..d1e0d90e74 100644 --- a/esmvalcore/preprocessor/_multimodel.py +++ b/esmvalcore/preprocessor/_multimodel.py @@ -1,11 +1,11 @@ """Statistics across cubes. -This module contains functions to compute statistics across multiple -cubes or products. +This module contains functions to compute statistics across multiple cubes or +products. -Wrapper functions separate esmvalcore internals, operating on products, -from generalized functions that operate on iris cubes. These wrappers -support grouped execution by passing a groupby keyword. +Wrapper functions separate esmvalcore internals, operating on products, from +generalized functions that operate on iris cubes. These wrappers support +grouped execution by passing a groupby keyword. """ from __future__ import annotations @@ -53,16 +53,16 @@ def _get_consistent_time_unit(cubes): def _unify_time_coordinates(cubes): """Make sure all cubes' share the same time coordinate. - This function extracts the date information from the cube and - reconstructs the time coordinate, resetting the actual dates to the - 15th of the month or 1st of July for yearly data (consistent with - `regrid_time`), so that there are no mismatches in the time arrays. + This function extracts the date information from the cube and reconstructs + the time coordinate, resetting the actual dates to the 15th of the month or + 1st of July for yearly data (consistent with `regrid_time`), so that there + are no mismatches in the time arrays. If cubes have different time units, it will reset the calendar to a the "standard" calendar with unit "days since 1850-01-01". - Might not work for (sub)daily data, because different calendars may - have different number of days in the year. + Might not work for (sub)daily data, because different calendars may have + different number of days in the year. """ t_unit = _get_consistent_time_unit(cubes) @@ -245,6 +245,7 @@ def _get_equal_coord_names_metadata(cubes, equal_coords_metadata): Note ---- Ignore coordinates whose names are not unique. + """ equal_names_metadata = {} for coord in cubes[0].coords(): @@ -360,6 +361,7 @@ def _equalise_var_metadata(cubes): If cubes have the same ``name()`` and ``units``, assign identical `standard_names`, `long_names`, and `var_names`. + """ attrs = ['standard_name', 'long_name', 'var_name'] equal_names_metadata = {} @@ -439,6 +441,7 @@ def _compute_slices(cubes): Note ---- For scalar cubes, simply return ``None``. + """ # Scalar cubes if cubes[0].shape == (): diff --git a/esmvalcore/preprocessor/_other.py b/esmvalcore/preprocessor/_other.py index c91866ade7..3d047a4e24 100644 --- a/esmvalcore/preprocessor/_other.py +++ b/esmvalcore/preprocessor/_other.py @@ -133,6 +133,7 @@ def histogram( `longitude` is not found in cube if `weights=True`, `latitude` is in `coords`, and no `cell_area` is given as :ref:`supplementary_variables`. + """ # Check arguments if isinstance(bins, str): @@ -247,9 +248,10 @@ def _calculate_histogram_lazy( ) -> da.Array: """Calculate histogram over data along axes (lazy version). - This will return an array of shape `(x1, x2, ..., n_bins)` where - `xi` are the dimensions of `data` not appearing in `axes` and - `n_bins` is the number of bins. + This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are + the dimensions of `data` not appearing in `axes` and `n_bins` is the number + of bins. + """ n_axes = len(along_axes) @@ -313,9 +315,10 @@ def _calculate_histogram_eager( ) -> np.ndarray: """Calculate histogram over data along axes (eager version). - This will return an array of shape `(x1, x2, ..., n_bins)` where - `xi` are the dimensions of `data` not appearing in `axes` and - `n_bins` is the number of bins. + This will return an array of shape `(x1, x2, ..., n_bins)` where `xi` are + the dimensions of `data` not appearing in `axes` and `n_bins` is the number + of bins. + """ # Create array with shape (x1, x2, ..., y) where `y` is the product of all # dimensions in `axes` and the `xi` are the remaining dimensions diff --git a/esmvalcore/preprocessor/_regrid.py b/esmvalcore/preprocessor/_regrid.py index 0e9e8aafc9..228bd7dc26 100644 --- a/esmvalcore/preprocessor/_regrid.py +++ b/esmvalcore/preprocessor/_regrid.py @@ -31,8 +31,10 @@ from esmvalcore.exceptions import ESMValCoreDeprecationWarning from esmvalcore.iris_helpers import has_irregular_grid, has_unstructured_grid from esmvalcore.preprocessor._shared import ( - get_array_module, get_dims_along_axes, +) +from esmvalcore.preprocessor._shared import ( + get_array_module, preserve_float_dtype, ) from esmvalcore.preprocessor._supplementary_vars import ( diff --git a/esmvalcore/preprocessor/_regrid_esmpy.py b/esmvalcore/preprocessor/_regrid_esmpy.py index 3055f82f83..cce6dae92f 100755 --- a/esmvalcore/preprocessor/_regrid_esmpy.py +++ b/esmvalcore/preprocessor/_regrid_esmpy.py @@ -10,7 +10,6 @@ except ImportError: raise exc import warnings - import iris import numpy as np from iris.cube import Cube @@ -66,6 +65,7 @@ class ESMPyRegridder: `nearest`. mask_threshold: Threshold used to regrid mask of input cube. + """ def __init__( @@ -96,6 +96,7 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. + """ # These regridders are not lazy, so load source data once. cube.data # pylint: disable=pointless-statement @@ -123,6 +124,7 @@ class _ESMPyScheme: ---------- mask_threshold: Threshold used to regrid mask of source cube. + """ _METHOD = '' @@ -160,6 +162,7 @@ def regridder(self, src_cube: Cube, tgt_cube: Cube) -> ESMPyRegridder: ------- ESMPyRegridder Regridder instance. + """ return ESMPyRegridder( src_cube, @@ -181,6 +184,7 @@ class ESMPyAreaWeighted(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. + """ _METHOD = 'area_weighted' @@ -198,6 +202,7 @@ class ESMPyLinear(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. + """ _METHOD = 'linear' @@ -215,6 +220,7 @@ class ESMPyNearest(_ESMPyScheme): 2.14.0. Please use :class:`~esmvalcore.preprocessor.regrid_schemes.IrisESMFRegrid` instead. + """ _METHOD = 'nearest' @@ -444,7 +450,8 @@ def get_grid_representant(cube, horizontal_only=False): def get_grid_representants(src, dst): - """Construct cubes representing the source and destination grid. + """ + Construct cubes representing the source and destination grid. This method constructs two new cubes that representant the grids, i.e. the spatial dimensions of the given cubes. diff --git a/esmvalcore/preprocessor/_regrid_unstructured.py b/esmvalcore/preprocessor/_regrid_unstructured.py index ce94d7fa68..6618c728c0 100644 --- a/esmvalcore/preprocessor/_regrid_unstructured.py +++ b/esmvalcore/preprocessor/_regrid_unstructured.py @@ -26,10 +26,10 @@ class UnstructuredNearest(IrisUnstructuredNearest): """Unstructured nearest-neighbor regridding scheme. - This class is a wrapper around - :class:`iris.analysis.UnstructuredNearest` that removes any - additional X or Y coordinates prior to regridding if necessary. It - can be used in :meth:`iris.cube.Cube.regrid`. + This class is a wrapper around :class:`iris.analysis.UnstructuredNearest` + that removes any additional X or Y coordinates prior to regridding if + necessary. It can be used in :meth:`iris.cube.Cube.regrid`. + """ def regridder( @@ -50,6 +50,7 @@ def regridder( ------- UnstructuredNearestNeigbourRegridder Regridder instance. + """ # Unstructured nearest-neighbor regridding requires exactly one X and # one Y coordinate (latitude and longitude). Remove any X or Y @@ -78,6 +79,7 @@ class UnstructuredLinearRegridder: Cube defining the source grid. tgt_cube: Cube defining the target grid. + """ def __init__(self, src_cube: Cube, tgt_cube: Cube) -> None: @@ -125,6 +127,7 @@ def _get_weights_and_idx( The output arrays will be numpy arrays here (instead of dask) since resulting arrays are only 2D and will be computed anyway later during regridding. + """ # Make sure that source and target grid have identical units src_lat = src_lat.copy() @@ -188,6 +191,7 @@ def __call__(self, cube: Cube) -> Cube: ------- Cube Regridded cube. + """ if not has_unstructured_grid(cube): raise ValueError( @@ -316,6 +320,7 @@ def _interpolate(self, data: np.ndarray) -> np.ndarray: Before the interpolation, the input is extended by the data on the convex hull to consider the periodic boundary conditions of a sphere (this has also been done for the weights calculation). + """ data = self._add_convex_hull_twice(data, self._convex_hull_idx) interp_data = np.einsum( @@ -342,6 +347,7 @@ def _calculate_weights( Output shapes (M: number of target grid points) - weights: (M, 3) - indices: (M, 3) + """ tri = Delaunay(src_points) simplex = tri.find_simplex(tgt_points) @@ -367,6 +373,7 @@ class UnstructuredLinear: This will drop all cell measures, ancillary variables and aux factories, and any auxiliary coordinate that spans the dimension of the unstrucutred grid. + """ def __repr__(self) -> str: @@ -391,5 +398,6 @@ def regridder( ------- UnstructuredLinearRegridder Regridder instance. + """ return UnstructuredLinearRegridder(src_cube, tgt_cube) diff --git a/esmvalcore/preprocessor/_rolling_window.py b/esmvalcore/preprocessor/_rolling_window.py index 4b0b5cdf14..9e62275a45 100644 --- a/esmvalcore/preprocessor/_rolling_window.py +++ b/esmvalcore/preprocessor/_rolling_window.py @@ -39,6 +39,7 @@ def rolling_window_statistics( ------- iris.cube.Cube Rolling-window statistics cube. + """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) cube = cube.rolling_window(coordinate, agg, window_length, *agg_kwargs) diff --git a/esmvalcore/preprocessor/_shared.py b/esmvalcore/preprocessor/_shared.py index 1ed78b9766..67c3b89f5d 100644 --- a/esmvalcore/preprocessor/_shared.py +++ b/esmvalcore/preprocessor/_shared.py @@ -1,4 +1,5 @@ -"""Shared functions for preprocessor. +""" +Shared functions for preprocessor. Utility functions that can be used for multiple preprocessor steps """ @@ -67,6 +68,7 @@ def get_iris_aggregator( An invalid `operator` is specified, i.e., it is not found in :mod:`iris.analysis` or the returned object is not an :class:`iris.analysis.Aggregator`. + """ cap_operator = operator.upper() aggregator_kwargs = dict(operator_kwargs) @@ -136,6 +138,7 @@ def aggregator_accept_weights(aggregator: iris.analysis.Aggregator) -> bool: ------- bool ``True`` if aggregator support weights, ``False`` otherwise. + """ weighted_aggregators_cls = ( iris.analysis.WeightedAggregator, @@ -176,6 +179,7 @@ def update_weights_kwargs( ------- dict Updated keyword arguments. + """ kwargs = dict(kwargs) if aggregator_accept_weights(aggregator) and kwargs.get('weights', True): @@ -214,6 +218,7 @@ def get_normalized_cube( ------- Cube Input cube normalized with statistics cube. + """ if normalize == 'subtract': normalized_cube = cube - statistics_cube @@ -245,10 +250,11 @@ def get_normalized_cube( def preserve_float_dtype(func: Callable) -> Callable: """Preserve object's float dtype (all other dtypes are allowed to change). - This can be used as a decorator for preprocessor functions to ensure - that floating dtypes are preserved. For example, input of type - float32 will always give output of type float32, but input of type - int will be allowed to give output with any type. + This can be used as a decorator for preprocessor functions to ensure that + floating dtypes are preserved. For example, input of type float32 will + always give output of type float32, but input of type int will be allowed + to give output with any type. + """ @wraps(func) @@ -375,6 +381,7 @@ def get_time_weights(cube: Cube) -> np.ndarray | da.core.Array: Array of time weights for averaging. Returns a :class:`dask.array.Array` if the input cube has lazy data; a :class:`numpy.ndarray` otherwise. + """ time = cube.coord('time') coord_dims = cube.coord_dims('time') diff --git a/esmvalcore/preprocessor/_time.py b/esmvalcore/preprocessor/_time.py index 5fd60d807a..d4dff4c1f9 100644 --- a/esmvalcore/preprocessor/_time.py +++ b/esmvalcore/preprocessor/_time.py @@ -100,6 +100,7 @@ def extract_time( ------ ValueError Time ranges are outside the cube time limits. + """ t_1 = PartialDateTime(year=int(start_year), month=int(start_month), @@ -259,6 +260,7 @@ def clip_timerange(cube: Cube, timerange: str) -> Cube: ------ ValueError Time ranges are outside the cube's time limits. + """ start_date = _parse_start_date(timerange.split('/')[0]) end_date = _parse_end_date(timerange.split('/')[1]) @@ -316,6 +318,7 @@ def extract_season(cube: Cube, season: str) -> Cube: ------ ValueError Requested season is not present in the cube. + """ season = season.upper() @@ -369,6 +372,7 @@ def extract_month(cube: Cube, month: int) -> Cube: ------ ValueError Requested month is not present in the cube. + """ if month not in range(1, 13): raise ValueError('Please provide a month number between 1 and 12.') @@ -442,6 +446,7 @@ def hourly_statistics( ------- iris.cube.Cube Hourly statistics cube. + """ if not cube.coords('hour_group'): iris.coord_categorisation.add_categorised_coord( @@ -493,6 +498,7 @@ def daily_statistics( ------- iris.cube.Cube Daily statistics cube. + """ if not cube.coords('day_of_year'): iris.coord_categorisation.add_day_of_year(cube, 'time') @@ -533,6 +539,7 @@ def monthly_statistics( ------- iris.cube.Cube Monthly statistics cube. + """ if not cube.coords('month_number'): iris.coord_categorisation.add_month_number(cube, 'time') @@ -577,6 +584,7 @@ def seasonal_statistics( ------- iris.cube.Cube Seasonal statistic cube. + """ seasons = tuple(sea.upper() for sea in seasons) @@ -623,6 +631,7 @@ def spans_full_season(cube: Cube) -> list[bool]: ------- list[bool] Truth statements if time bounds are within (month*29, month*31) + """ time = cube.coord('time') num_days = [(tt.bounds[0, 1] - tt.bounds[0, 0]) for tt in time] @@ -666,6 +675,7 @@ def annual_statistics( ------- iris.cube.Cube Annual statistics cube. + """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -707,6 +717,7 @@ def decadal_statistics( ------- iris.cube.Cube Decadal statistics cube. + """ # TODO: Add weighting in time dimension. See iris issue 3290 # https://github.com/SciTools/iris/issues/3290 @@ -1025,6 +1036,7 @@ def regrid_time( NotImplementedError An invalid `frequency` is given or `calendar` is set for a non-supported frequency. + """ # Do not overwrite input cube cube = cube.copy() @@ -1208,6 +1220,7 @@ def timeseries_filter( Cube does not have time coordinate. NotImplementedError: `filter_type` is not implemented. + """ try: cube.coord('time') @@ -1282,6 +1295,7 @@ def resample_hours( `interval` is not a divisor of 24; invalid `interpolate` given; or input data does not contain any target hour (if `interpolate` is ``None``). + """ allowed_intervals = (1, 2, 3, 4, 6, 12) if interval not in allowed_intervals: @@ -1373,6 +1387,7 @@ def resample_time( ------- iris.cube.Cube Cube with the new frequency. + """ time = cube.coord('time') dates = time.units.num2date(time.points) @@ -1410,6 +1425,7 @@ def _get_lst_offset(lon_coord: Coord) -> np.ndarray: ---- This function expects longitude in degrees. Can be in [0, 360] or [-180, 180] format. + """ # Make sure that longitude is in degrees and shift it to [-180, 180] first # (do NOT overwrite input coordinate) @@ -1426,6 +1442,7 @@ def _get_lsts(time_coord: DimCoord, lon_coord: Coord) -> np.ndarray: ---- LSTs outside of the time bins given be the time coordinate bounds are put into a bin below/above the time coordinate. + """ # Pad time coordinate with 1 time step at both sides for the bins for LSTs # outside of the time coordinate @@ -1473,6 +1490,7 @@ def _get_time_index_and_mask( (LSTs) are given. E.g., for hourly data with first time point 01:00:00 UTC, LST in Berlin is already 02:00:00 (assuming no daylight saving time). Thus, for 01:00:00 LST on this day, there is no value for Berlin. + """ # Make sure that time coordinate has bounds (these are necessary for the # binning) and uses 'hours' as reference units @@ -1537,6 +1555,7 @@ def _transform_to_lst_eager( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. + """ # Apart from the time index, all other dimensions will stay the same; this # is ensured with np.ogrid @@ -1580,6 +1599,7 @@ def _transform_to_lst_lazy( reorder the data along the time axis based on the longitude axis. `mask` is 2D with shape (time, lon) that will be applied to the final data. + """ new_data = da.apply_gufunc( _transform_to_lst_eager, @@ -1610,6 +1630,7 @@ def _transform_arr_to_lst( ---- This function either calls `_transform_to_lst_eager` or `_transform_to_lst_lazy` depending on the type of input data. + """ if isinstance(data, np.ndarray): func = _transform_to_lst_eager # type: ignore @@ -1790,6 +1811,7 @@ def local_solar_time(cube: Cube) -> Cube: Input cube has multidimensional `longitude` coordinate. ValueError `time` coordinate of input cube is not monotonically increasing. + """ # Make sure that cube has valid time and longitude coordinates _check_cube_coords(cube) diff --git a/esmvalcore/preprocessor/_trend.py b/esmvalcore/preprocessor/_trend.py index b81d656034..c592f5196e 100644 --- a/esmvalcore/preprocessor/_trend.py +++ b/esmvalcore/preprocessor/_trend.py @@ -96,6 +96,7 @@ def linear_trend(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. + """ coord = cube.coord(coordinate, dim_coords=True) @@ -150,6 +151,7 @@ def linear_trend_stderr(cube, coordinate='time'): iris.exceptions.CoordinateNotFoundError The dimensional coordinate with the name ``coordinate`` is not found in ``cube``. + """ coord = cube.coord(coordinate, dim_coords=True) diff --git a/esmvalcore/preprocessor/_units.py b/esmvalcore/preprocessor/_units.py index c71fc384d6..8c96f78ae1 100644 --- a/esmvalcore/preprocessor/_units.py +++ b/esmvalcore/preprocessor/_units.py @@ -112,6 +112,7 @@ def convert_units(cube, units): ------- iris.cube.Cube converted cube. + """ try: cube.convert_units(units) diff --git a/esmvalcore/preprocessor/_volume.py b/esmvalcore/preprocessor/_volume.py index 9705f4e4e9..840af3214e 100644 --- a/esmvalcore/preprocessor/_volume.py +++ b/esmvalcore/preprocessor/_volume.py @@ -66,6 +66,7 @@ def extract_volume( ------- iris.cube.Cube z-coord extracted cube. + """ if z_min > z_max: # minimum is below maximum, so switch them around @@ -123,6 +124,7 @@ def calculate_volume(cube: Cube) -> da.core.Array: ------- dask.array.core.Array Grid volumes. + """ # Load depth field and figure out which dim is which depth = cube.coord(axis='z') @@ -252,6 +254,7 @@ def volume_statistics( ------- iris.cube.Cube Collapsed cube. + """ has_cell_measure = bool(cube.cell_measures('ocean_volume')) @@ -336,6 +339,7 @@ def axis_statistics( ------- iris.cube.Cube Collapsed cube. + """ (agg, agg_kwargs) = get_iris_aggregator(operator, **operator_kwargs) @@ -422,6 +426,7 @@ def depth_integration(cube: Cube) -> Cube: ------- iris.cube.Cube Collapsed cube. + """ result = axis_statistics(cube, axis='z', operator='sum') result.rename('Depth_integrated_' + str(cube.name())) @@ -475,6 +480,7 @@ def extract_transect( ValueError Latitude and longitude are both floats or lists; not allowed to slice on both axes at the same time. + """ # ### coord_dim2 = False @@ -565,6 +571,7 @@ def extract_trajectory( ------ ValueError Latitude and longitude have different dimensions. + """ from iris.analysis.trajectory import interpolate diff --git a/esmvalcore/preprocessor/shapefiles/ar6.prj b/esmvalcore/preprocessor/shapefiles/ar6.prj index 8f73f480ff..a30c00a55d 100644 --- a/esmvalcore/preprocessor/shapefiles/ar6.prj +++ b/esmvalcore/preprocessor/shapefiles/ar6.prj @@ -1 +1 @@ -GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/esmvalcore/typing.py b/esmvalcore/typing.py index d5c60fc83e..410b31f0f8 100644 --- a/esmvalcore/typing.py +++ b/esmvalcore/typing.py @@ -17,8 +17,8 @@ NetCDFAttr = Union[str, Number, Iterable] """Type describing netCDF attributes. -`NetCDF attributes`_ -can +`NetCDF attributes +`_ can be strings, numbers or sequences. """ diff --git a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py index 4f26feaf9e..d988e02441 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_bnu_esm.py @@ -27,7 +27,7 @@ def setUp(self): self.fix = Cl(None) def test_get(self): - """Test fix get.""" + """Test fix get""" fix = Fix.get_fixes('CMIP5', 'BNU-ESM', 'Amon', 'cl') assert fix == [Cl(None), GenericFix(None)] diff --git a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py index ba41ddae48..ce6ebe0121 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cmip5/test_cnrm_cm5.py @@ -17,7 +17,7 @@ def setUp(self): self.fix = Msftmyz(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) @@ -37,7 +37,7 @@ def setUp(self): self.fix = Msftmyzba(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'CNRM-CM5', 'Amon', 'msftmyzba'), [Msftmyzba(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py index a0805f4efe..4b480ef81f 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py +++ b/tests/integration/cmor/_fixes/cmip5/test_ec_earth.py @@ -26,7 +26,7 @@ def setUp(self): self.fix = Sic(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sic'), [Sic(None), GenericFix(None)]) @@ -45,7 +45,7 @@ def setUp(self): self.fix = Sftlf(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'sftlf'), [Sftlf(None), GenericFix(None)]) @@ -90,7 +90,7 @@ def setUp(self): self.fix = Tas(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'tas'), [Tas(None), GenericFix(None)]) @@ -147,7 +147,7 @@ def setUp(self): self.fix = Areacello(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Omon', 'areacello'), [Areacello(None), GenericFix(None)], @@ -209,7 +209,7 @@ def setUp(self): self.fix = Pr(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'EC-EARTH', 'Amon', 'pr'), [Pr(None), GenericFix(None)], diff --git a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py index 0220aecb2c..c0705e58fa 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py +++ b/tests/integration/cmor/_fixes/cmip5/test_fio_esm.py @@ -29,7 +29,7 @@ def setUp(self): self.fix = Ch4(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'ch4'), [Ch4(None), GenericFix(None)]) @@ -48,7 +48,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'FIO-ESM', 'Amon', 'co2'), [Co2(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py index f2aa86d7b2..8a4fa19fd1 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm2p1.py @@ -40,7 +40,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -62,7 +62,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'Amon', 'areacello'), [Areacello(self.vardef), @@ -106,7 +106,7 @@ def setUp(self): self.fix = Sit(self.var_info_mock) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM2P1', 'OImon', 'sit'), [Sit(self.var_info_mock), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py index 89b62a21f9..bcda26c95b 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_cm3.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -39,7 +39,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-CM3', 'Amon', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py index d0f0c5245c..d5189e84c4 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2g.py @@ -75,7 +75,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -96,7 +96,7 @@ def setUp(self): self.fix = Usi(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'usi'), [Usi(self.vardef), @@ -118,7 +118,7 @@ def setUp(self): self.fix = Vsi(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'day', 'vsi'), [Vsi(self.vardef), @@ -140,7 +140,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2G', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py index 9fe2db7c83..1897ba5c85 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py +++ b/tests/integration/cmor/_fixes/cmip5/test_gfdl_esm2m.py @@ -23,7 +23,7 @@ def setUp(self): self.fix = Sftof(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'sftof'), [Sftof(None), AllVars(None), GenericFix(None)]) @@ -43,7 +43,7 @@ def setUp(self): self.fix = Co2(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'Amon', 'co2'), [Co2(None), AllVars(None), GenericFix(None)]) @@ -64,7 +64,7 @@ def setUp(self): self.fix = Areacello(self.vardef) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'GFDL-ESM2M', 'fx', 'areacello'), [Areacello(self.vardef), diff --git a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py index 85bede7678..0e6a4fc57a 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py +++ b/tests/integration/cmor/_fixes/cmip5/test_hadgem2_cc.py @@ -9,7 +9,7 @@ class TestAllVars(unittest.TestCase): """Test allvars fixes.""" def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'tas'), [AllVars(None), GenericFix(None)]) @@ -18,7 +18,7 @@ def test_get(self): class TestO2(unittest.TestCase): """Test o2 fixes.""" def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'HADGEM2-CC', 'Amon', 'o2'), [O2(None), AllVars(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py index 64fcbc250c..1e14dfd30c 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py +++ b/tests/integration/cmor/_fixes/cmip5/test_miroc_esm_chem.py @@ -18,7 +18,7 @@ def setUp(self): self.fix = Tro3(None) def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MIROC-ESM-CHEM', 'Amon', 'tro3'), [Tro3(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py index baabbbf599..f4d39eb70b 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py +++ b/tests/integration/cmor/_fixes/cmip5/test_mri_esm1.py @@ -9,7 +9,7 @@ class TestMsftmyz(unittest.TestCase): """Test msftmyz fixes.""" def test_get(self): - """Test fix get.""" + """Test fix get""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MRI-ESM1', 'Amon', 'msftmyz'), [Msftmyz(None), GenericFix(None)]) diff --git a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py index fc962f38b7..b600311d5a 100644 --- a/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py +++ b/tests/integration/cmor/_fixes/cmip5/test_noresm1_me.py @@ -69,7 +69,7 @@ def test_tas(cubes_in, cubes_out): def test_get(): - """Test fix get.""" + """Test fix get""" assert Fix.get_fixes('CMIP5', 'NORESM1-ME', 'Amon', 'tas') == [ Tas(None), GenericFix(None) ] diff --git a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py index b4c1b9f7e9..65ca211e12 100644 --- a/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py +++ b/tests/integration/cmor/_fixes/cmip6/test_gfdl_cm4.py @@ -2,7 +2,6 @@ import iris import numpy as np import pytest -from cf_units import Unit from esmvalcore.cmor._fixes.cmip6.gfdl_cm4 import ( Cl, @@ -16,10 +15,11 @@ Tos, Uas, ) -from esmvalcore.cmor._fixes.common import OceanFixGrid, SiconcFixScalarCoord +from esmvalcore.cmor._fixes.common import SiconcFixScalarCoord, OceanFixGrid from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info +from cf_units import Unit def test_get_cl_fix(): diff --git a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py index 9668681c06..63428e913c 100644 --- a/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py +++ b/tests/integration/cmor/_fixes/cordex/test_cnrm_cerfacs_cnrm_cm5.py @@ -4,8 +4,7 @@ from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5 import ( aladin63, - wrf381p, -) + wrf381p,) from esmvalcore.cmor.fix import Fix from esmvalcore.cmor.table import get_var_info diff --git a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py index f1149064a0..c54bea04cd 100644 --- a/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py +++ b/tests/integration/cmor/_fixes/cordex/test_miroc_miroc5.py @@ -1,6 +1,6 @@ """Tests for the fixes of MIROC-MIROC5.""" -import iris import pytest +import iris from esmvalcore.cmor._fixes.cordex.miroc_miroc5 import wrf361h from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_fix.py b/tests/integration/cmor/_fixes/test_fix.py index cfbbbebf31..1e97c62fd4 100644 --- a/tests/integration/cmor/_fixes/test_fix.py +++ b/tests/integration/cmor/_fixes/test_fix.py @@ -10,7 +10,9 @@ from esmvalcore.cmor._fixes.cmip5.canesm2 import FgCo2 from esmvalcore.cmor._fixes.cmip5.cesm1_bgc import Gpp from esmvalcore.cmor._fixes.cmip6.cesm2 import Omon, Tos -from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import Tas +from esmvalcore.cmor._fixes.cordex.cnrm_cerfacs_cnrm_cm5.aladin63 import ( + Tas, +) from esmvalcore.cmor._fixes.cordex.cordex_fixes import AllVars from esmvalcore.cmor._fixes.fix import GenericFix from esmvalcore.cmor.fix import Fix diff --git a/tests/integration/cmor/_fixes/test_native_datasets.py b/tests/integration/cmor/_fixes/test_native_datasets.py index 1a732f1788..5399bf887e 100644 --- a/tests/integration/cmor/_fixes/test_native_datasets.py +++ b/tests/integration/cmor/_fixes/test_native_datasets.py @@ -89,6 +89,7 @@ def fix(): We use `tas` as a dummy variable here, but will use monkeypatching to customize the variable information of the fix in the tests below. This will allow us to test all common cases. + """ vardef = get_var_info('CMIP6', 'Amon', 'tas') extra_facets = {} diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index cc4237f5b7..fbddec7fe0 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -43,8 +43,9 @@ def create_test_file(filename, tracking_id=None): def _get_files(root_path, facets, tracking_id): """Return dummy files. - Wildcards are only supported for `dataset` and `institute`; in this - case return files for the two "models" AAA and BBB. + Wildcards are only supported for `dataset` and `institute`; in this case + return files for the two "models" AAA and BBB. + """ if facets['dataset'] == '*': all_facets = [ @@ -140,6 +141,7 @@ def patched_failing_datafinder(tmp_path, monkeypatch): - Variable rsutcs for model AAA Otherwise, return files just like `patched_datafinder`. + """ def tracking_ids(i=0): diff --git a/tests/integration/data_finder.yml b/tests/integration/data_finder.yml index 9b90bc7da6..40e0c3e821 100644 --- a/tests/integration/data_finder.yml +++ b/tests/integration/data_finder.yml @@ -452,7 +452,7 @@ get_input_filelist: - ta_Amon_HadGEM2-ES_historical_r1i1p1*.nc found_files: - historical/Amon/ta/HadGEM2-ES/r1i1p1/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -472,7 +472,7 @@ get_input_filelist: found_files: - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_195912-198411.nc - MOHC/HadGEM2-ES/historical/mon/atmos/Amon/r1i1p1/v20120928/ta/ta_Amon_HadGEM2-ES_historical_r1i1p1_198412-200511.nc - + - drs: NCI variable: <<: *variable @@ -593,7 +593,7 @@ get_input_filelist: found_files: - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_195001-199912.nc - historical/atmos/mon/ta/HADGEM1/r1i1p1/ta_HADGEM1_200001-200112.nc - + - drs: NCI variable: variable_group: test diff --git a/tests/integration/preprocessor/_extract_region/test_intersect.py b/tests/integration/preprocessor/_extract_region/test_intersect.py index 813576e4c6..41442c9c01 100644 --- a/tests/integration/preprocessor/_extract_region/test_intersect.py +++ b/tests/integration/preprocessor/_extract_region/test_intersect.py @@ -1,8 +1,8 @@ -"""Temporary test. +""" +Temporary test. Remove this test and test file after iris fixes this -https://github.com/SciTools/iris/issues/5413 -. +https://github.com/SciTools/iris/issues/5413 . """ import iris import numpy as np diff --git a/tests/integration/preprocessor/_mask/__init__.py b/tests/integration/preprocessor/_mask/__init__.py index 1b1a5d625b..9886ea9eed 100644 --- a/tests/integration/preprocessor/_mask/__init__.py +++ b/tests/integration/preprocessor/_mask/__init__.py @@ -1,4 +1,5 @@ -"""Test _mask.py. +""" +Test _mask.py Integration tests for the esmvalcore.preprocessor._mask module """ diff --git a/tests/integration/preprocessor/_regrid/__init__.py b/tests/integration/preprocessor/_regrid/__init__.py index bb8eab5e54..e19e118a0f 100644 --- a/tests/integration/preprocessor/_regrid/__init__.py +++ b/tests/integration/preprocessor/_regrid/__init__.py @@ -1 +1,4 @@ -"""Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module.""" +""" +Integration tests for the :mod:`esmvalcore.preprocessor._regrid` module. + +""" diff --git a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py index f666ff64cf..7b4d4eb9b5 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py +++ b/tests/integration/preprocessor/_regrid/test_extract_coordinate_points.py @@ -1,5 +1,8 @@ -"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function.""" +""" +Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function. + +""" import unittest @@ -20,7 +23,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point.""" + """Test linear interpolation when extracting a single point""" point = extract_coordinate_points( self.cube, {'grid_latitude': 2.1, 'grid_longitude': 2.1}, @@ -63,7 +66,7 @@ def test_extract_point__single_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point.""" + """Test nearest match when extracting a single point""" point = extract_coordinate_points( self.cube, @@ -96,7 +99,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate.""" + """Test linear interpolation for an array of one coordinate""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -148,7 +151,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate.""" + """Test nearest match for an array of one coordinate""" point = extract_coordinate_points( self.cube, @@ -189,8 +192,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with linear - interpolation.""" + """Test for both latitude and longitude arrays, with + linear interpolation""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], @@ -220,7 +223,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match.""" + """Test for both latitude and longitude arrays, with nearest match""" point = extract_coordinate_points( self.cube, {'grid_latitude': [0, 1.1, 1.5, 1.51, 4, 5], diff --git a/tests/integration/preprocessor/_regrid/test_extract_point.py b/tests/integration/preprocessor/_regrid/test_extract_point.py index 79ec2e5685..d3d93945b9 100644 --- a/tests/integration/preprocessor/_regrid/test_extract_point.py +++ b/tests/integration/preprocessor/_regrid/test_extract_point.py @@ -1,5 +1,8 @@ -"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function.""" +""" +Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function. + +""" import unittest @@ -20,7 +23,7 @@ def setUp(self): self.cs = iris.coord_systems.GeogCS(iris.fileformats.pp.EARTH_RADIUS) def test_extract_point__single_linear(self): - """Test linear interpolation when extracting a single point.""" + """Test linear interpolation when extracting a single point""" point = extract_point(self.cube, 2.1, 2.1, scheme='linear') self.assertEqual(point.shape, (3,)) @@ -55,7 +58,7 @@ def test_extract_point__single_linear(self): assert point.data.mask.all() def test_extract_point__single_nearest(self): - """Test nearest match when extracting a single point.""" + """Test nearest match when extracting a single point""" point = extract_point(self.cube, 2.1, 2.1, scheme='nearest') self.assertEqual(point.shape, (3,)) @@ -76,7 +79,7 @@ def test_extract_point__single_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_linear(self): - """Test linear interpolation for an array of one coordinate.""" + """Test linear interpolation for an array of one coordinate""" # Test points on the grid edges, on a grid point, halfway and # one in between. @@ -118,7 +121,7 @@ def test_extract_point__multiple_linear(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_nearest(self): - """Test nearest match for an array of one coordinate.""" + """Test nearest match for an array of one coordinate""" point = extract_point(self.cube, [1, 1.1, 1.5, 1.501, 2, 4], 2, scheme='nearest') @@ -147,8 +150,8 @@ def test_extract_point__multiple_nearest(self): self.assert_array_equal(point.data, masked) def test_extract_point__multiple_both_linear(self): - """Test for both latitude and longitude arrays, with linear - interpolation.""" + """Test for both latitude and longitude arrays, with + linear interpolation""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='linear') self.assertEqual(point.data.shape, (3, 6, 6)) @@ -176,7 +179,7 @@ def test_extract_point__multiple_both_linear(self): np.testing.assert_allclose(point.data, result) def test_extract_point__multiple_both_nearest(self): - """Test for both latitude and longitude arrays, with nearest match.""" + """Test for both latitude and longitude arrays, with nearest match""" point = extract_point(self.cube, [0, 1.1, 1.5, 1.51, 4, 5], [0, 1.1, 1.5, 1.51, 4, 5], scheme='nearest') self.assertEqual(point.data.shape, (3, 6, 6)) diff --git a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py index b7a2ed0bcd..b4f869d171 100644 --- a/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py +++ b/tests/integration/preprocessor/_regrid/test_get_cmor_levels.py @@ -1,6 +1,8 @@ -"""Integration tests for the :func: +""" +Integration tests for the :func: +`esmvalcore.preprocessor.regrid.get_cmor_levels` +function. -`esmvalcore.preprocessor.regrid.get_cmor_levels` function. """ import unittest diff --git a/tests/integration/preprocessor/_regrid/test_regrid.py b/tests/integration/preprocessor/_regrid/test_regrid.py index 00f35c0ad8..4e2e472681 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid.py +++ b/tests/integration/preprocessor/_regrid/test_regrid.py @@ -1,5 +1,8 @@ -"""Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` -function.""" +""" +Integration tests for the :func:`esmvalcore.preprocessor.regrid.regrid` +function. + +""" import iris import numpy as np diff --git a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py index 8b410771fc..fee070863c 100644 --- a/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py +++ b/tests/integration/preprocessor/_regrid/test_regrid_unstructured.py @@ -1,4 +1,4 @@ -"""Integration tests for unstructured regridding.""" +""" Integration tests for unstructured regridding.""" import numpy as np import pytest diff --git a/tests/integration/preprocessor/_supplementary_vars/test_register.py b/tests/integration/preprocessor/_supplementary_vars/test_register.py index bf4c1677d2..cfe6d5b7da 100644 --- a/tests/integration/preprocessor/_supplementary_vars/test_register.py +++ b/tests/integration/preprocessor/_supplementary_vars/test_register.py @@ -28,7 +28,7 @@ def test_func(): def test_register_invalid_fails(): - """Test that registering an invalid requirement fails.""" + """test that registering an invalid requirement fails.""" with pytest.raises(NotImplementedError): @_supplementary_vars.register_supplementaries( diff --git a/tests/integration/test_citation.py b/tests/integration/test_citation.py index 2bf34b4858..339cd253a0 100644 --- a/tests/integration/test_citation.py +++ b/tests/integration/test_citation.py @@ -4,11 +4,8 @@ from prov.model import ProvDocument import esmvalcore -from esmvalcore._citation import ( - CMIP6_URL_STEM, - ESMVALTOOL_PAPER, - _write_citation_files, -) +from esmvalcore._citation import (CMIP6_URL_STEM, ESMVALTOOL_PAPER, + _write_citation_files) from esmvalcore._provenance import ESMVALTOOL_URI_PREFIX diff --git a/tests/parse_pymon.py b/tests/parse_pymon.py index a9e9b21891..e63da518cc 100644 --- a/tests/parse_pymon.py +++ b/tests/parse_pymon.py @@ -1,7 +1,7 @@ -"""Parse and display test memory. +""" +Parse and display test memory. -Uses pytest-monitor plugin from -https://github.com/CFMTech/pytest-monitor +Uses pytest-monitor plugin from https://github.com/CFMTech/pytest-monitor Lots of other metrics can be read from the file via sqlite parsing., currently just MEM_USAGE (RES memory, in MB). """ diff --git a/tests/sample_data/multimodel_statistics/test_multimodel.py b/tests/sample_data/multimodel_statistics/test_multimodel.py index b99e183cbb..4c40d94875 100644 --- a/tests/sample_data/multimodel_statistics/test_multimodel.py +++ b/tests/sample_data/multimodel_statistics/test_multimodel.py @@ -204,6 +204,7 @@ def test_multimodel_regression_month(timeseries_cubes_month, span): """Test statistic fail due to differing input coordinates (pressure). See https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = timeseries_cubes_month name = 'timeseries_monthly' @@ -293,6 +294,7 @@ def test_multimodel_merge_error(timeseries_cubes_month, span): """Test statistic with slightly different vertical coordinates. See https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = timeseries_cubes_month msg = ( @@ -320,6 +322,7 @@ def test_multimodel_no_time_dimension(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -347,6 +350,7 @@ def test_multimodel_0d_1d_time_no_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -365,6 +369,7 @@ def test_multimodel_0d_1d_time_ignore_scalars(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim cubes[1] = cubes[1][0] # use 0D time dim for one cube @@ -389,6 +394,7 @@ def test_multimodel_only_some_time_dimensions(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[:, 0] for cube in timeseries_cubes_month] # remove Z-dim @@ -414,6 +420,7 @@ def test_multimodel_diff_scalar_time_fail(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -435,6 +442,7 @@ def test_multimodel_diff_scalar_time_ignore(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] @@ -457,6 +465,7 @@ def test_multimodel_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): @@ -482,6 +491,7 @@ def test_multimodel_do_not_ignore_scalar_coords(timeseries_cubes_month, span): first value) since the original coordinate differs slightly across cubes and leads to merge errors. See also https://github.com/ESMValGroup/ESMValCore/issues/956. + """ cubes = [cube[0, 0] for cube in timeseries_cubes_month] for (idx, cube) in enumerate(cubes): diff --git a/tests/unit/cmor/test_cmor_check.py b/tests/unit/cmor/test_cmor_check.py index e1ba8ce9ac..957136fd42 100644 --- a/tests/unit/cmor/test_cmor_check.py +++ b/tests/unit/cmor/test_cmor_check.py @@ -137,7 +137,7 @@ def test_warning_fail_on_error(self): ) def test_report_debug_message(self): - """"Test report debug message function.""" + """"Test report debug message function""" checker = CMORCheck(self.cube, self.var_info) self.assertFalse(checker.has_debug_messages()) checker.report_debug_message('New debug message') @@ -270,8 +270,8 @@ def test_rank_unstructured_grid(self): self._check_cube() def test_bad_generic_level(self): - """Test check fails in metadata if generic level coord has wrong - var_name.""" + """Test check fails in metadata if generic level coord + has wrong var_name.""" depth_coord = CoordinateInfoMock('depth') depth_coord.axis = 'Z' depth_coord.generic_lev_name = 'olevel' @@ -385,26 +385,26 @@ def test_check_bad_coord_var_name_strict_flag(self): self._check_fails_in_metadata() def test_check_missing_lon_strict_flag(self): - """Test check fails for missing longitude with --cmor-check strict.""" + """Test check fails for missing longitude with --cmor-check strict""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata() def test_check_missing_lat_strict_flag(self): - """Test check fails for missing latitude with --cmor-check strict.""" + """Test check fails for missing latitude with --cmor-check strict""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata() def test_check_missing_time_strict_flag(self): - """Test check fails for missing time with --cmor-check strict.""" + """Test check fails for missing time with --cmor-check strict""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata() def test_check_missing_coord_strict_flag(self): - """Test check fails for missing coord other than lat and lon with - --cmor-check strict.""" + """Test check fails for missing coord other than lat and lon + with --cmor-check strict""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -453,26 +453,26 @@ def test_check_bad_coord_standard_name_relaxed_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lon_relaxed_flag(self): - """Test check fails for missing longitude with --cmor-check relaxed.""" + """Test check fails for missing longitude with --cmor-check relaxed""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('longitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_lat_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed.""" + """Test check fails for missing latitude with --cmor-check relaxed""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('latitude') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_time_relaxed_flag(self): - """Test check fails for missing latitude with --cmor-check relaxed.""" + """Test check fails for missing latitude with --cmor-check relaxed""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_fails_in_metadata(check_level=CheckLevels.RELAXED) def test_check_missing_coord_relaxed_flag(self): """Test check reports warning for missing coord other than lat and lon - with --cmor-check relaxed.""" + with --cmor-check relaxed""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -535,15 +535,15 @@ def test_check_missing_lat_none_flag(self): self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_time_none_flag(self): - """Test check reports warning for missing time with --cmor-check - ignore.""" + """Test check reports warning for missing time + with --cmor-check ignore""" self.var_info.table_type = 'CMIP5' self.cube.remove_coord('time') self._check_warnings_on_metadata(check_level=CheckLevels.IGNORE) def test_check_missing_coord_none_flag(self): """Test check reports warning for missing coord other than lat, lon and - time with --cmor-check ignore.""" + time with --cmor-check ignore""" self.var_info.coordinates.update( {'height2m': CoordinateInfoMock('height2m')} ) @@ -603,10 +603,11 @@ def _check_debug_messages_on_metadata(self): self.assertTrue(checker.has_debug_messages()) def test_non_requested(self): - """Warning if requested values are not present. + """ + Warning if requested values are not present. - Check issue a warning if a values requested for a coordinate are - not correct in the metadata step + Check issue a warning if a values requested + for a coordinate are not correct in the metadata step """ coord = self.cube.coord('air_pressure') values = np.linspace(0, 40, len(coord.points)) @@ -616,10 +617,11 @@ def test_non_requested(self): self.assertTrue(checker.has_warnings()) def test_requested_str_values(self): - """Warning if requested values are not present. + """ + Warning if requested values are not present. - Check issue a warning if a values requested for a coordinate are - not correct in the metadata step + Check issue a warning if a values requested + for a coordinate are not correct in the metadata step """ region_coord = CoordinateInfoMock('basin') region_coord.standard_name = 'region' @@ -806,19 +808,19 @@ def test_bad_out_name_region_area_type(self): self._check_debug_messages_on_metadata() def test_bad_out_name_onedim_latitude(self): - """Warning if onedimensional lat has bad var_name at metadata.""" + """Warning if onedimensional lat has bad var_name at metadata""" self.var_info.table_type = 'CMIP6' self.cube.coord('latitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_onedim_longitude(self): - """Warning if onedimensional lon has bad var_name at metadata.""" + """Warning if onedimensional lon has bad var_name at metadata""" self.var_info.table_type = 'CMIP6' self.cube.coord('longitude').var_name = 'bad_name' self._check_fails_in_metadata() def test_bad_out_name_other(self): - """Warning if general coordinate has bad var_name at metadata.""" + """Warning if general coordinate has bad var_name at metadata""" self.var_info.table_type = 'CMIP6' self.cube.coord('time').var_name = 'bad_name' self._check_fails_in_metadata() @@ -925,7 +927,8 @@ def get_cube(self, var_info, set_time_units="days since 1850-1-1 00:00:00", frequency=None): - """Create a cube based on a specification. + """ + Create a cube based on a specification. Parameters ---------- @@ -939,6 +942,7 @@ def get_cube(self, Returns ------- iris.cube.Cube + """ coords = [] scalar_coords = [] diff --git a/tests/unit/preprocessor/_derive/test_toz.py b/tests/unit/preprocessor/_derive/test_toz.py index 12dee514a5..262deab1e0 100644 --- a/tests/unit/preprocessor/_derive/test_toz.py +++ b/tests/unit/preprocessor/_derive/test_toz.py @@ -5,7 +5,6 @@ import pytest import esmvalcore.preprocessor._derive.toz as toz - from .test_co2s import get_coord_spec, get_ps_cube diff --git a/tests/unit/preprocessor/_detrend/test_detrend.py b/tests/unit/preprocessor/_detrend/test_detrend.py index acf9c6cbe0..9b53f65d51 100644 --- a/tests/unit/preprocessor/_detrend/test_detrend.py +++ b/tests/unit/preprocessor/_detrend/test_detrend.py @@ -4,10 +4,11 @@ import iris import iris.coords +from iris.cube import Cube import numpy as np import pytest from cf_units import Unit -from iris.cube import Cube + from numpy.testing import assert_array_almost_equal from esmvalcore.preprocessor._detrend import detrend diff --git a/tests/unit/preprocessor/_mapping/test_mapping.py b/tests/unit/preprocessor/_mapping/test_mapping.py index 2af937349c..dc838b3a54 100644 --- a/tests/unit/preprocessor/_mapping/test_mapping.py +++ b/tests/unit/preprocessor/_mapping/test_mapping.py @@ -6,11 +6,8 @@ import numpy as np import tests -from esmvalcore.preprocessor._mapping import ( - get_empty_data, - map_slices, - ref_to_dims_index, -) +from esmvalcore.preprocessor._mapping import (get_empty_data, map_slices, + ref_to_dims_index) class TestHelpers(tests.Test): diff --git a/tests/unit/preprocessor/_regrid/__init__.py b/tests/unit/preprocessor/_regrid/__init__.py index 5774c41a41..2c0e5a2f47 100644 --- a/tests/unit/preprocessor/_regrid/__init__.py +++ b/tests/unit/preprocessor/_regrid/__init__.py @@ -1,7 +1,9 @@ -"""Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module.""" +""" +Unit tests for the :mod:`esmvalcore.preprocessor.regrid` module. -from typing import Literal +""" +from typing import Literal import iris import iris.fileformats import numpy as np @@ -9,7 +11,10 @@ def _make_vcoord(data, dtype=None): - """Create a synthetic test vertical coordinate.""" + """ + Create a synthetic test vertical coordinate. + + """ if dtype is None: dtype = np.dtype('int8') @@ -42,7 +47,10 @@ def _make_cube( dtype=None, grid: Literal['regular', 'rotated', 'mesh'] = 'regular', ): - """Create a 3d synthetic test cube.""" + """ + Create a 3d synthetic test cube. + + """ if dtype is None: dtype = np.dtype('int8') diff --git a/tests/unit/preprocessor/_regrid/test__create_cube.py b/tests/unit/preprocessor/_regrid/test__create_cube.py index cfb4434bb4..e0f65eab78 100644 --- a/tests/unit/preprocessor/_regrid/test__create_cube.py +++ b/tests/unit/preprocessor/_regrid/test__create_cube.py @@ -1,5 +1,8 @@ -"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` -function.""" +""" +Unit tests for the :func:`esmvalcore.preprocessor.regrid._create_cube` +function. + +""" import unittest diff --git a/tests/unit/preprocessor/_regrid/test__stock_cube.py b/tests/unit/preprocessor/_regrid/test__stock_cube.py index 8b2290f531..8142b66ed8 100644 --- a/tests/unit/preprocessor/_regrid/test__stock_cube.py +++ b/tests/unit/preprocessor/_regrid/test__stock_cube.py @@ -1,5 +1,8 @@ -"""Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` -function.""" +""" +Unit tests for the :func:`esmvalcore.preprocessor.regrid._stock_cube` +function. + +""" import unittest from unittest import mock diff --git a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py index 1375027263..5896f442ba 100644 --- a/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py +++ b/tests/unit/preprocessor/_regrid_iris_esmf_regrid/test_regrid_iris_esmf_regrid.py @@ -1,8 +1,8 @@ """Tests for `esmvalcore.preprocessor._regrid_iris_esmf_regrid`.""" -import esmf_regrid import iris.cube import numpy as np import pytest +import esmf_regrid from esmvalcore.preprocessor.regrid_schemes import IrisESMFRegrid diff --git a/tests/unit/preprocessor/_volume/test_volume.py b/tests/unit/preprocessor/_volume/test_volume.py index 1370cc5765..d45b9bd744 100644 --- a/tests/unit/preprocessor/_volume/test_volume.py +++ b/tests/unit/preprocessor/_volume/test_volume.py @@ -435,8 +435,9 @@ def test_volume_statistics(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_volume_nolevbounds(self): - """Test to take the volume weighted average of a cube with no bounds in - the z axis.""" + """Test to take the volume weighted average of a cube with no bounds + in the z axis. + """ self.assertFalse(self.grid_4d_znobounds.coord(axis='z').has_bounds()) result = volume_statistics(self.grid_4d_znobounds, 'mean') @@ -448,7 +449,7 @@ def test_volume_nolevbounds(self): self.assertFalse(result.cell_measures('ocean_volume')) def test_calculate_volume_lazy(self): - """Test that calculate_volume returns a lazy volume. + """Test that calculate_volume returns a lazy volume The volume chunks should match those of the input cube for computational efficiency. @@ -599,7 +600,7 @@ def test_volume_statistics_2d_lat_cellarea(self): self.assertEqual(result.units, 'kg m-3') def test_volume_statistics_invalid_bounds(self): - """Test z-axis bounds is not 2 in last dimension.""" + """Test z-axis bounds is not 2 in last dimension""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_invalid_z_bounds, 'mean') @@ -610,7 +611,7 @@ def test_volume_statistics_invalid_bounds(self): ) def test_volume_statistics_invalid_units(self): - """Test z-axis units cannot be converted to m.""" + """Test z-axis units cannot be converted to m""" with self.assertRaises(ValueError) as err: volume_statistics(self.grid_4d_sigma_space, 'mean') diff --git a/tests/unit/test_dataset.py b/tests/unit/test_dataset.py index c583252993..25129dbf5d 100644 --- a/tests/unit/test_dataset.py +++ b/tests/unit/test_dataset.py @@ -890,8 +890,7 @@ def test_from_files_with_globs(monkeypatch, session): def test_from_files_with_globs_and_missing_facets(monkeypatch, session): """Test `from_files` with wildcards and files with missing facets. - Tests a combination of files with complete facets and missing - facets. + Tests a combination of files with complete facets and missing facets. """ rootpath = Path('/path/to/data') file1 = esmvalcore.local.LocalFile( @@ -974,8 +973,8 @@ def test_from_files_with_globs_and_missing_facets(monkeypatch, session): def test_from_files_with_globs_and_automatic_missing(monkeypatch, session): """Test `from_files`. - Test with wildcards and files with missing facets that can be - automatically added. + Test with wildcards and files with missing facets that can be automatically + added. """ rootpath = Path('/path/to/data') file = esmvalcore.local.LocalFile( diff --git a/tests/unit/test_iris_io.py b/tests/unit/test_iris_io.py index 500aa492d9..1b81c78d2f 100644 --- a/tests/unit/test_iris_io.py +++ b/tests/unit/test_iris_io.py @@ -41,7 +41,8 @@ def create_regular_cube(): def test_iris_save_with_lazy_coordinate(tmp_path): - """Test saving a cube with fully lazy coords and data. + """ + Test saving a cube with fully lazy coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ @@ -55,7 +56,8 @@ def test_iris_save_with_lazy_coordinate(tmp_path): def test_iris_save_with_regular_coordinate(tmp_path): - """Test saving a cube with numpy array coords and data. + """ + Test saving a cube with numpy array coords and data. Motivated by https://github.com/SciTools/iris/issues/4599 """ diff --git a/tests/unit/test_naming.py b/tests/unit/test_naming.py index 1a9255c255..41971a60a8 100644 --- a/tests/unit/test_naming.py +++ b/tests/unit/test_naming.py @@ -1,19 +1,20 @@ -"""Checks to ensure that files follow the naming convention.""" +"""Checks to ensure that files follow the naming convention""" import os import unittest class TestNaming(unittest.TestCase): - """Test naming of files and folders.""" + """Test naming of files and folders""" def setUp(self): - """Prepare tests.""" + """Prepare tests""" folder = os.path.join(__file__, '..', '..', '..') self.esmvaltool_folder = os.path.abspath(folder) def test_windows_reserved_names(self): - """Check that no file or folder uses a Windows reserved name. + """ + Check that no file or folder uses a Windows reserved name Files can not differ from a reserved name by the extension only """ @@ -36,7 +37,8 @@ def test_windows_reserved_names(self): reserved_names.isdisjoint(without_extensions), error_msg) def test_avoid_casing_collisions(self): - """Check that there are no names differing only in the capitalization. + """ + Check that there are no names differing only in the capitalization This includes folders differing from files """ @@ -50,8 +52,8 @@ def test_avoid_casing_collisions(self): 'capitalization'.format(dirpath)) def test_no_namelist(self): - """Check that there are no namelist references in file and folder - names. + """ + Check that there are no namelist references in file and folder names This will help us to avoid bad merges with stale branches """