def ingest(self, spectra='h-uuo'): nist_download = download_ionization(spectra) ionization_data = parse_ionization_data(nist_download) for i, row in ionization_data.iterrows(): ion = Ion(ion_number=row.ion_number, ionization_energy=row.ionization_energy) ion.atom = self.atomic_db.session.query(Atom).filter_by( atomic_number=row.atomic_number).one() self.atomic_db.session.add(ion) self.atomic_db.session.commit()
def test_ions(raw_ions, atomic_database): ionization_string = \ raw_ions.set_index(['atomic_number', 'ion_number']).ix[(1, 0)][ 'ionization_string'].strip() energy = float(re.findall("\d+.\d+", ionization_string)[0]) testing.assert_almost_equal(energy, 13.5984, decimal=3) ionization_data = parse_ionization_data(raw_ions) assert list(ionization_data.columns._array_values()) == [u'atomic_number', u'ion_number', u'method', u'ionization_energy', u'ionization_energy_uncertainty'] ion_engery = ionization_data.set_index(['atomic_number', 'ion_number']).ix[(1, 0)][ 'ionization_energy'] testing.assert_almost_equal(ion_engery) NISTIonization(atomic_database).ingest() atomic_databasesession.query(Ion).filter(and_(Ion.ion_number == 1, Atom.id \ == 1))