-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
positive
attributes in custom CMOR variables (#2380)
- Loading branch information
Showing
18 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Test derivation of `lwcre`.""" | ||
import numpy as np | ||
import pytest | ||
from iris.cube import Cube, CubeList | ||
|
||
import esmvalcore.preprocessor._derive.lwcre as lwcre | ||
|
||
|
||
@pytest.fixture | ||
def cubes(): | ||
rlut_cube = Cube( | ||
3, standard_name='toa_outgoing_longwave_flux', units='W m-2' | ||
) | ||
rlutcs_cube = Cube( | ||
1, | ||
standard_name='toa_outgoing_longwave_flux_assuming_clear_sky', | ||
units='W m-2', | ||
) | ||
return CubeList([rlut_cube, rlutcs_cube]) | ||
|
||
|
||
def test_lwcre_calculation(cubes): | ||
"""Test calculation of `lwcre`.""" | ||
derived_var = lwcre.DerivedVariable() | ||
out_cube = derived_var.calculate(cubes) | ||
np.testing.assert_equal(out_cube.data, -2) | ||
assert out_cube.units == 'W m-2' | ||
assert out_cube.attributes['positive'] == 'down' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Test derivation of `netcre`.""" | ||
import numpy as np | ||
import pytest | ||
from iris.cube import Cube, CubeList | ||
|
||
import esmvalcore.preprocessor._derive.netcre as netcre | ||
|
||
|
||
@pytest.fixture | ||
def cubes(): | ||
rlut_cube = Cube( | ||
3, standard_name='toa_outgoing_longwave_flux', units='W m-2' | ||
) | ||
rlutcs_cube = Cube( | ||
1, | ||
standard_name='toa_outgoing_longwave_flux_assuming_clear_sky', | ||
units='W m-2', | ||
) | ||
rsut_cube = Cube( | ||
3, standard_name='toa_outgoing_shortwave_flux', units='W m-2' | ||
) | ||
rsutcs_cube = Cube( | ||
1, | ||
standard_name='toa_outgoing_shortwave_flux_assuming_clear_sky', | ||
units='W m-2', | ||
) | ||
return CubeList([rlut_cube, rlutcs_cube, rsut_cube, rsutcs_cube]) | ||
|
||
|
||
def test_netcre_calculation(cubes): | ||
"""Test calculation of `netcre`.""" | ||
derived_var = netcre.DerivedVariable() | ||
out_cube = derived_var.calculate(cubes) | ||
np.testing.assert_equal(out_cube.data, -4) | ||
assert out_cube.units == 'W m-2' | ||
assert out_cube.attributes['positive'] == 'down' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Test derivation of `rsnt`.""" | ||
import numpy as np | ||
import pytest | ||
from iris.cube import Cube, CubeList | ||
|
||
import esmvalcore.preprocessor._derive.rsnt as rsnt | ||
|
||
|
||
@pytest.fixture | ||
def cubes(): | ||
rsdt_cube = Cube( | ||
3, standard_name='toa_incoming_shortwave_flux', units='W m-2' | ||
) | ||
rsut_cube = Cube( | ||
1, standard_name='toa_outgoing_shortwave_flux', units='W m-2' | ||
) | ||
return CubeList([rsdt_cube, rsut_cube]) | ||
|
||
|
||
def test_rsnt_calculation(cubes): | ||
"""Test calculation of `rsnt`.""" | ||
derived_var = rsnt.DerivedVariable() | ||
out_cube = derived_var.calculate(cubes) | ||
np.testing.assert_equal(out_cube.data, 2) | ||
assert out_cube.units == 'W m-2' | ||
assert out_cube.attributes['positive'] == 'down' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Test derivation of `swcre`.""" | ||
import numpy as np | ||
import pytest | ||
from iris.cube import Cube, CubeList | ||
|
||
import esmvalcore.preprocessor._derive.swcre as swcre | ||
|
||
|
||
@pytest.fixture | ||
def cubes(): | ||
rsut_cube = Cube( | ||
3, standard_name='toa_outgoing_shortwave_flux', units='W m-2' | ||
) | ||
rsutcs_cube = Cube( | ||
1, | ||
standard_name='toa_outgoing_shortwave_flux_assuming_clear_sky', | ||
units='W m-2', | ||
) | ||
return CubeList([rsut_cube, rsutcs_cube]) | ||
|
||
|
||
def test_swcre_calculation(cubes): | ||
"""Test calculation of `swcre`.""" | ||
derived_var = swcre.DerivedVariable() | ||
out_cube = derived_var.calculate(cubes) | ||
np.testing.assert_equal(out_cube.data, -2) | ||
assert out_cube.units == 'W m-2' | ||
assert out_cube.attributes['positive'] == 'down' |