pycroxe#

PyCroXe#

Python API for CroXe: a relational database of cross-sections and rate coefficients for atomic processes and alike. If you are lookig for the database itself, see CroXe.

Classes#

CroXeConnection([url, host, user, ...])

Thin wrapper around a SQLAlchemy sqlalchemy.engine.Connection.

Functions#

connect([url, host, user, connector, database])

If used outside of a with statement, create and return an unopened pycroxe.CroXeConnection. The intended use is within a with statement, which returns instead an open pycroxe.CroXeConnection::.

Generic data retrieval#

get_species_properties(conn[, symbols])

Return properties of selected species by symbols in the form of a xarray.Dataset.

Usage#

This root module provides, through the function pycroxe.connect() and the class pycroxe.CroXeConnection, the basic interface to manage connections with any instance of CroXe.

While pycroxe.CroXeConnection is provided mainly for type hinting, the recommended usage of pycroxe.connect() is within a with statement:

from pycroxe import connect

with connect() as conn:
    ...

which will return a pycroxe.CroXeConnection instance acting as a context manager (i.e. will take care of opening and closing connections automatically).

You can change the default connection URL (mariadb+mariadbconnector://croxe-guest@localhost/CroXe) by, in order of decreasing precedence:

  1. passing a valid URL as an argument to pycroxe.connect()

  2. setting the environment variable CROXE_DB to a valid URL

  3. changing specific parts of the default URL with pycroxe.connect() keyword arguments

You get also access to some generic data retrieval functions, such as pycroxe.get_species_properties().

See pycroxe.beam for full documentation of more specialized queries and cross-section retrieval, and pycroxe.fitfunctions for the fit function registry.

Notes#

PyCroXe URLs follow the SQLAlchemy pattern (dialect+driver://username@host:port/database)

It is also possible, but not advisable, to get direct access to the pycroxe.CroXeConnection class. In this case, the caller will be responsible for closing the connection:

from pycroxe import CroXeConnection

conn = CroXeConnection()
conn.open()
...
conn.close()