Scripts API Documentation

Main Scripts

Export Accelerator Timeline

This is an example script to generate static plots of the accelerator data via matplotlib. To run the script, make sure your environment has the requirements of requirements_export_charts.txt installed.

export_charts.plot(data: DataFrame, configuration: PlotConfiguration) Figure[source]

Generate interactive plots with matplotlib, based on the given configuration, which defines the columns to use, labels and the text positions.

Parameters:
  • data (pd.DataFrame) -- DataFrame containing the (modified) accelerator timeline data

  • configuration (PlotConfiguration) -- See utilities.plot_helper.PlotConfiguration

Returns:

Matplotlib figure

Return type:

Figure

Interactive Accelerator Timeline

This script allows you to interactively explore the accelerator data, either by running the script and viewing the plots in a browser, by running the script in interactive-mode e.g. in vscode or by checking the from this script generated gallery.

To run the script, make sure your environment has the requirements of requirements_interactive_charts.txt installed.

interactive_charts.plot(data: DataFrame, configuration: PlotConfiguration) Figure[source]

Generate interactive plots with plotly, based on the given configuration, which defines the columns to use and the text positions.

Parameters:
  • data (pd.DataFrame) -- DataFrame containing the (modified) accelerator timeline data

  • configuration (PlotConfiguration) -- See utilities.plot_helper.PlotConfiguration

Returns:

plotly figure

Return type:

go.Figure

Utilities

CSV Reader

Functionality to gather the data from the CSV file into an easy-to-use format: A pandas DataFrame. In addition, some manipulation on the data is done, so that all the required data for plotting is present in the frame.

utilities.csv_reader.import_collider_data() DataFrame[source]

Load the data from the CSV file and perform some additional data-filtering and calculations.

Returns:

The loaded data in form of a DataFrame.

Return type:

pd.DataFrame

Plot Helper

Helper functions that are common for both matplotlib and plotly. These help to define what to plot, to organize the data and to align the text in the plot.

class utilities.plot_helper.ParticleTypeMap(name: str, shorthand: str, latex: str, symbol: str, color: str)[source]
class utilities.plot_helper.PlotConfiguration(*args, **kwargs)[source]
utilities.plot_helper.assign_textposition(data: DataFrame) DataFrame[source]

Create two columns, which will tell the plot where the text should be placed.

Parameters:

data (pd.DataFrame) -- DataFrame containing a Name column.

Returns:

DataFrame with the new Columns.

Return type:

pd.DataFrame

utilities.plot_helper.check_all_types_accounted_for(data: DataFrame | None = None) None[source]

Helper function to check if all particle types in the list are accounted for and hence will be plotted.

Parameters:

data (pd.DataFrame) -- DataFrame containing the accelerator timeline data.

Sphinx Helper

Some functionality to make working with Sphinx easier.

utilities.sphinx_helper.get_gallery_dir() Path[source]

Get the gallery directory.

Returns:

Path to the gallery directory.

Return type:

Path

utilities.sphinx_helper.is_interactive() bool[source]

Check if we are running in interactive mode.

Returns:

True if in interactive mode.

Return type:

bool

utilities.sphinx_helper.is_sphinx_build() bool[source]

Check if we are running in sphinx build mode.

Returns:

True if in sphinx build mode.

Return type:

bool