sportran.i_o.read_tablefile.TableFile¶
- class sportran.i_o.read_tablefile.TableFile(data_file, select_ckeys=None, **kwargs)¶
Bases:
object
A table-style file that can be read in blocks.
- Example:
jfile = TableFile(data_file) jfile.read_datalines(NSTEPS=100, select_ckeys=[‘Step’, ‘Temp’, ‘flux’]) print(jfile.data)
Variables (columns) are organized into a dictionary according to the column headers. LAMMPS-style vector variables header are grouped together (only if group_vector = True). If the name starts with “c_” or “v_”, this is stripped away.
e.g. c_flux[0] c_flux[1] c_flux[2] –> placed in ‘flux0’ key
Comments lines are ignored.
The input file should look like this:
# COMMENT LINE # COMMENT LINE # COMMENT LINE Step Temp TotEng Press c_flux[1] c_flux[2] c_flux[3] c_stress[1] c_stress[2] 0 257.6477 -1085.7346 -1944.803 -129.20254 124.70804 -200.42864 -64.236389 -134.0399 1 247.37505 -1085.734 -1909.333 -133.77141 124.25897 -103.27461 -61.022597 -83.17237 2 238.37359 -1087.9214 -1874.56 -138.58616 115.84038 -5.7728078 -58.471318 -74.51758 etc.
- __init__(data_file, select_ckeys=None, **kwargs)¶
LAMMPS_Current(data_file, select_ckeys, **kwargs)
- **kwargs:
group_vectors [default: True] GUI [default: False] print_elapsed [default: True]
Methods
__init__
(data_file[, select_ckeys])LAMMPS_Current(data_file, select_ckeys, **kwargs)
gotostep
(start_step)Go to the start_step-th line in the time series (assumes step=1). start_step = -1 --> ignore, continue from current step 0 --> go to start step N --> go to N-th step.
read_datalines
([NSTEPS, start_step, ...])Read NSTEPS steps of file, starting from start_step, and store only the selected ckeys. INPUT: NSTEPS -> number of steps to read (default: 0 -> reads all the file) start_step = -1 -> continue from current step (default) 0 -> go to start step N -> go to N-th step select_ckeys -> an array with the column keys you want to read (see all_ckeys for a list) max_vector_dim -> when reading vectors read only this number of components (None = read all components) even_NSTEPS -> round the number of steps to an even number (default: True) OUTPUT: data -> a dictionary with the selected-column steps.
- gotostep(start_step)¶
Go to the start_step-th line in the time series (assumes step=1). start_step = -1 –> ignore, continue from current step
0 –> go to start step N –> go to N-th step
- read_datalines(NSTEPS=0, start_step=- 1, select_ckeys=None, max_vector_dim=None, even_NSTEPS=True)¶
Read NSTEPS steps of file, starting from start_step, and store only the selected ckeys. INPUT:
NSTEPS -> number of steps to read (default: 0 -> reads all the file) start_step = -1 -> continue from current step (default)
0 -> go to start step N -> go to N-th step
select_ckeys -> an array with the column keys you want to read (see all_ckeys for a list) max_vector_dim -> when reading vectors read only this number of components (None = read all components) even_NSTEPS -> round the number of steps to an even number (default: True)
- OUTPUT:
data -> a dictionary with the selected-column steps