labcore.analysis.hvplotting#
HoloViews-based plotting for labstack. Contains a set of classes and functions that can be used to plot labstack-style data.
- Important Classes:
- Nodes:
- Node: a base class for all nodes. Nodes are the basic blocks we use for
processing data. They can be chained together to form a pipeline.
LoaderNode: a node that loads and preprocesses data.
ReduxNode: a node that reduces data dimensionality (e.g. by averaging).
ValuePlot: plots data values.
ComplexHist: plots histograms of complex data (‘IQ readout histograms’).
- Widgets:
XYSelect: a widget for selecting x and y axes.
#TODO:
When fitting real and imaginary data, the color of the dot and line between data crosses. For example if the imaginary line is red with dots red, after adding a fit to the real data, the dots of imaginary will remain red, but the lines will be orange and the dots of the fit will orange but the lines red
Program refuses to open if it cannot find the config file.
Program refuses to open if it cannot find data properly formatted. This might be ok but a nice error message should appear.
Module Attributes
Type alias for valid data. |
|
Type alias for displaying raw data. |
Functions
|
|
|
|
|
|
|
Classes
|
|
|
|
|
Node base class. |
|
PlotNode, Node subclass |
|
|
|
|
|
- class labcore.analysis.hvplotting.ComplexHist(*args, **kwargs)[source]#
Bases:
PlotNode- fit_axis_options()[source]#
Returns a list of the different axes you can make a fit for in this node.
Should be overridden by subclasses to return the appropriate object.
- get_plot()[source]#
Returns the plot as a holoviews object
Used for saving the plot as html or png.
Can/Should be overridden by subclasses to return the appropriate object.
- name = 'ComplexHist'#
- labcore.analysis.hvplotting.Data#
Type alias for valid data. Can be either a pandas DataFrame or an xarray Dataset.
alias of
Dataset|DataFrame
- labcore.analysis.hvplotting.DataDisplay#
Type alias for displaying raw data.
- class labcore.analysis.hvplotting.MagnitudePhasePlot(*args, **kwargs)[source]#
Bases:
PlotNode- fit_axis_options()[source]#
Returns a list of the different axes you can make a fit for in this node.
Should be overridden by subclasses to return the appropriate object.
- name = 'MagnitudePhasePlot'#
- class labcore.analysis.hvplotting.Node(path=None, data_in: Dataset | DataFrame | None = None, *args: Any, **kwargs: Any)[source]#
Bases:
ViewerNode base class.
A simple wrapper class that we use to standardize the way we process data. Aim: whenever input data is set/updated,
Node.processis called (in the base class it simply sets output equal to input). User-defined nodes may watchdata_inanddata_outto update UI or anything else. Pipelines are formed by appending nodes to each other usingNode.append.Nodes with graphs must implement a
get_plot()function that returns a holoviews graph object in order for that graph to be able to be saved as either an html or png file.Params#
- data_in
input data. Must be either a pandas DataFrame or an xarray Dataset.
- data_out
processed output data. Must be either a pandas DataFrame or an xarray Dataset.
- units_in
units of input data. Must be a dictionary with keys corresponding to dimensions, and values corresponding to units.
- units_out
units of output data. Must be a dictionary with keys corresponding to dimensions, and values corresponding to units.
- meta_in
any input metadata. Arbitrary keys/value.
- meta_out
any output metadata. Arbitrary keys/value.
- static complex_dependents(data: Dataset | DataFrame | None) dict[str, dict[str, str]][source]#
Returns a dictionary of complex dependents and their real/imaginary parts.
Requires that complex data has already been split.
- Parameters:
data – input data.
- Returns:
“dependent”: {“real”: “dependent_Re”, “imag”: “dependent_Im”}} dependent_Re and dependent_Im are the dimensions actually present in the data.
- Return type:
dictionary of the form
- static data_dims(data: Dataset | DataFrame | None) tuple[list[str], list[str]][source]#
Returns the dimensions of the data.
Format: (independents, dependents); both as lists of strings.
- Raises:
NotImplementedError – if data is not a pandas DataFrame or an xarray Dataset.
- data_in = None#
- data_in_view() DataFrame | Dataset | str | None[source]#
Updating view of input data (as table; as provided by the data type).
Updates on change of
data_in.
- data_out = None#
- data_out_view() DataFrame | Dataset | str | None[source]#
Updating view of output data (as table; as provided by the data type).
Updates on change of
data_out.
- dim_label(dim: str, which: str = 'out') str[source]#
Generate dimension label for use in plots.
- Parameters:
dim – dimension name.
which – Either “in” or “out”, depending on whether we want the input or output data of the Node. Default is “out”.
- Return type:
dimension label, including units if available.
- dim_labels(which: str = 'out') dict[str, str][source]#
Generate dimension labels for use in plots.
Generates all dimension labels for the data. See
Node.dim_labelfor more information.
- static mean(data: Dataset | DataFrame, *dims: str) Dataset | DataFrame[source]#
Takes the mean of data along the given dimensions.
- Parameters:
data – input data.
*dims – dimensions to take the mean along
- Return type:
data after taking the mean
- Raises:
NotImplementedError – if data is not a pandas DataFrame or an xarray Dataset.
- meta_in = {}#
- meta_out = {}#
- name = 'Node'#
- plot() Viewable[source]#
A reactive panel object that allows selecting a plot type, and shows the plot.
Updates on change of
data_out.
- plot_obj() Node | None[source]#
The actual plot object.
Updates on change of
data_outor the selection of the plot value.- Return type:
A dedicated plotting node.
- process() None[source]#
Process data.
By default, simply sets
data_outequal todata_in.Can/Should be overridden by subclasses to do more complicated things.
- static render_data(data: Dataset | DataFrame | None) DataFrame | Dataset | str | None[source]#
Shows data as renderable object.
- Raises:
NotImplementedError – if data is not a pandas DataFrame or an xarray Dataset.
- static split_complex(data: Dataset | DataFrame) Dataset | DataFrame[source]#
Split complex dependents into real and imaginary parts.
TODO: should update units as well
- Parameters:
data – input data.
- Return type:
data with complex dependents split into real and imaginary parts.
- Raises:
NotImplementedError – if data is not a pandas DataFrame or an xarray Dataset.
- units_in = {}#
- units_out = {}#
- class labcore.analysis.hvplotting.PlotNode(path=None, *args, **kwargs)[source]#
Bases:
NodePlotNode, Node subclass
A superclass of all nodes that make plots of some sort. Mostly deals with define/creating fits for whatever graph subnode is instantiated.
- FITS = None#
- fit_axis_options() list[source]#
Returns a list of the different axes you can make a fit for in this node.
Should be overridden by subclasses to return the appropriate object.
- get_arguments()[source]#
Gets argument values for the currently selected fit and fit axis. Pulls data from the json if one exists, otherwise runs fit.guess and takes those values.
- get_plot()[source]#
Returns the plot as a holoviews object
Used for saving the plot as html or png.
Can/Should be overridden by subclasses to return the appropriate object.
- get_values(axis: str)[source]#
Gets a dictionary of values from the result of the FitResult’s params_to_dict() function.
- name = 'PlotNode'#
- plot_panel()[source]#
Creates and returns a panel with the class’s plot
Should be overridden by subclasses to return the desired plot.
- process()[source]#
Make a copy of the data so that changes (added fits) don’t carry to other graphs/other analysis. Add saved arguments for all fits/axes.
- refresh_graph = None#
- reguess_fit(event)[source]#
Resets the current args to the results of the Fit.guess() function for the current fit class.
- set_fit_box_helper(new_box: bool, fit_func_name: str, fitted: bool = False)[source]#
Removes and/or creates a fit box. If new_box == True this will (re)create the fit box.
- class labcore.analysis.hvplotting.ReduxNode(*args, **kwargs)[source]#
Bases:
Node- OPTS = ['None', 'Mean']#
- coordinates = []#
- name = 'ReduxNode'#
- operations = []#
- class labcore.analysis.hvplotting.ValuePlot(*args, **kwargs)[source]#
Bases:
PlotNode- fit_axis_options()[source]#
Returns a list of the different axes you can make a fit for in this node.
Should be overridden by subclasses to return the appropriate object.
- name = 'ValuePlot'#