roxieapi.output.plots module

Plot routines

class roxieapi.output.plots.RoxieGraphsPlotly(output_parser: RoxieOutputParser)[source]

Bases: object

Roxie Graph output A class for plotting Standard graph plots from a roxie output

plot_device_graph(graphPlot: GraphPlot, opt_step: int = 1, trans_step: int = 1, fig_size: Tuple[float, float] | None = None) Figure | None[source]

Plot a device graph :param graphPlot: The GraphPlot object from the RoxieOutputParser :param opt_step: Optimization step :param trans_step: Transient step :param fig_size: Size of the figure (in inch), defaults to None :return: a plotly graph_objs.Figure object, or None if Plot data is missing

static plot_forces(data: DataFrame, fig_size: Tuple[float, float] | None = None) Figure[source]

Plot The Forces on conductor (plot similar to roxie plot in pdf) :param data: The dataframe with the forces defined (from RoxieOutputParser) :param fig_size: Size of the figure in inches, defaults to None :return: the figure

static plot_graph(graphPlot: GraphPlot, data: Dict[int, DataFrame], fig_size: Tuple[float, float] | None = None) Figure | None[source]

Plot a graph :param graphPlot: The GraphPlot object from the RoxieOutputParser :param data: Corresponding data object from the ROxieOutputParser :param fig_size: Size of the figure (in inch), defaults to None :return: a plotly graph_objs.Figure object, or None if Plot data is missing

static plot_harmonics(coil: HarmonicCoil, fig_size: Tuple[float, float] | None = None) Figure[source]

Plot the Harmonics as a bar graph :param coil: The coil to plot the harmonics for :param fig_size: Size of figure, in inches, defaults to None :return: The figure

plot_optimization_graph(graphPlot: GraphPlot, fig_size: Tuple[float, float] | None = None) Figure | None[source]

Plot a device graph :param graphPlot: The GraphPlot object from the RoxieOutputParser :param fig_size: Size of the figure (in inch), defaults to None :return: a plotly graph_objs.Figure object, or None if Plot data is missing

plot_transient_graph(graphPlot: GraphPlot, opt_step: int = 1, fig_size: Tuple[float, float] | None = None) Figure | None[source]

Plot a device graph :param graphPlot: The GraphPlot object from the RoxieOutputParser :param opt_step: Optimization step :param fig_size: Size of the figure (in inch), defaults to None :return: a plotly graph_objs.Figure object, or None if Plot data is missing

class roxieapi.output.plots.RoxiePlotOutputs(output_file: str, input_file: str | None)[source]

Bases: object

Convenience class for plotting roxie outputs. Bundles all Required classes for plotting in one class:

Example usage:

```python output_file = “/path/to/roxie/output.xml” input_file = “/path/to/roxie/input.xml”

plot_outputs = RoxiePlotOutputs(output_file, input_file) ```

Access to the individual objects:

  • plot_outputs.output: RoxieOutputParser object

  • plot_outputs.input: RoxieInputBuilder object

  • plot_outputs.graphs: RoxieGraphsPlotly object

  • plot_outputs.plots2d: RoxiePlots2D object

  • plot_outputs.plots3d: RoxiePlots3D object

  • plot_outputs.tables: RoxiePrintTables object

Content is output using Ipython display functions, including Headers, plots and tables.

output_2dplots(opt_step: int = 1, trans_step: int = 1, fig_size=(8, 8), plots: List[int] | None = None) None[source]

Print all 2d plots :param opt_step: Optimization step number, defaults to 1 :param trans_step: Transient step number, defaults to 1 :param fig_size: Figure size in inches, defaults to (12,8) :param plots: List of plots to print, or None for all

output_3dplots(opt_step: int = 1, trans_step: int = 1, fig_size=(10, 8), plots: List[int] | None = None) None[source]

Print all 3d plots :param opt_step: Optimization step number, defaults to 1 :param trans_step: Transient step number, defaults to 1 :param fig_size: Figure size in inches, defaults to (12,8) :param plots: List of plots to print, or None for all

output_conductor_forces(opt_step: int = 1, trans_step: int = 1, fig_size=(12, 8)) None[source]

Print conductor forces for Time step :param opt_step: The Optimization step number :param trans_step: The transient step number :param fig_size: Size of the output figures in inches

output_design_variables(opt_step: int = 1) None[source]

Print design variables :param opt_step: The Optimization step number

output_device_graphs(opt_step: int = 1, trans_step: int = 1, fig_size=(12, 8), plots: List[int] | None = None) None[source]

Print all device graphs :param opt_step: Optimization step number, defaults to 1 :param trans_step: Transient step number, defaults to 1 :param fig_size: Figure size in inches, defaults to (12,8) :param plots: List of plots to print, or None for all

output_harmonic_coils(opt_step: int = 1, trans_step: int = 1, header_level: int = 1) None[source]

Print Harmonic coil results :param opt_step: The Optimization step number :param trans_step: The transient step number :param header_level: Header level for each harmonic coil

output_objective_results(opt_step: int = 1) None[source]

Print objective results :param opt_step: The Optimization step number

output_optimization_graphs(fig_size=(12, 8), plots: List[int] | None = None) None[source]

Print all optimization graphs :param fig_size: Figure size in inches, defaults to (12,8) :param plots: List of plots to print, or None for all

output_report(header_level: int = 1) None[source]

Output a full run report :param header_level: The level of header to start with (default: 1)

output_run_summary() None[source]

Generate a summary of the run

output_transient_graphs(opt_step: int = 1, fig_size=(12, 8), plots: List[int] | None = None) None[source]

Print all transient graphs :param opt_step: Optimization step number, defaults to 1 :param fig_size: Figure size in inches, defaults to (12,8) :param plots: List of plots to print, or None for all

class roxieapi.output.plots.RoxiePlots2D(output_parser: RoxieOutputParser)[source]

Bases: object

2D Plots for roxie (geometry + data)

class CBarInfo(pos: str = 'w', lbls: List[str] = <factory>, vmin: Optional[float] = None, vmax: Optional[float] = None, objs: List[matplotlib.colorizer._ScalarMappable] = <factory>)[source]

Bases: object

lbls: List[str]
objs: List[_ScalarMappable]
pos: str = 'w'
vmax: float | None = None
vmin: float | None = None
create_anim(pl: Plot2D, opt_step: int = 1, start_trans_step: int = 1, end_trans_step: int | None = None, anim_filename: str | Path = 'animation.gif', figsize=(8, 8), duration=500)[source]

Creates a GIF animation from pre-generated snapshots of a cross-section plot.

Parameters:
  • pl – The Plot2D object.

  • opt_step – Optimization step.

  • start_trans_step – Start transient step.

  • end_trans_step – End transient step.

  • figsize – Figure size.

  • gif_filename – Name of the output GIF file.

  • duration – Frame duration in milliseconds.

Returns:

Saves an animated GIF.

plot_conductor_forces(opt_step: int = 1, trans_step: int = 1, fig_size: Tuple[int, int] = (12, 8)) Figure | None[source]

Generates a set of 2D crosssection plots with Forces overlay (one plot per force) :param output_parser: The output parser :param opt_step: optimization step, defaults to 1 :param trans_step: transient step, defaults to 1 :param fig_size: figure size in inches, defaults to (12, 8) :return: the matplotlib figure object, or None if no conductor forces are available

plot_xs(pl: Plot2D, opt_step: int = 1, trans_step: int = 1, figsize=(8, 8), eddy_step: int | None = None) Figure[source]

Plot a 2D plot with the specified optimization step, transient step, and eddy step.

Parameters:
  • pl (Plot2D) – The 2D plot to generate

  • opt_step (int, optional) – Optimization step number, by default 1

  • trans_step (int, optional) – Transient step number, by default 1

  • figsize (tuple, optional) – Figure size in inches, by default (8, 8)

  • eddy_step (Optional[int], optional) – Eddy step number, by default None (uses the last eddy step)

Returns:

The generated figure

Return type:

matplotlib.figure.Figure

class roxieapi.output.plots.RoxiePlots3D(output_parser: RoxieOutputParser)[source]

Bases: object

create_brick_geometries(opt_step: int = 1) MultiBlock[source]
create_coil_geometries(opt_step: int = 1) MultiBlock[source]
create_coilblock_geometry(opt_step: int = 1) MultiBlock[source]
create_endspacer_geometries(opt_step: int = 1) MultiBlock[source]
create_iron_geometry(opt_step: int = 1) MultiBlock[source]
get_brick_geometry(pl: Plot3D, opt_step: int = 1, trans_step: int = 1) MultiBlock[source]
get_coil_geometry(pl: Plot3D, opt_step: int = 1, trans_step: int = 1) MultiBlock[source]
get_coilblock_geometry(pl: Plot3D, opt_step: int = 1, trans_step: int = 1) MultiBlock[source]
get_endspacer_geometry(pl: Plot3D, opt_step: int = 1, trans_step: int = 1) MultiBlock[source]
get_iron_geometry(pl: Plot3D, opt_step: int = 1, trans_step: int = 1) MultiBlock[source]
plot_3d(pl: Plot3D, opt_step: int = 1, trans_step: int = 1, fig_size=(10, 8)) Plotter[source]
class roxieapi.output.plots.RoxiePrintTables(ib: RoxieInputBuilder, op: RoxieOutputParser)[source]

Bases: object

Roxie table output for tabular data

get_design_variables(opt_step) DataFrame[source]

Return the design variables for opt step :param opt_step: The Optimization step number :return A DafaFrame containing design variable name and values

get_harmonic_coil(opt_step, trans_step, coil_nr) Tuple[DataFrame, DataFrame, DataFrame][source]

Return the harmonic coil table

Parameters:
  • opt_step – The Optimization step number

  • trans_step – The transient step number

  • coil_nr – Number of the harmonic coil

Returns:

A set of 3Pandas dataframes to plot: Coil information, Field information, Multipoles

get_objective_variables(opt_step) DataFrame[source]

Return the Objectives variables for opt step :param opt_step: The Optimization step number :return A DafaFrame containing objective variable name and values

print_design_variables(designVariables: Dict[int, DesignVariableResult], input_design: DataFrame | None) DataFrame[source]
print_harmonic_coil(coil: HarmonicCoil) Tuple[DataFrame, DataFrame, DataFrame][source]

Prints a harmonic coil output as Markdown :param coil: The Harmonic coil to print :return: A set of 3Pandas dataframes to plot: Coil information, Field information, Multipoles

print_objective_results(objectives: Dict[int, ObjectiveResult], input_objectives: DataFrame | None) DataFrame[source]