FESOM / tripyview

Triangular plotting for FESOM2
MIT License
4 stars 3 forks source link

vprofile Image size of 73406x436 pixels is too large. #131

Closed JanStreffing closed 2 weeks ago

JanStreffing commented 2 months ago

For 60 years ref and 60 years experiment with core2 I get at this position:

 --> compute vprofile:
     --> compute: Kv

This error:

papermill.exceptions.PapermillExecutionError:
---------------------------------------------------------------------------
Exception encountered at "In [7]":
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[7], line 23
     20 if save_fname!=None: sfpath = [save_fname] # --> needed for diagrun papermille functionality
     22 #__________________________________________________________________________________________________
---> 23 hfig, hax = tpv.plot_vline(data_list           ,
     24                     box        = box           ,
     25                     box_idx    = None          ,
     26                     boxl_opt   = dict()        , # option for box label string
     27                     nrow       = nrow0         , # number of row in figures panel
     28                     ncol       = ncol0         ,
     29                     do_rescale = do_rescale    ,
     30                     ax_opt=dict({'fig_sizefac':2,}),
     31                     do_allcycl = do_allcycl    ,
     32                     n_cycl     = n_cycl        ,
     33                     do_enum    = do_enum       ,
     34                     do_shdw    = do_shdw       ,
     35                     do_mean    = do_mean       ,
     36                     do_save    = sfpath, save_dpi=save_dpi,)

File /work/ab0246/a270092/software/tripyview/tripyview/sub_plot.py:2564, in plot_vline(data, box, box_idx, box_label, boxl_opt, cinfo, nrow, ncol, proj, n_cycl, do_allcycl, do_shdw, do_mean, do_rescale, plt_opt, mark_opt, do_grid, grid_opt, ax_title, ax_xlabel, ax_ylabel, ax_xunit, ax_yunit, ax_opt, ax_xlim, ax_ylim, do_enum, enum_opt, enum_str, enum_x, enum_y, enum_dir, do_save, save_dpi, save_opt, nargout)
   2560                 if not allinone and nbox>1: hax_ii.set_title(str_blabel, fontsize=hax_ii.fs_label)
   2562 #___________________________________________________________________________
   2563 # save figure based on do_save contains either None or pathname
-> 2564 do_savefigure(do_save, hfig, dpi=save_dpi, save_opt=save_opt)
   2566 #___________________________________________________________________________
   2567 list_argout=[]

File /work/ab0246/a270092/software/tripyview/tripyview/sub_plot.py:5969, in do_savefigure(do_save, hfig, dpi, do_info, save_opt)
   5966 if not os.path.isdir(sdname): os.makedirs(sdname)
   5968 #___________________________________________________________________
-> 5969 hfig.savefig(os.path.join(sdname,sfname), format=sfformat, dpi=dpi,
   5970             **save_optdefault)

File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/figure.py:3395, in Figure.savefig(self, fname, transparent, **kwargs)
   3393     for ax in self.axes:
   3394         _recursively_make_axes_transparent(stack, ax)
-> 3395 self.canvas.print_figure(fname, **kwargs)

File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/backend_bases.py:2204, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2200 try:
   2201     # _get_renderer may change the figure dpi (as vector formats
   2202     # force the figure dpi to 72), so we need to set it again here.
   2203     with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2204         result = print_method(
   2205             filename,
   2206             facecolor=facecolor,
   2207             edgecolor=edgecolor,
   2208             orientation=orientation,
   2209             bbox_inches_restore=_bbox_inches_restore,
   2210             **kwargs)
   2211 finally:
   2212     if bbox_inches and restore_bbox:
File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/backend_bases.py:2054, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2050     optional_kws = {  # Passed by print_figure for other renderers.
   2051         "dpi", "facecolor", "edgecolor", "orientation",
   2052         "bbox_inches_restore"}
   2053     skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2054     print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
   2055         *args, **{k: v for k, v in kwargs.items() if k not in skip}))
   2056 else:  # Let third-parties do as they see fit.
   2057     print_method = meth

File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:496, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    449 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    450     """
    451     Write the figure to a PNG file.
    452
   (...)
    494         *metadata*, including the default 'Software' key.
    495     """
--> 496     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:444, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    439 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    440     """
    441     Draw the canvas, then save it using `.image.imsave` (to which
    442     *pil_kwargs* and *metadata* are forwarded).
    443     """
--> 444     FigureCanvasAgg.draw(self)
    445     mpl.image.imsave(
    446         filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
    447         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:382, in FigureCanvasAgg.draw(self)
    380 def draw(self):
    381     # docstring inherited
--> 382     self.renderer = self.get_renderer()
    383     self.renderer.clear()
    384     # Acquire a lock on the shared font cache.

File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:397, in FigureCanvasAgg.get_renderer(self)
    395 reuse_renderer = (self._lastKey == key)
    396 if not reuse_renderer:
--> 397     self.renderer = RendererAgg(w, h, self.figure.dpi)
    398     self._lastKey = key
    399 return self.renderer

File /work/ab0246/a270092/software/miniconda3/envs/py39/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py:70, in RendererAgg.__init__(self, width, height, dpi)
     68 self.width = width
     69 self.height = height
---> 70 self._renderer = _RendererAgg(int(width), int(height), dpi)
     71 self._filter_renderers = []
     73 self._update_methods()

ValueError: Image size of 73406x436 pixels is too large. It must be less than 2^16 in each direction.
patrickscholz commented 2 weeks ago

problem is here you define a reference run which means that he computes the anomalous Kv, which has of course also negative values. Than you try to scale anomalous positive and negative values with a log10 scaling which doesnt accept negative inputs. I try now to switch from log10 to slog10 scaling when it encounters negativ values together with do_rescale='log10'

patrickscholz commented 2 weeks ago

hopefully fixed with push https://github.com/FESOM/tripyview/pull/143