aim2dat.fct

Modules to analyze and compare functions (e.g. DOS or spectra).

Submodules

Package Contents

Classes

DiscretizedAxis

Class to create an axis to discretize a 1d function i.e. a 2d plot

DiscretizedGrid

Class to create a grid to discretize a 1d function i.e. a 2d plot.

FunctionAnalysis

Class to analyze and compare functions.

FunctionDiscretizationFingerprint

Fingerprint for functions based on the DOS-Fingerprint presented in

class aim2dat.fct.DiscretizedAxis(axis_type, **kwargs)[source]

Class to create an axis to discretize a 1d function i.e. a 2d plot in a grid. Different methods for the discretization are available.

Overview

Properties

T

x –> y or y –> x.

axis

Axis array. Contains the discrete values.

axis_type

Specify whether this axis should be used as x or y axis in a grid.

discretization_method

Discretize the specified range.

is_empty

Check whether the axis is empty.

shape

Tuple specifying the dimensions of the axis (like numpy).

Methods

discretize_axis(**kwargs)

Perform the discretization of the specified range.

transpose()

Change the axis_type: x –> y or y –> x.

property T : DiscretizedAxis

x –> y or y –> x.

Returns:

DiscretizedAxis – Transposed axis.

Type:

Change the axis_type

property axis : numpy.array

Axis array. Contains the discrete values.

Returns:

np.array – The discretized range.

property axis_type : str

Specify whether this axis should be used as x or y axis in a grid.

Returns:

str – indicating whether this axis should be used as x or y axis in case of a merge into a grid.

Raises:

ValueError – The axis_type attribute needs to be specified

property discretization_method : collections.abc.Callable

Discretize the specified range. Can be chosen via a string, accepting the methods specified in _available_discretization_methods or by passing a callable function.

Returns:

Callable – Method to discretize the axis.

property is_empty : bool

Check whether the axis is empty.

Returns:

bool – Whether the axis is empty.

property shape : tuple

Tuple specifying the dimensions of the axis (like numpy).

Returns:

tuple – The shape of the axis.

discretize_axis(**kwargs) DiscretizedAxis[source]

Perform the discretization of the specified range.

Returns:

DiscretizedAxis

transpose() DiscretizedAxis[source]

Change the axis_type: x –> y or y –> x.

Returns:

DiscretizedAxis – Transposed axis.

class aim2dat.fct.DiscretizedGrid(**kwargs)[source]

Class to create a grid to discretize a 1d function i.e. a 2d plot.

Use the plot_grid method to visualize the created grid.

Overview

Properties

grid

Return the internal grid as a list of lists.

is_empty

Check whether the axis is empty.

Methods

create_grid()

Create the internal grid which is based on a list of lists.

plot_grid()

Plot the grid.

property grid : list

Return the internal grid as a list of lists.

Returns:

type – list: List of lists representing the x-values and discretized y-values.

property is_empty : bool

Check whether the axis is empty.

Returns:

bool – Whether the axis is empty.

create_grid() DiscretizedGrid[source]

Create the internal grid which is based on a list of lists. Each list contains the energy-value (x) as the first argument and the DOS-values (y) as a list in the second argument.

Returns:

DiscretizedGrid – Discretized grid.

plot_grid()[source]

Plot the grid.

class aim2dat.fct.FunctionAnalysis(**kwargs)[source]

Class to analyze and compare functions.

Overview

Properties

allowed_distance_methods

Return allowed distance methods.

Methods

calculate_correlation(label1, label2)

Calculate the pearson-correlation between the values of two functions.

calculate_discrete_fingerprint(label, grid)

Calculate a discretized fingerprint of a function (doi:10.1038/s41597-022-01754-z).

calculate_distance(label1, label2, method)

Calculate the distance between the values of two functions.

compare_areas(label1, label2)

Compare the enclosed areas of two functions.

compare_functions_by_discrete_fingerprint(label1, label2, grid)

Compare two functions based on a discretized fingerprint

import_data(data_label, x_values, y_values)

Import data into the internal memory.

property allowed_distance_methods : list

Return allowed distance methods.

calculate_correlation(label1: str, label2: str) float[source]

Calculate the pearson-correlation between the values of two functions.

Parameters:
  • label_1 (str) – Label of the first dataset.

  • label_2 (str) – Label of the second dataset.

Returns:

float – The correlation.

calculate_discrete_fingerprint(label: str, grid: aim2dat.fct.discretization.DiscretizedGrid) numpy.array[source]

Calculate a discretized fingerprint of a function (doi:10.1038/s41597-022-01754-z).

Parameters:
  • label (str) – Label of the dataset.

  • grid (DiscretizedGrid) – The grid to discretize the function.

Returns:

np.array – Discretized fingerprint.

calculate_distance(label1: str, label2: str, method: str = 'euclidian') float[source]

Calculate the distance between the values of two functions.

Parameters:
  • label1 (str) – Label of the first dataset.

  • label2 (str) – Label of the second dataset.

  • method (str) – The metric to calculate the distance. Defaults to “euclidian”.

Returns:

float – Abs. error

compare_areas(label1: str, label2: str) float[source]

Compare the enclosed areas of two functions.

Parameters:
  • label1 (str) – Label of the first dataset.

  • label2 (str) – Label of the second dataset.

Returns:

float – The ratio of the areas. (A1 / A2)

compare_functions_by_discrete_fingerprint(label1: str, label2: str, grid: aim2dat.fct.discretization.DiscretizedGrid) float[source]

Compare two functions based on a discretized fingerprint (doi:10.1038/s41597-022-01754-z).

Parameters:
  • label1 (str) – Label of the first dataset.

  • label2 (str) – Label of the second dataset.

  • grid (DiscretizedGrid) – The grid to discretize the function.

Returns:

float – Similarity.

import_data(data_label: str, x_values: numpy.array, y_values: numpy.array)[source]

Import data into the internal memory.

Parameters:
  • data_label (str) – Label for the internal memory.

  • x_values (np.array) – x-values of the function.

  • y_values (np.array) – y-values of the function.

class aim2dat.fct.FunctionDiscretizationFingerprint(grid, **kwargs)[source]

Fingerprint for functions based on the DOS-Fingerprint presented in doi:10.1038/s41597-022-01754-z.

Overview

Methods

calculate_fingerprint(x_values, y_values, label)

Calculate the fingerprint.

compare_fingerprints(label_1, label_2)

Compare two fingerprints that are stored in the internal memory.

plot_fingerprint(x_values, y_values)

Plot the discretized function and the corresponding grid.

calculate_fingerprint(x_values: numpy.array, y_values: numpy.array, label: str = None) numpy.array[source]

Calculate the fingerprint.

Parameters:
  • x_values (np.array) – x-values of the function.

  • y_values (np.array) – y-values of the function. In case it’s a 2D-array, each row will be interpreted as a dataset and the fingerprint is calculated by concatenating the individual fingerprints.

  • label (str) – Label for the internal memory. Defaults to None.

Returns:

np.array – The discretized fingerprint.

compare_fingerprints(label_1: str, label_2: str) float[source]

Compare two fingerprints that are stored in the internal memory.

Parameters:
  • label_1 (str) – Label of the first fingerprint.

  • label_2 (str) – Label of the second fingerprint.

Returns:

float – Similarity measure.

plot_fingerprint(x_values: numpy.array, y_values: numpy.array) matplotlib.pyplot.Figure[source]

Plot the discretized function and the corresponding grid.

Parameters:
  • x_values (np.array) – x-values of the function.

  • y_values (np.array) – y-values of the function.

Returns:

plt.Figure – Plot of the discretized function.