PPTs logo

Table Of Contents

The ParaUtils module - Utility methods for paramagnetic observables

Introduction and notes

These are mainly utility methods to deal with Euler angles and rotation matricies.

API Documentation, Usage Examples and Doctests

Utility methods for paramagnetic observables

ParaUtils.ABGFromRotMatrixZXZ(rotMat)

Return the 3 Euler angles (A, B, G) in ZXZ from a given rotation matrix.

Parameters:
  • rotMat – The value for cos (radians)

Warning

This method is yet to be written. ZYZ is the favoured convention.

ParaUtils.ABGFromRotMatrixZYZ(rotMat)

Return the 3 Euler angles (A, B, G) in ZYZ from a given rotation matrix.

Parameters:
  • rotMat – The value for cos (radians)

Warning

At the present moment this method does not handle cases where the generated rotation matrix contains Euler angles at 0,90,180,270 or 360 degrees respectively. Need to look how Numbat handles this.

Example Usage/Doctests:

>>> import random
>>> from math import degrees
>>> rand_angles = []
>>> det_angles  = []
>>> for i in range(0, 10):
...    a,b,g = random.randint(271,359), random.randint(1,89),            random.randint(181,269)
...    rand_angles.append(a)
...    rand_angles.append(b)
...    rand_angles.append(g)
...    zyz = ZYZRot(a,b,g)
...    vals =  ABGFromRotMatrixZYZ(zyz)
...    for i in range (0, len(vals)):
...        det_angles.append(degrees((vals[i])))
...
>>> for i in range(0, len(det_angles)):
...    if round(det_angles[i], 0) != rand_angles[i]:
...        print 'fail'
...
ParaUtils.FixAngle(angle)

Return an angle such that it is [0:2pi] bound.

Useful as the angles determined from an optimization are not [0:2pi] bound

Parameters:
  • angle – An Euler angle determined from the optimization

Example Usage/Doctests:

>>> res = []
>>> test = [0.0, 100.0, 360.0, 361.0, 720.0, -100.0, -360.0, -361.0, -720.0]
>>> corr = [0.0, 100.0,   0.0,   1.0,   0.0,  260.0,    0.0,  359.0,    0.0]
>>> for i in range(0, len(test)):
...    res.append(FixAngle(test[i]))
...
>>> print res == corr
True
ParaUtils.FromVVU(AxorRh)

Return the Axial or Rhombic component converted from van Vleck units.

van Vleck units = m3/3.77 10-35, See: http://www.cerm.unifi.it/Downloads/Xplor/PARArestraints.pdf

Parameters:
  • AxorRh – Axial or Rhombic component of the X-tensor

:type AxorRh : float

ParaUtils.RotX90()

Returns the rotation matrix for a 90 degree rotation about X.

[[1, 0, 0], [0, 0, 1], [0, -1, 0]]

Used in UTR determination

Example Usage/Doctests:

>>> rx90 = RotX90()
>>> print rx90
[[ 1.  0.  0.]
 [ 0.  0.  1.]
 [ 0. -1.  0.]]
ParaUtils.RotY90()

Returns the rotation matrix for a 90 degree rotation about Y.

[[0, 0, -1], [0, 1, 0], [1, 0, 0]]

Used in UTR determination

Example Usage/Doctests:

>>> ry90 = RotY90()
>>> print ry90
[[ 0.  0. -1.]
 [ 0.  1.  0.]
 [ 1.  0.  0.]]
ParaUtils.RotZ90()

Returns the rotation matrix for a 90 degree rotation about Z.

[[0, 1, 0], [-1, 0, 0], [0, 0, 1]]

Used in UTR determination

Example Usage/Doctests:

>>> rz90 = RotZ90()
>>> print rz90
[[ 0.  1.  0.]
 [-1.  0.  0.]
 [ 0.  0.  1.]]
ParaUtils.ToVVU(AxorRh)

Return the Axial or Rhombic component converted to van Vleck units.

van Vleck units = m3/3.77 10-35, See: http://www.cerm.unifi.it/Downloads/Xplor/PARArestraints.pdf

Parameters:
  • AxorRh – Axial or Rhombic component of the X-tensor

:type AxorRh : float

ParaUtils.ZXZRot(A, B, G, scal=1.0)

Returns a ZXZ rotation matrix when given 3 Euler angles (in degrees).

See: http://mathworld.wolfram.com/EulerAngles.html

Parameters:
  • A – The (A)lpha angle (degrees)
  • B – The (B)eta angle (degrees)
  • G – The (G)amma angle (degrees)
  • scal – Scale the rotation matix by a constant [OPTIONAL]

Example Usage/Doctests:

>>> a,b,g = 0.0, 0.0, 0.0
>>> zxz = ZXZRot(a,b,g)
>>> print zxz
[[ 1.  0.  0.]
 [-0.  1.  0.]
 [ 0. -0.  1.]]
>>> #TODO: More complicated testing...
ParaUtils.ZYZRot(A, B, G, scal=1.0)

Returns a ZYZ rotation matrix when given 3 Euler angles (in degrees).

See: http://mathworld.wolfram.com/EulerAngles.html

Parameters:
  • A – The (A)lpha angle (degrees)
  • B – The (B)eta angle (degrees)
  • G – The (G)amma angle (degrees)
  • scal – Scale the rotation matix by a constant [OPTIONAL]

Example Usage/Doctests:

>>> a,b,g = 0.0, 0.0, 0.0
>>> zyz = ZYZRot(a,b,g)
>>> print zyz
[[ 1.  0. -0.]
 [-0.  1.  0.]
 [ 0.  0.  1.]]
>>> #TODO: More complicated testing...
ParaUtils.correctAngle(cosv, sinv)

Return an angle in correct quadrant given a cosine and sine of the angle.

Applies sin in [-pi/2, x, pi/2] and cos in [0, x, pi]

This agrees with Numbat code.

Parameters:
  • cosv – The value for cos (radians)
  • sinv – The value for sin (radians)

Example Usage/Doctests:

>>> import math
>>> cosL = [20, 110]
>>> sinL = [-70, -35, 35, 70 ]
>>> for c in range(0, len(cosL)):
...    for s in range(0, len(sinL)):
...        x = correctAngle(math.radians(cosL[c]), math.radians(sinL[s]))
...        print cosL[c],    sinL[s],        math.degrees(x)
20 -70 290.0
20 -35 325.0
20 35 35.0
20 70 70.0
110 -70 250.0
110 -35 250.0
110 35 110.0
110 70 110.0
ParaUtils.loadSession(inname)

Returns a ParaParser object -unpickle (re-initilize a saved session)

Parameters:
  • inname – the filename (& path), which the pickled object is stored
ParaUtils.lookupMGR(spin_type)

Return the gyromagnetic ratio(s) for the given spin type.

From: http://nmrwiki.org/wiki/index.php?title=Gyromagnetic_ratio

The values defined are consistent with those in Xplor-NIH.

Note

As ‘N’itrogen can be 14N or 15N both gyromagnetic ratios are returned in that order.

Note

This method really doesn’t belong here. Will be moved (perhaps to ParaParser) soon. If in ParaParser all parsed RDC sets will have a MGR lookup method...

Parameters:
  • spin_type – The atom identifier for the spin (can be H, C, N, O, or P)
ParaUtils.rdcScal(S, g1, g2, B0, temp)

Calculate the scaling constant.for the RDC calculation.

See: Journal of Biomolecular NMR, 22: 365-368, 2002 for an explaination.

Note

This method really doesn’t belong here. Will be moved (perhaps to ParaParser) soon. If in ParaParser all parsed RDC sets will have a MGR lookup method...

Parameters:
  • S – The order parameter. Defaults to 1.0
  • g1 – Gyromagnetic ratio for spin 1 in the RDC
  • g2 – Gyromagnetic ratio for spin 2 in the RDC
  • B0 – The magnetic field strength (in Tesla). Defaults to 18.8T
  • temp – The experimental temperature (in Kelvin). Defaults to 298K

Quirks/TODO