From 95ddac93c911133665981d9c43d704c6cffa416f Mon Sep 17 00:00:00 2001 From: Schmid Timo Date: Tue, 24 Oct 2023 10:24:34 +0200 Subject: [PATCH] minor edits --- climada/util/calibrate/base.py | 30 +++++++++++------------ doc/tutorial/climada_util_calibrate.ipynb | 4 +-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/climada/util/calibrate/base.py b/climada/util/calibrate/base.py index 34ae892e0e..1701747282 100644 --- a/climada/util/calibrate/base.py +++ b/climada/util/calibrate/base.py @@ -166,17 +166,16 @@ def plot_impf_variability( plot_haz: bool = True, **plot_kwargs ): - """Plot impact function variability with parameter combinations of almost equal - cost function values + + """Plot impact function variability with parameter combinations of + almost equal cost function values Args: - cost_func_diff (float, optional): Max deviation from optimal cost function value - (as fraction). Defaults to 0.1 (i.e. 10%). + cost_func_diff (float, optional): Max deviation from optimal cost + function value (as fraction). Defaults to 0.1 (i.e. 10%). p_space_df (pd.DataFrame, optional): parameter space. Defaults to None. - plot_haz (bool, optional): Whether or not to plot hazard intensity distibution. - Defaults to False. - haz_vals (np.array, optional): Hazard values at exposure points (if - pre-calculated). Defaults to None. + plot_haz (bool, optional): Whether or not to plot hazard intensity + distibution. Defaults to False. """ haz_type = self.input.hazard.haz_type @@ -194,16 +193,16 @@ def plot_impf_variability( # Retrieve parameters of impact functions with cost function values # within 'cost_func_diff' % of the best estimate max_cost_func_val = p_space_df['Cost Function'].min()*(1+cost_func_diff) - params_within_range = p_space_df.loc[p_space_df['Cost Function']<=max_cost_func_val, - params] + params_within_range = p_space_df.loc[p_space_df['Cost Function'] <= + max_cost_func_val,params] # Initialize figure fig,ax = plt.subplots() #Plot best-fit impact function best_impf = self.impf_set.get_func(haz_type=haz_type)[0] - ax.plot(best_impf.intensity,best_impf.mdd*best_impf.paa*100,color='tab:blue', - lw=2,zorder=3,label='best fit') + ax.plot(best_impf.intensity,best_impf.mdd*best_impf.paa*100, + color='tab:blue',lw=2,zorder=3,label='best fit',**plot_kwargs) #Plot all impact functions within 'cost_func_diff' % of best estimate for row in range(params_within_range.shape[0]): @@ -213,8 +212,8 @@ def plot_impf_variability( temp_impf_set = self.input.impact_func_creator(**sel_params) temp_impf = temp_impf_set.get_func(haz_type=haz_type)[0] - ax.plot(temp_impf.intensity,temp_impf.mdd*temp_impf.paa*100,color='grey', - alpha=0.4,label=label) + ax.plot(temp_impf.intensity,temp_impf.mdd*temp_impf.paa*100, + color='grey',alpha=0.4,label=label) # Plot hazard intensity value distributions if plot_haz: @@ -224,7 +223,8 @@ def plot_impf_variability( ax2.hist(haz_vals.data,bins=40,color='tab:orange', alpha=0.3,label='Hazard intensity\noccurence') ax2.set(ylabel='Hazard intensity occurence (#Exposure points)') - ax.axvline(x=haz_vals.max(),label='Maximum hazard value',color='tab:orange') + ax.axvline(x=haz_vals.max(),label='Maximum hazard value', + color='tab:orange') ax2.legend(loc='lower right') ax.set(xlabel=f"Intensity ({self.input.hazard.units})", diff --git a/doc/tutorial/climada_util_calibrate.ipynb b/doc/tutorial/climada_util_calibrate.ipynb index 61fbf432e6..869590129b 100644 --- a/doc/tutorial/climada_util_calibrate.ipynb +++ b/doc/tutorial/climada_util_calibrate.ipynb @@ -2503,7 +2503,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -2512,7 +2512,7 @@ "" ] }, - "execution_count": 34, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" },