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@127.0.0.1/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.4.0

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.4.0
File Size Uploaded Provenance Actions
pycroxe-0.4.0.tar.gz 33.7 kB Without provenance Details for pycroxe-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 71.6 kB

Release files / pycroxe-0.4.0.tar.gz

Download URL pycroxe-0.4.0.tar.gz
Size 33.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b68a55ac929bbc275e432aeec579e43d69acbc7a76c65d2f7e42f6a031461daa
BLAKE2b-256 checksum
How to use checksums
cc0aab195ab5b7898db25da7aaed4a5cb364bf0df08dd198a9c579bdae717b28
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.4.0-py3-none-any.whl

Download URL pycroxe-0.4.0-py3-none-any.whl
Size 37.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b57737a01aa2ae8bcb3dcbd2e9fd28377f19300b6954f4f0003046d04d166ab8
BLAKE2b-256 checksum
How to use checksums
8fcf7d8da15eebec3b7d7efb0f8b589fa0d64390f286c51d5b9f3f2a52d7d059
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.4.0

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