Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pepsico/app_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ def seasonal_wwc(
.map(length_of_longest_spell, "T")
)
wwc_units = "days"
if variable == "dry_day_persistence":
data_ds = 100 * data_ds.map(
count_days_in_spells, "T", min_spell_length=2, skipna=True,
min_count=1,
) / data_ds.sum(skipna=True, min_count=1)
wwc_units = "%"
if variable == "wet_day_persistence":
data_ds = 100 * data_ds.map(
count_days_in_spells, "T", min_spell_length=2, skipna=True,
min_count=1,
) / data_ds.sum(skipna=True, min_count=1)
wwc_units = "%"
# This is all a bit tedious but I didn't figure out another way to keep
# seasons_ends and renaming time dim T
# Can revisit later if this code has a future
Expand Down
15 changes: 13 additions & 2 deletions pepsico/proj_wwc/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def app_layout():
"longest_wet_spell",
# "wet_day_persistence",
# "dry_day_persistence",
# "longest_dry_spell",
# "longest_wet_spell",
"wet_day_persistence",
"dry_day_persistence",
# "dry_spells_mean_length",
# "dry_spells_median_length",
],
Expand All @@ -69,8 +73,8 @@ def app_layout():
"Min Temperature 10th %-ile",
"Longest Dry Spell",
"Longest Wet Spell",
# "Mean Wet Day Persistence",
# "Mean Dry Day Persistence",
"Wet Day Persistence",
"Dry Day Persistence",
# "Mean Dry Spells Length",
# "Median Dry Spells Length",
],
Expand Down Expand Up @@ -241,6 +245,13 @@ def app_layout():
as lesser or equal / greather than a user-defined threshold.
"""
]),
html.P([
html.B("Dry/Wet Day Persistence (dry/wet_day_persistence):"),"""
Ratio of cumulative (at least 2) dry/wet days against total
dry/wet days in the season. A dry/wet day is defined as lesser
or equal / greather than a user-defined threshold.
"""
]),
),

lou.map(GLOBAL_CONFIG["zoom"]),
Expand Down
4 changes: 3 additions & 1 deletion pepsico/proj_wwc/maproom.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,9 @@ def map_attributes(data, variable):
colorscale = CMAPS["prcp_anomaly"]
if data.name in ["tasmin", "tasmax"]:
colorscale = CMAPS["temp_anomaly"]
if variable in ["frost_days", "dry_days", "longest_dry_spell"]:
if variable in [
"frost_days", "dry_days", "longest_dry_spell", "dry_day_persistence"
]:
colorscale = colorscale.reversed()
map_amp = np.max(np.abs(data)).values
colorscale = colorscale.rescaled(-1*map_amp, map_amp)
Expand Down