yamdb package

Subpackages

Submodules

yamdb.yamdb module

yamdb … Yet Another Materials Database.

class yamdb.yamdb.DirectProperty(func_dict)[source]

Bases: object

Generate direct access methods for a property from all available sources.

Parameters:

func_dict (dictionary) – Function dictionary containing property methods for all available sources.

class yamdb.yamdb.MixtureProperties(substance)[source]

Bases: object

Generate a mixture properties object from a substance dictionary.

Parameters:

substance (dictionary) – Substance dictionary to build the mixture properties object from.

get_compositions_with_property(property_, keep_range=False)[source]

Return a list of mixture compositions.

For that information on the requested property is available.

Parameters:
  • property (str) – property for that compositions are search for

  • keep_range (bool, default: False) – if composition ‘range’ should be kept in the output list

Returns:

list of compositions that contain property information

Return type:

str

get_compositions_with_property_source(property_, source, keep_range=False)[source]

Return a list of mixture compositions.

For that information on the requested property from the requested source is available.

Parameters:
  • property (str) – property for that compositions are search for

  • source (str) – reference/source for coefficient values

  • keep_range (bool, default: False) – if composition ‘range’ should be kept in the output list

Returns:

list of compositions that contain property information

Return type:

str

class yamdb.yamdb.Properties(substance)[source]

Bases: object

Generate a properties object from a substance dictionary.

Parameters:

substance (dictionary) – Substance dictionary to build the properties object from.

constant_properties = ['Tm', 'Tb', 'M']
get_comment(prop, source)[source]

Return commment if there is one.

Parameters:
  • prop (str) – property to be investigated

  • source (str) – source for the property equation

Returns:

comment if available else None

Return type:

str

get_default_source(prop)[source]

Return the default source for requested property.

Parameters:

prop (str) – property to be investigated

Returns:

default source, None if not defined

Return type:

str

get_equation_limits(prop, source, variable='T')[source]

Return temperature limits of the equation.

Parameters:
  • prop (str) – property to be investigated

  • source (str) – source

  • variable (str) – variable who’s limits should be shown (‘T’ for temperature (default) or ‘x’ for fraction)

Returns:

  • min (float) – lower bound variable range (temperature by default)

  • max (float) – upper bound variable range (temperature by default)

get_property_list()[source]

Return a list of all available properties.

Returns:

list of available properties

Return type:

str

get_reference(prop, source)[source]

Return reference if there is one, else source.

Parameters:
  • prop (str) – property to be investigated

  • source (str) – source for the property equation

Returns:

reference if available else source

Return type:

str

get_source_list(prop)[source]

Return a list of all available sources for requested property.

Parameters:

prop (str) – property to be investigated

Returns:

list of available sources

Return type:

str

class yamdb.yamdb.SubstanceDB(fname)[source]

Bases: object

Load a database file (YAML or JSON) and build a substance object.

Parameters:

fname (str) – Filename of the database file.

get_substance(name)[source]

Return a properties dictionary for the requested substance.

Parameters:

name (str) – Substance name (elemental symbol or composition, e.g., ‘Na’ or ‘CaCl2-NaCl’).

Returns:

Dictionary of properties available for the substance.

Return type:

dictionary or None

has_component(name)[source]

Check if a component is available from the SubstanceDB.

Parameters:

name (str) – Component name (e.g., ‘CaCl2’ that could be present as part of ‘CaCl2-NaCl’ or ‘BaCl2-CaCl2’).

Returns:

List of compositions that contain the requested component.

Return type:

str or None

has_substance(name)[source]

Check if a substance is available from the SubstanceDB.

Parameters:

name (str) – Substance name (elemental symbol or composition, i.e., ‘Na’ or ‘CaCl2-NaCl’).

Returns:

True if substance is found, False otherwise.

Return type:

bool

list_substances()[source]

List substances contained in SubstanceDB.

Returns:

List of substances.

Return type:

str

yamdb.yamdb.extract_concentration(key)[source]

Sort keys according to first concentration value (helper function).

Parameters:

key (str) – Composition in mol%.

Returns:

Fraction of first component in mol% or “999” if key is “range”.

Return type:

float

yamdb.yamdb.get_file_digest(fname, algorithm='sha1')[source]

Get file digest of file.

Parameters:
  • fname (str) – Name of the file whose hash should be determined.

  • algorithm (str, optional) – Hash algorithm to be used (the default is ‘sha1’).

Returns:

Hash as hexadecimal string.

Return type:

str

See also

hashlib.file_digest

yamdb.yamdb.get_from_Janz1992(substance)[source]

Get properties object from the Janz1992.yml file included in yamdb/data.

Parameters:

substance (str) – Substance name (elemental symbol or composition, e.g., ‘NaCl’ or ‘CaCl2-NaCl’).

Returns:

Properties or MixtureProperties object.

Return type:

Properties or MixtureProperties

yamdb.yamdb.get_from_metals(substance)[source]

Get properties object from the metals.yml file included in yamdb/data.

Parameters:

substance (str) – Substance name (elemental symbol or composition, e.g., ‘Na’ or ‘Ga’).

Returns:

Properties or MixtureProperties object.

Return type:

Properties or MixtureProperties

yamdb.yamdb.get_from_references(key)[source]

Get reference for key from the references.yml file included in yamdb/data.

Parameters:

key (str) – Citation key of the reference, e.g. ‘IidaGuthrie1988’.

Returns:

Reference corresponding to the supplied citation key.

Return type:

str

yamdb.yamdb.get_from_salts(substance)[source]

Get properties object from the salts.yml file included in yamdb/data.

Parameters:

substance (str) – Substance name (elemental symbol or composition, e.g., ‘NaCl’ or ‘CaCl2-NaCl’).

Returns:

Properties or MixtureProperties object.

Return type:

Properties or MixtureProperties

yamdb.yamdb.get_properties_from_db(db_file, substance)[source]

Get properties object from a specific database file.

Parameters:
  • db_file (str) – Filename of the database file.

  • substance (str) – Substance name (elemental symbol or composition, e.g., ‘Na’ or ‘CaCl2-NaCl’).

Returns:

Properties or MixtureProperties object.

Return type:

Properties or MixtureProperties

yamdb.yamdb.get_references_from_db(db_file, key)[source]

Get reference for key from db_file.

Parameters:
  • db_file (str) – Name of the reference database YAML file, e.g. ‘references.yml’

  • key (str) – Citation key of the reference, e.g. ‘IidaGuthrie1988’.

Returns:

Reference corresponding to the supplied citation key.

Return type:

str

yamdb.yamdb.load_yaml_references(db_file)[source]

Load a YAML references file.

Parameters:

db_file (str) – Filename of the YAML references database file, e.g. ‘references.yml’.

yamdb.yamref module

yamref … BibTeX references for yamdb (Yet Another Materials Database).

class yamdb.yamref.BibTexDB(fname)[source]

Bases: object

Provide the content of a BibTeX file to resolve references.

Parameters:

fname (str) – Filename of the BibTeX database file.

get_entry(key)[source]

Get the formatted BibTeX entry (string) for cite key.

Parameters:

key (str) – Citation key of the entry, e.g ‘IidaGuthrie1988’.

Returns:

Formatted entry/record belonging to the cite key.

Return type:

str or None

See also

bibtexparser

get_source_filename(key)[source]

Get the filename of the pdf containing the cited paper.

Not meaningful for general use.

Parameters:

key (str) – Citation key of the entry, e.g ‘IidaGuthrie1988’.

Returns:

Filename of the cited paper.

Return type:

str or None

get_unformatted_entry(key)[source]

Get the unformatted BibTeX entry (dict) for cite key.

Parameters:

key (str) – Citation key of the entry, e.g ‘IidaGuthrie1988’.

Returns:

Unformatted entry/record corresponding to the BibTeX entry.

Return type:

dict or None

See also

bibtexparser

yamdb.yamref.get_from_references(key)[source]

Get reference for key from the references.bib file included in yamdb/data.

Parameters:

key (str) – Citation key of the reference, e.g. ‘IidaGuthrie1988’.

Returns:

Reference corresponding to the supplied citation key.

Return type:

str

yamdb.yamref.get_references_from_db(db_file, key)[source]

Get reference for key from db_file.

Parameters:
  • db_file (str) – Name of the reference database BibTeX file, e.g. ‘references.bib’

  • key (str) – Citation key of the reference, e.g. ‘IidaGuthrie1988’.

Returns:

Reference corresponding to the supplied citation key.

Return type:

str

Module contents