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.3.tar.gz (14.6 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.3-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asdcache-0.2.3.tar.gz
  • Upload date:
  • Size: 14.6 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.3.tar.gz
Algorithm Hash digest
SHA256 64dc966dd2aaf8ce37fb618588dc66a361ba83617819dd2f24416f88fc7099a6
MD5 762c92173692feae1677e3c5d42bb920
BLAKE2b-256 d02580c75f425f9ee0ba1aed5c2770a90fe1f82c1271b01c71a9343974488467

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asdcache-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 14.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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4d56796b3b452079ad7c8516689afe2cc2fb4d9fe64aa1f0c97b2cce86c834f9
MD5 9bb47b3aa3b626649d4701772ef6efb0
BLAKE2b-256 708c55bedc519b83e0bff94f00708205ec7cce91c0ba82d49976b7b747875b11

See more details on using hashes here.

Provenance

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