pymor.gui package

Submodules

gl module

This module provides a widget for displaying patch plots of scalar data assigned to 2D-grids using OpenGL. This widget is not intended to be used directly. Instead, use visualize_patch or PatchVisualizer.


class pymor.gui.gl.ColorBarWidget(parent, U=None, vmin=None, vmax=None)[source]

Bases: QGLWidget

Methods

ColorBarWidget

initializeGL, paintEvent, resizeGL, set


class pymor.gui.gl.GLPatchWidget(parent, grid, vmin=None, vmax=None, bounding_box=([0, 0], [1, 1]), codim=2)[source]

Bases: QGLWidget

Methods

GLPatchWidget

initializeGL, paintGL, resizeGL, set, set_coordinates


pymor.gui.gl.colormap_texture(name='viridis')[source]

pymor.gui.gl.compile_shader(source, vertex=True)[source]

Compile a vertex shader from source.


Create a shader program with from compiled shaders.

jupyter module

This module provides plotting support inside the Jupyter notebook.

To use these routines you first have to execute

%matplotlib notebook

inside the given notebook.


class pymor.gui.jupyter.LogViewer(out, accordion=None)[source]

Bases: logging.Handler

Methods

LogViewer

close, emit

Handler

acquire, createLock, flush, format, get_name, handle, handleError, release, set_name, setFormatter, setLevel

Filterer

addFilter, filter, removeFilter

Attributes

LogViewer

empty, out

Handler

name

__repr__()[source]

Return repr(self).

close()[source]

Tidy up any resources used by the handler.

This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.


class pymor.gui.jupyter.LoggingRedirector[source]

Bases: object

Methods

LoggingRedirector

start, stop


pymor.gui.jupyter.load_ipython_extension(ipython)[source]

pymor.gui.jupyter.progress_bar(sequence, every=None, size=None, name='Parameters')[source]

pymor.gui.jupyter.unload_ipython_extension(ipython)[source]

pymor.gui.jupyter.visualize_patch(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None, legend=None, separate_colorbars=False, rescale_colorbars=False, columns=2)[source]

Visualize scalar data associated to a two-dimensional Grid as a patch plot.

The grid’s ReferenceElement must be the triangle or square. The data can either be attached to the faces or vertices of the grid.

Parameters

grid

The underlying Grid.

U

VectorArray of the data to visualize. If len(U) > 1, the data is visualized as a time series of plots. Alternatively, a tuple of VectorArrays can be provided, in which case a subplot is created for each entry of the tuple. The lengths of all arrays have to agree.

bounding_box

A bounding box in which the grid is contained.

codim

The codimension of the entities the data in U is attached to (either 0 or 2).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

separate_colorbars

If True, use separate colorbars for each subplot.

rescale_colorbars

If True, rescale colorbars to data in each frame.

columns

The number of columns in the visualizer GUI in case multiple plots are displayed at the same time.

matplotlib module

This module provides a widgets for displaying plots of scalar data assigned to one- and two-dimensional grids using matplotlib. This widget is not intended to be used directly.


class pymor.gui.matplotlib.Matplotlib1DWidget(parent, grid, count, vmin=None, vmax=None, legend=None, codim=1, separate_plots=False, dpi=100)[source]

Bases: FigureCanvasQTAgg

Methods

Matplotlib1DWidget

set


class pymor.gui.matplotlib.MatplotlibPatchAxes(figure, grid, bounding_box=None, vmin=None, vmax=None, codim=2, colorbar=True)[source]

Bases: object

Methods

MatplotlibPatchAxes

set


class pymor.gui.matplotlib.MatplotlibPatchWidget(parent, grid, bounding_box=None, vmin=None, vmax=None, codim=2, dpi=100)[source]

Bases: FigureCanvasQTAgg

Methods

MatplotlibPatchWidget

set

qt module

This module provides a few methods and classes for visualizing data associated to grids. We use the Qt widget toolkit for the GUI.


class pymor.gui.qt.PlotMainWindow(U, plot, length=1, title=None)[source]

Bases: object

Base class for plot main windows.

Methods

PlotMainWindow

rewind, slider_changed, speed_changed, step_backward, step_forward, to_end, toggle_play, update_solution


pymor.gui.qt._launch_qt_app(main_window_factory, block)[source]

Wrapper to display plot in a separate process.


pymor.gui.qt.stop_gui_processes()[source]

pymor.gui.qt.visualize_matplotlib_1d(grid, U, codim=1, title=None, legend=None, separate_plots=False, block=False)[source]

Visualize scalar data associated to a one-dimensional Grid as a plot.

The grid’s ReferenceElement must be the line. The data can either be attached to the subintervals or vertices of the grid.

Parameters

grid

The underlying Grid.

U

VectorArray of the data to visualize. If len(U) > 1, the data is visualized as a time series of plots. Alternatively, a tuple of VectorArrays can be provided, in which case several plots are made into the same axes. The lengths of all arrays have to agree.

codim

The codimension of the entities the data in U is attached to (either 0 or 1).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

separate_plots

If True, use subplots to visualize multiple VectorArrays.

block

If True, block execution until the plot window is closed.


pymor.gui.qt.visualize_patch(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None, legend=None, separate_colorbars=False, rescale_colorbars=False, backend='gl', block=False, columns=2)[source]

Visualize scalar data associated to a two-dimensional Grid as a patch plot.

The grid’s ReferenceElement must be the triangle or square. The data can either be attached to the faces or vertices of the grid.

Parameters

grid

The underlying Grid.

U

VectorArray of the data to visualize. If len(U) > 1, the data is visualized as a time series of plots. Alternatively, a tuple of VectorArrays can be provided, in which case a subplot is created for each entry of the tuple. The lengths of all arrays have to agree.

bounding_box

A bounding box in which the grid is contained.

codim

The codimension of the entities the data in U is attached to (either 0 or 2).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

separate_colorbars

If True, use separate colorbars for each subplot.

rescale_colorbars

If True, rescale colorbars to data in each frame.

backend

Plot backend to use (‘gl’ or ‘matplotlib’).

block

If True, block execution until the plot window is closed.

columns

The number of columns in the visualizer GUI in case multiple plots are displayed at the same time.

Defaults

backend (see pymor.core.defaults)

visualizers module


class pymor.gui.visualizers.OnedVisualizer(grid, codim=1, block=False)[source]

Bases: pymor.core.interfaces.BasicInterface

Visualize scalar data associated to a one-dimensional Grid as a plot.

The grid’s ReferenceElement must be the line. The data can either be attached to the subintervals or vertices of the grid.

Parameters

grid

The underlying Grid.

codim

The codimension of the entities the data in U is attached to (either 0 or 1).

block

If True, block execution until the plot window is closed.

visualize(U, m, title=None, legend=None, block=None)[source]

Visualize the provided data.

Parameters

U

VectorArray of the data to visualize. If len(U) > 1, the data is visualized as a time series of plots. Alternatively, a tuple of VectorArrays can be provided, in which case several plots are made into the same axes. The lengths of all arrays have to agree.

m

Filled in by pymor.models.ModelBase.visualize (ignored).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

block

If True, block execution until the plot window is closed. If None, use the default provided during instantiation.


class pymor.gui.visualizers.PatchVisualizer(grid, bounding_box=([0, 0], [1, 1]), codim=2, backend=None, block=False)[source]

Bases: pymor.core.interfaces.BasicInterface

Visualize scalar data associated to a two-dimensional Grid as a patch plot.

The grid’s ReferenceElement must be the triangle or square. The data can either be attached to the faces or vertices of the grid.

Parameters

grid

The underlying Grid.

bounding_box

A bounding box in which the grid is contained.

codim

The codimension of the entities the data in U is attached to (either 0 or 2).

backend

Plot backend to use (‘gl’, ‘matplotlib’, ‘jupyter’).

block

If True, block execution until the plot window is closed.

visualize(U, m, title=None, legend=None, separate_colorbars=False, rescale_colorbars=False, block=None, filename=None, columns=2)[source]

Visualize the provided data.

Parameters

U

VectorArray of the data to visualize. If len(U) > 1, the data is visualized as a time series of plots. Alternatively, a tuple of VectorArrays can be provided, in which case a subplot is created for each entry of the tuple. The lengths of all arrays have to agree.

m

Filled in by pymor.models.ModelBase.visualize (ignored).

title

Title of the plot.

legend

Description of the data that is plotted. Most useful if U is a tuple in which case legend has to be a tuple of strings of the same length.

separate_colorbars

If True, use separate colorbars for each subplot.

rescale_colorbars

If True, rescale colorbars to data in each frame.

block

If True, block execution until the plot window is closed. If None, use the default provided during instantiation.

filename

If specified, write the data to a VTK-file using pymor.tools.vtkio.write_vtk instead of displaying it.

columns

The number of columns in the visualizer GUI in case multiple plots are displayed at the same time.