Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into local_time_preproc
Browse files Browse the repository at this point in the history
  • Loading branch information
schlunma committed Dec 21, 2023
2 parents 8ca8e65 + 1f55ec9 commit f7b75b8
Show file tree
Hide file tree
Showing 12 changed files with 1,106 additions and 925 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
# Test building documentation
docker:
- image: condaforge/mambaforge
resource_class: small
resource_class: medium
steps:
- checkout
- run:
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/build-and-deploy-on-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ jobs:
build-n-publish:
name: Build and publish ESMValCore on PyPi
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/ESMValCore/
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install pep517
Expand All @@ -34,14 +40,10 @@ jobs:
--binary
--out-dir dist/
.
#- name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.test_pypi_password }}
# repository_url: https://test.pypi.org/legacy/
# - name: Publish distribution to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ authors:
given-names: Joerg

cff-version: 1.2.0
date-released: 2023-11-01
date-released: 2023-12-19
doi: "10.5281/zenodo.3387139"
license: "Apache-2.0"
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/ESMValGroup/ESMValCore/"
title: ESMValCore
version: "v2.10.0rc1"
version: "v2.10.0"
...
348 changes: 176 additions & 172 deletions conda-linux-64.lock

Large diffs are not rendered by default.

1,475 changes: 741 additions & 734 deletions doc/changelog.rst

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
'nbsphinx',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
Expand Down Expand Up @@ -450,6 +451,36 @@
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
}

# -- Extlinks extension -------------------------------------------------------
# See https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html

extlinks = {
"discussion": (
"https://github.com/ESMValGroup/ESMValCore/discussions/%s",
"Discussion #%s",
),
"issue": (
"https://github.com/ESMValGroup/ESMValCore/issues/%s",
"Issue #%s",
),
"pull": (
"https://github.com/ESMValGroup/ESMValCore/pull/%s",
"Pull request #%s",
),
"release": (
"https://github.com/ESMValGroup/ESMValCore/releases/tag/%s",
"ESMValCore %s",
),
"team": (
"https://github.com/orgs/ESMValGroup/teams/%s",
"@ESMValGroup/%s",
),
"user": (
"https://github.com/%s",
"@%s",
),
}

# -- Custom Document processing ----------------------------------------------

sys.path.append(os.path.dirname(__file__))
Expand Down
3 changes: 1 addition & 2 deletions doc/quickstart/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ Extensive documentation on setting up Dask Clusters is available

If not all preprocessor functions support lazy data, computational
performance may be best with the default scheduler.
See `issue #674 <https://github.com/ESMValGroup/ESMValCore/issues/674>`_ for
progress on making all preprocessor functions lazy.
See :issue:`674` for progress on making all preprocessor functions lazy.

**Example configurations**

Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
- geopy
- humanfriendly
- importlib_metadata # required for Python < 3.10
- iris >=3.6.0
- iris >=3.6.1
- iris-esmf-regrid >=0.7.0
- isodate
- jinja2
Expand All @@ -37,7 +37,7 @@ dependencies:
- psutil
- py-cordex
- pybtex
- python >=3.9
- python >=3.9,<3.12
- python-stratify >=0.3
- pyyaml
- requests
Expand Down
12 changes: 12 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_hr.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def fix_metadata(self, cubes):
return cubes


class Tasmax(Tas):
"""Fixes for tasmax."""


class Ta(Fix):
"""Fixes for ta."""

Expand Down Expand Up @@ -100,3 +104,11 @@ def fix_metadata(self, cubes):
add_scalar_height_coord(cube, height=10.0)

return cubes


class Uas(SfcWind):
"""Fixes for uas."""


class Vas(SfcWind):
"""Fixes for vas."""
16 changes: 16 additions & 0 deletions esmvalcore/cmor/_fixes/cmip6/mpi_esm1_2_xr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class Tas(BaseTas):
"""Fixes for tas."""


class Tasmax(BaseTas):
"""Fixes for tasmax."""


class Tasmin(BaseTas):
"""Fixes for tasmin."""


class Ta(BaseFix):
"""Fixes for ta."""

Expand All @@ -27,3 +35,11 @@ class Ua(BaseFix):

class SfcWind(BaseSfcWind):
"""Fixes for sfcWind."""


class Uas(BaseSfcWind):
"""Fixes for uas."""


class Vas(BaseSfcWind):
"""Fixes for vas."""
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
'scipy>=1.6',
# See the following issue for info on the iris pin below:
# https://github.com/ESMValGroup/ESMValTool/issues/3239#issuecomment-1613298587
'scitools-iris>=3.4.0',
'scitools-iris>=3.6.1',
'shapely>=2.0.0',
'stratify>=0.3',
'yamale',
Expand Down
114 changes: 112 additions & 2 deletions tests/integration/cmor/_fixes/cmip6/test_mpi_esm1_2_hr.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
"""Test fixes for MPI-ESM1-2-HR."""
import iris

from esmvalcore.cmor._fixes.cmip6.mpi_esm1_2_hr import AllVars, Cl, Cli, Clw
import pytest
from cf_units import Unit

from esmvalcore.cmor._fixes.cmip6.mpi_esm1_2_hr import (
AllVars,
Cl,
Cli,
Clw,
SfcWind,
Tas,
)
from esmvalcore.cmor._fixes.common import ClFixHybridPressureCoord
from esmvalcore.cmor._fixes.fix import Fix
from esmvalcore.cmor.table import get_var_info


def test_get_allvars_fix():
Expand Down Expand Up @@ -42,6 +52,58 @@ def test_allvars_r2i1p1f1():
assert fixed_cubes[1].coord('latitude').points[0] == -86.49036676628


@pytest.fixture
def sfcwind_cubes():
correct_lat_coord = iris.coords.DimCoord([0.0],
var_name='lat',
standard_name='latitude')
wrong_lat_coord = iris.coords.DimCoord([0.0],
var_name='latitudeCoord',
standard_name='latitude')
correct_lon_coord = iris.coords.DimCoord([0.0],
var_name='lon',
standard_name='longitude')
wrong_lon_coord = iris.coords.DimCoord([0.0],
var_name='longitudeCoord',
standard_name='longitude')
correct_cube = iris.cube.Cube([[10.0]], var_name='sfcWind',
dim_coords_and_dims=[(correct_lat_coord, 0),
(correct_lon_coord, 1)]
)
wrong_cube = iris.cube.Cube([[10.0]],
var_name='ta',
dim_coords_and_dims=[(wrong_lat_coord, 0),
(wrong_lon_coord, 1)])
scalar_cube = iris.cube.Cube(0.0, var_name='ps')
return iris.cube.CubeList([correct_cube, wrong_cube, scalar_cube])


@pytest.fixture
def tas_cubes():
correct_lat_coord = iris.coords.DimCoord([0.0],
var_name='lat',
standard_name='latitude')
wrong_lat_coord = iris.coords.DimCoord([0.0],
var_name='latitudeCoord',
standard_name='latitude')
correct_lon_coord = iris.coords.DimCoord([0.0],
var_name='lon',
standard_name='longitude')
wrong_lon_coord = iris.coords.DimCoord([0.0],
var_name='longitudeCoord',
standard_name='longitude')
correct_cube = iris.cube.Cube([[10.0]],
var_name='tas',
dim_coords_and_dims=[(correct_lat_coord, 0),
(correct_lon_coord, 1)])
wrong_cube = iris.cube.Cube([[10.0]],
var_name='ta',
dim_coords_and_dims=[(wrong_lat_coord, 0),
(wrong_lon_coord, 1)])
scalar_cube = iris.cube.Cube(0.0, var_name='ps')
return iris.cube.CubeList([correct_cube, wrong_cube, scalar_cube])


def test_get_cl_fix():
"""Test getting of fix."""
fixes = Fix.get_fixes('CMIP6', 'MPI-ESM1-2-HR', 'Amon', 'cl')
Expand Down Expand Up @@ -73,3 +135,51 @@ def test_get_clw_fix():
def test_clw_fix():
"""Test fix for ``clw``."""
assert Clw is ClFixHybridPressureCoord


def test_get_sfcwind_fix():
fixes = Fix.get_fixes('CMIP6', 'MPI_ESM1_2_HR', 'day', 'sfcWind')
assert SfcWind(None) in fixes


def test_sfcwind_fix_metadata(sfcwind_cubes):
for cube in sfcwind_cubes:
with pytest.raises(iris.exceptions.CoordinateNotFoundError):
cube.coord('height')
height_coord = iris.coords.AuxCoord(10.0,
var_name='height',
standard_name='height',
long_name='height',
units=Unit('m'),
attributes={'positive': 'up'})
vardef = get_var_info('CMIP6', 'day', 'sfcWind')
fix = SfcWind(vardef)

out_cubes = fix.fix_metadata(sfcwind_cubes)
assert out_cubes[0].var_name == 'sfcWind'
coord = out_cubes[0].coord('height')
assert coord == height_coord


def test_get_tas_fix():
fixes = Fix.get_fixes('CMIP6', 'MPI_ESM1_2_HR', 'day', 'tas')
assert Tas(None) in fixes


def test_tas_fix_metadata(tas_cubes):
for cube in tas_cubes:
with pytest.raises(iris.exceptions.CoordinateNotFoundError):
cube.coord('height')
height_coord = iris.coords.AuxCoord(2.0,
var_name='height',
standard_name='height',
long_name='height',
units=Unit('m'),
attributes={'positive': 'up'})
vardef = get_var_info('CMIP6', 'day', 'tas')
fix = Tas(vardef)

out_cubes = fix.fix_metadata(tas_cubes)
assert out_cubes[0].var_name == 'tas'
coord = out_cubes[0].coord('height')
assert coord == height_coord

0 comments on commit f7b75b8

Please sign in to comment.