Skip to main content

Access Xspec models and corresponding JAX/XLA ops.

Project description

xspex

PyPI - Python Version PyPI - Version License: GPL v3
Coverage Status

Access Xspec models and corresponding JAX/XLA ops, based on xspec_models_cxc and extending-jax.

Installation

Note: HEASoft & Xspec v12.12.1+ are required to be installed on your system. You can download it from here.

pip install xspex

Example

import jax
import jax.numpy as jnp
import numpy as np
import xspex

# For accuracy, it is recommended to enable double precision
jax.config.update('jax_enable_x64', True)

# Get APEC model primitive, whose JVP rule is defined by finite difference
apec, info = xspex.get_primitive('apec')

# Evaluate the model via JAX primitive
value = apec(
    params=jnp.array([1.0, 1.0, 0.0]),
    egrid=jnp.geomspace(0.1, 0.2, 6),
    spec_num=1,
)
print(value)  # [1.27358561 0.37946811 0.2477116  0.1071355  0.10049102]

# Evaluate the model function
value2 = xspex.apec(
    pars=np.array([1.0, 1.0, 0.0]),
    energies=np.geomspace(0.1, 0.2, 6),
)
print(value2)  # [1.27358561 0.37946811 0.2477116  0.1071355  0.10049102]

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

xspex-0.0.8.tar.gz (70.4 kB view details)

Uploaded Source

File details

Details for the file xspex-0.0.8.tar.gz.

File metadata

  • Download URL: xspex-0.0.8.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for xspex-0.0.8.tar.gz
Algorithm Hash digest
SHA256 cbecd42f885acdd8be8a9abaefd3e24b66d293df3c22427a6bde791bb90ffa4b
MD5 f2012088f4292f182a412f3703d77448
BLAKE2b-256 5291b53ede1f332e25dcc92b4351374a2e5bc3b312bcd3691abaeb2939e04052

See more details on using hashes here.

Provenance

The following attestation bundles were made for xspex-0.0.8.tar.gz:

Publisher: ci.yml on wcxve/xspex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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