chemspectranslator

chemspectranslator is a universal translator for chemical mechanism species

chemspectranslator is an interface to a spreadsheet providing translations between (lumped) species in photochemical mechanisms (such as MOZART, RADM2, SAPRC…) and also observations during field campaigns (FRAPPE, DC3, …). It does its best to calculate reasonable conversion factors, but can only be as good as the underlying dataset.

Installation

pip install chemspectranslator

Command-line scripts

Translate species

chemical mechanism species translator.

usage: chemspectranslate [-h] species source dest

Positional Arguments

species One or several (comma-separated) species names to be translated
source Mechanism shortcut from which to translate.
dest Mechanism shortcut to which to translate.

Examples

import chemspectranslator
cs = chemspectranslator.Translator()

# How is BIGENE (MOZART_T1 species) represented in RADM2?
result = cs.translate('BIGENE', 'MOZART_T1', 'RADM2')
# result is now a ``TranslationResult``

# Do something with the result:
for prefactor, species in result:
   print("Species {:s} represented with a pre-factor of {:f}".format(species, prefactor))
# Species MACR represented with a pre-factor of 0.647059
# Species HC5 represented with a pre-factor of 0.009804
# Species OLI represented with a pre-factor of 0.807292
# Species ALD represented with a pre-factor of 0.133333
# Species NROG represented with a pre-factor of 0.009346
# Species OLT represented with a pre-factor of 0.853933
# Species TOL represented with a pre-factor of 0.096154
# Species MVK represented with a pre-factor of 0.666667
# Species HC8 represented with a pre-factor of 0.001527


# Convenience function
print(result)
#  0.647 * MACR +  0.010 * HC5 +  0.807 * OLI +  0.133 * ALD +  0.009 * NROG +  0.854 * OLT +  0.096 * TOL +  0.667 * MVK +  0.002 * HC8

API

Translator

class chemspectranslator.Translator

Google sheets API translator is a chemspectranslator DB that uses the MasterList provided online.

addMech(mech)

Add a mechanism.

dump(f=<open file '<stdout>', mode 'w'>)

Dump the full DB (might take a while) to <f>. <f> can be a file handle or another connection. Defaults to sys.stdout.

list()

List the full DB (might take a while).

listMechs()

Return a list of mechanism names known to the database.

mechExists(name)

Does a mechanism name exist in the database?

mergeMechs(mechList, mergedName)

Merge mechanisms in <mechList> and create a new merged mechanism <mergedName>

parseField(txt)

Takes a string (a full input text field), breaks it (e.g. ‘ 3*A + 3 * B’) into items and removes spaces (e.g. [ ‘3*A’, ‘3 * B’ ] ). Break characters considered are “+” and “;”.

parseItem(txt)

Splits item into prefactor, count and species, e.g. ‘0.4 * TOLUENE’ or ‘3 PAR’.

translate(spec, source, target, caseSensitive=True)

Translate species <spec> from mechanism <source> to mechanism <target>.

uids

List of unique IDs in the translator DB.