Skip to main content

A package for interacting with CollisionDB

Project description

PyPI version PyPI pyversions Code style

Introduction to PyCollisionDB

PyCollisionDB is a Python package for interacting with CollisionDB or ALADDIN2, databases of plasma collisional cross sections and rate coefficients.

Datasets in these collisional databases can be retrieved in a standardized way and compared, aggregated, and assessed using a set of predefined Python methods.

Installation

The PyCollisionDB package can be installed either from PYPI using pip

python3 -m pip install pycollisiondb

or from the source by running (one of the two) from the project source directory.

# either
python setup.py install

# or
python3 -m pip install .

PyCollision

The PyCollision object represents the main instance of the PyCollisionDB package for interacting with collisional databases, and datasets may be compared, output in various formats, and manipulated using the methods object as described below:

>>> from pycollisiondb.pycollisiondb import PyCollision

Convert Units

The PyCollision method convert_units can be used to change the units of datasets.

>>> pycoll.datasets[102737].x
array([  1000.,   4000.,   9000.,  16000.,  25000.,  36000.,  49000.,
     64000.,  81000., 100000.])
>>> # The units of all datasets are changed,
>>> # Energy is changed from eV.u-1 (default) to keV.u-1 and sigma from cm2 (default) to a02 (atomic units).
>>> # This accesses the pyqn library.
 >>> pycoll.convert_units({'E': 'keV.u-1', 'sigma': 'a02'})
 >>> pycoll.datasets[102737].x
 array([  1.,   4.,   9.,  16.,  25.,  36.,  49.,  64.,  81., 100.])
>>> # Change the units of a single dataset,
>>> # provide the column name followed by units as arguments.
>>> pycoll.datasets[102737].convert_units('sigma', 'm2')

Visualization tools

The PyCollision method plot_all_datasets can be used to create plots using the pyplot submodule of the Matplotlib library as the visualization utility.

>>> import matplotlib.pyplot as plt
>>> %matplotlib notebook
>>> # Make a plot, indicating how the data should be labelled.
>>> fig, ax = plt.subplots()
>>> # The default legend consists of qid/pk and reaction labels,
>>> # it can be customized to include refs and process_types or either of these lables.
>>> pycoll.plot_all_datasets(ax, label=('reaction', 'qid', 'refs', 'process_types'))
>>> plt.legend()
figure

Connection to the ALADDIN2 API

>>> #By default, PyCollisionDB interacts with the API to the CollisionDB server
>>> pycoll.API_URL
'https://db-amdis.org/collisiondb/api/'

>>> #API_URL can be directed to ALADDIN2 server by passing argument DB_URL
>>> DB_URL = 'https://db-amdis.org/aladdin2'
>>> pycoll = PyCollision.get_datasets(query=query,DB_URL=DB_URL)
>>> pycoll.API_URL
'https://db-amdis.org/aladdin2/api/'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycollisiondb-0.1.5.tar.gz (19.8 kB view hashes)

Uploaded Source

Built Distribution

pycollisiondb-0.1.5-py3-none-any.whl (14.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page