Viewer

class tfv.viewer.Viewer(size=(240, 120), units='mm', step=1, wait=0.01, format='%d/%m/%Y %H:%M:%S', display=True)

Class to explore/view time varying model result data

Parameters:
  • size (tuple) – Size of underlying figure as (width, height) in specified units

  • units ({'mm', 'cm' or 'm'}) – Figure units

  • step (integer) – The step size of the slider, i.e. how manly values it skips

  • wait (float) – The wait time in seconds between each step when in ‘play’ mode

  • format ({'num', 'hms', '%d/%m/%Y %H:%M:%S', '%d-%m-%Y', '%H:%M:%S %d-%m-%Y', ...}) – The slider value display format. Any custom datetime format string can be passed in addition to ‘num’ for the python date time as a number and ‘hms’ for total hours, minutes and seconds.

  • display (boolean) – Switch to display current time as text using the specified format. Default True.

figure

Underlying matplotlib figure object

Type:

matplotlib.pyplot.Figure

time_vector

Time vector associated with display

Type:

np.ndarray

time_current

Current time of display

Type:

np.float64

text

Text of the display

Type:

string

animate(file_path, ts, te, dt, fps=10, dpi=150)

Writes animation file for specified time interval.

Parameters:
  • file_path (string) – File path to output animation

  • ts (float) – Start time as python time stamp

  • te (float) – End time as python time stamp

  • dt (float) – Time increment at which to save frame

  • fps (integer) – Frames per second

  • dpi (integer) – Resolution in dots per inch (dpi)

connect(function)

Subscribes callback to slider

disconnect(function)

Removes callback subscription

print(file_path, format='png', dpi=300)

Prints Viewer objects figure to image file.

Parameters:
  • file_path (string) – File path to output image file

  • format (string) – File format i.e ‘png’, ‘pdf’, ‘jpg’

  • dpi (integer) – Resolution in dots per inch (dpi)

property show_time

Whether the viewer time title is visible.

property step

Slider step size.

property text

Viewer title text.

property time_current

Current time shown by the viewer.

property time_fmt

Format string used for time display.

property time_vector

Time vector controlled by the viewer slider.

property wait

Wait time between animation steps.