Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add options to save figures when plotting streamflow figures #103

Merged
merged 2 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 28 additions & 2 deletions pyhelp/bilan.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ def calc_yearly_streamflow(help_output, surf_output):
return yearly_qflow


def plot_sim_vs_obs_yearly_streamflow(sim_qflow, obs_qflow, fig_title):
def plot_sim_vs_obs_yearly_streamflow(sim_qflow, obs_qflow, fig_title,
figname=None):
"""
Plot simulated vs observed yearly total and base streamflow.

Parameters
----------
figname : str, optional
The abolute path of the file where to save the figure to disk.
Note that the format of the file is inferred from the extension of
"figname".
"""
fwidth, fheight = 9, 5.5
fig, ax = plt.subplots()
Expand Down Expand Up @@ -117,11 +124,24 @@ def plot_sim_vs_obs_yearly_streamflow(sim_qflow, obs_qflow, fig_title):
ax.text(0.5, 1, fig_title, fontsize=16, ha='center', va='bottom',
transform=ax.transAxes+offset)

# Save figure to file.
if figname is not None:
fig.savefig(figname)

def plot_streamflow_scatter(sim_qflow, obs_qflow, fig_title):
return fig


def plot_streamflow_scatter(sim_qflow, obs_qflow, fig_title, figname=None):
"""
Create a scatter plot comparing simulated total and base
streamflow yearly values with observed values.

Parameters
----------
figname : str, optional
The abolute path of the file where to save the figure to disk.
Note that the format of the file is inferred from the extension of
"figname".
"""
# Join both dataframe in a single dataframe.
yearly_qflow = sim_qflow.copy()
Expand Down Expand Up @@ -197,3 +217,9 @@ def plot_streamflow_scatter(sim_qflow, obs_qflow, fig_title):
borderaxespad=0, loc='lower right', borderpad=0.5,
bbox_to_anchor=(1, 0), ncol=1)
legend.draw_frame(False)

# Save figure to file.
if figname is not None:
fig.savefig(figname)

return fig
3 changes: 0 additions & 3 deletions pyhelp/scripts/postprocess_tair_moy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"""
Script permettant de faire le post-processing des données de la température
moyenne journalière pour une simulation pyhelp donnée.

Created on Wed May 18 14:43:58 2022
@author: User
"""

from pyhelp.managers import (
Expand Down