当前位置: 首页>>代码示例>>Python>>正文


Python MagresAtoms.load_magres方法代码示例

本文整理汇总了Python中magres.atoms.MagresAtoms.load_magres方法的典型用法代码示例。如果您正苦于以下问题:Python MagresAtoms.load_magres方法的具体用法?Python MagresAtoms.load_magres怎么用?Python MagresAtoms.load_magres使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在magres.atoms.MagresAtoms的用法示例。


在下文中一共展示了MagresAtoms.load_magres方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
    def test(self):
        from magres.atoms import MagresAtoms

        atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, 'ethanol-all.magres'))

        self.assertEqual(len(atoms), 9)

        for atom in atoms:
            "{} {}".format(atom, atom.ms.iso)

        atoms.species('H').set_reference(10.0)

        for atom in atoms.species('H'):
            "{} {}".format(atom, atom.ms.cs)

        for atom in atoms.within(atoms.C1, 2.0):
            "{} {}".format(atom, atom.ms.iso, atom.ms.aniso)

        self.assertEqual(len(atoms.species('H').ms.iso), 6)

        self.assertAlmostEqual(mean(atoms.C1.bonded.species('H').ms.iso), 29.9838078506)
        self.assertAlmostEqual(mean(atoms.C2.bonded.species('H').ms.iso), 28.7851386496)
        self.assertAlmostEqual(mean(atoms.O1.bonded.species('H').ms.iso), 31.9849757497)

        self.assertEqual(atoms.C1.ms.sigma.shape, (3, 3))
        self.assertEqual(len(atoms.C1.ms.evecs), 3)
        self.assertEqual(len(atoms.C1.ms.evals), 3)
开发者ID:tfgg,项目名称:magres-format,代码行数:29,代码来源:test_getting_started_cs.py

示例2: test_angles

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
 def test_angles(self):
   atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "angles/angles1.magres"))
   
   self.assertTrue(allclose(atoms.angle(atoms.C1, atoms.C2, atoms.C4, degrees=True), 45.0))
   self.assertTrue(allclose(atoms.angle(atoms.C1, atoms.C2, atoms.C6, degrees=True), 90.0))
   
   self.assertTrue(allclose(atoms.angle(atoms.C2, atoms.C1, atoms.C4), math.pi/2.0))
   self.assertTrue(allclose(atoms.angle(atoms.C2, atoms.C1, atoms.C6), math.pi/4.0))
开发者ID:davedavemckay,项目名称:magres-format,代码行数:10,代码来源:test_angles.py

示例3: test_labels

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
  def test_labels(self):
    atoms = MagresAtoms.load_magres(self.species)

    self.assertEquals(len(atoms), 3)
    self.assertEquals(len(atoms.label('H')), 1)
    self.assertEquals(len(atoms.label('C')), 0)
    self.assertEquals(len(atoms.label('C1')), 1)
    self.assertEquals(len(atoms.label('C2')), 1)
开发者ID:ccp9-community,项目名称:magres-format,代码行数:10,代码来源:test_atoms.py

示例4: test_replace_isc

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
  def test_replace_isc(self):
    atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol-isc.magres"))

    atoms.C2.isc[0].K

    with self.assertRaises(Exception):
      atoms.C2.isc[0].K = numpy.array([1,2,3])

    orig_iso = atoms.C2.isc[0].K_iso
    new_K = atoms.C2.isc[0].K * 2.0

    atoms.C2.isc[0].K = new_K
    
    self.assertEqual(atoms.C2.isc[0].K_iso, orig_iso * 2.0)
开发者ID:davedavemckay,项目名称:magres-format,代码行数:16,代码来源:test_isc.py

示例5: test_full_isc

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
  def test_full_isc(self):
    magres_files = [MagresFile(open(os.path.join(DATA_DIR, "ethanol", f))) for f in os.listdir(os.path.join(DATA_DIR, "ethanol")) if f.startswith('ethanol-jc')]

    self.assertEqual(len(magres_files), 9)

    atoms = MagresAtoms.load_magres(magres_files)

    for atom in atoms:
      self.assertTrue(hasattr(atom, "isc"))

    self.assertEqual(len(atoms.isc), len(atoms) * (len(atoms) - 1))

    # Check every atom has couplings to every other atom
    for atom in atoms:
      self.assertEqual(len(atom.isc), len(atoms)-1)
开发者ID:davedavemckay,项目名称:magres-format,代码行数:17,代码来源:test_isc.py

示例6: test_within_orthorhombic

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
    def test_within_orthorhombic(self):
        atoms = MagresAtoms.load_magres(self.orthorhombic)

        self.assertEqual(len(atoms), 1)

        p = atoms[0].position

        self.assertEqual(len(atoms.within(p, 1.0)), 3)

        num_within_3 = 0
        for atom in atoms.within(p, 10.0):
            if atom.dist(atoms[0]) <= 3.0:
                num_within_3 += 1

        self.assertEqual(len(atoms.within(p, 3.0)), num_within_3)
        self.assertEqual(len(atoms.within(p, 5.0).within(p, 2.0)), len(atoms.within(p, 2.0).within(p, 5.0)))
开发者ID:tfgg,项目名称:magres-format,代码行数:18,代码来源:test_atoms.py

示例7: test_replace_efg

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
  def test_replace_efg(self):
    """
      Check that we can replace the tensor on an atom.
    """

    atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol/ethanol-nmr.magres"))

    with self.assertRaises(Exception):
      atoms.C1.efg.V = numpy.array([1,2,3])

    orig_Cq = atoms.C1.efg.Cq
    new_V = atoms.C1.efg.V * 2.0

    atoms.C1.efg.V = new_V
    
    self.assertEqual(atoms.C1.efg.Cq, orig_Cq * 2.0)
开发者ID:davedavemckay,项目名称:magres-format,代码行数:18,代码来源:test_efg.py

示例8: test_efg

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
  def test_efg(self):
    atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol/ethanol-nmr.magres"))
    
    self.assertTrue(hasattr(atoms, "efg"))

    self.assertEqual(len(atoms.efg), 9)

    # Check that the EFGs are traceless
    for efg in atoms.efg:
      self.assertTrue(numpy.trace(efg.V)/3.0 < 1e-12)

    # Check that the principal components are ordered by the Haeberlen convention
    # |Vzz| >= |Vxx| >= |Vyy|
    for efg in atoms.efg:
      self.assertTrue(abs(efg.evals[2]) >= abs(efg.evals[0]))
      self.assertTrue(abs(efg.evals[0]) >= abs(efg.evals[1]))
开发者ID:davedavemckay,项目名称:magres-format,代码行数:18,代码来源:test_efg.py

示例9: test_isc

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
  def test_isc(self):
    atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol-isc.magres"))

    self.assertTrue(hasattr(atoms.C2, "isc"))
    self.assertTrue(hasattr(atoms.C2, "isc_orbital_p"))
    self.assertTrue(hasattr(atoms.C2, "isc_orbital_d"))
    self.assertTrue(hasattr(atoms.C2, "isc_spin"))
    self.assertTrue(hasattr(atoms.C2, "isc_fc"))

    self.assertEqual(len(atoms.C2.isc), len(atoms)-1)

    perturb_atom = atoms.get('C', 2)

    for isc in atoms.C2.isc:
      self.assertEqual(isc.atom1, perturb_atom)
      self.assertEqual(isc.K_iso, numpy.trace(isc.K)/3.0)
    
    # Check that the principal components are ordered by the Haeberlen convention
    for isc in atoms.C2.isc:
      self.assertTrue(abs(isc.K_evals[2] - isc.K_iso) >= abs(isc.K_evals[0] - isc.K_iso))
      self.assertTrue(abs(isc.K_evals[0] - isc.K_iso) >= abs(isc.K_evals[1] - isc.K_iso))
开发者ID:davedavemckay,项目名称:magres-format,代码行数:23,代码来源:test_isc.py

示例10: test_efg

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
    def test_efg(self):
        atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "ethanol/ethanol-nmr.magres"))

        self.assertTrue(hasattr(atoms, "efg"))

        self.assertEqual(len(atoms.efg), 9)

        # Check that the EFGs are traceless
        for efg in atoms.efg:
            self.assertTrue(numpy.trace(efg.V) / 3.0 < 1e-12)

        # Check that the principal components are ordered by the Haeberlen convention
        # |Vzz| >= |Vxx| >= |Vyy|
        for efg in atoms.efg:
            self.assertTrue(abs(efg.evals[2]) >= abs(efg.evals[0]))
            self.assertTrue(abs(efg.evals[0]) >= abs(efg.evals[1]))

        # Check that eta is positive and <=1 (Cq can be positive or negative)
        # eta = (Vxx - Vyy)/Vzz, 0 <= eta <= 1
        for efg in atoms.efg:
            self.assertTrue((efg.evals[1] - efg.evals[0]) / efg.evals[2] >= 0)
            self.assertTrue((efg.evals[1] - efg.evals[0]) / efg.evals[2] <= 1)
            self.assertTrue(efg.eta >= 0)
            self.assertTrue(efg.eta <= 1)
开发者ID:tfgg,项目名称:magres-format,代码行数:26,代码来源:test_efg.py

示例11: test_angles_boundary

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
 def test_angles_boundary(self):
   atoms = MagresAtoms.load_magres(os.path.join(DATA_DIR, "angles/angles1.magres"))
   
   self.assertTrue(allclose(atoms.angle(atoms.C2, atoms.C1, atoms.C3, degrees=True), 180.0))
   self.assertTrue(allclose(atoms.angle(atoms.C6, atoms.C1, atoms.C9, degrees=True), 90.0))
开发者ID:davedavemckay,项目名称:magres-format,代码行数:7,代码来源:test_angles.py

示例12: print

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
from __future__ import print_function
import sys
import math
import numpy
from magres.atoms import MagresAtoms

# Load T1Si0.magres sample into an atoms structure
atoms = MagresAtoms.load_magres("../samples/T1Si0.magres")

atomAl15 = atoms.get("Al", 15)

for atom in atoms.species("Al"):
    if atom == atomAl15:
        continue

    Vzz = atom.efg.evecs[2]
    dr = atom.position - atomAl15.position

    Vzz_dr_ang = math.acos(numpy.dot(Vzz, dr) / math.sqrt(numpy.dot(dr, dr) * numpy.dot(Vzz, Vzz)))

    print(atom, atom.efg.Cq, Vzz_dr_ang)
开发者ID:tfgg,项目名称:magres-format,代码行数:23,代码来源:atoms_efg.py

示例13:

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
from magres.atoms import MagresAtoms

atoms = MagresAtoms.load_magres('samples/simple.magres')

print atoms[0].position

Catoms = atoms.species('C')

print "1"
for atom in Catoms.within(atoms[0], 1.0):
  print atom, atom.position

print "5"
for atom in Catoms.within(atoms[0], 3.0):
  print atom, atom.position

print "5-1"
for atom in Catoms.within(atoms[0], 3.0).within(atoms[0], 1.0):
  print atom, atom.position

print "1-5"
for atom in Catoms.within(atoms[0], 1.0).within(atoms[0], 3.0):
  print atom, atom.position


开发者ID:ccp9-community,项目名称:magres-format,代码行数:25,代码来源:atoms_simple.py

示例14: Copyright

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
# -*- coding: utf-8 -*-

# =============================================================================
# Copyright (C) 2015 Christian Fernandez
# Laboratoire Catalyse et Spectrochimie, Caen, France.
# [email protected]
#
# This software is governed by the CeCILL-B license under French law
# and abiding by the rules of distribution of free software.
# You can  use, modify and/ or redistribute the software under
# the terms of the CeCILL-B license as circulated by CEA, CNRS and INRIA
# at the following URL "http://www.cecill.info".
#
# See Licence.txt in the main directory
# =============================================================================

"""Short description.

A longer description.

"""

from __future__ import print_function

from magres.atoms import MagresAtoms, MagresAtomsView
ethanol_atoms = MagresAtoms.load_magres('../samples/ethanol-all.magres')

ethanol_atoms.calculate_bonds()
开发者ID:tfgg,项目名称:magres-format,代码行数:30,代码来源:test_other.py

示例15: parse_atom_list

# 需要导入模块: from magres.atoms import MagresAtoms [as 别名]
# 或者: from magres.atoms.MagresAtoms import load_magres [as 别名]
atoms_filter_str = a.atoms

if atoms_filter_str:
  atoms_filter = parse_atom_list(atoms_filter_str)
else:
  atoms_filter = lambda x: True

tensors = ['ms']

lines = []

print "# Number\tAtom\tIso\tAniso\tAsym\tPath"

if os.path.isfile(a.source_dir):
  magres_atoms = [MagresAtoms.load_magres(a.source_dir)]
else:
  magres_atoms = load_all_magres(a.source_dir)

isos = {}

for iso_ in a.iso:
  num = re.findall('([0-9]+)', iso_)[0]
  sym = re.findall('([A-Za-z]+)', iso_)[0]

  isos[sym] = int(num)

for i, atoms in enumerate(magres_atoms):
  num = get_numeric(atoms.magres_file.path)

  for s, iso in isos.items():
开发者ID:davedavemckay,项目名称:magres-format,代码行数:32,代码来源:extract-ms.py


注:本文中的magres.atoms.MagresAtoms.load_magres方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。