Skip to content

Commit

Permalink
Merge branch 'feature/1012_lee1043_stats-MoV_xcdat' of github.com:PCM…
Browse files Browse the repository at this point in the history
…DI/pcmdi_metrics into feature/1012_lee1043_stats-MoV_xcdat
  • Loading branch information
lee1043 committed Apr 24, 2024
2 parents d886049 + 113d045 commit 6a414c6
Show file tree
Hide file tree
Showing 11 changed files with 628 additions and 1,442 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def parallel_coordinate_plot(
show_boxplot=False,
show_violin=False,
violin_colors=("lightgrey", "pink"),
violin_label=None,
title=None,
identify_all_models=True,
xtick_labelsize=None,
Expand All @@ -35,6 +36,8 @@ def parallel_coordinate_plot(
legend_off=False,
legend_ncol=6,
legend_bbox_to_anchor=(0.5, -0.14),
legend_loc="upper center",
legend_fontsize=10,
logo_rect=None,
logo_off=False,
model_names2=None,
Expand Down Expand Up @@ -72,6 +75,7 @@ def parallel_coordinate_plot(
- `show_boxplot`: bool, default=False, show box and wiskers plot
- `show_violin`: bool, default=False, show violin plot
- `violin_colors`: tuple or list containing two strings for colors of violin. Default=("lightgrey", "pink")
- `violin_label`: string to label the violin plot, when violin plot is not splited. Default is None.
- `title`: string, default=None, plot title
- `identify_all_models`: bool, default=True. Show and identify all models using markers
- `xtick_labelsize`: number, fontsize for x-axis tick labels (optional)
Expand All @@ -81,6 +85,8 @@ def parallel_coordinate_plot(
- `legend_off`: bool, default=False, turn off legend
- `legend_ncol`: integer, default=6, number of columns for legend text
- `legend_bbox_to_anchor`: tuple, defulat=(0.5, -0.14), set legend box location
- `legend_loc`: string, default="upper center", set legend box location
- `legend_fontsize`: float, default=8, legend font size
- `logo_rect`: sequence of float. The dimensions [left, bottom, width, height] of the new Axes.
All quantities are in fractions of figure width and height. Optional.
- `logo_off`: bool, default=False, turn off PMP logo
Expand Down Expand Up @@ -110,6 +116,7 @@ def parallel_coordinate_plot(
2022-09 violin plots added
2023-03 median centered option added
2023-04 vertical center option diversified (median, mean, or given number)
2024-03 parameter added for violin plot label
"""
params = {
"legend.fontsize": "large",
Expand Down Expand Up @@ -340,10 +347,31 @@ def parallel_coordinate_plot(
ax.set_title(title, fontsize=18)

if not legend_off:
# ax.legend(loc="upper center", ncol=6, bbox_to_anchor=(0.5, -0.14))
ax.legend(
loc="upper center", ncol=legend_ncol, bbox_to_anchor=legend_bbox_to_anchor
)
if violin_label is not None:
# Get all lines for legend
lines = [violin["bodies"][0]] + ax.lines
# Get labels for legend
labels = [violin_label] + [line.get_label() for line in ax.lines]
# Remove unnessasary lines that its name starts with '_' to avoid the burden of warning message
lines = [aa for aa, bb in zip(lines, labels) if not bb.startswith("_")]
labels = [bb for bb in labels if not bb.startswith("_")]
# Add legend
ax.legend(
lines,
labels,
loc=legend_loc,
ncol=legend_ncol,
bbox_to_anchor=legend_bbox_to_anchor,
fontsize=legend_fontsize,
)
else:
# Add legend
ax.legend(
loc=legend_loc,
ncol=legend_ncol,
bbox_to_anchor=legend_bbox_to_anchor,
fontsize=legend_fontsize,
)

if not logo_off:
fig, ax = add_logo(fig, ax, logo_rect)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@
"# Add Watermark\n",
"ax.text(0.5, 0.5, 'Example', transform=ax.transAxes,\n",
" fontsize=100, color='black', alpha=0.2,\n",
" ha='center', va='center', rotation='25')"
" ha='center', va='center', rotation=25)"
]
},
{
Expand Down Expand Up @@ -716,7 +716,7 @@
"# Add Watermark\n",
"ax.text(0.5, 0.5, 'Example', transform=ax.transAxes,\n",
" fontsize=100, color='black', alpha=0.2,\n",
" ha='center', va='center', rotation='25')"
" ha='center', va='center', rotation=25)"
]
},
{
Expand Down
62 changes: 31 additions & 31 deletions pcmdi_metrics/graphics/portrait_plot/portrait_plot_example.ipynb

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions pcmdi_metrics/graphics/portrait_plot/portrait_plot_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,6 @@ def prepare_data(data, xaxis_labels, yaxis_labels, debug=False):
if debug:
print("num_divide:", num_divide)

# Mask out nan data
data = np.ma.masked_invalid(data)

return data, num_divide


Expand Down
148 changes: 70 additions & 78 deletions pcmdi_metrics/graphics/portrait_plot/portrait_plot_mean_clim.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pcmdi_metrics/graphics/share/read_json_mean_clim.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def extract_data(results_dict, var_list, region, stat, season, mip, debug=False)
model_list = sorted(
list(results_dict["rlut"]["RESULTS"].keys()), key=str.casefold
)

print("extract_data:: model_list: ", model_list)
if debug:
print("extract_data:: model_list: ", model_list)

data_list = []
for model in model_list:
Expand Down
6 changes: 5 additions & 1 deletion pcmdi_metrics/precip_distribution/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Precip distribution metrics

Reference: Ahn, M.-S., P. A. Ullrich, P. J. Gleckler, J. Lee, A. C. Ordonez, and A. G. Pendergrass, 2022: Evaluating Precipitation Distributions at Regional Scales: A Benchmarking Framework and Application to CMIP5 and CMIP6. Geoscientific Model Development (Submitted)
Reference:
Ahn, M.-S., P. A. Ullrich, P. J. Gleckler, J. Lee, A. C. Ordonez, and A. G. Pendergrass, 2023: Evaluating Precipitation Distributions at Regional Scales: A Benchmarking Framework and Application to CMIP5 and CMIP6. Geoscientific Model Development, 16, 3927–3951, https://doi.org/10.5194/gmd-16-3927-2023.

Ahn, M.-S., P. A. Ullrich, J. Lee, P. J. Gleckler, H.-Y. Ma, C. R. Terai, P. A. Bogenschutz, and A. C. Ordonez, 2023: Bimodality in Simulated Precipitation Frequency Distributions and Its Relationship with Convective Parameterizations, 01 June 2023, PREPRINT (Version 1) available at Research Square, https://doi.org/10.21203/rs.3.rs-2874349/v1. (Under revision)


## Driver code:
- `precip_distribution_driver.py`
Expand Down

0 comments on commit 6a414c6

Please sign in to comment.