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.0.tar.gz (12.7 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.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asdcache-0.2.0.tar.gz
  • Upload date:
  • Size: 12.7 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.0.tar.gz
Algorithm Hash digest
SHA256 2c73bec544ab8a6f4ae28e18a4859307d430ba7af27e190cf63f0fc78c464025
MD5 a40be07e3c5b860a0430aeb1b718d5b3
BLAKE2b-256 29f2a6a10b040064c12ed544dc694310d10f8d1599caff6a9e357e5ecbb3bac1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asdcache-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 186177516b2a6f534a5033c70267fe039404fb71cd2560f33e26e45822cf7ff5
MD5 c3098f499b19dd2a9fe04c86e7e0ab58
BLAKE2b-256 0aaf1240a35499f833c4721522e8d260855aa8ff8e9e41d0af1bfd7d3b7478f0

See more details on using hashes here.

Provenance

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