Topological Material Analysis 0.5
Analyse the structures of materials using tools from TDA
Loading...
Searching...
No Matches
toma_functions Namespace Reference

Functions

 check_params ()
 Check the parameters for the computation.
 read_configuration (str configuration_file, str configuration)
 import a specified structure from a configuration file
 read_computation_settings (str settings_file, settings_name)
 import a specified settings from a file
 load_configuration_settings ()
 Load the configuration settings.
 load_computation_settings ()
 Load the computation settings.
 write_dgm_csv (dgm, file_path, plot_name="")
 Save a digram as a csv file, with the option to save a plot as well.
 save_plots ()
 Save plots to a directory.
 save_dgms_as_csv ()
 Save the persistence diagrams as csv files.
 read_sample (str structure_file, str configuration)
 import a specified sample range from a configuration file
 read_oineus_settings (str structure_file, str setting_name)
 import settings for kernel/image/cokernel
 sample_at (str file_path, str format, sample_index, int repeat_x, int repeat_y, int repeat_z, atom_list, radius_list)
 Sample a structure at a particular time, with cell repetitions.
 sample_all_diffusion (str file_path, str format, int sample_step=1)
 Sample all the diffusion paths from a given file.
 weighted_alpha_diode (points)
 Use diode to fill the weighted alpha shapes.
 convert_simps_to_oineus (list simplices)
 Diode is set to create simplices for dionysus, so we need to convert them to the correct type for oineus.
 oineus_compare (x, y)
 Comparison to compare list of simplicies to get them in the order for oineus.
 sub_complex (pandas.DataFrame points, float z_upper, float z_lower)
 Given the points, and the upper and lower thresholds in the 'z'-component.
 oineus_filtration (pandas.DataFrame points, oineus.ReductionParams params)
 Given a set of points, compute the oineus.filtration of the alpha complex.
 oineus_pair (pandas.DataFrame points, list sub)
 Given a set of points, and the points that are in the subset L, construct the complexes and map between them.
 oineus_process (pandas.DataFrame points, oineus.ReductionParams params)
 Given some points with weights, and the number of threads to use, obtain the persistent homology of the weighted alpha complex of these points, using oineus.
 oineus_kernel_image_cokernel (pandas.DataFrame points, oineus.ReductionParams params, float upper_threshold, float lower_threshold)
 Given points, and parameters for oineus, calculate the kernel/image/cokernel persistence as desired.
 calculate_APF (dgm)
 Calcualte the APF from a diagram.
 compute ()
 test ()
 define various functions needed for later
 plot_APF (numpy.array APF, str name)
 Plot an accumulated persistence function.
 plot_APFs (list APFs, list APF_names, str fig_name)
 Plot a set accumulated persistence function, with automatic colour differentiation.
 plot_PD (dgm, str name)
 Plot a persistence diagram, with a specific colour.
 plot_PDs (dgms, str name)
 Plot several persistence diagrams, with automatic colour choices.
 plot_kernel_image_cokernel_PD (kicr, int d, bool codomain, bool kernel, bool image, bool cokernel, str name)
 Plot kernel, image, cokernel on same figure.
 generate_plots ()
 Generate plots for a single configuration.
 get_representative_loops (pandas.DataFrame dgm, R, filt)
 Get representative of each homology class in dimension 1.
 get_0_and_1_cycles (loop, filt)
 Get the vertices and edges of a loop.
 loop_composition (verts, filt, points, atom_types)
 Get the composition of a given representative.
 generate_visulisation_df (pandas.DataFrame dgm, R, filt, points, atom_types)
 generate the pandas.DataFrame containing the information about the points so we can display it
 get_neighbour_cells (pandas.DataFrame points, list cycle_vertices, filt)
 Get the neighbouring cells of a given cycle.
 generate_display (pandas.DataFrame points, pandas.DataFrame dgm, int id, filt, neighbours=False)
 Display a representative of a cycle.

Function Documentation

◆ calculate_APF()

toma_functions.calculate_APF ( dgm)

Calcualte the APF from a diagram.

Parameters
dgmthe diargam you want to calculate the APF for
Returns
APF the APF as a list of coordiantes

◆ check_params()

toma_functions.check_params ( )

Check the parameters for the computation.

Check the parameters for the computation

This function checks the parameters for the computation and loads them into the session state.

◆ compute()

toma_functions.compute ( )

◆ convert_simps_to_oineus()

toma_functions.convert_simps_to_oineus ( list simplices)

Diode is set to create simplices for dionysus, so we need to convert them to the correct type for oineus.

Parameters
simplicesa list of simplices from diode
Returns
oin_simps a list of oineus simplices

◆ generate_display()

toma_functions.generate_display ( pandas.DataFrame points,
pandas.DataFrame dgm,
int id,
filt,
neighbours = False )

Display a representative of a cycle.

Parameters
pointspandas.DataFrame of the atoms
dgmpandas.DataFrame of the representatives of cycles
idint corresponding to the id of the cycle you want to visualise
Returns
fig plotly.express figure displaying the ring

◆ generate_plots()

toma_functions.generate_plots ( )

Generate plots for a single configuration.

Generate plots for a single configuration

This function generates persistence diagrams and APF plots for a single configuration. It creates empty lists to store the plots, then populates them based on enabled options.

The following plots can be generated:

  • Persistence diagrams in dimensions 0,1,2 if enabled via pd0, pd1, pd2 flags
  • Kernel/image/cokernel persistence diagrams if those computations are enabled
  • APF plots in dimensions 0,1,2 if enabled via apf0, apf1, apf2 flags
  • Kernel/image/cokernel APF plots if those computations are enabled

The plots are stored in st.session_state for later display.

Note
Requires that persistent homology has already been computed and stored in session state

◆ generate_visulisation_df()

toma_functions.generate_visulisation_df ( pandas.DataFrame dgm,
R,
filt,
points,
atom_types )

generate the pandas.DataFrame containing the information about the points so we can display it

Parameters
dgmpandas.DataFrame of the diagram, with columns birth, death, birth simplex, death simplex, cycle rep

◆ get_0_and_1_cycles()

toma_functions.get_0_and_1_cycles ( loop,
filt )

Get the vertices and edges of a loop.

Parameters
looplist containing the ids of the edges in the loop
filtoineus filtration
Returns
verts, edges lists of vertices and edges in the loop

◆ get_neighbour_cells()

toma_functions.get_neighbour_cells ( pandas.DataFrame points,
list cycle_vertices,
filt )

Get the neighbouring cells of a given cycle.

Parameters
pointspandas.DataFrame of the points (atoms) in the structure
cycle_verticeslist of the vertices in the cycle
filtoineus filtration
Returns
neighbour_0_cells, neighbour_1_cells, neighbour_2_cells lists of neighbouring 0, 1 and 2-cells

◆ get_representative_loops()

toma_functions.get_representative_loops ( pandas.DataFrame dgm,
R,
filt )

Get representative of each homology class in dimension 1.

Parameters
dgmpandas.DataFrame containing the diagram and the birth and death simplex id
filtoineus filtration
Returns
dgm pandas.DataFrame with new column cycle rep

◆ load_computation_settings()

toma_functions.load_computation_settings ( )

Load the computation settings.

Load computation settings from the session state

This function reads computation settings from st.session_state and loads them into the session state. It uses read_computation_settings() to parse the settings file and extract:

  • n_threads: Number of threads for Oineus to use
  • save_plots: Whether to save plots
  • kernel: Whether to compute kernel persistence
  • image: Whether to compute image persistence
  • cokernel: Whether to compute cokernel persistence
  • thickness: Thickness settings

◆ load_configuration_settings()

toma_functions.load_configuration_settings ( )

Load the configuration settings.

Load configuration settings from the session state

This function reads configuration settings from st.session_state and loads them into the session state. It uses read_configuration() to parse the config file and extract:

  • atoms: ASE Atoms object containing atomic positions and types
  • radii: Dictionary mapping atom types to their radii
  • repeat_x/y/z: Number of times to repeat the cell in each direction

The settings are read from:

  • st.session_state["config_file"]: Path to configuration file
  • st.session_state["config_name"]: Name of configuration section to use

The parsed settings are stored back in st.session_state as:

  • st.session_state.atoms
  • st.session_state.radii
  • st.session_state.repeat_x/y/z

◆ loop_composition()

toma_functions.loop_composition ( verts,
filt,
points,
atom_types )

Get the composition of a given representative.

Parameters
looplist containing the ids of the edges in the loop
pointspandas.DataFrame of the points (atoms) in the structure
atom_typeslist of the atom types we are considering (restricting to)
Returns
comp dictionary listing the number of atoms of each type in the loop

◆ oineus_compare()

toma_functions.oineus_compare ( x,
y )

Comparison to compare list of simplicies to get them in the order for oineus.

Parameters
xsimplex to compare
ysimplex to compare
Returns
-1 if x<y, 1 otherwise

◆ oineus_filtration()

toma_functions.oineus_filtration ( pandas.DataFrame points,
oineus.ReductionParams params )

Given a set of points, compute the oineus.filtration of the alpha complex.

Parameters
pointspandas.DataFrame containing points and their weights
paramsoineus.ReductionParams which contains the settings for oineus
Returns
K oineus.filtration

◆ oineus_kernel_image_cokernel()

toma_functions.oineus_kernel_image_cokernel ( pandas.DataFrame points,
oineus.ReductionParams params,
float upper_threshold,
float lower_threshold )

Given points, and parameters for oineus, calculate the kernel/image/cokernel persistence as desired.

Parameters
pointspandas.DataFrame of the points, with columns 'x','y','z','w' corresponding to the coordinates and weights respectively
kernelboolean parameter to set if kernel persistence is calculated
imageboolean parameter to set if image persistence is calculated
cokernelboolean parameter to set if cokernel persistence is calculated
n_threadsnumber of threads to use in oineus
upper_thresholdfloat, z-coordinate above which points are in the subcomplex
lower_thresholdfloat z-coordinate below which points are in the subcomplex
Returns
kicr oineus object which contains the kernel, image, cokernel persistence diagrams as required, can also calculate ones that weren't initially specificed

◆ oineus_pair()

toma_functions.oineus_pair ( pandas.DataFrame points,
list sub )

Given a set of points, and the points that are in the subset L, construct the complexes and map between them.

The subcomplex L will consists of all simplices whose vertex are in the subset.

Parameters
pointspandas.DataFrame containing the points and their weights
suba list containing the indices of the points on which we construct the subcomplex
Returns
K list of simplices for the entire complex, as needed by oineus
L list of simplices for the subcomplex, as needed by oineus
L_to_K list which tells you how to map the simplices in L to the simplices in K

◆ oineus_process()

toma_functions.oineus_process ( pandas.DataFrame points,
oineus.ReductionParams params )

Given some points with weights, and the number of threads to use, obtain the persistent homology of the weighted alpha complex of these points, using oineus.

Parameters
pointspandas.DataFrame of the points, with colums 'x','y','z','w'
paramsoineus.ReudctionParams
Returns
dgm_1 pandas.DataFrame of the indexed dimension 1 diagram
dgm_2 pandas.DataFrame of the indexed dimension 2 diagram

◆ plot_APF()

toma_functions.plot_APF ( numpy.array APF,
str name )

Plot an accumulated persistence function.

Parameters
APF- numpy.array with 2 columns of coordinates which define the APF
name- title for the plot
Returns
a plotly.express figure

◆ plot_APFs()

toma_functions.plot_APFs ( list APFs,
list APF_names,
str fig_name )

Plot a set accumulated persistence function, with automatic colour differentiation.

Parameters
APFs- accumlated persistence functions to plot
Returns
a matplotlib figure

◆ plot_kernel_image_cokernel_PD()

toma_functions.plot_kernel_image_cokernel_PD ( kicr,
int d,
bool codomain,
bool kernel,
bool image,
bool cokernel,
str name )

Plot kernel, image, cokernel on same figure.

Parameters
kicroineus::KerImCokReduced
dthe dimension to extract (either 1 or 2)
kernelbool to plot kernel
imagebool to plot image
cokernelbool to plot cokernel
Returns
figu figure with the chosen PD diagrams

◆ plot_PD()

toma_functions.plot_PD ( dgm,
str name )

Plot a persistence diagram, with a specific colour.

Points at infinity are plotted at a height of 1.1 times the last finite point to die.

Parameters
dgm- pandas.DataFrame of the diagram
name- name to use as title of the plot
Returns
a plotly.express figure

◆ plot_PDs()

toma_functions.plot_PDs ( dgms,
str name )

Plot several persistence diagrams, with automatic colour choices.

Points at infinity are plotted at a height of 1.1 times the last finite point to die.

Parameters
dgms- list of diagrams
name- title to use for the plot

@results a plotly.express figure

◆ read_computation_settings()

toma_functions.read_computation_settings ( str settings_file,
settings_name )

import a specified settings from a file

Parameters
settings_filepath to the file to use for configurations
settings_namename of the structure to use
Returns
n_threads, save_plots, kernel, image, cokernel, thickness the number of threads for Oineus to use, wether plots should be saved, compute kernel persistence, compute image persistence, compute cokernel persistence, thickness settings

◆ read_configuration()

toma_functions.read_configuration ( str configuration_file,
str configuration )

import a specified structure from a configuration file

Parameters
configuration_filepath to the file to use for configurations
configurationname of the structure to use
Returns
atoms, radii, repeat_x, repeat_y, repeat_z the atom symbols, radii to use for the atoms, repetition in x-axis, repetition in y-axis, repetition in z-axis

◆ read_oineus_settings()

toma_functions.read_oineus_settings ( str structure_file,
str setting_name )

import settings for kernel/image/cokernel

Parameters
file_pathpath to the ini file containing the settings
settings_namename of the settings to use
Returns
params oineus.ReductionParams with the settings to use

◆ read_sample()

toma_functions.read_sample ( str structure_file,
str configuration )

import a specified sample range from a configuration file

Parameters
file_pathpath to the file to use for configurations
sample_rangename of the structure to use
Returns
sample_start, sample_end, sample_step first sample, last sample, step between each one

◆ sample_all_diffusion()

toma_functions.sample_all_diffusion ( str file_path,
str format,
int sample_step = 1 )

Sample all the diffusion paths from a given file.

Parameters
file_path: str, path to the file to use for configurations
format: str, format of the file
backbone_list: list, list of backbone atoms to use
flow_list: list, list of flow atoms to use

◆ sample_at()

toma_functions.sample_at ( str file_path,
str format,
sample_index,
int repeat_x,
int repeat_y,
int repeat_z,
atom_list,
radius_list )

Sample a structure at a particular time, with cell repetitions.

Parameters
atomsinitial configuration
sample_indextime to sample at
repeat_xrepetition in x dir
repeat_yrepetition in y dir
repeat_zrepetition in z dir @parm atom_list list of atoms in the config
radius_listlist of radii to use for the atoms
Returns
points data frame of the points including the repetitions with columns 'Atom', 'x', 'y', 'z', 'w'

◆ save_dgms_as_csv()

toma_functions.save_dgms_as_csv ( )

Save the persistence diagrams as csv files.

Save the persistence diagrams as csv files, reading the file path from the session state.

◆ save_plots()

toma_functions.save_plots ( )

Save plots to a directory.

Save plots to a directory

This function saves plots to a specified directory. It uses the following from st.session_state:

  • st.session_state.file_path: Path to the file containing the data
  • st.session_state.sample_indices: Indices of samples to process
  • st.session_state.params: Computation settings
  • st.session_state.kicr_params: KICRcomputation settings

◆ sub_complex()

toma_functions.sub_complex ( pandas.DataFrame points,
float z_upper,
float z_lower )

Given the points, and the upper and lower thresholds in the 'z'-component.

Parameters
pointspandas.DataFrame containing of the points.
z_upperfloat giving the upper threshold, any point above this is in the subcomplex
z_lowerfloat giving the lower threshold, any point below this is in the subcomplex
Returns
sub_comp list containing the indices of the points on which we build the subcomplex

◆ test()

toma_functions.test ( )

define various functions needed for later

◆ weighted_alpha_diode()

toma_functions.weighted_alpha_diode ( points)

Use diode to fill the weighted alpha shapes.

Parameters
pointspandas.DataFrame with columns 'x', 'y', 'z' for coordinates, and column 'w' with the weights.
Returns
weighted alpha shape from diode.

◆ write_dgm_csv()

toma_functions.write_dgm_csv ( dgm,
file_path,
plot_name = "" )

Save a digram as a csv file, with the option to save a plot as well.

Parameters
dgmthe diagram to be saved, and plotted
dirdirectory in which to save the files
namename of the structure
save_plotsave the plots as well