vipr_reflectometry.flow_models.plot_scripts package

Submodules

vipr_reflectometry.flow_models.plot_scripts.basic_corner_plot_script module

Standalone basic corner plot — run with: python plot_basic_corner_plot.py [-o output.svg]

Plots all posterior samples as a corner plot (no clustering overlay).

Data file: <script_stem>_data.npz with arrays:

samples — (n_samples, n_params) float param_names — (n_params,) str (object array)

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0, corner>=2.0.0

vipr_reflectometry.flow_models.plot_scripts.basic_corner_plot_script.find_data_file() Path
vipr_reflectometry.flow_models.plot_scripts.basic_corner_plot_script.load_data(npz_path: Path) tuple
vipr_reflectometry.flow_models.plot_scripts.basic_corner_plot_script.make_plot(title: str = 'Posterior Distribution - All Samples') Figure

Create a clean corner plot using the corner package.

vipr_reflectometry.flow_models.plot_scripts.centroid_curves_image_plot module

Standalone centroid curves plot — run with: python plot_centroid_forward_curves.py [-o output.svg]

Plots experimental reflectivity data together with predicted (dotted) and polished (solid) curves for each cluster mode on a log scale.

Data file: <script_stem>_data.csv with columns:

q_exp, R_exp, [dR_exp] q_mode_N, R_pred_mode_N, [R_pol_mode_N] (N = 1, 2, …)

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0

vipr_reflectometry.flow_models.plot_scripts.centroid_curves_image_plot.find_data_file() Path

Locate companion CSV: plot_<id>.py → <id>_data.csv

vipr_reflectometry.flow_models.plot_scripts.centroid_curves_image_plot.load_data(csv_path: Path) dict

Load CSV and return {col_name: [str_values]}.

vipr_reflectometry.flow_models.plot_scripts.centroid_curves_image_plot.make_plot(title: str = 'Centroid Reflectivity Curves') Figure

Create reflectivity curves plot for all cluster modes.

Reads the companion CSV from the script directory. Columns:

q_exp — experimental Q values R_exp — experimental reflectivity dR_exp — experimental errors (optional) q_mode_N — Q grid for mode N (N = 1, 2, …) R_pred_mode_N — predicted curve for mode N R_pol_mode_N — polished curve for mode N (optional)

vipr_reflectometry.flow_models.plot_scripts.cluster_centroids_plot module

Standalone plot — run with: python plot_cluster_centroids_summary.py [-o output.svg]

Grouped bar chart showing cluster centroid parameter values (predicted vs polished). Reads the companion CSV from ../diagrams/cluster_centroids_summary.csv.

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0

vipr_reflectometry.flow_models.plot_scripts.cluster_centroids_plot.load_data(csv_path: Path) dict[str, list]

Load centroid summary CSV. Returns {col_name: [values]}.

vipr_reflectometry.flow_models.plot_scripts.cluster_centroids_plot.make_plot(title: str = 'Cluster Centroid Parameters') Figure

Grouped bar chart: one group per physical parameter, one bar per cluster mode.

If polished columns (e.g. ‘Thickness_L1_polished’) are present, they are shown as hatched bars beside each predicted bar for direct comparison.

CSV column layout:

cluster_id — mode index (0-based) cluster_label — raw DBSCAN label cluster_size — number of samples <param> — centroid value for parameter <param> <param>_polished — polished value (optional)

vipr_reflectometry.flow_models.plot_scripts.cluster_curves_plot module

Standalone plot — run with: python plot_cluster_curves_interactive.py [-o output.svg]

Plots reflectivity curves for all cluster centroids from the cluster analysis. Reads the companion CSV from ../diagrams/cluster_curves_interactive.csv.

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0

vipr_reflectometry.flow_models.plot_scripts.cluster_curves_plot.load_data(csv_path: Path) dict[str, list[float]]

Load all columns from the curves CSV, skipping padded empty cells.

vipr_reflectometry.flow_models.plot_scripts.cluster_curves_plot.make_plot(title: str = 'Centroid Reflectivity Curves') Figure

Plot reflectivity curves for all cluster centroids.

Column layout expected in CSV (all optional except q_values):

q_values — model Q-grid (x-axis for predicted curves) experimental_q — experimental Q-grid (may differ) experimental_curve — experimental R values experimental_curve_error — experimental R error bars (optional) mode_0_curve_pred — Mode 1 predicted curve (on q_values grid) mode_0_curve_pol — Mode 1 polished curve (on mode_0_q_pol grid, optional) mode_0_q_pol — Q-grid for polished curve (optional) mode_1_curve_pred — Mode 2 predicted curve …

vipr_reflectometry.flow_models.plot_scripts.cluster_marginals_plot module

Standalone marginal distributions plot — run with: python plot_marginals_mode_N.py [-o output.svg]

Plots 1-D parameter histograms for a single cluster mode.

Data file: <script_stem>_data.npz with arrays:

samples — (n_samples_in_cluster, n_params) float param_names — (n_params,) str (object array) mode_index — scalar int (1-based display index) color_index — scalar int (tab10 index) centroid — (n_params,) float (optional) polished — (n_params,) float (optional)

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0

vipr_reflectometry.flow_models.plot_scripts.cluster_marginals_plot.find_data_file() Path
vipr_reflectometry.flow_models.plot_scripts.cluster_marginals_plot.load_data(npz_path: Path) dict
vipr_reflectometry.flow_models.plot_scripts.cluster_marginals_plot.make_plot(title: str = '') Figure

Create 1-D marginal histograms for a single cluster mode.

vipr_reflectometry.flow_models.plot_scripts.clustered_corner_plot_script module

Standalone clustered corner plot — run with: python plot_clustered_corner_plot.py [-o output.svg]

Reconstructs the corner plot with cluster-coloured 1-D histograms and 2-D contours from the exported NPZ data file.

Data file: <script_stem>_data.npz with arrays:

samples — (n_samples, n_params) float cluster_labels — (n_samples,) int param_names — (n_params,) str (object array) centroid_labels — (n_modes,) int (optional) centroids — (n_modes, n_params) float (optional) polished — (n_modes, n_params) float (optional, NaN if unavailable)

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0, scipy>=1.7.0

vipr_reflectometry.flow_models.plot_scripts.clustered_corner_plot_script.find_data_file() Path
vipr_reflectometry.flow_models.plot_scripts.clustered_corner_plot_script.load_data(npz_path: Path) dict

Return exported clustered-corner data including optional centroid overlays.

vipr_reflectometry.flow_models.plot_scripts.clustered_corner_plot_script.make_plot(title: str = 'Posterior Distribution - Cluster Modes') Figure

vipr_reflectometry.flow_models.plot_scripts.gmm_model_selection_plot module

Standalone GMM model selection plot — run with: python plot_gmm_model_selection.py [-o output.svg]

Plots BIC/AIC and Silhouette vs K curves to help identify the optimal number of Gaussian mixture components for cluster analysis.

Data file: <script_stem>_data.csv with columns:

K, bic, aic, silhouette

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0

vipr_reflectometry.flow_models.plot_scripts.gmm_model_selection_plot.find_data_file() Path
vipr_reflectometry.flow_models.plot_scripts.gmm_model_selection_plot.load_data(csv_path: Path) dict
vipr_reflectometry.flow_models.plot_scripts.gmm_model_selection_plot.make_plot(title: str = 'Model Selection: GMM') Figure

Plot BIC/AIC and Silhouette vs K.

vipr_reflectometry.flow_models.plot_scripts.hdbscan_sweep_plot module

Standalone HDBSCAN sweep plot — run with: python plot_hdbscan_sweep.py [-o output.svg]

Plots number of clusters and Silhouette score vs min_cluster_size to help select the optimal HDBSCAN hyperparameter.

Data file: <script_stem>_data.csv with columns:

min_cluster_size, n_clusters, silhouette

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0

vipr_reflectometry.flow_models.plot_scripts.hdbscan_sweep_plot.find_data_file() Path
vipr_reflectometry.flow_models.plot_scripts.hdbscan_sweep_plot.load_data(csv_path: Path) dict
vipr_reflectometry.flow_models.plot_scripts.hdbscan_sweep_plot.make_plot(title: str = 'Model Selection: HDBSCAN') Figure

Plot cluster count and Silhouette vs min_cluster_size.

vipr_reflectometry.flow_models.plot_scripts.parameter_boxplot_plot module

Standalone parameter box-plot — run with: python plot_parameter_boxplot.py [-o output.svg]

Shows the distribution of parameter values within each cluster mode as box plots.

Data file: <script_stem>_data.npz with arrays:

samples — (n_samples, n_params) float cluster_labels — (n_samples,) int param_names — (n_params,) str (object array)

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0

vipr_reflectometry.flow_models.plot_scripts.parameter_boxplot_plot.find_data_file() Path
vipr_reflectometry.flow_models.plot_scripts.parameter_boxplot_plot.load_data(npz_path: Path) tuple
vipr_reflectometry.flow_models.plot_scripts.parameter_boxplot_plot.make_plot(title: str = 'Parameter Uncertainty per Cluster Mode') Figure

Create box-plots showing parameter uncertainty per cluster.

vipr_reflectometry.flow_models.plot_scripts.silhouette_plot_script module

Standalone silhouette plot — run with: python plot_silhouette_plot.py [-o output.svg]

Visualises cluster quality using silhouette coefficients.

Data file: <script_stem>_data.npz with arrays:

samples — (n_samples, n_params) float cluster_labels — (n_samples,) int

No VIPR installation required. Dependencies: matplotlib>=3.5.0, numpy>=1.21.0, scikit-learn>=0.24.0

vipr_reflectometry.flow_models.plot_scripts.silhouette_plot_script.find_data_file() Path
vipr_reflectometry.flow_models.plot_scripts.silhouette_plot_script.load_data(npz_path: Path) tuple
vipr_reflectometry.flow_models.plot_scripts.silhouette_plot_script.make_plot(title: str = 'Silhouette Plot - Cluster Quality Assessment') Figure

Create silhouette plot from saved samples and cluster labels.

Module contents

Standalone plot scripts for flow model cluster analysis.