30 lines
759 B
Python
30 lines
759 B
Python
import os
|
|
os.environ['DJANGO_SETTINGS_MODULE'] ='isotables.settings'
|
|
|
|
import django
|
|
django.setup()
|
|
|
|
from isotopapp.models import Isotope
|
|
|
|
with open("../isotopetable.dat") as f:
|
|
for line in f:
|
|
if line.startswith("%") or line.startswith("proton"): continue
|
|
print(line)
|
|
a,b,c,d,e,f,g,h,i = line.split()
|
|
iso = Isotope.objects.create(
|
|
n_protons=int(a),
|
|
n_nucleons = int(b),
|
|
stable = True if c=="-" else False,
|
|
symbol = d,
|
|
name = e,
|
|
spin_quantum_number = float(f),
|
|
gamma = float(g)*7.622593285, # MHz/T
|
|
natural_abundance = float(h),
|
|
)
|
|
if i == "NaN":
|
|
iso.quadrupole_moment = float(i)
|
|
|
|
iso.save()
|
|
|
|
|