Skip to main content

xspectrampoline

Installing the XSPEC model library can be as easy as

pip install xspectrampoline

and that's what this package provides.

Usage

This package is indented only for providing the XSPEC model binaries, and is not a wrapper around the model library. The minimal wrapper code that exists is code you would have to write anyway, but beyond that there may are too many ways the models could be put together for Python usage. That's an exercise left to the reader.

Whilst you think about that, here's how you can use xspectrampoline

# Importing calls FNINIT in the libXS
import xspectrampoline

# Get a handle to the minimal wrapper
lib_xspec = xspectrampoline.get_libraries()

# Get the function by the symbol name
powerlaw = lib_xspec.get_model("C_powerlaw")

# Setup an energy, parameter, and output arrays
energy = np.linspace(0.01, 10.0, 100, dtype=np.float64)
parameters = np.array([3.0], dtype=np.float64)
output = np.zeros(len(energy) - 1, dtype=np.float64)
error = np.zeros(len(energy) - 1, dtype=np.float64)

# Invoke the model
powerlaw(energy, parameters, output, error)

# Then do things with `output`
...

Overwriting which libraries are used

By default xspectrampoline bundles everything that is needed to use the XSPEC model library. But what if you already have HEASOFT / XSPEC installed and want to use your local version? xspectrampoline checks if the HEADAS environment variable is set and determines the library locations accordingly. If you want to use your local version, just make sure HEADAS points to the right location and your linker paths are configured via headinit.

xspectrampoline sets the HEADAS environment variable if it's not already set. You can also access the path it uses to resolve the libraries using

import xspectrampoline

headas_path = xspectrampoline.get_HEADAS()
print(headas_path)

How does it work

This package is possible all thanks to Julia's BinaryBuilder.jl who have done all the hard work for making compiled libraries relatively easy to share around. The XSPEC model library was cross compiled into LibXSPEC_jll.jl for Linux and MacOS, and xspectrampoline is basically those artifacts bundled for distribution with Python.

For developers

To bundle things locally, ensure you have setuptools, wheel, and build installed:

python3 -m pip install --upgrade setuptool wheel build

You can then use the Makefile targets to automate the build commands. The Makefile fetches the BinaryBuilder.jl artifacts, unpacks them, and runs the necessary Python packaging commands to create the wheels. Those will then be available under ./dist in your local directory.

make

You can test the packaging by installing from the wheel:

python -m pip install ./dist/xspectrampoline-0.1.0-py3-none-linux_x86_64.whl

selecting the correct platform tag as needed.

There are also handy targets for doing this:

make install    # install the wheel on your system

make clean      # delete all files (include dist) that were generating during
                # the packaging process

Testing locally

Because you need to test the locally installed version of xspectrampoline, you need to make sure you run pytest outside of the root directory. After you've installed the wheel, the easiest way to do this is

cd test && pytest -vvv .

Metadata

Release files for xspectrampoline 0.1.5

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

Built distributions (wheels)

Table of built distributions (wheels) for xspectrampoline 0.1.5
File
xspectrampoline-0.1.5-py3-none-manylinux_2_24_x86_64.whl Python 3 none Linux glibc 2.24+ x86-64 Details
xspectrampoline-0.1.5-py3-none-macosx_15_0_arm64.whl Python 3 none macOS 15.0+ ARM64 Details
xspectrampoline-0.1.5-py3-none-macosx_14_0_x86_64.whl Python 3 none macOS 14.0+ x86-64 Details
xspectrampoline-0.1.5-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details

Total release size: 95.9 MB

Release files / xspectrampoline-0.1.5-py3-none-manylinux_2_24_x86_64.whl

Download URL xspectrampoline-0.1.5-py3-none-manylinux_2_24_x86_64.whl
Size 63.5 MB
Tags Linux glibc 2.24+ x86-64 Python 3
SHA-256 checksum
How to use checksums
fd1437c43b4d9bbb7006be88bd6edf716b56d41153ce6fd20992b4fcaa28fd9c
BLAKE2b-256 checksum
How to use checksums
15643fdb22eb2d7e3948909826f41a20fef996e28d71f35746cb687bb943d567
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / xspectrampoline-0.1.5-py3-none-macosx_15_0_arm64.whl

Download URL xspectrampoline-0.1.5-py3-none-macosx_15_0_arm64.whl
Size 10.3 MB
Tags Python 3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
7e2e9c9c5e61d1b172b9bdb1260b07703f238eb87365b3acc0250ac0a475a423
BLAKE2b-256 checksum
How to use checksums
afc28cd05e524dedd9057e28e2ac9fef6b273bf66ad0a16310be5267b58e2b0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / xspectrampoline-0.1.5-py3-none-macosx_14_0_x86_64.whl

Download URL xspectrampoline-0.1.5-py3-none-macosx_14_0_x86_64.whl
Size 11.8 MB
Tags Python 3 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
03912b247d89e571bcb817a5e6f93312c281276466ddd5829d10de2fc3cc079e
BLAKE2b-256 checksum
How to use checksums
f0e08bcff6172d8b4127e55816e40b45320445625e81b30d53f971e61ce334e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / xspectrampoline-0.1.5-py3-none-macosx_14_0_arm64.whl

Download URL xspectrampoline-0.1.5-py3-none-macosx_14_0_arm64.whl
Size 10.3 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
2210c4b5cf56f746779e5744bfb592d7abf90db517fffe2c2149f1e9622c007d
BLAKE2b-256 checksum
How to use checksums
210c6cd43a50cc2d43666d696f68495b7cdfd25d13067f5ed65e7a752b55785b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.1.5 This release

4 release files

0.1.3

4 release files

0.1.2

3 release files

0.1.1

4 release files

0.1.0

2 release files

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