Skip to content

Commit 9636505

Browse files
Introduction of the variable prodlnox for EMAC (#2499)
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com> Co-authored-by: Manuel Schlund <manuel.schlund@dlr.de>
1 parent 03b6871 commit 9636505

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

esmvalcore/cmor/_fixes/emac/emac.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,34 @@ def fix_metadata(self, cubes):
211211
return CubeList([cube])
212212

213213

214+
class Prodlnox(EmacFix):
215+
"""Fixes for ``prodlnox``."""
216+
217+
def fix_metadata(self, cubes):
218+
"""Fix metadata."""
219+
noxcg_cube = self.get_cube(
220+
cubes, var_name=['NOxcg_cav', 'NOxcg_ave', 'NOxcg']
221+
)
222+
noxic_cube = self.get_cube(
223+
cubes, var_name=['NOxic_cav', 'NOxic_ave', 'NOxic']
224+
)
225+
dt_cube = self.get_cube(cubes, var_name='dt')
226+
227+
cube = ((
228+
noxcg_cube.collapsed(
229+
['longitude', 'latitude'], iris.analysis.SUM, weights=None
230+
) +
231+
noxic_cube.collapsed(
232+
['longitude', 'latitude'], iris.analysis.SUM, weights=None
233+
)) /
234+
dt_cube
235+
)
236+
cube.units = 'kg s-1'
237+
cube.var_name = self.vardef.short_name
238+
239+
return CubeList([cube])
240+
241+
214242
Evspsbl = NegateData
215243

216244

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
SOURCE: CMIP6
2+
!============
3+
variable_entry: prodlnox
4+
!============
5+
modeling_realm: atmos
6+
!----------------------------------
7+
! Variable attributes:
8+
!----------------------------------
9+
standard_name:
10+
units: kg s-1
11+
long_name: Tendency of atmosphere mass content of NOx from lightning
12+
comment: Production NOX (NO+NO2) by lightning globally integrated
13+
!----------------------------------
14+
! Additional variable information:
15+
!----------------------------------
16+
dimensions: time
17+
out_name: prodlnox
18+
type: real
19+
!----------------------------------
20+
!

esmvalcore/config/extra_facets/emac-mappings.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ EMAC:
7474
prc:
7575
raw_name: [aprc_cav, aprc_ave, aprc]
7676
channel: Amon
77+
prodlnox: # derived from NOxcg_*, NOxic_*
78+
channel: Amon
7779
prl: # non-CMOR variable
7880
raw_name: [aprl_cav, aprl_ave, aprl]
7981
channel: Amon

tests/integration/cmor/_fixes/emac/test_emac.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
MP_SS_tot,
2323
Od550aer,
2424
Pr,
25+
Prodlnox,
2526
Rlds,
2627
Rlus,
2728
Rlut,
@@ -931,6 +932,36 @@ def test_clwvi_fix(cubes_2d):
931932
np.testing.assert_allclose(cube.data, [[[2.0]]])
932933

933934

935+
def test_get_prodlnox_fix():
936+
"""Test getting of fix."""
937+
fix = Fix.get_fixes('EMAC', 'EMAC', 'Amon', 'prodlnox')
938+
assert fix == [Prodlnox(None), AllVars(None), GenericFix(None)]
939+
940+
941+
def test_prodlnox_fix(cubes_2d):
942+
"""Test fix."""
943+
cubes_2d[0].var_name = 'NOxcg_cav'
944+
cubes_2d[1].var_name = 'NOxic_cav'
945+
cubes_2d[2].var_name = 'dt'
946+
cubes_2d[0].units = 'kg'
947+
cubes_2d[1].units = 'kg'
948+
cubes_2d[2].units = 's'
949+
950+
fixed_cubes = fix_metadata(cubes_2d, 'Amon', 'prodlnox')
951+
952+
assert len(fixed_cubes) == 1
953+
cube = fixed_cubes[0]
954+
assert cube.var_name == 'prodlnox'
955+
assert cube.standard_name is None
956+
assert cube.long_name == (
957+
'Tendency of atmosphere mass content of NOx from lightning'
958+
)
959+
assert cube.units == 'kg s-1'
960+
assert 'positive' not in cube.attributes
961+
962+
np.testing.assert_allclose(cube.data, [[[2.0]]])
963+
964+
934965
def test_get_co2mass_fix():
935966
"""Test getting of fix."""
936967
fix = Fix.get_fixes('EMAC', 'EMAC', 'Amon', 'co2mass')

0 commit comments

Comments
 (0)