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 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 1 week 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.2.tar.gz (13.3 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.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asdcache-0.2.2.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for asdcache-0.2.2.tar.gz
Algorithm Hash digest
SHA256 227a18f09e8f800f818eafe55b1f58efd639224f2df22f47e5afb68bc4a3e481
MD5 6d3799e7d7c21ab9a8a955eb63bbfa9f
BLAKE2b-256 386331d47152eca0afbc3e920cade18d07024646986b948879a4b823b8e7312c

See more details on using hashes here.

Provenance

The following attestation bundles were made for asdcache-0.2.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: asdcache-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for asdcache-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 34f910f730f0f51e8fb5b365a9df61ff2c86126c806dee1565a29634ab6954d6
MD5 15a113697725be5d9a16982823fc744c
BLAKE2b-256 d5dc576f9068de90bb5a8a4ce41ba107bf5a52e939ccb0d715e00238faccc112

See more details on using hashes here.

Provenance

The following attestation bundles were made for asdcache-0.2.2-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