Skip to content

Commit 1b2c598

Browse files
authored
Merge branch 'mahf708/eamxx/vert-contraction-diag' (PR #7156)
Adds support for vertically contracted diagnostic fields in EAMxx by introducing a new diagnostic (VertContractDiag) and integrating it throughout the codebase. Key changes include adding a new regex in the I/O utilities to recognize vertical contraction field names, implementing the VertContractDiag class across header and source files with the associated logic for averaging/summing, and adding test cases and documentation updates to support and illustrate the new diagnostic. [BFB]
2 parents 620edab + 3d150d2 commit 1b2c598

File tree

10 files changed

+660
-2
lines changed

10 files changed

+660
-2
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Field contraction diagnostics
2+
3+
In EAMxx, we can automatically calculate field reductions
4+
across the horizontal columns and across the model vertical levels.
5+
We call these horizontal and vertical reductions.
6+
7+
## Horizontal reduction
8+
9+
We currently offer only one horizontal reduction $C$, and it is defined as
10+
11+
$$
12+
C_{\dots k} = \sum_{i} w_{i} \cdot F_{i \dots k}
13+
$$
14+
15+
where $F_\text{i...k}$ is the field at column $i$ and level $k$,
16+
and $w_{i}$ is the weight at column $i$.
17+
We note that the field $F$ can have other dimensions ($\dots$).
18+
The weight $w$ is defined as the area fraction in column $i$,
19+
that is, the area in column $i$ divided by the total area in all columns.
20+
21+
To select the horizontal reduction, you only need to suffix
22+
a field name `X` with `_horiz_avg` in the output requests.
23+
24+
| Reduction | Weight | Description |
25+
| --------- | ------ | ----------- |
26+
| `X_horiz_avg` | Area fraction | Average across all columns |
27+
28+
## Vertical reduction
29+
30+
We currently offer three vertical reductions $C$, defined as
31+
32+
$$
33+
C_{\dots} = \sum_{k} w_{k} \cdot F_{\dots k}
34+
$$
35+
36+
where $F_{\dots k}$ is the field at level $k$,
37+
and $w_{k}$ is the weight at level $k$.
38+
39+
To select the vertical reduction, you only need to suffix
40+
a field name `X` with `_vert_(avg|sum)_(dp|dz)_weighted` or
41+
`_vert_(avg|sum)` in the output yaml files.
42+
43+
| Reduction | Weight | Description |
44+
| --------- | ------ | ----------- |
45+
| `X_vert_avg_dp_weighted` | $\Delta p_{k}$ | Average across all levels, weighted by $\Delta p_{k}$ |
46+
| `X_vert_sum_dp_weighted` | $\Delta p_{k}$ | Sum across all levels, weighted by $\Delta p_{k}$ |
47+
| `X_vert_avg_dz_weighted` | $\Delta z_{k}$ | Average across all levels, weighted by $\Delta z_{k}$ |
48+
| `X_vert_sum_dz_weighted` | $\Delta z_{k}$ | Sum across all levels, weighted by $\Delta z_{k}$ |
49+
| `X_vert_avg` | 1 | Average across all levels |
50+
| `X_vert_sum` | 1 | Sum across all levels |
51+
52+
The supported weighting options for now are
53+
54+
- `pseudo_density` field in EAMxx, $\Delta p_{k}$, in units of Pa;
55+
- `dz` field in EAMxx, $\Delta z_{k}$, in units of m;
56+
- and no weighting, which is equivalent to using a weight of 1.
57+
58+
In the case of `pseudo_density`, the weighting is scaled by 1/g,
59+
where g is the gravitational acceleration, in units of m/s$^2$.
60+
61+
## Example
62+
63+
```yaml
64+
%YAML 1.1
65+
---
66+
filename_prefix: monthly.outputs
67+
averaging_type: average
68+
max_snapshots_per_file: 1
69+
fields:
70+
physics_pg2:
71+
field_names:
72+
# in this example, we use T_mid in units of K
73+
- T_mid_horiz_avg # K
74+
- T_mid_vert_avg_dp_weighted # K
75+
- T_mid_vert_sum_dp_weighted # K * Pa * s / (m * m)
76+
- T_mid_vert_avg_dz_weighted # K
77+
- T_mid_vert_sum_dz_weighted # K * m
78+
- T_mid_vert_avg # K
79+
- T_mid_vert_sum # K
80+
output_control:
81+
frequency: 1
82+
frequency_units: nmonths
83+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Online diagnostics
2+
3+
EAMxx has facilities to output optional diagnostics
4+
that are computed during runtime. These diagnostics
5+
are designed generically and composably, and are requestable by users.
6+
7+
More details to follow.

components/eamxx/mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ nav:
1818
- 'IO Metadata': 'user/io_metadata.md'
1919
- 'Multi-Instance and NBFB': 'user/multi-instance-mvk.md'
2020
- 'EAMxx runtime parameters': 'user/eamxx_params.md'
21+
- 'Diagnostics':
22+
- 'Overview': 'user/diags/index.md'
23+
- 'Field contraction diagnostics': 'user/diags/field_contraction.md'
2124
- 'Presentations': 'user/presentations.md'
2225
- 'Developer Guide':
2326
# - 'Overview': 'developer/index.md'

components/eamxx/src/diagnostics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set(DIAGNOSTIC_SRCS
2222
virtual_temperature.cpp
2323
water_path.cpp
2424
wind_speed.cpp
25+
vert_contract.cpp
2526
)
2627

2728
add_library(diagnostics ${DIAGNOSTIC_SRCS})

components/eamxx/src/diagnostics/register_diagnostics.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "diagnostics/aerocom_cld.hpp"
2626
#include "diagnostics/atm_backtend.hpp"
2727
#include "diagnostics/horiz_avg.hpp"
28+
#include "diagnostics/vert_contract.hpp"
2829

2930
namespace scream {
3031

@@ -53,6 +54,7 @@ inline void register_diagnostics () {
5354
diag_factory.register_product("AeroComCld",&create_atmosphere_diagnostic<AeroComCld>);
5455
diag_factory.register_product("AtmBackTendDiag",&create_atmosphere_diagnostic<AtmBackTendDiag>);
5556
diag_factory.register_product("HorizAvgDiag",&create_atmosphere_diagnostic<HorizAvgDiag>);
57+
diag_factory.register_product("VertContractDiag",&create_atmosphere_diagnostic<VertContractDiag>);
5658
}
5759

5860
} // namespace scream

components/eamxx/src/diagnostics/tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ CreateDiagTest(atm_backtend "atm_backtend_test.cpp")
7474

7575
# Test horizontal averaging
7676
CreateDiagTest(horiz_avg "horiz_avg_test.cpp")
77+
78+
# Test for vertical contraction
79+
CreateDiagTest(vert_contract "vert_contract_test.cpp")

0 commit comments

Comments
 (0)