Skip to content

viz⚓︎

Plot utilities.

Modules:

Name Description
series

Time series management and processing.

NoneDict ⚓︎

Bases: DotDict

DotDict with getattr that (silently) falls back to None.

amplitude_animation(EE, dt=None, interval=1, periodicity=None, blit=True, fignum=None, repeat=False) ⚓︎

Animation of line chart.

Using an ensemble of the shape (time, ensemble size, state vector length).

Parameters:

Name Type Description Default
EE ndarray

Ensemble arry of the shape (K, N, Nx). K is the length of time, N is the ensemble size, and Nx is the length of state vector.

required
dt float

Time interval of each frame.

None
interval float

Delay between frames in milliseconds. Defaults to 200.

1
periodicity bool

The mode of the wrapping. "+1": the first element is appended after the last. "±05": adding the midpoint of the first and last elements. Default: "+1"

None
blit bool

Controls whether blitting is used to optimize drawing. Default: True

True
fignum int

Figure index. Default: None

None
repeat bool

If True, repeat the animation. Default: False

False

axis_scale_by_array(ax, arr, axis='y', nbins=3) ⚓︎

Scale axis so that the arr entries appear equidistant.

The full transformation is piecewise-linear.

Parameters:

Name Type Description Default
ax axes
required
arr ndarray

Array for plotting

required
axis str

Scaled axis, which can be 'x', 'y' or 'z'. Defaults: 'y'

'y'
nbins int

Number of major ticks. Defaults: 3

3

collapse_str(string, length=6) ⚓︎

Truncate a string (in the middle) to the given length

default_fig_adjustments(tables, xticks_from_data=False) ⚓︎

Beautify. These settings do not generalize well.

default_styles(coord, baseline_legends=False) ⚓︎

Quick and dirty (but somewhat robust) styling.

estimate_good_plot_length(xx, tseq=None, mult=100) ⚓︎

Estimate the range of the xx slices for plotting.

The length is based on the estimated time scale (wavelength) of the system. Provide sensible fall-backs (better if tseq is supplied).

Parameters:

Name Type Description Default
xx ndarray

Plotted array

required
tseq [`tools.chronos.Chronology`][]

object with property dko. Defaults: None

None
mult int

Number of waves for plotting. Defaults: 100

100

Returns:

Name Type Description
K int

length for plotting

Examples:

>>> K_lag = estimate_good_plot_length(stats.xx, tseq, mult=80)

integer_hist(E, N, centrd=False, weights=None, **kwargs) ⚓︎

Histogram for integers.

Parameters:

Name Type Description Default
E ndarray

Ensemble array.

required
N int

Number of histogram bins.

required
centrd bool

If True, each bin is centered in the midpoint. Default: False

False
weights float

Weights for histogram. Default: None

None
kwargs dict

keyword arguments for matplotlib.hist

{}

make_label(coord, no_key=NO_KEY, exclude=()) ⚓︎

Make label from coord.

not_available_text(ax, txt=None, fs=20) ⚓︎

Plot given text on the figure

Parameters:

Name Type Description Default
ax axes
required
txt str

Printed text. Defaults: '[Not available]'

None
fs float

Font size. Defaults: 20.

20

plot_err_components(stats) ⚓︎

Plot components of the error.

Parameters:

Name Type Description Default
stats Stats
required
Note

It was chosen to plot(ii, mean_in_time(abs(err_i))), and thus the corresponding spread measure is MAD. If one chose instead: plot(ii, std_spread_in_time(err_i)), then the corresponding measure of spread would have been spread. This choice was made in part because (wrt. subplot 2) the singular values (svals) correspond to rotated MADs, and because rms(umisf) seems too convoluted for interpretation.

plot_hovmoller(xx, tseq=None) ⚓︎

Plot Hovmöller diagram.

Parameters:

Name Type Description Default
xx ndarray

Plotted array

required
tseq [`tools.chronos.Chronology`][]

object with property dko. Defaults: None

None

plot_pause(interval) ⚓︎

Like plt.pause, but better.

Actually works in Jupyter notebooks, unlike plt.pause.

In regular mpl (interactive) backends: doesn't focus window. NB: doesn't create windows either. For that, use plt.pause or plt.show instead.

plot_rank_histogram(stats) ⚓︎

Plot rank histogram of ensemble.

Parameters:

Name Type Description Default
stats
required

set_ilim(ax, i, Min=None, Max=None) ⚓︎

Set bounds on axis i.

Parameters:

Name Type Description Default
ax axes
required
i int

1: x-axis; 2: y-axis; 3: z-axis

required
Min float

Lower bound limit. Defaults: None

None
Max float

Upper bound limit. Defaults: None

None

setup_wrapping(M, periodicity=None) ⚓︎

Make state indices representative for periodic system.

More accurately: Wrap the state indices and create a function that does the same for state vectors (or and ensemble thereof).

Parameters:

Name Type Description Default
M int

Length of the periodic domain

required
periodicity bool

The mode of the wrapping. "+1": the first element is appended after the last. "±05": adding the midpoint of the first and last elements. Default: "+1"

None

Returns:

Name Type Description
ii ndarray

indices of periodic domain

wrap func

transform non-periodic data into periodic data

stretch(a, b, factor=1, int_=False) ⚓︎

Stretch distance a-b by factor.

Parameters:

Name Type Description Default
a float

Lower bound of domain.

required
b float

Upper bound of domain.

required
factor float

Streching factor. Defaults: 1

1
int_ bool

If True, the domain bounds are integer. Defaults: False

False

Returns:

Name Type Description
a float

Lower bound of domain.

b float

Upper bound of domain.

xtrema(xx, axis=None) ⚓︎

Get minimum and maximum of a sequence.

Parameters:

Name Type Description Default
xx ndarray
required
axis int

Specific axis for min and max. Defaults: None

None

Returns:

Name Type Description
a float

min value

b float

max value