Skip to main content

A Python module to retrieve data from the NIST Atomic Spectra Database (ASD), using caching for fast, efficient data handling

Project description

ASDCache

ASDCache logo

DOI GitHub License GitHub Workflow Status build GitHub Workflow Status docs PyPI - Version PyPI - Python versions PyPI - Downloads Pepy Total Downloads Ruff Hatch project

ASDCache is a Python project to retrieve data from the NIST Atomic Spectra Database (ASD), using caching for fast, efficient data handling.

To make the most use out of the cache, ASDCache is opinionated in the information it retrieves from the ASD; it always requests the same schema of information and locally computes additional fields, to provide a more 'machine-useable' experience.

It also coerces most of the retrieved data to be of a strictly numeric type, which strips out footnotes and annotations, but preserves e.g. bibliographic reference labels.

You should thus still be sure to check and attribute the NIST ASD when making use of ASDCache!

The main goals and benefits of ASDCache are:

  • Make the data from the NIST ASD locally accessible as a Dataframe for use in analysis of spectra
  • Retrieve a consistent schema of the data that represents the 'human readable' format, but enforce strictly numeric data for important columns
    • This removes footnotes and other annotations, be sure to check the ASD itself as well for this information.
  • Use caching to dramatically speed up data retrieval, from minutes down to milliseconds in some cases
    • Cache time-to-live is two weeks by default, meaning you still get updates to the ASD in a reasonable time frame
    • The cache time-to-live can be adjusted
  • Cache data to allow working offline, or even transfering the ASD data to an offline system.
    • The cache is only updated when a request for new data succeeds
  • Limit repeated queries for the same information, avoiding network overhead and server load.

ASDCache is not affiliated with NIST or the NIST ASD in any way, it simply tries to help make it more accessible.

Installing

ASDCache can be installed with pip.

pip install ASDCache

Further optional features can be installed by specifying the polars or docs feature flag, as defined in pyproject.toml.

To install all dependencies to locally serve and update the documentation for instance, you can run:

pip install ASDCache[docs]

Installing the polars feature is not required, in case polars is already installed in the active environment, it is possible to use polars instead of pandas as a Dataframe backend for ASDCache.

Documentation

Documentation for ASDCache is available on this page.

Example

A brief example below demonstrates how to use SpectraCache to query the NIST ASD for spectroscopic data for different species and plot their respective relative intensities.

Note that these relative intensities are in principle not comparable between different species or sources and merely serve as a guide.

More elaborate examples can be found in the example section of the documentation

from ASDCache import SpectraCache, BibCache
import matplotlib.pyplot as plt

nist = ASDCache()
lines_H_I = nist.fetch("H I")


plt.plot(lines_H_I['obs_wl_air(nm)'], lines_H_I['intens'], label=f"{lines_H_I['element'].unique()[0]} {lines_H_I['sp_num'].unique()[0]}")


nist.fetch("O I-III") # caches data from NIST but does not assign to a variable

# Oxygen I-III will still be plotted, each ionization state separately.
lines_all_cached = nist.get_all_cached()
for species,lines in lines_all_cached.groupby(["element","sp_num"]):
    plt.plot(lines['obs_wl_air(nm)'], lines['intens'], label=f"{species[0]} {species[1]}", marker='x', ls='none')
plt.legend()

Citing

Be sure to cite the NIST ASD when using ASDCache in your work, since it is the source of the data.

ASDCache itself can be cited using the following DOI provided via Zenodo: 10.5281/zenodo.14673488

See also this page for more information

License

ASDCache is licensed under the MIT license.

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

asdcache-0.2.4.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asdcache-0.2.4-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file asdcache-0.2.4.tar.gz.

File metadata

  • Download URL: asdcache-0.2.4.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for asdcache-0.2.4.tar.gz
Algorithm Hash digest
SHA256 6e95f3be7cb3f83927dfecbb0a37c3eb64ae7c26fc8054817caa94b25609e39e
MD5 f293526dbaa793c49f1d660665fd20eb
BLAKE2b-256 6d56a1b2b3e85308778ea2e4f111c8000bcda045b460d95ab7165fdd1a0f0c16

See more details on using hashes here.

Provenance

The following attestation bundles were made for asdcache-0.2.4.tar.gz:

Publisher: build.yml on AntoineTUE/ASDCache

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

File details

Details for the file asdcache-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: asdcache-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for asdcache-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 93b581d108df16e23c314c14816eb81c840f814e9f6ec6cc25e579b996bab33b
MD5 80e9cf3b689a0966896b8d99893730c2
BLAKE2b-256 9e140d01b3901e332c77cb7ce08d6da8d46a284d7455d10178f9d05cc626a1e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for asdcache-0.2.4-py3-none-any.whl:

Publisher: build.yml on AntoineTUE/ASDCache

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