NIST Atomic Weights and Isotopic CompositionsΒΆ

This database provides atomic weights for elements 1 through 118 and isotopic compositions (abundances). Look here for the detailed description.

Initialize a database. In this document we’ll be using a memory database as an example.

In [1]:
from carsus import init_db
session = init_db("sqlite://")
session.commit()
Initializing the database
Ingesting basic atomic data

Create an ingester

In [2]:
from carsus.io.nist import NISTWeightsCompIngester
ingester = NISTWeightsCompIngester()

Use download() to download the data from the source. With the default arguments, only the data for the most common isotopes will be downloaded.

In [3]:
ingester.download()
Downloading the data from http://physics.nist.gov/cgi-bin/Compositions/stand_alone.pl

Use ingest() to persist the data into the database. Don’t forget to commit the session!

In [4]:
ingester.ingest(session)
session.commit()
Ingesting atomic weights

Now you have the data in your database. Currently only atomic weights are supported in carsus. To get them you can use this query:

In [5]:
from carsus.model import Atom, AtomicWeight
q = session.query(Atom, AtomicWeight).join(Atom.quantities.of_type(AtomicWeight))
for atom, weight in q[:5]:
    print "symbol: {}, atomic number: {}, weight: {}".format(atom.symbol, atom.atomic_number, weight.quantity)
symbol: H, atomic number: 1, weight: 1.007975 u
symbol: He, atomic number: 2, weight: 4.002602 u
symbol: Li, atomic number: 3, weight: 6.9675 u
symbol: Be, atomic number: 4, weight: 9.0121831 u
symbol: B, atomic number: 5, weight: 10.8135 u

You can also convert quanities to different units in queries:

In [6]:
from astropy import units as u
q = session.query(Atom, AtomicWeight.quantity.to(u.kg).value).\
    join(Atom.quantities.of_type(AtomicWeight))
for atom, weight_value in q[:5]:
    print "symbol: {}, atomic number: {}, weight: {}".format(atom.symbol, atom.atomic_number, weight_value*u.kg)
symbol: H, atomic number: 1, weight: 1.67378149613e-27 kg
symbol: He, atomic number: 2, weight: 6.6464755217e-27 kg
symbol: Li, atomic number: 3, weight: 1.15698033922e-26 kg
symbol: Be, atomic number: 4, weight: 1.4965078809e-26 kg
symbol: B, atomic number: 5, weight: 1.79562352324e-26 kg