The Kuttruff Clustering Algorithm¶
Readers are referred to the section on clustering for a detailed description of the clustering algorithms.
Luna Command¶
./tpx3dump process -i /Users/Ciaran/atlassian-bitbucket-pipelines-runner/temp/e71169e4-520a-5b30-a5ab-ee8a44eb5fac/build/docs/source/_static/example_data.tpx3 -o /Users/Ciaran/atlassian-bitbucket-pipelines-runner/temp/e71169e4-520a-5b30-a5ab-ee8a44eb5fac/build/docs/source/_static/example_data.h5 --layout single --clustering-algorithm Kuttruff2024 --eps-t 170ns --eps-s 6 --kuttruff-buffer-size 15
Python Script¶
1import os, sys
2import h5py # ensure you have `pip install h5py`
3import pandas as pd # ensure you have `pip install pandas`
4from typing import *
5import matplotlib.pyplot as plt
6import seaborn as sns
7import warnings
8
9warnings.filterwarnings("ignore") # suppress warnings from plotting libraries.
10
11sns.set_context(context="talk")
12
13# add some paths to PYTHONPATH
14for directory in ["..", "."]:
15 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), directory)))
16
17# on our system "EXAMPLE_DATA_HDF5" refers to the absolute path
18# to a hdf5 file generated by luna. Replace with your own!
19from env_vars_for_docs_examples import EXAMPLE_DATA_HDF5, PLOTS_DIRECTORY
20
21# re-use functions from previous example
22from ex2_read_data_time_units import TimeUnit, load_clusters
23
24TOA_UNIT = TimeUnit.Nanoseconds
25
26from ex5_plot_cluster_2d_histogram import plot_2d_histogram_cluster_data
27
28
29
30if __name__ == "__main__":
31
32 fname = os.path.join(PLOTS_DIRECTORY, f"ex13_kuttruff_clustering_algorithm.png")
33
34 cluster_data: pd.DataFrame = load_clusters(EXAMPLE_DATA_HDF5, toa_unit=TOA_UNIT)
35
36 plot_2d_histogram_cluster_data(cluster_data=cluster_data, variable="ctot", fname=fname)
37
Script Output¶