diff --git a/pepsico/app_calc.py b/pepsico/app_calc.py index a8926cdd..17f8aecf 100644 --- a/pepsico/app_calc.py +++ b/pepsico/app_calc.py @@ -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 diff --git a/pepsico/proj_wwc/layout.py b/pepsico/proj_wwc/layout.py index 6f1cb77c..6c92f6d8 100644 --- a/pepsico/proj_wwc/layout.py +++ b/pepsico/proj_wwc/layout.py @@ -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", ], @@ -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", ], @@ -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"]), diff --git a/pepsico/proj_wwc/maproom.py b/pepsico/proj_wwc/maproom.py index c12ec4f2..ac9758f7 100644 --- a/pepsico/proj_wwc/maproom.py +++ b/pepsico/proj_wwc/maproom.py @@ -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)