Skip to main content

AtomDB python library. This is a very early development version.

Project description

PYATOMDB

This is pre-alpha release code. Many functions have just been ripped from my hard disk and not yet fully vetted. Possibly the most complete section is the “spectrum” module. Sample code is in the docs subfolder.

Installation

Standard python installation: python setup.py install

Version History

0.0.0.1 July 17th 2015: initial release

0.0.0.2 July 21st 2015: added dummyfirst keyword to pyatomdb.spectrum.make_spectrum

0.0.0.3 August 12th 2015: fixed some errors in spectrum.py. Updated readme.

0.0.0.4 August 12th 2015: fixed example script in manual.

0.0.0.5 August 17th 2015: added PI cross section graphing data. Updated get_data to fetch files from remote server

0.0.0.6 August 18th 2015: Fixed bug with documentation ============ Introduction ============

pyatomdb is a selection of utilities designed to interact with the AtomDB database. Currently, these utilities are in a far from finished format, however progress on this is ongoing. These have been taken from a series of codes on my laptop which were useful. Some produce lots of unhelpful onscreen output.

There are several different modules currently. These are:

  • atomdb : a series of codes for interacting with the AtomDB atomic database

  • atomic : basic atomic data routines - e.g. converting element symbols to atomic number, etc.

  • const : a series of physical constants

  • spectrum: routines for generating spectra from the published AtomDB line and continuum emissivity files

  • util : sumple utility codes (sorting etc) that pyatomdb relies on.

Currently, only the spectrum library has been extensively tested. Expect bugs. Report those bugs!

License

Pyatomdb is released under the Smithsonian License:

Copyright 2015 Smithsonian Institution. Permission is granted to use, copy, modify, and distribute this software and its documentation for educational, research and non-profit purposes, without fee and without a signed licensing agreement, provided that this notice, including the following two paragraphs, appear in all copies, modifications and distributions. For commercial licensing, contact the Office of the Chief Information Officer, Smithsonian Institution, 380 Herndon Parkway, MRC 1010, Herndon, VA. 20170, 202-633-5256.

This software and accompanying documentation is supplied “as is” without warranty of any kind. The copyright holder and the Smithsonian Institution: (1) expressly disclaim any warranties, express or implied, including but not limited to any implied warranties of merchantability, fitness for a particular purpose, title or non-infringement; (2) do not assume any legal liability or responsibility for the accuracy, completeness, or usefulness of the software; (3) do not represent that use of the software would not infringe privately owned rights; (4) do not warrant that the software is error-free or will be maintained, supported, updated or enhanced; (5) will not be liable for any indirect, incidental, consequential special or punitive damages of any kind or nature, including but not limited to lost profits or loss of data, on any basis arising from contract, tort or otherwise, even if any of the parties has been warned of the possibility of such loss or damage.

Usage

Interrogating the database

This makes use of the atomdb module. Before starting, it is a good idea to download the AtomDB tarballs from www.atomdb.org/Downloads: the latest one is version 3.0.2. This dataset contains the filemap, which identifies the correct files for each different ion and process.

It is also important to set the ATOMDB environment variable to point to where this data was untarred, e.g. the folder with the filemap in it, so $ATOMDB/filemap should exist. e.g:

bash: export ATOMDB=/myfolder/atomdb_v3.0.2
csh: setenv ATOMDB /myfolder/atomdb_v3.0.2

or within python:

import os
os.environ['ATOMDB']='/myfolder/atomdb_v3.0.2'

Currently, the AtomDB database is more than 10GB of data, so we are avoiding distributing it to all users. You can, however, get the individual data you need using the get_data routine:

lvdata = pyatomdb.atomdb.get_data(z0, z1, ftype)

This will try to open the file locally if it exists, and if it does not it will then go to the AtomDB FTP server and download the data for element z0, ion z1, with ftype a 2-character string denoting the type of data to get:

  • IR: ionization and recombination

  • LV: energy levels

  • LA: radiative transition data (lambda and A-values)

  • EC: electron collision data

  • PC: proton collision data

  • DR: dielectronic recombination satellite line data

  • PI: XSTAR photoionization data

  • AI: autoionization data

So to open the energy levels for oxygen with 2 electrons (O 6+, or O VII):

lvdata = pyatomdb.atomdb.get_data(8,7,'LV')

Data files are stored in $ATOMDB/APED/<elsymb>/<elsymb>_<ionnum>/

Making a Spectrum

These functions are in the spectrum module:

import pyatomdb, numpy, pylab

# set up a grid of energy bins to model the spectrum on:
ebins=numpy.linspace(0.3,10,1000)

# define a broadening, in keV, for the lines
de = 0.01

# define the temperature at which to plot (keV)
te = 3.0

# find the index which is closest to this temperature
ite = pyatomdb.spectrum.get_index( te, teunits='keV', logscale=False)

# create both a broadened and an unbroadened spectrum
a = pyatomdb.spectrum.make_spectrum(ebins, ite,dummyfirst=True)
b = pyatomdb.spectrum.make_spectrum(ebins, ite, broadening=de, \
                                    broadenunits='kev',dummyfirst=True)
# The dummyfirst argument adds an extra 0 at teh beginning of the
# returned array so it is the same length as ebins. It allows
# accurate plotting using the "drawstyle='steps'" flag to plot.

# plot the results
fig = pylab.figure()
fig.show()
ax = fig.add_subplot(111)

ax.loglog(ebins, a, drawstyle='steps', label='Unbroadened')
ax.loglog(ebins, b, drawstyle='steps', label='sigma = %.2f'%(de))
ax.set_xlabel('Energy (keV)')
ax.set_ylabel('Emissivity (ph cm$^{3}$ s$^{-1}$ bin$^{-1}$)')
ax.legend(loc=0)
pylab.draw()
zzz = raw_input("Press enter to continue")

print "Listing lines between 1 and 2 A"
# now list the lines in a wavelength region
llist = pyatomdb.spectrum.list_lines([1,2.0], index=ite)
# print these to screen
pyatomdb.spectrum.print_lines(llist)
# print to screen, listing the energy, not the wavelength
print "Listing lines between 1 and 2 A, using keV."

pyatomdb.spectrum.print_lines(llist, specunits = 'keV')

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

pyatomdb-0.0.0.6.tar.gz (46.1 kB view details)

Uploaded Source

File details

Details for the file pyatomdb-0.0.0.6.tar.gz.

File metadata

  • Download URL: pyatomdb-0.0.0.6.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyatomdb-0.0.0.6.tar.gz
Algorithm Hash digest
SHA256 8aca33387bde08c4b37faca5ce3a66a689e4aa66285c5a5e33a440af9d0f8d24
MD5 a7bf2ce3fd63514dec46955590b96ccc
BLAKE2b-256 c7d8cc7a43670f5288e0f24a21dbc4bb7a7b7334d1d3015d3c67988d203f53d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page