From 3dc79481cddaece7b907db29b8184d60003d0197 Mon Sep 17 00:00:00 2001 From: Fariborz Daneshvar Date: Wed, 10 Jan 2024 17:48:39 +0000 Subject: [PATCH 1/4] add unit name and convertor to the label of plot_selected_probability_field function --- ensembleperturbation/plotting/surrogate.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ensembleperturbation/plotting/surrogate.py b/ensembleperturbation/plotting/surrogate.py index 607ca144..56a7d653 100644 --- a/ensembleperturbation/plotting/surrogate.py +++ b/ensembleperturbation/plotting/surrogate.py @@ -567,7 +567,11 @@ def plot_kl_surrogate_fit( def plot_selected_probability_fields( - node_prob_field: xarray.Dataset, level_list: list, output_directory: PathLike + node_prob_field: xarray.Dataset, + level_list: list, + output_directory: PathLike + label_unit_convert_factor: float = 1, + label_unit_name: str = 'm', ): probabilities = node_prob_field.probabilities @@ -589,7 +593,7 @@ def plot_selected_probability_fields( for lvl in level_list: figure = pyplot.figure() figure.set_size_inches(10, 10 / 1.61803398875) - figure.suptitle(f'Probability of water level exceeding {lvl}-m') + figure.suptitle(f'Probability of water level exceeding {lvl * label_unit_convert_factor}-{label_unit_name}') for index, source in enumerate(sources): map_axis = figure.add_subplot(2, len(sources), index + 1) map_axis.title.set_text(f'{source}') From 5710cfc4a648edbd61ec2aa95671e437eeaf3f14 Mon Sep 17 00:00:00 2001 From: Fariborz Daneshvar Date: Wed, 10 Jan 2024 17:55:58 +0000 Subject: [PATCH 2/4] update savefig name and use round of lvl*factor in plot_selected_probability_field --- ensembleperturbation/plotting/surrogate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ensembleperturbation/plotting/surrogate.py b/ensembleperturbation/plotting/surrogate.py index 56a7d653..a2c14540 100644 --- a/ensembleperturbation/plotting/surrogate.py +++ b/ensembleperturbation/plotting/surrogate.py @@ -593,7 +593,7 @@ def plot_selected_probability_fields( for lvl in level_list: figure = pyplot.figure() figure.set_size_inches(10, 10 / 1.61803398875) - figure.suptitle(f'Probability of water level exceeding {lvl * label_unit_convert_factor}-{label_unit_name}') + figure.suptitle(f'Probability of water level exceeding {round(lvl*label_unit_convert_factor)}-{label_unit_name}') for index, source in enumerate(sources): map_axis = figure.add_subplot(2, len(sources), index + 1) map_axis.title.set_text(f'{source}') @@ -637,7 +637,7 @@ def plot_selected_probability_fields( if output_directory is not None: figure.savefig( - output_directory / f'probability_exceeding_{lvl}m.png', + output_directory / f'probability_exceeding_{round(lvl*label_unit_convert_factor)}_{label_unit_name}.png', dpi=200, bbox_inches='tight', ) From 6cdffdab09423defd30f7151bf47ef7901c78cae Mon Sep 17 00:00:00 2001 From: Fariborz Daneshvar Date: Wed, 10 Jan 2024 18:13:12 +0000 Subject: [PATCH 3/4] add missing ',' in line 572 of surrogate.py --- ensembleperturbation/plotting/surrogate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ensembleperturbation/plotting/surrogate.py b/ensembleperturbation/plotting/surrogate.py index a2c14540..c1f2a16b 100644 --- a/ensembleperturbation/plotting/surrogate.py +++ b/ensembleperturbation/plotting/surrogate.py @@ -569,7 +569,7 @@ def plot_kl_surrogate_fit( def plot_selected_probability_fields( node_prob_field: xarray.Dataset, level_list: list, - output_directory: PathLike + output_directory: PathLike, label_unit_convert_factor: float = 1, label_unit_name: str = 'm', ): From c015173c11490046d35eb72bde26cad489447e82 Mon Sep 17 00:00:00 2001 From: Fariborz Daneshvar Date: Wed, 10 Jan 2024 19:10:12 +0000 Subject: [PATCH 4/4] run oitnb and format surrogate.py --- ensembleperturbation/plotting/surrogate.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ensembleperturbation/plotting/surrogate.py b/ensembleperturbation/plotting/surrogate.py index c1f2a16b..bf2e0681 100644 --- a/ensembleperturbation/plotting/surrogate.py +++ b/ensembleperturbation/plotting/surrogate.py @@ -567,8 +567,8 @@ def plot_kl_surrogate_fit( def plot_selected_probability_fields( - node_prob_field: xarray.Dataset, - level_list: list, + node_prob_field: xarray.Dataset, + level_list: list, output_directory: PathLike, label_unit_convert_factor: float = 1, label_unit_name: str = 'm', @@ -593,7 +593,9 @@ def plot_selected_probability_fields( for lvl in level_list: figure = pyplot.figure() figure.set_size_inches(10, 10 / 1.61803398875) - figure.suptitle(f'Probability of water level exceeding {round(lvl*label_unit_convert_factor)}-{label_unit_name}') + figure.suptitle( + f'Probability of water level exceeding {round(lvl*label_unit_convert_factor)}-{label_unit_name}' + ) for index, source in enumerate(sources): map_axis = figure.add_subplot(2, len(sources), index + 1) map_axis.title.set_text(f'{source}') @@ -637,7 +639,8 @@ def plot_selected_probability_fields( if output_directory is not None: figure.savefig( - output_directory / f'probability_exceeding_{round(lvl*label_unit_convert_factor)}_{label_unit_name}.png', + output_directory + / f'probability_exceeding_{round(lvl*label_unit_convert_factor)}_{label_unit_name}.png', dpi=200, bbox_inches='tight', )