cohesivm.analysis
This Module contains the Analysis Abstract Base Class and the implemented analysis classes
(standalone modules) which follow this ABC. The main responsibility is to quickly have access to analysis results
of measurement data.
- result_buffer(func: Callable) Callable[source]
Decorator for members of the
Analysis.functionswhich enables the function to store the results in theAnalysisobject. If another function depends on these results it skips the repeated calculation.- Parameters:
func – The function to be decorated.
- Returns:
The decorated function.
- class Analysis(functions: Dict[str, Callable[[str], DatabaseValue]], plots: Dict[str, Callable[[str], Figure]], dataset: Dataset | Dict[str, ndarray], contact_position_dict: Dict[str, Tuple[float, float]] | None = None)[source]
Bases:
objectImplements specific analysis functions for a type of measurement.
- Parameters:
functions – A dictionary of the available analysis functions. The methods should take the contact id as only argument and return single values or a tuple of values.
plots – A dictionary of the available analysis plots. The methods should take the contact id as only argument and return a
matplotlib.pyplot.Figureobject.dataset – A tuple of (1) data arrays which are mapped to contact IDs and (2) the corresponding metadata of the dataset. Optionally, only a data dictionary is provided but then, a
contact_position_dictis required.contact_position_dict – An optional dictionary of contact IDs and the corresponding positions/coordinates on the sample. Should be provided if the
Metadatais not contained in thedataset.
- property contact_position_dict: Dict[str, Tuple[float, float]] | None
A mapping of contact IDs with the corresponding positions/coordinates on the sample
- property functions: Dict[str, Callable[[str], DatabaseValue]]
A dictionary of the available analysis functions.
- generate_result_dict(function_name: str) Dict[str, Any][source]
Applies an analysis function to each measurement in the data.
- Parameters:
function_name – The string name of the analysis function from
functions.- Returns:
A dictionary of contact IDs and the corresponding analysis results.
- generate_result_maps(function_name: str | None, result_dict: None | Dict[str, Any] = None) List[ndarray][source]
Applies an analysis function to each measurement in the data and uses the contact positions to construct Numpy arrays of the results which represent the sample layout. Optionally uses the provided
result_dict. If the contact positions do not fall on a regular grid, the gaps will be filled withnumpy.nan.- Parameters:
function_name – The string name of the analysis function from the
functions. Will be ignored if aresult_dictis provided.result_dict – A dictionary of contact IDs and the corresponding analysis results.
- Returns:
A list of
numpy.ndarrayobjects with analysis results structured corresponding to thecontact_position_dict.
- plot_result_map(result_map: ndarray, title: str | None = None, save_path: str | None = None, vrange: Tuple[float, float] = (None, None))[source]
Displays a result map as pixel plot with a corresponding color bar.
- Parameters:
result_map – A Numpy array of analysis results.
title – An optional title for the plot.
save_path – An optional path and filename to save the plot as an image.
vrange – An optional value range for the pixel plot.
Implemented Analysis