pencil.visu

Visualization routines.

Submodules

Attributes

pc_print

Functions

animate_interactive(data[, t, dim_order, fps, title, ...])

Assemble a 2D animation from a 3D array.

animate_multislices([field, datadir, proc, extension, ...])

read a list of 2D slice files, combine them, and assemble an animation.

animate_slices_compareruns([field, datadir1, ...])

read 2D slice files from two different runs

make_movie([field, datadir, proc, extension, format, ...])

read 2D slice files and assemble an animation in a mpg movie.

animate_slices([field, datadir, proc, extension, ...])

read 2D slice files and assemble an animation.

lic(vectorfield[, filepath, filename, cmap, ...])

Plotting a vector field in Line Integral Convolution style.

Package Contents

pencil.visu.pc_print
pencil.visu.animate_interactive(data, t=None, dim_order=(0, 1, 2), fps=10.0, title=None, x_label='x', y_label='y', font_size=24, color_bar=0, colorbar_label=None, sloppy=True, fancy=False, range_min=None, range_max=None, extent=[-1, 1, -1, 1], shade=False, azdeg=0, altdeg=65, arrows_x=None, arrows_y=None, arrows_res_x=10, arrows_res_y=10, arrows_pivot='mid', arrows_width=0.002, arrows_scale=5, arrows_color='black', plot_arrows_grid=False, movie_file=None, bitrate=1800, keep_images=False, figsize=(8, 7), dpi=300, **kwimshow)

Assemble a 2D animation from a 3D array.

call signature:

animate_interactive(data, t=None, dim_order=(0, 1, 2),

fps=10.0, title=None, x_label=’x’, y_label=’y’, font_size=24, color_bar=0, colorbar_label=None, sloppy=True, fancy=False, range_min=None, range_max=None, extent=[-1, 1, -1, 1], shade=False, azdeg=0, altdeg=65, arrows_x=None, arrows_y=None, arrows_res_x=10, arrows_res_y=10, arrows_pivot=’mid’, arrows_width=0.002, arrows_scale=5, arrows_color=’black’, plot_arrows_grid=False, movie_file=None, bitrate=1800, keep_images=False, figsize=(8, 7), dpi=300, **kwimshow)

Assemble a 2D animation from a 3D array. data has to be a 3D array of shape [nt, nx, ny] and who’s time index has the same dimension as t. The time index of data as well as its x and y indices can be changed via dim_order.

Keyword arguments:

dim_order:

Ordering of the dimensions in the data array (t, x, y).

fps:

Frames per second of the animation.

title:

Title of the plot.

x_label:

Label of the x-axis.

y_label:

Label of the y-axis.

font_size:

Font size of the title, x and y label. The size of the x- and y-ticks is 0.5*font_size and the colorbar ticks’ font size is 0.5*font_size.

color_bar: [ 0 | 1 ]

Determines how the colorbar changes: (0 - no cahnge; 1 - adapt extreme values).

colorbar_label:

Label of the color bar.

sloppy: [ True | False ]

If True the update of the plot lags one frame behind. This speeds up the plotting.

fancy: [ True | False ]

Use fancy font style.

range_min, range_max:

Range of the colortable.

extent: [ None | (left, right, bottom, top) ]

Limits for the axes (domain).

shade: [ False | True ]

If True plot a shaded relief instead of the usual colormap. Note that with this option cmap has to be specified like cmap = plt.cm.hot instead of cmap = ‘hot’. Shading cannot be used with the color_bar = 0 option.

azdeg, altdeg:

Azimuth and altitude of the light source for the shading.

arrows_x:

Data containing the x-component of the arrows.

arrows_y:

Data containing the y-component of the arrows.

arrows_res_xY:

Plot every arrows_res_xY arrow in x and y.

arrows_pivot: [ ‘tail’ | ‘middle’ | ‘tip’ ]

The part of the arrow that is used as pivot point.

arrows_width:

Width of the arrows.

arrows_scale:

Scaling of the arrows.

arrows_color:

Color of the arrows.

plot_arrows_grid: [ False | True ]

If ‘True’ the grid where the arrows are aligned to is shown.

movie_file: [ None | string ]

The movie file where the animation should be saved to. If ‘None’ no movie file is written. Requires ‘ffmpeg’ to be installed.

bitrate:

Bitrate of the movie file. Set to higher value for higher quality.

keep_images: [ False | True ]

If ‘True’ the images for the movie creation are not deleted.

figsize:

Size of the figure in inches.

dpi:

Dots per inch of the frame.

**kwimshow:

Remaining arguments are identical to those of pylab.imshow. Refer to that help.

pencil.visu.animate_multislices(field=['uu1'], datadir='data/', proc=-1, extension='xz', format='native', tmin=0.0, tmax=1e+38, amin=0.0, amax=1.0, transform='plane[0]', oldfile=False, outfile='')

read a list of 2D slice files, combine them, and assemble an animation.

Options:

field — list of variables to slice datadir — path to data directory proc — an integer giving the processor to read a slice from extension — which plane of xy,xz,yz,Xz. for 2D this should be overwritten. format — endian. one of little, big, or native (default) tmin — start time tmax — end time amin — minimum value for image scaling amax — maximum value for image scaling transform — insert arbitrary numerical code to combine the slices outfile — if set, write the slice values in the text file

pencil.visu.animate_slices_compareruns(field='uu1', datadir1='data/', datadir2='data/', proc=-1, extension='xz', format='native', tmin=0.0, tmax=1e+38, wait=0.0, amin=0.0, amax=1.0, transform='', oldfile=False, makemovie=False)

read 2D slice files from two different runs note that the runs must have same precision and sizes

Options:

field — which variable to slice datadir1 — path to data directory of first simulation datadir2 — path to data directory of second imulation proc — an integer giving the processor to read a slice from extension — which plane of xy,xz,yz,Xz. for 2D this should be overwritten. format — endian. one of little, big, or native (default) tmin — start time tmax — end time amin — minimum value for image scaling amax — maximum value for image scaling transform — insert arbitrary numerical code to modify the slice wait — pause in seconds between animation slices makemovie — assemble an animation if makemovie option is set

pencil.visu.make_movie(field='uu1', datadir='data/', proc=-1, extension='xz', format='native', tmin=0.0, tmax=1e+38, amin=0.0, amax=1.0, transform='', oldfile=False, norm=None, save=None, figsize=(16, 4), fps=12)

read 2D slice files and assemble an animation in a mpg movie.

Quickly written from the example at http://matplotlib.sourceforge.net/faq/howto_faq.html

Options:

field — which variable to slice datadir— path to data directory proc — an integer giving the processor to read a slice from extension — which plane of xy,xz,yz,Xz. for 2D this should be overwritten. format — endian. one of little, big, or native (default) tmin — start time tmax — end time amin — minimum value for image scaling amax — maximum value for image scaling transform — insert arbitrary numerical code to modify the slice norm — scales calar data save — directory to save file figsize — tuple containing the size of the figure fps — Frames per seconds for the video

pencil.visu.animate_slices(field='uu1', datadir='data/', proc=-1, extension='xz', format='native', tmin=0.0, tmax=1e+38, wait=0.0, amin=0.0, amax=1.0, transform='', oldfile=False)

read 2D slice files and assemble an animation.

Options:

field — which variable to slice datadir — path to data directory proc — an integer giving the processor to read a slice from extension — which plane of xy,xz,yz,Xz. for 2D this should be overwritten. format — endian. one of little, big, or native (default) tmin — start time tmax — end time amin — minimum value for image scaling amax — maximum value for image scaling transform — insert arbitrary numerical code to modify the slice wait — pause in seconds between animation slices

pencil.visu.lic(vectorfield, filepath='.', filename='tmp', cmap='bone', kernellen=31, DPI=300, SIZE=(1024, 1024), PNG=True, EPS=False, PDF=False, FIG_BACKGROUND='white', DEBUG=True)

Plotting a vector field in Line Integral Convolution style.

Parameters:
  • vectorfield – put vectorfield here, shape is: [Nx, Ny, 2]

  • filepath – where to store imapge

  • filename – image name

  • cmap – put colormap here

  • kernellen – ??? whats this good for?

  • DPI – set dpi

  • size – in inches