File tree Expand file tree Collapse file tree 11 files changed +53
-27
lines changed
esmvalcore/preprocessor/_derive
integration/preprocessor/_derive
unit/preprocessor/_derive Expand file tree Collapse file tree 11 files changed +53
-27
lines changed Original file line number Diff line number Diff line change 5151 conda update -y conda > /logs/conda.txt 2>&1
5252 conda env update >> /logs/conda.txt 2>&1
5353 set +x; conda activate esmvaltool; set -x
54- conda install -yS r-base r-yaml julia ncl -c conda-forge
54+ conda install -yS r-base r-yaml ncl -c conda-forge
5555 pip install . > /logs/install.txt 2>&1
5656 # Log versions
5757 dpkg -l > /logs/versions.txt
@@ -120,6 +120,7 @@ jobs:
120120 conda update -y conda > /logs/conda.txt 2>&1
121121 conda env update >> /logs/conda.txt 2>&1
122122 set +x; conda activate esmvaltool; set -x
123+ conda install -yS r-base r-yaml ncl -c conda-forge
123124 pip install -e .[develop] > /logs/install.txt 2>&1
124125 # Log versions
125126 dpkg -l > /logs/versions.txt
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ channels:
55
66dependencies :
77 - esmpy
8- - iris>=2.2
8+ - iris>=2.2.1
99 - graphviz
1010 - gcc_linux-64
1111 - libunwind # Needed for Python3.7+
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ def derive(cubes,
107107 "'%s' not found" , fx_var , short_name )
108108
109109 # Derive variable
110- DerivedVariable = ALL_DERIVED_VARIABLES [short_name ] # noqa: N806
110+ DerivedVariable = ALL_DERIVED_VARIABLES [short_name . lower () ] # noqa: N806
111111 cube = DerivedVariable ().calculate (cubes )
112112
113113 # Set standard attributes
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -22,23 +22,23 @@ build:
2222 # Increment the build number when building a new conda package of the same
2323 # esmvalcore version, reset to 0 when building a new version.
2424 number : 0
25+ noarch : python
2526 script : |
2627 python setup.py install --single-version-externally-managed --record=/tmp/record.txt
2728
2829requirements :
2930 build :
3031 - git
31- - python {{ python }}
32+ - python>=3.6
3233 # Normally installed via pip:
3334 - pytest-runner
3435 - setuptools_scm
3536 run :
3637 # esmvaltool
37- - python
38+ - python>=3.6
3839 - libunwind # specifically for Python3.7+
3940 - graphviz
40- - iris>=2.2
41- - matplotlib<3,>=2 # required by iris
41+ - iris>=2.2.1
4242 - python-stratify
4343 # Normally installed via pip:
4444 - cf-units
@@ -52,7 +52,7 @@ requirements:
5252 - psutil
5353 - pydot
5454 - pyyaml
55- - yamale # in esmvalgroup and birdhouse channel
55+ - yamale # in esmvalgroup channel
5656
5757test :
5858 # TODO: add unit tests? This seems to require installing the tests
6868 home : https://www.esmvaltool.org
6969 license : Apache License, Version 2.0
7070 license_file : LICENSE
71- summary : " ESMValCore: core functionalities for the ESMValTool, a community diagnostic and performance metrics tool for routine evaluation of Earth system models in CMIP."
72- description : " ESMValCore: core functionalities for the ESMValTool, a community diagnostic and performance metrics tool for routine evaluation of Earth system models in CMIP."
71+ summary : " ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts ."
72+ description : " ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts ."
Original file line number Diff line number Diff line change 1+ import iris
12from iris .cube import Cube , CubeList
23
34from esmvalcore .preprocessor import derive
45from esmvalcore .preprocessor ._derive import get_required
6+ from esmvalcore .preprocessor ._derive .csoil_grid import DerivedVariable
57
68
79def test_get_required ():
@@ -67,3 +69,32 @@ def test_derive_noop():
6769
6870 print (cube )
6971 assert cube is alb
72+
73+
74+ def test_derive_mixed_case_with_fx (tmp_path , monkeypatch ):
75+
76+ short_name = 'cSoil_grid'
77+ long_name = 'Carbon Mass in Soil Pool relative to grid cell area'
78+ units = 'kg m-2'
79+
80+ csoil_cube = Cube ([])
81+ fx_cube = Cube ([])
82+ fx_cube .var_name = 'sftlf'
83+ fx_file = str (tmp_path / 'sftlf_file.nc' )
84+ iris .save (fx_cube , target = fx_file )
85+
86+ def mock_calculate (self , cubes ):
87+ assert len (cubes ) == 2
88+ assert cubes [0 ] == csoil_cube
89+ assert cubes [1 ].var_name == fx_cube .var_name
90+ return Cube ([])
91+
92+ monkeypatch .setattr (DerivedVariable , 'calculate' , mock_calculate )
93+
94+ derive (
95+ [csoil_cube ],
96+ short_name ,
97+ long_name ,
98+ units ,
99+ fx_files = {'sftlf' : fx_file },
100+ )
Original file line number Diff line number Diff line change 11"""Test derivation of `cSoil_grid`."""
22import mock
33
4- import esmvalcore .preprocessor ._derive . cSoil_grid as cSoil_grid
4+ from esmvalcore .preprocessor ._derive import csoil_grid
55
66CUBES = 'mocked cubes'
77STD_NAME = 'soil_carbon_content'
88
99
10- @mock .patch .object (cSoil_grid , 'grid_area_correction' , autospec = True )
11- def test_cSoil_grid_calculation (mock_grid_area_correction ):
10+ @mock .patch .object (csoil_grid , 'grid_area_correction' , autospec = True )
11+ def test_csoil_grid_calculation (mock_grid_area_correction ):
1212 """Test calculation of `cSoil_grid."""
13- derived_var = cSoil_grid .DerivedVariable ()
13+ derived_var = csoil_grid .DerivedVariable ()
1414 derived_var .calculate (CUBES )
1515 mock_grid_area_correction .assert_called_once_with (CUBES , STD_NAME )
Original file line number Diff line number Diff line change 11"""Test derivation of `cVeg_grid`."""
22import mock
33
4- import esmvalcore .preprocessor ._derive . cVeg_grid as cVeg_grid
4+ from esmvalcore .preprocessor ._derive import cveg_grid
55
66CUBES = 'mocked cubes'
77STD_NAME = 'vegetation_carbon_content'
88
99
10- @mock .patch .object (cVeg_grid , 'grid_area_correction' , autospec = True )
11- def test_cVeg_grid_calculation (mock_grid_area_correction ):
10+ @mock .patch .object (cveg_grid , 'grid_area_correction' , autospec = True )
11+ def test_cveg_grid_calculation (mock_grid_area_correction ):
1212 """Test calculation of `cVeg_grid."""
13- derived_var = cVeg_grid .DerivedVariable ()
13+ derived_var = cveg_grid .DerivedVariable ()
1414 derived_var .calculate (CUBES )
1515 mock_grid_area_correction .assert_called_once_with (CUBES , STD_NAME )
You can’t perform that action at this time.
0 commit comments