@@ -180,7 +180,9 @@ def calculate_sensitivity(
180180 self .sensitivity [gid ][key ][:, ko ] = Si [key ]
181181
182182 # calculate importance
183- self .sensitivity [gid ]["r" ][:, ko ] = np .sqrt (Si ["mu_star" ]** 2 + Si ["sigma" ]** 2 )
183+ self .sensitivity [gid ]["r" ][:, ko ] = np .sqrt (
184+ Si ["mu_star" ] ** 2 + Si ["sigma" ] ** 2
185+ )
184186
185187 # write to cache
186188 self .write_cache (
@@ -199,7 +201,6 @@ def plot(self):
199201 # sigma ~ mu_star +- mu_star_conf
200202
201203 for kg , group in enumerate (self .groups ):
202-
203204 # heatmap: of µ* (mu_star)
204205 for key in ["mu_star" ]:
205206 self .plot_sensitivity (
@@ -219,9 +220,11 @@ def plot(self):
219220 # individual plots;
220221 plot_morris_indices (
221222 sa = self ,
222- fig_path = self .results_path / f"{ self .prefix } _sensitivity_{ kg :>02} _{ group .uid } .png" ,
223+ fig_path = self .results_path
224+ / f"{ self .prefix } _sensitivity_{ kg :>02} _{ group .uid } .png" ,
223225 )
224226
227+
225228def plot_morris_indices (
226229 sa , # SensitivityAnalysis,
227230 fig_path : Path ,
@@ -238,42 +241,47 @@ def plot_morris_indices(
238241 gid = group .uid
239242
240243 for ko , output in enumerate (sa .outputs ):
241- f_path = fig_path .parent / f"{ fig_path .stem } _{ ko :>03} _{ output .uid } { fig_path .suffix } "
244+ f_path = (
245+ fig_path .parent
246+ / f"{ fig_path .stem } _{ ko :>03} _{ output .uid } { fig_path .suffix } "
247+ )
242248
243249 mu_star = sa .sensitivity [gid ]["mu_star" ][:, ko ]
244250 sigma = sa .sensitivity [gid ]["sigma" ][:, ko ]
245251 mu_star_conf = sa .sensitivity [gid ]["mu_star_conf" ][:, ko ]
246- r = sa .sensitivity [gid ]["r" ][:, ko ]
252+ # r = sa.sensitivity[gid]["r"][:, ko]
247253
248254 # width
249255 figsize = (10 , 5 )
250256 label_fontsize = 15
251257
252- f , axes = plt .subplots (nrows = 1 , ncols = 2 , figsize = figsize , layout = "constrained" )
258+ f , axes = plt .subplots (
259+ nrows = 1 , ncols = 2 , figsize = figsize , layout = "constrained"
260+ )
253261 f .suptitle (output_labels [output .uid ], fontsize = 20 , fontweight = "bold" )
254262
255- sorted_idx = np .argsort (mu_star .values ) # [::-1]
263+ sorted_idx = np .argsort (mu_star .values ) # [::-1]
256264
257265 axes [0 ].barh (
258266 y = [categories [i ] for i in sorted_idx ],
259267 width = [mu_star .values [i ] for i in sorted_idx ],
260- label = 'µ*' ,
268+ label = "µ*" ,
261269 facecolor = [colors [i ] for i in sorted_idx ],
262270 edgecolor = "black" ,
263271 alpha = 0.8 ,
264272 xerr = [mu_star_conf .values [i ] for i in sorted_idx ],
265273 capsize = 5 ,
266274 )
267275
268- axes [0 ].set_xlabel ('µ*' , fontsize = label_fontsize , fontweight = "bold" )
269- axes [0 ].set_ylabel (' Parameter' , fontsize = label_fontsize , fontweight = "bold" )
276+ axes [0 ].set_xlabel ("µ*" , fontsize = label_fontsize , fontweight = "bold" )
277+ axes [0 ].set_ylabel (" Parameter" , fontsize = label_fontsize , fontweight = "bold" )
270278 # axes[0].set_title(output_labels[output.uid], fontsize=20, fontweight="bold")
271279 # ax.grid(True, axis="y")
272280 # ax.tick_params(axis='x', labelrotation=90)
273281 # axes[0].tick_params(axis='y', labelweight='bold')
274282 # ax.legend()
275283 for label in axes [0 ].get_yticklabels ():
276- label .set_fontweight (' bold' )
284+ label .set_fontweight (" bold" )
277285
278286 for kp in range (len (categories )):
279287 axes [1 ].errorbar (
@@ -296,8 +304,8 @@ def plot_morris_indices(
296304 textcoords = "offset points" ,
297305 fontweight = "bold" ,
298306 )
299- axes [1 ].set_xlabel ('µ*' , fontsize = label_fontsize , fontweight = "bold" )
300- axes [1 ].set_ylabel ('σ' , fontsize = label_fontsize , fontweight = "bold" )
307+ axes [1 ].set_xlabel ("µ*" , fontsize = label_fontsize , fontweight = "bold" )
308+ axes [1 ].set_ylabel ("σ" , fontsize = label_fontsize , fontweight = "bold" )
301309 # axes[1].legend()
302310
303311 for kax , ax in enumerate (axes ):
@@ -312,4 +320,3 @@ def plot_morris_indices(
312320
313321 plt .savefig (f_path , dpi = 300 , bbox_inches = "tight" )
314322 plt .show ()
315-
0 commit comments