Skip to content

Commit df84868

Browse files
authored
Merge pull request #3948 from CliMA/j/add-mslp
Adds MSLP diagnostic
2 parents 3ea8d3b + a3a8fc2 commit df84868

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

config/model_configs/diagnostic_edmfx_era5_initial_condition.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ output_default_diagnostics: false
3939
diagnostics:
4040
- short_name: [ta, ua, wa, va, rhoa, hur, hus, clw, cli]
4141
period: 60mins
42-
- short_name: [rsut, rlut, ts, pr]
42+
- short_name: [rsut, rlut, ts, pr, mslp]
4343
period: 60mins

src/diagnostics/core_diagnostics.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,3 +1503,36 @@ add_diagnostic_variable!(
15031503
comments = "Energy available to a parcel lifted moist adiabatically from the surface. We assume fully reversible phase changes and no precipitation.",
15041504
compute! = compute_cape!,
15051505
)
1506+
1507+
function compute_mslp!(out, state, cache, time)
1508+
thermo_params = CAP.thermodynamics_params(cache.params)
1509+
g = TD.Parameters.grav(thermo_params)
1510+
R_m_surf = Fields.level(
1511+
lazy.(TD.gas_constant_air.(thermo_params, cache.precomputed.ᶜts)),
1512+
1,
1513+
)
1514+
1515+
# get pressure, temperature, and height at the lowest atmospheric level
1516+
p_level = Fields.level(cache.precomputed.ᶜp, 1)
1517+
t_level = Fields.level(
1518+
lazy.(TD.air_temperature.(thermo_params, cache.precomputed.ᶜts)),
1519+
1,
1520+
)
1521+
z_level = Fields.level(Fields.coordinate_field(state.c.ρ).z, 1)
1522+
1523+
# compute sea level pressure using the hypsometric equation
1524+
if isnothing(out)
1525+
return @. p_level * exp(g * z_level / (R_m_surf * t_level))
1526+
else
1527+
@. out = p_level * exp(g * z_level / (R_m_surf * t_level))
1528+
end
1529+
end
1530+
1531+
add_diagnostic_variable!(
1532+
short_name = "mslp",
1533+
long_name = "Mean Sea Level Pressure",
1534+
standard_name = "mean_sea_level_pressure",
1535+
units = "Pa",
1536+
comments = "Mean sea level pressure computed from the hypsometric equation",
1537+
compute! = compute_mslp!,
1538+
)

0 commit comments

Comments
 (0)