DiFfRG.file_io#

Classes#

Functions#

mkdir(path)

Creates a directory if it does not exist.

get_parameters_from_name(→ dict)

get_vtk_data(vtkdata)

Utility function to extract nodes and data from a (loaded) vtk file.

read_csv(csv[, delim, header])

Reads a csv file and returns a pandas dataframe.

read_k_csv(filename[, delim, kName])

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

split_csv(csv[, name])

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

Module Contents#

class DiFfRG.file_io.FEMData(filename: str)#
filename#
slice_cache#
dir#
timesteps = []#
files = []#
get_full_data()#
get_data_slice(t: float = -1)#
class DiFfRG.file_io.FEMData1D(filename: str, cs=0, mass_name='u')#

Bases: FEMData

get_raw_x(t: float = -1)#
get_raw_array(name: str, t: float = -1)#
get_x(t: float = -1)#
get_array(name: str, t: float = -1)#
class DiFfRG.file_io.SimulationData1D(name)#

Bases: FEMData1D

pvd_file#
params#
csv_files#
csv_data#
get_csv(name)#
DiFfRG.file_io.mkdir(path: str)#

Creates a directory if it does not exist.

Parameters:

path (str) – The path to the directory to be created.

DiFfRG.file_io.get_parameters_from_name(name: str) dict#
DiFfRG.file_io.get_vtk_data(vtkdata)#

Utility function to extract nodes and data from a (loaded) vtk file.

Parameters:

vtkdata – The loaded vtk data.

Returns:

A tuple containing a numpy array of nodes and a dict with the arrays in the vtkdata.

Return type:

tuple

DiFfRG.file_io.read_csv(csv, delim=',', header='infer')#

Reads a csv file and returns a pandas dataframe.

Parameters:
  • csv (str) – The path to the csv file.

  • delim (str, optional) – Delimiter used in the csv file. Defaults to “,”.

  • header (str, optional) – Header argument for pandas. Use None if no header exists. Defaults to “infer”.

Returns:

The data in the csv file.

Return type:

pandas.DataFrame

DiFfRG.file_io.read_k_csv(filename, delim=',', kName='kGeV')#

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

Parameters:
  • filename (str) – The path to the csv file.

  • delim (str, optional) – Delimiter used in the csv file. Defaults to “,”.

  • kName (str, optional) – The name of the column which contains the values of k. Defaults to “kGeV”.

Returns:

A tuple containing a list with the unique values of k and a list of pandas dataframes for each value of k.

Return type:

tuple

DiFfRG.file_io.split_csv(csv, name='kGeV')#

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

Parameters:
  • filename (str) – The path to the csv file.

  • delim (str, optional) – Delimiter used in the csv file. Defaults to “,”.

  • kName (str, optional) – The name of the column which contains the values of k. Defaults to “kGeV”.

Returns:

A tuple containing a list with the unique values of k and a list of pandas dataframes for each value of k.

Return type:

tuple