PlotDimsMixin

class PlasmaCalcs.plotting.plot_tools.plot_dims.PlotDimsMixin

Bases: object

adds methods for inferring plot dims, and properties for plot dims.

subclasses should define plot_dims_attrs = dict(
x = name of attr which stores the un-inferred dim for plot x axis
y = name of attr which stores the un-inferred dim for plot y axis
t = name of attr which stores the un-inferred dim for plot t axis (i.e. frames in a movie)
dims = name of attr which stores the list of all possible dims, from which other dims might be inferred.
t_necessary_if = name of attr which stores the condition under which t does not need to be inferred.
). If not all of these are provided, some (or all) InferrablePlotDimsMixin methods will crash.
defines properties:
x_plot_dim, y_plot_dim, t_plot_dim:
infer the related dim (x,y,t, respectively),
using values at plot_dims_attrs, and DEFAULTS.PLOT.DIMS_INFER.
setting x_plot_dim=value also sets self.{plot_dims_attrs[‘x’]}=value, etc.
xy_plot_dims:
(x_plot_dim, y_plot_dim); setting value also sets self.x_plot_dim and y_plot_dim.
xyt_plot_dims:
similar to xy_plot_dims, but for (x_plot_dim, y_plot_dim, t_plot_dim).
For an example of using this Mixin, see XarrayImage.

Methods

infer_xyt_dims(*[, xy_fail_ok, t_fail_ok])

infers (x,y,t) dims from self.x, y, dim.

_get_plot_dims_attr_value(x[, default])

get value of self.{plot_dims_attrs[x]}, where x = 'x', 'y', 't', 'dims', or 't_necessary_if'.

_set_plot_dims_attr_value(x, value)

set value of self.{plot_dims_attrs[x]}, where x = 'x', 'y', 't', 'dims', or 't_necessary_if'.

Attributes

t_plot_dim

the dimension which is actually used to index the movie's frames (i.e. the "time axis").

x_plot_dim

the dimension which is actually used to index the plot's x axis.

xy_plot_dims

(self.x_plot_dim, self.y_plot_dim)

xyt_plot_dims

(self.x_plot_dim, self.y_plot_dim, self.t_plot_dim)

y_plot_dim

the dimension which is actually used to index the plot's y axis.

_get_plot_dims_attr_value(x, default=NO_VALUE)

get value of self.{plot_dims_attrs[x]}, where x = ‘x’, ‘y’, ‘t’, ‘dims’, or ‘t_necessary_if’.

_set_plot_dims_attr_value(x, value)

set value of self.{plot_dims_attrs[x]}, where x = ‘x’, ‘y’, ‘t’, ‘dims’, or ‘t_necessary_if’.

infer_xyt_dims(*, xy_fail_ok=False, t_fail_ok=True)

infers (x,y,t) dims from self.x, y, dim.

xy_fail_ok, t_fail_ok: bool
controls behavior when failing to infer a dim:
True –> return None for that dim
False –> raise PlottingAmbiguityError
t_fail_ok corresponds to t; xy_fail_ok corresponds to x,y.
see also: DEFAULTS.PLOT.DIMS_INFER, plotting.infer_xyt_dims, infer_xy_dims, infer_movie_dim
property t_plot_dim

the dimension which is actually used to index the movie’s frames (i.e. the “time axis”).

setting self.t_plot_dim=value also sets self.{plot_dims_attrs[‘t’]}=value.
getting self.t_plot_dim will get self.{plot_dims_attrs[‘t’]} if it is not None;
otherwise, infer from self.{plot_dims_attrs[‘dims’]}, self.{plot_dims_attrs[‘x’]}, and self.{plot_dims_attrs[‘y’]}
if self.{plot_dims_attrs[‘t_necessary_if’]}(), result might be None.
property x_plot_dim

the dimension which is actually used to index the plot’s x axis.

setting self.x_plot_dim=value also sets self.{plot_dims_attrs[‘x’]}=value.
getting self.x_plot_dim will get self.{plot_dims_attrs[‘x’]} if it is not None;
otherwise, infer from self.{plot_dims_attrs[‘dims’]}, self.{plot_dims_attrs[‘t’]}, and self.{plot_dims_attrs[‘y’]}.
property xy_plot_dims

(self.x_plot_dim, self.y_plot_dim)

property xyt_plot_dims

(self.x_plot_dim, self.y_plot_dim, self.t_plot_dim)

property y_plot_dim

the dimension which is actually used to index the plot’s y axis.

setting self.y_plot_dim=value also sets self.{plot_dims_attrs[‘y’]}=value.
getting self.y_plot_dim will get self.{plot_dims_attrs[‘y’]} if it is not None;
otherwise, infer from self.{plot_dims_attrs[‘dims’]}, self.{plot_dims_attrs[‘t’]}, and self.{plot_dims_attrs[‘x’]}.