eon.fileio#

Con(figuration) i/o library

Module Contents#

Classes#

ini

Dynamics

The Dynamics class handles I/O for the dynamics.txt file of an aKMC simulation.

Table

A class that provides a nice io abstraction for table like data. The data is saved in a pretty printed format. Also provides nice data retrival methods.

Functions#

save_prng_state

get_prng_state

length_angle_to_box

box_to_length_angle

loadcons

loadposcars

loadcon

Load a con file filein: may be either a filename or a file-like object

savecon

Save a con file fileout: can be either a file name or a file-like object p: information (in the form of an atoms object) to save w: write/append flag

load_mode

Reads a mode.dat file into an N by 3 numpy array modefilein: may be either a file-like object of a filename

save_mode

Saves an Nx3 numpy array into a mode.dat file. modefileout: may be either a filename or file-like object displace_vector: the mode (Nx3 numpy array)

save_results_dat

Saves a results.dat file from a dictionary

modify_config

parse_results

Reads a results.dat file and gives a dictionary of the values contained therein

loadposcar

Load the POSCAR file named filename and returns an atoms object

saveposcar

Save a POSCAR fileout: name to save it under point: atoms object to save w: write/append flag

load_potfiles

Data#

API#

eon.fileio.logger#

‘getLogger(…)’

eon.fileio.save_prng_state()[source]#
eon.fileio.get_prng_state()[source]#
eon.fileio.length_angle_to_box(boxlengths, angles)[source]#
eon.fileio.box_to_length_angle(box)[source]#
eon.fileio.loadcons(filename)[source]#
eon.fileio.loadposcars(filename)[source]#
eon.fileio.loadcon(filein, reset=True)[source]#

Load a con file filein: may be either a filename or a file-like object

eon.fileio.savecon(fileout, p, w='w')[source]#

Save a con file fileout: can be either a file name or a file-like object p: information (in the form of an atoms object) to save w: write/append flag

eon.fileio.load_mode(modefilein)[source]#

Reads a mode.dat file into an N by 3 numpy array modefilein: may be either a file-like object of a filename

eon.fileio.save_mode(modefileout, displace_vector)[source]#

Saves an Nx3 numpy array into a mode.dat file. modefileout: may be either a filename or file-like object displace_vector: the mode (Nx3 numpy array)

eon.fileio.save_results_dat(fileout, results)[source]#

Saves a results.dat file from a dictionary

eon.fileio.modify_config(config_path, changes)[source]#
eon.fileio.parse_results(filein)[source]#

Reads a results.dat file and gives a dictionary of the values contained therein

eon.fileio.loadposcar(filein)[source]#

Load the POSCAR file named filename and returns an atoms object

eon.fileio.saveposcar(fileout, p, w='w', direct=False)[source]#

Save a POSCAR fileout: name to save it under point: atoms object to save w: write/append flag

class eon.fileio.ini(filenames)[source]#

Bases: configparser.ConfigParser

read()[source]#
get(section, option, default='ini_no_default', **kwargs)[source]#
abstract getint(*args)[source]#
abstract getfloat(*args)[source]#
abstract getboolean(*args)[source]#
set(section, option, value)[source]#
class eon.fileio.Dynamics(filename)[source]#

The Dynamics class handles I/O for the dynamics.txt file of an aKMC simulation.

Initialization

append(reactant_id, process_id, product_id, step_time, total_time, barrier, rate, energy)[source]#
append_sb(reactant_id, process_id, product_id, step_time, total_time, basin_id, rate, energy)[source]#
get()[source]#
eon.fileio.load_potfiles(pot_dir)[source]#
exception eon.fileio.TableException[source]#

Bases: Exception

class eon.fileio.Table(filename, columns=None, overwrite=False)[source]#

A class that provides a nice io abstraction for table like data. The data is saved in a pretty printed format. Also provides nice data retrival methods.

t = Table(“sample.tbl”, [‘id’, ‘name’, ‘age’ ]) t.eagerwrite = False t.add_row({‘id’:0,’name’:”Sam”,”age”:24}) t.add_row({‘id’:1,’name’:”David”,”age”:50}) t.add_row({‘id’:2,’name’:”Anna”,”age”:21}) t #doctest: +NORMALIZE_WHITESPACE id name age

-- ----- ---
0  Sam   24
1  David 50
2  Anna  21

Rows can be accessed directly:

t.rows[1] #doctest: +SKIP {‘age’: 50, ‘id’: 1, ‘name’: ‘David’} t.max_value(‘age’) #doctest: +NORMALIZE_WHITESPACE 50 t.min_row(‘age’) #doctest: +NORMALIZE_WHITESPACE +SKIP {‘age’: 21, ‘id’: 2, ‘name’: ‘Anna’} sorted(t.min_row(‘id’).items()) #doctest: +NORMALIZE_WHITESPACE [(‘age’, 24), (‘id’, 0), (‘name’, ‘Sam’)] len(t) #doctest: +NORMALIZE_WHITESPACE 3 sum(t.getcolumn(‘age’)) #doctest: +NORMALIZE_WHITESPACE 95 t.write() #doctest: +SKIP

The table can be loaded from disk without specifying columns. This is slightly unsafe because the columns can’t be checked, but it could cut down on the verbosity in some places.

t2 = Table(“sample.tbl”) #doctest: +SKIP

Initialization

init()[source]#

Checks to see if self.filename exists. If it does self.rows will be initialized from disk.

read(filename)[source]#
write()[source]#
writefilehandle(filehandle)[source]#
add_row(row)[source]#
delete_row(column, value)[source]#
delete_row_func(column, func)[source]#
find_value(column, func)[source]#
find_row(column, func)[source]#
min_value(column)[source]#
min_row(column)[source]#
max_value(column)[source]#
max_row(column)[source]#
get_row(column, value)[source]#
get_rows(column, value)[source]#
get_column(column)[source]#