echemdb.entry
A Data Package describing tabulated data for which the units of the column names (pandas) or fields (frictionless) are known.
Datapackages are the individual elements of a Database
and
are denoted as entry.
EXAMPLES:
Data Packages containing published data, also contain information on the source of the data.:
>>> from echemdb.database import Database
>>> db = Database.create_example()
>>> entry = db['alves_2011_electrochemistry_6010_f1a_solid']
>>> entry.bibliography
Entry('article',
fields=[
('title', 'Electrochemistry at Ru(0001) in a flowing CO-saturated electrolyte—reactive and inert adlayer phases'),
('journal', 'Physical Chemistry Chemical Physics'),
('volume', '13'),
('number', '13'),
('pages', '6010--6021'),
('year', '2011'),
('publisher', 'Royal Society of Chemistry'),
('abstract', 'We investigated ...')],
persons=OrderedCaseInsensitiveDict([('author', [Person('Alves, Otavio B'), Person('Hoster, Harry E'), Person('Behm, Rolf J{\\"u}rgen')])]))
- class echemdb.entry.Entry(package)
A data packages describing tabulated data.
EXAMPLES:
Entries are normally obtained by opening a
Database
of entries:>>> from echemdb.database import Database >>> database = Database.create_example() >>> entry = next(iter(database))
- property bibliography
Return a pybtex bibliography object.
EXAMPLES:
>>> entry = Entry.create_examples()[0] >>> entry.bibliography Entry('article', fields=[ ('title', ... ... >>> entry_no_bib = Entry.create_examples(name="no_bibliography")[0] >>> entry_no_bib.bibliography ''
- citation(backend='text')
Return a formatted reference for the entry’s bibliography such as:
Doe, et al., Journal Name, volume (YEAR) page, “Title”
Rendering default is plain text ‘text’, but can be changed to any format supported by pybtex, such as markdown ‘md’, ‘latex’ or ‘html’.
EXAMPLES:
>>> entry = Entry.create_examples()[0] >>> entry.citation(backend='text') 'O. B. Alves et al. Electrochemistry at Ru(0001) in a flowing CO-saturated electrolyte—reactive and inert adlayer phases. Physical Chemistry Chemical Physics, 13(13):6010–6021, 2011.' >>> print(entry.citation(backend='md')) O\. B\. Alves *et al\.* *Electrochemistry at Ru\(0001\) in a flowing CO\-saturated electrolyte—reactive and inert adlayer phases*\. *Physical Chemistry Chemical Physics*, 13\(13\):6010–6021, 2011\.
- classmethod create_examples(name='alves_2011_electrochemistry_6010')
Return some example entries for use in automated tests.
The examples are built on-demand from data in echemdb’s examples directory.
EXAMPLES:
>>> Entry.create_examples() [Entry('alves_2011_electrochemistry_6010_f1a_solid')]
An entry without associated BIB file.
>>> Entry.create_examples(name="no_bibliography") [Entry('no_bibliography')]
- property df
Return the data of this entry as a data frame.
EXAMPLES:
>>> entry = Entry.create_examples()[0] >>> entry.df t E j 0 0.000000 -0.103158 -0.998277 1 0.020000 -0.102158 -0.981762 ...
The units and descriptions of the axes in the data frame can be recovered:
>>> entry.package.get_resource('echemdb').schema.fields [{'name': 't', 'type': 'number', 'unit': 's'}, {'name': 'E', 'type': 'number', 'unit': 'V', 'reference': 'RHE'}, {'name': 'j', 'type': 'number', 'unit': 'A / m2'}]
- field_unit(field_name)
Return the unit of the
field_name
of theechemdb
resource.EXAMPLES:
>>> entry = Entry.create_examples()[0] >>> entry.field_unit('E') 'V'
- property identifier
Return a unique identifier for this entry, i.e., its filename.
EXAMPLES:
>>> entry = Entry.create_examples()[0] >>> entry.identifier 'alves_2011_electrochemistry_6010_f1a_solid'
- plot(x_label=None, y_label=None, name=None)
Return a plot of this entry.
The default plot is constructed from the first two columns of the dataframne.
EXAMPLES:
>>> entry = Entry.create_examples()[0] >>> entry.plot() Figure(...)
The plot can also be returned with custom axis units available in the resource:
>>> entry.plot(x_label='j', y_label='E') Figure(...)
- rescale(units)
Returns a rescaled
Entry
with axes in the specifiedunits
. Provide a dict, where the key is the axis name and the value the new unit, such as {‘j’: ‘uA / cm2’, ‘t’: ‘h’}.EXAMPLES:
The units without any rescaling:
>>> entry = Entry.create_examples()[0] >>> entry.package.get_resource('echemdb').schema.fields [{'name': 't', 'type': 'number', 'unit': 's'}, {'name': 'E', 'type': 'number', 'unit': 'V', 'reference': 'RHE'}, {'name': 'j', 'type': 'number', 'unit': 'A / m2'}]
A rescaled entry using different units:
>>> rescaled_entry = entry.rescale({'j':'uA / cm2', 't':'h'}) >>> rescaled_entry.package.get_resource('echemdb').schema.fields [{'name': 't', 'type': 'number', 'unit': 'h'}, {'name': 'E', 'type': 'number', 'unit': 'V', 'reference': 'RHE'}, {'name': 'j', 'type': 'number', 'unit': 'uA / cm2'}]
The values in the data frame are scaled to match the new units:
>>> rescaled_entry.df t E j 0 0.000000 -0.103158 -99.827664 1 0.000006 -0.102158 -98.176205 ...