Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic/atomic symbols #69

Merged
merged 4 commits into from
Jan 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tardis/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@

default_atom_h5_path = os.path.join(os.path.dirname(__file__), 'data', 'atom_data.h5')

def data_path(fname):
data_dir = os.path.join(os.path.dirname(__file__), 'data')
return os.path.join(data_dir, fname)

atomic_symbols_data = np.recfromtxt(data_path('atomic_symbols.dat'),
names=['atomic_number', 'symbol'])

symbol2atomic_number = OrderedDict(zip(atomic_symbols_data['symbol'], atomic_symbols_data['atomic_number']))
atomic_number2symbol = OrderedDict(atomic_symbols_data)


@PendingDeprecationWarning
def read_atomic_data(fname=None):
Expand Down
118 changes: 118 additions & 0 deletions tardis/data/atomic_symbols.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
1 H
2 He
3 Li
4 Be
5 B
6 C
7 N
8 O
9 F
10 Ne
11 Na
12 Mg
13 Al
14 Si
15 P
16 S
17 Cl
18 Ar
19 K
20 Ca
21 Sc
22 Ti
23 V
24 Cr
25 Mn
26 Fe
27 Co
28 Ni
29 Cu
30 Zn
31 Ga
32 Ge
33 As
34 Se
35 Br
36 Kr
37 Rb
38 Sr
39 Y
40 Zr
41 Nb
42 Mo
43 Tc
44 Ru
45 Rh
46 Pd
47 Ag
48 Cd
49 In
50 Sn
51 Sb
52 Te
53 I
54 Xe
55 Cs
56 Ba
57 La
58 Ce
59 Pr
60 Nd
61 Pm
62 Sm
63 Eu
64 Gd
65 Tb
66 Dy
67 Ho
68 Er
69 Tm
70 Yb
71 Lu
72 Hf
73 Ta
74 W
75 Re
76 Os
77 Ir
78 Pt
79 Au
80 Hg
81 Tl
82 Pb
83 Bi
84 Po
85 At
86 Rn
87 Fr
88 Ra
89 Ac
90 Th
91 Pa
92 U
93 Np
94 Pu
95 Am
96 Cm
97 Bk
98 Cf
99 Es
100 Fm
101 Md
102 No
103 Lr
104 Rf
105 Db
106 Sg
107 Bh
108 Hs
109 Mt
110 Ds
111 Rg
112 Cn
113 Uut
114 Fl
115 Uup
116 Lv
117 Uus
118 Uuo
6 changes: 6 additions & 0 deletions tardis/tests/test_atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ def test_atom_levels():
atom_data = atomic.AtomData.from_hdf5(atomic.default_atom_h5_path)
with pytest.raises(Exception):
raise Exception('test the atom_data thoroughly')

def test_atomic_symbol():
assert atomic.atomic_number2symbol[14] == 'Si'

def test_atomic_symbol_reverse():
assert atomic.symbol2atomic_number['Si'] == 14