Skip to content

Commit 281c306

Browse files
committed
Add derived variable
1 parent f459b14 commit 281c306

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

e3sm_diags/derivations/derivations.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
pminuse_convert_units,
5656
precst,
5757
prect,
58+
prect_frac,
5859
qflx_convert_to_lhflx,
5960
qflx_convert_to_lhflx_approxi,
6061
qflxconvert_units,
@@ -117,6 +118,16 @@
117118
rename(prw), target_units="kg/m2"
118119
), # EAMxx
119120
},
121+
"PRECC": {
122+
("PRECC",): lambda pr: convert_units(pr, target_units="mm/day"),
123+
("prc",): rename,
124+
},
125+
"PRECL": {
126+
("PRECL",): lambda pr: convert_units(rename(pr), target_units="mm/day"),
127+
},
128+
"PRECC_Frac": {
129+
("PRECC", "PRECL"): lambda precc, precl: prect_frac(precc, precl),
130+
},
120131
# Sea Surface Temperature: Degrees C
121132
# Temperature of the water, not the air. Ignore land.
122133
"SST": OrderedDict(
@@ -734,7 +745,6 @@
734745
("huss",): lambda q: convert_units(q, target_units="g/kg"),
735746
("d2m", "sp"): qsat,
736747
},
737-
"PRECC": {("prc",): rename},
738748
"TAUX": {
739749
("tauu",): lambda tauu: -tauu,
740750
("surf_mom_flux_U",): lambda tauu: -tauu, # EAMxx

e3sm_diags/derivations/formulas.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ def prect(precc: xr.DataArray, precl: xr.DataArray):
235235
return var
236236

237237

238+
def prect_frac(precc: xr.DataArray, precl: xr.DataArray):
239+
"""convective precipitation fraction = convective /(convective + large-scale)"""
240+
with xr.set_options(keep_attrs=True):
241+
var = precc / (precc + precl) * 100.0
242+
243+
var.attrs["units"] = "%"
244+
var.attrs["long_name"] = "convective precipitation fraction"
245+
246+
return var
247+
248+
238249
def precst(precc: xr.DataArray, precl: xr.DataArray):
239250
"""Total precipitation flux = convective + large-scale"""
240251
with xr.set_options(keep_attrs=True):

0 commit comments

Comments
 (0)