Data reader functions

Module responsible for data reading in DMT.

The functions here read from many different formats into a DMT-DataFrame. As reading and writing is always very close, recommended and often used save functions for DataFrames are also given.

Functions

read_data(filename)

Reads a given file into the internal DMT dataframe, the file’s extension determines the exact method which is then called for reading.

read_hdf(filename, key, convert_cmplx)

Reads in a .hdf file into the internal DMT format.

read_elpa(filename)

Reads in a .elpa file into the internal DMT format.

read_mdm(filename)

Reads in a .mdm file into the internal DMT format.

read_csv(filename)

Read .csv file and generate a DMT dataframe from it.

read_feather(filename)

Read .feather file and generate a DMT dataframe from it.

read_DEVICE_bin(filename)

Reads DEVICE binaries. Here the internal spacial data is saved. Returns a Dataframe.

read_ADS_bin(filename)

Reads a ADS raw data file into a DMT dataframe.

read_tikz_file(filename, col_x=None, col_y=None)

Reads a tikz plot file into a DMT dataframe.

save_hdf(df, save_dir, filename)

Save the dataframe df into save_dir as filename.h5 .

save_elpa(fname, ELPA, cols, firstline)

Save data as a elpa file.

DMT.core.data_reader.read_ADS_bin(filename)[source]

Reads a ADS raw data file into a DMT dataframe.

Parameters:
filenamestr

Path to the file to read

Returns:
dfDMT.core.Dataframe

DMT dataframe representing the data.

DMT.core.data_reader.read_DEVICE_bin(filename)[source]

Reads DEVICE binaries. Here the internal spacial data is saved. Returns a Dataframe.

Parameters:
filenamestr

Path to the file to read

Returns:
dfDMT.core.Dataframe

DMT dataframe representing the data.

DMT.core.data_reader.read_csv(filename, **kwargs)[source]

Read .csv file and generate a DMT dataframe from it.

Parameters:
filenamestr or os.Pathlike

filename of .csv file including path.

**kwargs

kwargs are passed to pandas.read_csv

Returns:
dfDMT.core.Dataframe

DMT dataframe representing the csv data.

DMT.core.data_reader.read_data(filename, key=None, **kwargs)[source]

General data reading routine.

Used to read in data of an arbitrary file format. Correct reading routine is selected based on file extension.

Parameters:
filenamestr

Name of the file to be read including path

Returns:
dfDMT.Dataframe()

Dataframe that contains the cleaned up data contained in file filename

DMT.core.data_reader.read_elpa(filename, header=2)[source]

Read .elpa file and generate a DMT dataframe from it.

Parameters:
filenamestr

filename of .elpa file including path.

headerinteger

Row number where actual data starts. Default=2 as is common for CEDIC in-house tools.

Returns:
dfDMT.core.Dataframe

DMT dataframe representing the elpa data.

DMT.core.data_reader.read_feather(filename, **kwargs)[source]

Read .feather file and generate a DMT dataframe from it.

Parameters:
filenamestr or os.Pathlike

filename of .csv file including path.

**kwargs

kwargs are passed to pandas.read_csv

Returns:
dfDMT.core.Dataframe

DMT dataframe representing the csv data.

DMT.core.data_reader.read_hdf(filename, key)[source]

Read .h5 file and return the stored pandas dataframe from it.

Parameters:
filenamestr or os.Pathlike

filename of .mdm file including path

Returns:
dataframeDMT.core.Dataframe

DMT DataFrame that stores the mdm data.

DMT.core.data_reader.read_mdm(filename)[source]

Read .mdm file and generate a DMT dataframe from it.

Parameters:
filenamestr or os.Pathlike

filename of .mdm file including path.

Returns:
DMT.core.Dataframe

DMT dataframe representing the mdm data.

DMT.core.data_reader.read_mdm_blocks(block, n_row, n_col, n_iccap_vars, iccap_vars)[source]
DMT.core.data_reader.read_tikz_file(filename, col_x=None, col_y=None)[source]

Reads a tikz plot file into a DMT dataframe.

Parameters:
filenamestr

Path to the file to read

col_xstr, optional

Base name of the x columns, if not given, it is ugly extracted from the file

col_ystr, optional

Base name of the y columns, if not given, it is ugly extracted from the file

Returns:
DMT.core.Dataframe

DMT dataframe representing the data.

DMT.core.data_reader.save_elpa(fname, ELPA, cols, firstline)[source]

Save data as a elpa file

Parameters:
fnamestr or os.Pathlike

Path to the file to save

ELPAobject

This parameter is passed to numpy.array as first parameter. Check this function for the supported types.

colslist[str]

List of column names

firstlinestr

First line (comment) for the file to create

DMT.core.data_reader.save_hdf(df, save_dir, filename)[source]

Save the dataframe df into save_dir as filename.h5 .

Parameters:
dfpd.Dataframe()

Pandas dataframe that shall be saved.

save_dirstr or os.Pathlike

Directory where the file shall be saved

filenamestr

Name of the file

Returns:
bool

if saving was successfull returns True, else False