Skip to content

Commit

Permalink
CDAT Migration Phase 3: Add Convective Precipitation Fraction in lat-…
Browse files Browse the repository at this point in the history
…lon (#875)
  • Loading branch information
tomvothecoder committed Oct 29, 2024
1 parent d9feeb4 commit ff05407
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion e3sm_diags/derivations/derivations.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
pminuse_convert_units,
precst,
prect,
prect_frac,
qflx_convert_to_lhflx,
qflx_convert_to_lhflx_approxi,
qflxconvert_units,
Expand Down Expand Up @@ -117,6 +118,16 @@
rename(prw), target_units="kg/m2"
), # EAMxx
},
"PRECC": {
("PRECC",): lambda pr: convert_units(pr, target_units="mm/day"),
("prc",): rename,
},
"PRECL": {
("PRECL",): lambda pr: convert_units(rename(pr), target_units="mm/day"),
},
"PRECC_Frac": {
("PRECC", "PRECL"): lambda precc, precl: prect_frac(precc, precl),
},
# Sea Surface Temperature: Degrees C
# Temperature of the water, not the air. Ignore land.
"SST": OrderedDict(
Expand Down Expand Up @@ -734,7 +745,6 @@
("huss",): lambda q: convert_units(q, target_units="g/kg"),
("d2m", "sp"): qsat,
},
"PRECC": {("prc",): rename},
"TAUX": {
("tauu",): lambda tauu: -tauu,
("surf_mom_flux_U",): lambda tauu: -tauu, # EAMxx
Expand Down
11 changes: 11 additions & 0 deletions e3sm_diags/derivations/formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ def prect(precc: xr.DataArray, precl: xr.DataArray):
return var


def prect_frac(precc: xr.DataArray, precl: xr.DataArray):
"""convective precipitation fraction = convective /(convective + large-scale)"""
with xr.set_options(keep_attrs=True):
var = precc / (precc + precl) * 100.0

var.attrs["units"] = "%"
var.attrs["long_name"] = "convective precipitation fraction"

return var


def precst(precc: xr.DataArray, precl: xr.DataArray):
"""Total precipitation flux = convective + large-scale"""
with xr.set_options(keep_attrs=True):
Expand Down

0 comments on commit ff05407

Please sign in to comment.