Skip to content

Update ENSO summary plot color scale and improve robustness#1372

Merged
lee1043 merged 5 commits into
PCMDI:mainfrom
zhangshixuan1987:enso_fix
May 22, 2026
Merged

Update ENSO summary plot color scale and improve robustness#1372
lee1043 merged 5 commits into
PCMDI:mainfrom
zhangshixuan1987:enso_fix

Conversation

@zhangshixuan1987

Copy link
Copy Markdown
Collaborator

Summary

This PR updates the color scheme used in the ENSO summary portrait plot and refactors the color-selection logic to improve maintainability, consistency, and visual clarity.

Changes

  • plot.py:
  1. Replaced hard-coded named colors (yellowgreen, plum, gold, turquoise) with a centralized _METRIC_TYPE_COLORS constant using ColorBrewer qualitative colors (#66c2a5, #8da0cb, #fc8d62, #e78ac3) and a consistent alpha of 0.45. This provides a more cohesive and accessible palette for distinguishing the four metric groups: background biases, ENSO characteristics, teleconnections, and processes/feedbacks.
  2. Simplified the color-selection logic by replacing the cascading if/elif chain with a concise next(..., default) expression, improving readability and making it easier to extend or reorder metric groups.
  3. Propagated the alpha value consistently to both text bounding-box labels and horizontal Line2D indicators.
  4. Replaced the cmo.balance colormap with RdBu_r, removing the dependency on cmo.balance.
  • dev.yml / pyproject.toml

  • Updated the supported Python version range to include Python 3.14, aligning with the latest e3sm_unified environment.

@zhangshixuan1987

Copy link
Copy Markdown
Collaborator Author

@lee1043 : Hi Jiwoo, the pull request here includes the changes to the color scale used for the enso sythentic metrics plot following our discussion during the E3SMv3 coupled large ensemble overview paper. The tests were performed along with CLIVAR-PRP/ENSO_metrics#95, and the sample figure can be found at https://compy-dtn.pnl.gov/zhan391/zppy_weekly_comprehensive_v3_www/zppy_main_branch_plus_unified_1_13rc7_refactor2/v3.LR.historical_0051/pcmdi_diags/model_vs_obs/ERROR_metric/enso_metric/enso_metric_skill_portrait.png.

@lee1043 lee1043 self-requested a review May 5, 2026 22:54
@lee1043 lee1043 added this to the 4.1 milestone May 5, 2026
This commit introduce modifications on parallel coordinate plots:
- Replace deprecated scale/scale_hue seaborn arguments
- Use density_norm="count" and common_norm=True
- Add bw_adjust and gridsize to smooth violin shading
- Keep cut=0 so shading remains bounded by sampled values
Adjust the split violin plot parameters to make group shading smoother
and more visible. Use width normalization with a common reference, apply
a small positive KDE cut to reduce abrupt clipping, and increase the KDE
bandwidth and grid resolution for smoother violin boundaries.
@kristinchang3

Copy link
Copy Markdown
Collaborator

Hi @lee1043 and @zhangshixuan1987 I tested the change to dev.yml which allows for a higher version of python and confirmed the Demo notebooks ran successfully with python v3.14.5. I was not able to run Demo 6 as the enso_driver script encounters this error: ModuleNotFoundError: No module named 'EnsoMetrics' .

I am not sure if that is expected as the ENSO code is still undergoing changes, but otherwise this PR looks good to me!

@zhangshixuan1987

Copy link
Copy Markdown
Collaborator Author

Hi @lee1043 and @zhangshixuan1987 I tested the change to dev.yml which allows for a higher version of python and confirmed the Demo notebooks ran successfully with python v3.14.5. I was not able to run Demo 6 as the enso_driver script encounters this error: ModuleNotFoundError: No module named 'EnsoMetrics' .

I am not sure if that is expected as the ENSO code is still undergoing changes, but otherwise this PR looks good to me!

@kristinchang3 : I think that enso metrics is currently deactivated by @lee1043 in pcmdi, so you will not have the library installed from .yml file.

@kristinchang3

Copy link
Copy Markdown
Collaborator

@zhangshixuan1987 sounds good! thank you for confirming.

@lee1043

lee1043 commented May 22, 2026

Copy link
Copy Markdown
Contributor

@kristinchang3 thank you for the testing, good to know PMP runs okay with Python 3.14.x. As @zhangshixuan1987 pointed out, we are yet to bring ENSO back to default library. At the beginning of the demo 6 ENSO notebook, therefore it is noted that you will need the following to run ENSO, until we bring it back.

!conda install -c conda-forge enso_metrics

Comment thread conda-env/dev.yml
# NOTE: If versions are updated, also `additional_dependencies` list for mypy in `.pre-commit-config.yaml`
- python >=3.10,<3.14
- python >=3.10,<3.15
- pip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhangshixuan1987 is there any specific reason for this python version coverage change? I think this will need comprehensive test.

@kristinchang3 I think there were some conflict when we were testing with python 3.14 but I cannot recall the details. Do you recall what it was about?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lee1043 When we tested previously, python 3.14 was still in the pre-release stage so I actually was not able to install it at all. But today, I was able to! The official release date for 3.14.5 that I tested is May 10th 2026.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my apologies @lee1043 for some reason I only received the notification for this comment after you approved and merged.

@lee1043 lee1043 merged commit 094a957 into PCMDI:main May 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants