ESMValGroup / ESMValTool

ESMValTool: A community diagnostic and performance metrics tool for routine evaluation of Earth system models in CMIP
https://www.esmvaltool.org
Apache License 2.0
216 stars 126 forks source link

recipe_monitor.yml failing due to matplotlib issues #3085

Closed sloosvel closed 1 year ago

sloosvel commented 1 year ago

Describe the bug As recported in #3076, the monitor diagnostics are failing due to issues with mapgenerator and matplotlib. @remi-kazeroni to fix this I will need to fix map generator so, I don't think I will open a PR in here. I will let you now when the issues and the new version with the fixes has been published.

sloosvel commented 1 year ago

So far, I am able to solve the issues in the timeseries plots. But for the maps I get a very strange error during the saving. I am still looking into it, but I add the log in here in case anyone may have an idea of what may be happening:

Traceback (most recent call last):
  File "/home/b/b381943/ESMValTool/esmvaltool/diag_scripts/monitor/monitor.py", line 577, in <module>
    main()
  File "/home/b/b381943/ESMValTool/esmvaltool/diag_scripts/monitor/monitor.py", line 573, in main
    Monitor(config).compute()
  File "/home/b/b381943/ESMValTool/esmvaltool/diag_scripts/monitor/monitor.py", line 169, in compute
    self.plot_monthly_climatology(cube, var_info)
  File "/home/b/b381943/ESMValTool/esmvaltool/diag_scripts/monitor/monitor.py", line 342, in plot_monthly_climatology
    plt.savefig(
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/pyplot.py", line 1023, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/figure.py", line 3343, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 2366, in print_figure
    result = print_method(
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 2232, in <lambda>
    print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 509, in print_png
    self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 457, in _print_pil
    FigureCanvasAgg.draw(self)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 400, in draw
    self.figure.draw(self.renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/artist.py", line 95, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/figure.py", line 3140, in draw
    mimage._draw_list_compositing_images(
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 538, in draw
    return super().draw(renderer=renderer, **kwargs)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 3064, in draw
    mimage._draw_list_compositing_images(
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/cartopy/mpl/geoaxes.py", line 262, in draw
    super().draw(renderer, *args, **kwargs)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/patches.py", line 591, in draw
    self._draw_paths_with_artist_properties(
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/patches.py", line 576, in _draw_paths_with_artist_properties
    renderer.draw_path(gc, *draw_path_args)
  File "/work/bk1088/b381943/mambaforge/envs/coretool28rc1/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 146, in draw_path
    self._renderer.draw_path(gc, path, transform, rgbFace)
TypeError: must be real number, not str
sloosvel commented 1 year ago

All clear now, it's an issue when setting the linewidth in mapgenerator. I will work with @fbeninca to fix it.

valeriupredoi commented 1 year ago

@sloosvel you guys managed to make some headway on this? Do you need any help?

sloosvel commented 1 year ago

Yes, mapgenerator has been updated in PyPi to include the changes that were needed https://pypi.org/project/mapgenerator/ . I guess it should be updated in conda forge now but I don't know who was doing that in the end.

valeriupredoi commented 1 year ago

mapgenerator on conda is updated indeed but there is a mismatch between the PyPI and conda forge versions https://anaconda.org/conda-forge/mapgenerator and https://pypi.org/project/mapgenerator/

sloosvel commented 1 year ago

It's not a mismatch, it's just that the newest version is not on condaforge.

sloosvel commented 1 year ago

Ok the newest version is there now, @remi-kazeroni I guess that when creating new environments, the recipe should run now

remi-kazeroni commented 1 year ago

Thanks for following up on this @sloosvel! I'll check during the next round of testing (today or tomorrow) that it works and we could then close this issue

remi-kazeroni commented 1 year ago

I got a successful run in https://esmvaltool.dkrz.de/shared/esmvaltool/v2.8.0rc2/recipe_monitor_20230321_133858/ My freshly created env has mapgenerator=1.0.7. Could you please check the output @sloosvel and close this issue if all fine?

sloosvel commented 1 year ago

The only differences in the plots that I have seen are some new ticks in the colorbars for the maps and a small change of size in the timeseries plots. It all looks fine to me, so I am closing this.

valeriupredoi commented 1 year ago

brilliant, many thanks @sloosvel :beer: