(preds: dict, TOA=False, surface=False,
title="", show=True, figsize=(16, 12), axes=None,
label="", **kwargs)
| 315 | |
| 316 | |
| 317 | def prediction_hist(preds: dict, TOA=False, surface=False, |
| 318 | title="", show=True, figsize=(16, 12), axes=None, |
| 319 | label="", **kwargs): |
| 320 | n_vars = len(preds.keys()) |
| 321 | n_cols = 3 if TOA and surface else 2 if (TOA or surface) else 1 |
| 322 | |
| 323 | surface_ax = 1 |
| 324 | TOA_ax = 2 if surface else 1 |
| 325 | |
| 326 | if axes is None: |
| 327 | fig, axs = plt.subplots(n_vars, n_cols, figsize=figsize) |
| 328 | fig.suptitle("Prediction magnitudes" if title == "" else title) |
| 329 | axs[0, 0].set_title('Mean') |
| 330 | |
| 331 | if surface: |
| 332 | axs[0, surface_ax].set_title('Surface') |
| 333 | if TOA: |
| 334 | axs[0, TOA_ax].set_title('TOA') |
| 335 | else: |
| 336 | axs = axes |
| 337 | |
| 338 | def set_bar_colors(patches, upto=5): |
| 339 | return |
| 340 | jet = plt.get_cmap('jet', len(patches)) |
| 341 | for i in range(len(patches)): |
| 342 | if i > upto: |
| 343 | return |
| 344 | patches[i].set_facecolor(jet(i * 10)) |
| 345 | |
| 346 | for (var_name, var_preds), ax_row in zip(preds.items(), axs): |
| 347 | # n_samples, n_levels = var_preds.shape |
| 348 | N, bins, patches = ax_row[0].hist(np.mean(var_preds, axis=1), label=label, **kwargs) |
| 349 | set_bar_colors(patches) |
| 350 | ax_row[0].set_ylabel(f"{var_name.upper()}", fontsize=20) |
| 351 | if surface: |
| 352 | N, bins, patches = ax_row[surface_ax].hist(var_preds[:, -1], label=label, **kwargs) |
| 353 | set_bar_colors(patches) |
| 354 | if TOA: |
| 355 | N, bins, patches = ax_row[TOA_ax].hist(var_preds[:, 0], label=label, **kwargs) |
| 356 | set_bar_colors(patches) |
| 357 | |
| 358 | axs[0, 0].legend() |
| 359 | if show: |
| 360 | plt.show() |
| 361 | |
| 362 | return axs |
| 363 | |
| 364 | |
| 365 | def prediction_bars(preds: dict, bins, TOA=False, surface=False, |
nothing calls this directly
no test coverage detected