spinguin.core.data_io

spinguin.core.data_io#

This module contains functions for reading data from files and converting it into suitable formats.

read_array(file_path: str, data_type: type) ndarray[source]#

Reads a .txt file where values are stored in a space-separated format and converts that into a NumPy array.

Parameters:
  • file_path (str) – Path to the file to be read.

  • data_type (type) – Data type of the values to be read (e.g., float or str).

Returns:

value_array – A NumPy array containing the values read from the file.

Return type:

ndarray

read_tensors(file_path: str) ndarray[source]#

Reads a file containing Cartesian interaction tensors (from quantum chemistry calculations) for each spin or spin pair.

The file should have the following format:

  • The first column is the index of the spin.

  • The subsequent columns represent the components of a 3x3 tensor.

This structure is repeated for each spin.

TODO: Input mahdollinen ilman nollatensoreita?

Parameters:

file_path (str) – Path to the file containing the tensors.

Returns:

tensors – A NumPy array containing the tensors.

Return type:

ndarray

read_xyz(file_path: str) ndarray[source]#

Reads a .xyz file where the first line specifies the number of atoms, the second line contains a comment, and the subsequent lines contain the atom symbols and Cartesian coordinates.

Parameters:

file_path (str) – Path to the .xyz file to be read.

Returns:

xyz – A NumPy array containing the atom symbols and Cartesian coordinates.

Return type:

ndarray