Skip to main content

Welcome to PyCroXe

The Python API that let you import data from CroXe, with intuitive calls and minimal effort.

If you are looking for the database itself, visit: https://codeberg.org/Kruayd/CroXe.

Table of contents

Installation

PyCroXe is publicly available on PyPI, so you can just:

pip install pycroxe

Example usage

tl;dr

import numpy as np
from pycroxe import connect, get_species_properties
from pycroxe.beam import get_cross_sections_by_projectiles

energies = np.geomspace(10, 1e5, 200) # energies in eV

with connect() as conn:
    sigma = get_cross_sections_by_projectiles(
        conn,
        energies,
        initial_projectiles=["H3+", "H2+", "H+"],
        target="H2",
    )

    species_data = get_species_properties(
        conn,
        symbols=sigma.coords["product"].to_numpy().tolist(),
    )

But please, find some time to read the rest of this README or the official docs!

Connecting

PyCroXe provides a connect function that can be used, as the name obviously suggests, to connect to any network-reachable instance of CroXe.

The intended usage is within a with statement; this will make connect, if no argument is provided, return an instance of a CroXeConnection class, acting as a context manager, with an open connection pointing towards the default URL mariadb+mariadbconnector://croxe-guest@localhost/CroXe:

from pycroxe import connect

with connect() as conn:
    ...

PyCroXe URLs follow the SQLAlchemy pattern (dialect+driver://username@host:port/database) and can be provided to the connect function, in order of descending precedence, by:

  1. directly passing them as argument

    with connect(
        "mariadb+mariadbconnector://user@server.institute.org/CroXe"
    ) as conn:
        ...
    
  2. setting up the environment variable CROXE_DB

    # if using bash
    export CROXE_DB="mysql+pymysql://user@server.institute.org/CroXe"
    
  3. changing specific parts of the default URL with keyword arguments

    with connect(
         host="server.institute.org",
         user="user",
         connector="mariadb+mariadbconnector",
         database="CroXe_2_electric_boogaloo"
    ) as conn:
         ...
    

Retrieving species properties

Function get_species_properties will return a xarray Dataset of properties of all the species stored in CroXe. If given the symbols keyword argument, data will be limited only to the chosen species:

from pycroxe import connect, get_species_properties

with connect() as conn:
    species_data = get_species_properties(
        conn,
        symbols=["H+", "H2"],
    )

Retrieving beam-on-target processes cross-sections

PyCroXe provides the beam module, which in turn provides the get_cross_sections_by_projectiles function. get_cross_sections_by_projectiles will first recursively find all processes that may derive from the given list of initial projectile species, and then return a 3D tensor of evaluated cross-sections, in the form of a xarray DataArray, with first dimension indexing energy values, the second indexing product species, and the last one indexing projectiles:

import numpy as np
from pycroxe import connect
from pycroxe.beam import get_cross_sections_by_projectiles

energies = np.geomspace(10, 1e5, 200) # energies in eV

with connect() as conn:
    sigma = get_cross_sections_by_projectiles(
        conn,
        energies,
        initial_projectiles=["H3+", "H2+", "H+"],
        target="H2",
    )

Full documentation

You can find the full documentation at https://pycroxe.readthedocs.io.

Contributing

Right now you can suggest changes through e-mail, but soon some more standard ways of contributing will be available.

License

PyCroXe is free as in freedom and licensed under the GPL v3.

Metadata

Release files for pycroxe 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycroxe 0.3.1
File Size Uploaded Provenance Actions
pycroxe-0.3.1.tar.gz 33.6 kB Without provenance Details for pycroxe-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycroxe 0.3.1
File Interpreter ABI Platform Actions
pycroxe-0.3.1-py3-none-any.whl Python 3 none any Details for pycroxe-0.3.1-py3-none-any.whl

Total release size: 71.4 kB

Release files / pycroxe-0.3.1.tar.gz

Download URL pycroxe-0.3.1.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7763f5486f48d40530cf8c7bc365859ebe89a8a9641645b9e0711730740d7121
BLAKE2b-256 checksum
How to use checksums
7a8653cb2e9d570997a8eb5a78644bde74686d4f6c50a9f5a3e0de39b7be890f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / pycroxe-0.3.1-py3-none-any.whl

Download URL pycroxe-0.3.1-py3-none-any.whl
Size 37.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4abe1a0e07df9742831e62b693a58f6596c0de5b625fc7af117395e1b45dfe5
BLAKE2b-256 checksum
How to use checksums
e69c9b0eee8405728505244ffaff2830dbf9a7480ab19fc8e2abc333b896d46d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for pycroxe 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page