unitpackage.database.echemdb

A Collection of data from the echemdb data repository displayed on the echemdb website. It provides additional functionalities compared to the Collection specific to the data in the echemdb repository.

EXAMPLES:

Create a collection from the Data Packages published in the echemdb data repository displayed on the echemdb website.:

>>> collection = Echemdb.from_remote()

Search the collection for entries from a single publication:

>>> collection.filter(lambda entry: entry.source.url == 'https://doi.org/10.1039/C0CP01001D')
[Echemdb('alves_2011_electrochemistry_6010_f1a_solid'), ...
class unitpackage.database.echemdb.Echemdb(package=None)

A collection of frictionless Data Packages.

Essentially this is just a list of data packages with some additional convenience wrap for use in the echemdb data repository displayed on the echemdb website.

EXAMPLES:

An example collection:

>>> collection = Collection.create_example()
>>> collection.package.resource_names
['alves_2011_electrochemistry_6010_f1a_solid',
'engstfeld_2018_polycrystalline_17743_f4b_1',
'no_bibliography']
class EchemdbEntry(resource)

A frictionless Data Package describing a CV.

EXAMPLES:

Entries are normally obtained by opening a Echemdb of entries:

>>> from unitpackage.database.echemdb import Echemdb
>>> collection = Echemdb.create_example()
>>> entry = next(iter(collection))
get_electrode(name)

Returns an electrode with the specified name.

EXAMPLES:

>>> entry = EchemdbEntry.create_examples()[0]
>>> entry.get_electrode('WE')
{'name': 'WE', 'function': 'workingElectrode', 'type': 'single crystal',
'crystallographicOrientation': '0001', 'material': 'Ru',
'preparationProcedure': 'Sputtering and flash annealing under UHV
conditions with repeated cycles of oxygen adsorption and desorption.',
'shape': {'height': {'unit': 'mm', 'value': 2}, 'type': 'hat shaped'},
'source': {'supplier': 'Mateck'}}

TESTS:

>>> entry.get_electrode('foo')
Traceback (most recent call last):
...
KeyError: "Electrode with name 'foo' does not exist"
plot(x_label='E', y_label='j', name=None)

Return a plot of this entry. The default plot is a Cyclic Voltammogram (‘j vs E’). When j is not present in the data, I is used instead.

EXAMPLES:

>>> entry = EchemdbEntry.create_examples()[0]
>>> entry.plot()
Figure(...)

The plot can also be returned with custom axis dimensions (field names) available in the resource:

>>> entry.plot(x_label='t', y_label='E')
Figure(...)

A plot resembling the original figure can be obtained by first rescaling:

>>> rescaled_entry = entry.rescale('original')
>>> rescaled_entry.plot()
Figure(...)
rescale(units)

Return a rescaled EchemdbEntry with axes in the specified units.

Usage is essentially the same as for rescale(), i.e., new units are expected as dict, where the key is the axis name and the value the new unit, such as {'j': 'uA / cm2', 't': 'h'}.

Additionally, the entry can be rescaled to the axes’ units of the original data. These units must be defined in the metadata of the resource, within the key figureDescription.fields:

>>> entry = EchemdbEntry.create_examples()[0]
>>> rescaled_entry = entry.rescale(units='original')
>>> rescaled_entry.mutable_resource.schema.fields
[{'name': 't', 'type': 'number', 'unit': 's'},
{'name': 'E', 'type': 'number', 'unit': 'V', 'reference': 'RHE'},
{'name': 'j', 'type': 'number', 'unit': 'mA / cm2'}]
thumbnail(width=96, height=72, dpi=72, **kwds)

Return a thumbnail of the entry’s curve as a PNG byte stream.

EXAMPLES:

>>> entry = EchemdbEntry.create_examples()[0]
>>> entry.thumbnail()
b'\x89PNG...'

The PNG’s width and height can be specified in pixels. Additional keyword arguments are passed to the data frame plotting method:

>>> entry.thumbnail(width=4, height=2, color='red', linewidth=2)
b"\x89PNG..."
Entry

alias of EchemdbEntry

describe()

Return some statistics about the echemdb database.

EXAMPLES:

>>> from unitpackage.database.echemdb import Echemdb
>>> collection = Echemdb.create_example()
>>> collection.describe() == \
... {'number of references': 2,
... 'number of entries': 3,
... 'materials': {'Cu', 'Ru'}}
True
materials()

Return the substrate materials in the collection.

EXAMPLES:

>>> from unitpackage.database.echemdb import Echemdb
>>> collection = Echemdb.create_example()
>>> collection.materials() == {'Cu', 'Ru'}
True