def __init__(self): self._angle_dict = {} f = open(context.get_fn('toyff_angles.txt')) for line in f: if line[0] != '#': key = tuple(int(word) for word in line[0:line.index(':')].split(",")) value = numpy.pi/180.0*float(line[line.index(':')+1:-1]) self._angle_dict[key] = value
def __init__(self): self._angle_dict = {} f = open(context.get_fn('toyff_angles.txt')) for line in f: if line[0] != '#': key = tuple( int(word) for word in line[0:line.index(':')].split(",")) value = numpy.pi / 180.0 * float(line[line.index(':') + 1:-1]) self._angle_dict[key] = value
f = file(filename) for i in xrange(39): f.next() for line in f: N = int(line[5:10]) Z = int(line[10:15]) mass = float(line[96:114].replace(" ", "").replace( "#", "")) * 1e-6 * amu add_mass(N, Z, mass) f.close() ame2003 = Ame2003(context.get_fn("mass.mas03")) class NubTab03(object): """An interface to a subset of the data that from NubTab03. This object contains an attribute abundances. This is a dictionary whose keys are the proton numbers (Z) and values are the corresponding values are again dictionaries. The latter dictionaries have the mass number (A) as keys and the corresponding isotope abundances as values. E.g. self.masses[6][12] is the abundance of carbon 12. If you use this interface, cite the following reference: The NUBASE evaluation of nuclear and decay properties. G. Audi, O. Bersillon, J. Blachot and A.H. Wapstra, Nuclear Physics A729, 3-128 (2003)
n_masses[Z+N] = mass f = file(filename) for i in xrange(39): f.next() for line in f: N = int(line[ 5:10]) Z = int(line[10:15]) mass = float(line[96:114].replace(" ", "").replace("#", ""))*1e-6*amu add_mass(N, Z, mass) f.close() ame2003 = Ame2003(context.get_fn("mass.mas03")) class NubTab03(object): """An interface to a subset of the data that from NubTab03. This object contains an attribute abundances. This is a dictionary whose keys are the proton numbers (Z) and values are the corresponding values are again dictionaries. The latter dictionaries have the mass number (A) as keys and the corresponding isotope abundances as values. E.g. self.masses[6][12] is the abundance of carbon 12. If you use this interface, cite the following reference: The NUBASE evaluation of nuclear and decay properties. G. Audi, O. Bersillon, J. Blachot and A.H. Wapstra, Nuclear Physics A729, 3-128 (2003)
if result is None: result = bond_type deviation = abs(bond_length - distance) else: new_deviation = abs(bond_length - distance) if deviation > new_deviation: result = bond_type deviation = new_deviation return result def get_length(self, n1, n2, bond_type=BOND_SINGLE): """Return the length of a bond between n1 and n2 of type bond_type Arguments: | ``n1`` -- the atom number of the first atom in the bond | ``n2`` -- the atom number of the second atom the bond Optional argument: | ``bond_type`` -- the type of bond [default=BOND_SINGLE] This is a safe method for querying a bond_length. If no answer can be found, this get_length returns None. """ dataset = self.lengths.get(bond_type) if dataset == None: return None return dataset.get(frozenset([n1, n2])) bonds = BondData(context.get_fn("bonds.csv"))
def _add_atom_info(self, atom_info): """Add an atom info object to the database""" self.atoms_by_number[atom_info.number] = atom_info self.atoms_by_symbol[atom_info.symbol.lower()] = atom_info def __len__(self): return len(self.atoms_by_symbol) def __getitem__(self, index): result = self.atoms_by_number.get(index) if (result is None) and isinstance(index, basestring): return self.atoms_by_symbol.get(index.lower()) else: return result def iter_numbers(self): """Iterate over all atom numbers in the periodic system Usage:: >>> from molmod.periodic import periodic >>> for number in periodic.iter_numbers(): ... print number, periodic[number].mass """ for number in sorted(self.atoms_by_number): yield number periodic = PeriodicData(context.get_fn("periodic.csv"))