Skip to content

Latest commit

 

History

History
97 lines (68 loc) · 5.14 KB

API.md

File metadata and controls

97 lines (68 loc) · 5.14 KB

API

class exaplot.RunParam(default_or_type, /, display=None)

A specialized class for defining a run parameter. This object is used within the init function to define a run parameter with additional characteristics, such as how it is displayed.

default_or_type can be either a default value or the value type. If a default value is given, the type will be inferred (equivalent to if a RunParam weren't used at all). If a value type is given, the GUI will not initialize the corresponding run argument.

The display argument is used as the string to display this parameter as in the GUI.


exaplot.init(plots, /, **params)

Initializes the plots and run parameters.

plots can be either a specific plot arrangement or simply the number of plots (using the default arrangement). If a specific plot arrangement is desired, it is recommended to use the plot editor to generate the plot arrangement. The default is a single plot.

The params keyword arguments specifies the run parameters. Each values may be either a value of type str, int, float, or RunParam.


exaplot.datafile(*, enable=True, path=Path("data.hdf5"), prompt=False)

Configures the data file settings. Scripts that omit this function entirely will have their data file disabled by default.

enable enables or disables writing to the data file.

path specifies the path of the data file. This may be a "hard-coded" path or it may be generated dynamically at runtime via a callback function. The callback function must take no arguments and return a PathLike value. Note that if the same file is used for subsequent runs, the data file will be written over.

If the prompt flag is set, the GUI will prompt the user with the file path before each run to allow any changes (or simply as a means to explicitly confirm the file path).


exaplot.stop()

Used to check if a stop signal has been received. If the stop button is clicked during a run, this will return True, otherwise this will return False.


exaplot.breakpoint()

This is an alternative method for checking if the stop signal has been received. This function will raise a special BaseException-derived exception if a stop has been issued (with the intention that the exception will terminate the run). This is typically used as a convenience where the stop function would be insufficient (e.g. in nested loops).


exaplot.msg(message, /, append=False)

Sets the message in the script message box.

If the append flag is set, messages will be appended to the existing message box contents.


exaplot.plot[plot_id](...)

The plot variable acts as a container for the active plots (or more specifically, a container of the plot handles). A specific plot is accessed by using its plot ID as the index (the ID of each plot can be found within the Plot Editor).

Data is plotted (and stored to the data file, if enabled) by calling the plot handle directly:

exaplot.plot[1](0, 1)

We can also assign a variable to a plot's handle:

plot_1 = exaplot.plot[1]
plot_1(0, 1)

The plot handle's signature/overload depends on the plot's active plot type. Each overload has a write keyword argument that can be used to omit the data from being stored in the data file (if the data file is enabled).

To clear a plot of any type, call the plot with no arguments:

# clear the plot
exaplot.plot[1]()

2-D plot:

plot[...](x, y, *, write=True)

Both x and y can be either single values or a sequence of values (sequences must be the same length).

Color map:

plot[...](col, row, value, *, write=True)
plot[...](row, values, *, write=True)
plot[...](frame, *, write=True)

The colormap overloads allow a user to plot a cell at a time, a row of cells, or the entire frame (all cells).

The col and row arguments are int types and increase from left to right and down to up, respectively (in other words, the grid represents the first quadrant of a two-dimensional Cartesian coordinate system).

The value argument can be any value of type Real (e.g. integers or floating point numbers). Similarly, values is a sequence of Real-type values, and frame is a sequence of sequences of Real-type values.