Managing IN/OUT data

This module provides utility functions for saving and loading data obtained from simulations.

ed_lgt.tools.manage_data.load_data_from_textfile(data_file_name, row_for_labels=False)[source]

This function acquires data from a text file made out of different columns and yields it as a dictonary

Parameters:
  • data_file_name (str) – name of the file

  • row_for_labels (bool, optional) – If True, the firs line contains the labels. Default to False.

Raises:

TypeError – If the input arguments are of incorrect types or formats.

Returns:

Dictonary where all the informations are stored

Return type:

dict

ed_lgt.tools.manage_data.load_dictionary(filename)[source]

This function loads the information of a Python dictionary from a .pkl file

Parameters:

filename (str) – name of the file where the dictionary is saved

ed_lgt.tools.manage_data.save_data_in_textfile(data_file, x_data, new_data)[source]

This function stores a set of values as a new column of a text file with already existing columns of values. Each column will be then easily used for comparison in plots.

Parameters:
  • data_file (str) – Name of the file where to save the set of values

  • x_data (list) – It contains the x values corresponding to the new set of values. The first entry is a string label

  • new_data (list) – It contains the new set of y values corresponding to the x_data. The first entry is a string label (typicalliy referred to the simulation)

Raises:

TypeError – If the input arguments are of incorrect types or formats.

ed_lgt.tools.manage_data.save_dictionary(dictionary, filename)[source]

This function save the information of a Python dictionary into a .pkl file

Parameters:
  • dictionary (dict) – dictionary to be saved

  • filename (str) – name of the file where to save the dictionary

ed_lgt.tools.manage_data.save_sparse_matrix_to_dat(sparse_matrix, filename)[source]

Save the non-zero entries of a scipy.sparse.csr_matrix to a .dat file.

Parameters: A (scipy.sparse.csr_matrix): The sparse matrix to save.

filename (str): The name of the file where the matrix will be saved.