Module iodata

This module contains all classes useful to manipulate, store and display data results.

The Data and DataSet are the two enduser classes important to manipulate the data. Here is an example of how to store values in a Data object:

from msspec.iodata import Data
import numpy as np


# Let's create first some dumy data
X = np.arange(0, 20)
Y = X**2

# Create a Data object. You need to give a title as an argument
data = Data('all my data')
# and append a new DataSet with its title
dset = data.add_dset('Dataset 0')

# To feed the DataSet with columns, use the add_columns method
# and provide as many keywords as you like. Each key being the
# column name and each value being an array holding the column
# data.
dset.add_columns(x=X, y=Y, z=X+2, w=Y**3)
# you can provide parameters with their values with keywords as well
dset.add_parameter(name='truc', group='main', value='3.14', unit='eV')

# To plot these data, you need to add a 'view' with its title
view = dset.add_view('my view')
# You then need to select which columns you which to plot and
# and under wich conditions (with the 'which' keyword)
view.select('x', 'y', where="z<10", legend=r"z = 0")
view.select('x', 'y', where="z>10", legend=r"z = 1")

# To pop up the graphical window
data.view()
class iodata.Data(title='')[source]

Bases: object

Creates a new Data object to store DataSets.

Parameters

title – The title of the Data object.

add_dset(title, overwrite=False)[source]

Adds a new DataSet in the Data object.

Parameters
  • title (str) – The name of the DataSet.

  • overwrite (bool) – Tells whether to re-create the dataset if it exists.

Returns

The newly created DataSet.

Return type

iodata.DataSet

delete_dset(title)[source]

Removes a DataSet from the Data object.

Parameters

title (str) – The DataSet name to be removed.

export(folder, overwrite=False)[source]
get_last_dset()[source]

Get the last DataSet of the Data object.

Returns

The lastly created DataSet in the Data object

Return type

iodata.DataSet

is_dirty()[source]

Wether the Data object needs to be saved.

Returns

A boolean value to indicate if Data has changed since last dump to hard drive.

Return type

bool

static load(filename)[source]

Loads an HDF5 file from the disc.

Parameters

filename (str) – The path to the file to laod.

Returns

A Data object.

Return type

iodata.Data

save(filename, append=False)[source]

Saves the current Data to the hard drive.

The Data, all its content along with parameters, defined views… are saved to the hard drive in the HDF5 file format. Please see hdfgroup for more details about HDF5.

Parameters
  • filename (str) – The name of the file to create or to append to.

  • append (bool) – Wether to create a neww file or to append to an existing one.

view()[source]

Pops up a grphical window to show all the defined views of the Data object.

class iodata.DataSet(title, notes='')[source]

Bases: object

This class can create an object to hold column-oriented data.

Parameters
  • title (str) – The text used to entitled the dataset

  • notes (str) – Some comments to add to the data

add_columns(**kwargs)[source]

Add columns to the dataset.

You can provide as many columns as you want to this function. This function can be called several times on the same dataset but each time with different column names. Column names are given as keywords.

Example

>>> from iodata import DataSet
>>> dset = DataSet('My Dataset', notes="Just an example")
>>> xdata = range(10)
>>> ydata = [i**2 for i in xdata]
>>> dset.add_columns(x=xdata, y=ydata)
>>> print dset
>>> +-------+
>>> | x  y  |
>>> +-------+
>>> | 0  0  |
>>> | 1  1  |
>>> | 2  4  |
>>> | 3  9  |
>>> | 4  16 |
>>> | 5  25 |
>>> | 6  36 |
>>> | 7  49 |
>>> | 8  64 |
>>> | 9  81 |
>>> +-------+
add_parameter(**kwargs)[source]

Add a parameter to store with the dataset.

Parameters

kwargs – list of keywords with str values.

These keywords are:
  • name: the name of the parameter.

  • group: the name of a group it belongs to.

  • value: the value of the parameter.

  • unit: the unit of the parameter.

For example:

from iodata import DataSet

mydset = DataSet("Experiment")
mydset.add_parameter(name='Spectrometer', group='misc', value='Omicron', unit='')
add_row(**kwargs)[source]

Add a row of data into the dataset.

Parameters

kwargs – Each keyword is a column name. The number of keywords (columns) must be coherent with the number of existing columns. If no column are defined yet, they will be created.

add_view(name, overwrite=False, **plotopts)[source]

Creates a new view named name with specied plot options.

Parameters
  • name (str) – name of the view.

  • plotopts – list of keywords for configuring the plots.

Returns

a view.

Return type

iodata._DataSetView

columns()[source]

Get all the column names.

Returns

List of column names.

Return type

List of str

delete_columns(*tags)[source]

Removes all columns name passed as arguments

Parameters

tags (str) – column names.

delete_rows(itemspec)[source]

Delete the rows specified with itemspec.

delete_view(name)[source]
export(filename='', mode='w')[source]

Export the DataSet to the given filename.

Parameters

filename (str) – The name of the file.

Warning

Not yet implemented

export_views(folder)[source]
get_cluster()[source]

Get all the atoms in the cluster.

Returns

The cluster

Return type

ase.Atoms

get_parameter(group=None, name=None)[source]

Retrieves all parameters for a given name and group.

  • If name is given and group is None, returns all parameters with such a name in all groups.

  • If group is given and name is None, returns all parameters in such a group

  • If both name and group are None. Returns all parameters (equivalent to

    iodata.DataSet.parameters()).

Parameters
  • group (str) – The group name or None.

  • name (str) – The parameter’s name or None.

Returns

A list of parameters.

Return type

List of dict

parameters()[source]

Returns the list of defined parameters.

Returns

all parameters defined in the iodata.DataSet object.

Return type

List of dict

select(*args, **kwargs)[source]
views()[source]

Returns all the defined views in the dataset.

Returns

A list of view

Return type

List of iodata._DataSetView

class iodata._DataSetView(dset, name, **plotopts)[source]

Bases: object

from_xml(xmlstr)[source]
get_data()[source]
get_figure()[source]
select(*args, **kwargs)[source]
serialize()[source]
set_plot_options(**kwargs)[source]
tags()[source]
to_xml()[source]