Skip to content

Commit ab4409b

Browse files
committed
Link to notebook and website
1 parent c7c0378 commit ab4409b

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/scippneutron/atoms/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,23 @@ def _find_line_with_isotope(isotope: str, io: TextIO) -> str | None:
201201

202202

203203
def _load_atomic_weight(element: str) -> tuple[int, sc.Variable | None]:
204+
# The CSV file was extracted from https://www.ciaaw.org/abridged-atomic-weights.htm
205+
# using the notebook in tools/atomic_weights.ipynb (in the ScippNeutron repo).
204206
with _open_bundled_parameters_file('atomic_weights.csv') as f:
207+
f.readline() # skip copyright
208+
f.readline() # skip header
205209
if line_remainder := _find_line_with_isotope(element, f):
206210
z, weight, error = line_remainder.rstrip().split(',')
207211
return int(z), _assemble_scalar(weight, error, 'Da')
208212
raise ValueError(f"No entry for element '{element}'")
209213

210214

211215
def _load_atomic_mass(isotope: str) -> sc.Variable | None:
216+
# The CSV file was extracted from https://www.ciaaw.org/atomic-masses.htm
217+
# using the notebook in tools/atomic_weights.ipynb (in the ScippNeutron repo).
212218
with _open_bundled_parameters_file('atomic_masses.csv') as f:
219+
f.readline() # skip copyright
220+
f.readline() # skip header
213221
if line_remainder := _find_line_with_isotope(isotope, f):
214222
weight, error = line_remainder.rstrip().split(',')
215223
return _assemble_scalar(weight, error, 'Da')

src/scippneutron/atoms/atomic_masses.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Numbers extracted using tools/atomic_weights.ipynb from https://www.ciaaw.org/atomic-masses.htm
12
Isotope,Atomic Mass [Da],Uncertainty [Da]
23
100Ag,99.916115443,0.000005367
34
100Cd,99.920348829,0.000001800

src/scippneutron/atoms/atomic_weights.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Numbers extracted using tools/atomic_weights.ipynb from https://www.ciaaw.org/abridged-atomic-weights.htm
12
Element,Z,Atomic Weight [Da],Uncertainty [Da]
23
H,1,1.008,0.0002
34
He,2,4.0026,0.0001

tools/atomic_weights.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
"outputs": [],
146146
"source": [
147147
"with open('atomic_weights.csv', 'w') as f:\n",
148+
" f.write(\"# Numbers extracted using tools/atomic_weights.ipynb from https://www.ciaaw.org/abridged-atomic-weights.htm\")\n",
148149
" f.write(\"Element,Z,Atomic Weight [Da],Uncertainty [Da]\\n\")\n",
149150
" for (symbol, z, weight, error) in atoms:\n",
150151
" if weight is None:\n",
@@ -207,10 +208,12 @@
207208
"metadata": {},
208209
"outputs": [],
209210
"source": [
210-
"latest.to_csv('atomic_masses.csv',\n",
211-
" columns=['mass', 'uncertainty'],\n",
212-
" index_label=\"Isotope\",\n",
213-
" header=[\"Atomic Mass [Da]\", \"Uncertainty [Da]\"])"
211+
"with open('atomic_masses.csv', 'w') as f:\n",
212+
" f.write(\"# Numbers extracted using tools/atomic_weights.ipynb from https://www.ciaaw.org/atomic-masses.htm\")\n",
213+
" latest.to_csv(f,\n",
214+
" columns=['mass', 'uncertainty'],\n",
215+
" index_label=\"Isotope\",\n",
216+
" header=[\"Atomic Mass [Da]\", \"Uncertainty [Da]\"])"
214217
]
215218
}
216219
],

0 commit comments

Comments
 (0)