Author: bugman
Date: Tue Nov 18 17:22:02 2014
New Revision: 26618
URL: http://svn.gna.org/viewcvs/relax?rev=26618&view=rev
Log:
Conversion of the basis_set argument for the align_tensor.svd user function.
The argument is now a string that accepts the values of 'unitary 9D', 'unitary
5D', and 'geometric
5D' to select between the different SVD matrices. This has been updated in the
test suite as well.
Modified:
trunk/pipe_control/align_tensor.py
trunk/test_suite/system_tests/scripts/n_state_model/5_state_xz.py
trunk/test_suite/unit_tests/_prompt/test_align_tensor.py
trunk/test_suite/unit_tests/align_tensor_testing_base.py
trunk/user_functions/align_tensor.py
Modified: trunk/pipe_control/align_tensor.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/align_tensor.py?rev=26618&r1=26617&r2=26618&view=diff
==============================================================================
--- trunk/pipe_control/align_tensor.py (original)
+++ trunk/pipe_control/align_tensor.py Tue Nov 18 17:22:02 2014
@@ -1626,10 +1626,26 @@
raise RelaxNoTensorError('alignment', tensor)
-def svd(basis_set=0, tensors=None):
- """Function for calculating the singular values of all the loaded tensors.
-
- The matrix on which SVD will be performed is::
+def svd(basis_set='unitary 9D', tensors=None):
+ """Calculate the singular values of all the loaded tensors.
+
+ The basis set can be set to one of:
+
+ 'unitary 9D', the unitary 9D basis set {Sxx, Sxy, Sxz, Syx, Syy, Syz,
Szx, Szy, Szz}. The is the only basis set which is a linear map, hence angles
are preserved.
+ 'unitary 5D', the unitary 5D basis set {Sxx, Syy, Sxy, Sxz, Syz}.
+ 'geometric 5D', the geometric 5D basis set {Szz, Sxxyy, Sxy, Sxz,
Syz}. This is also the Pales standard notation.
+
+ If the selected basis set is the default of 'unitary 9D', the matrix on
which SVD will be performed will be::
+
+ | Sxx1 Sxy1 Sxz1 Syx1 Syy1 Syz1 Szx1 Szy1 Szz1 |
+ | Sxx2 Sxy2 Sxz2 Syx2 Syy2 Syz2 Szx2 Szy2 Szz2 |
+ | Sxx3 Sxy3 Sxz3 Syx3 Syy3 Syz3 Szx3 Szy3 Szz3 |
+ | . . . . . . . . . |
+ | . . . . . . . . . |
+ | . . . . . . . . . |
+ | SxxN SxyN SxzN SyxN SyyN SyzN SzxN SzyN SzzN |
+
+ Otherwise if the selected basis set is 'unitary 5D', the matrix for SVD
is::
| Sxx1 Syy1 Sxy1 Sxz1 Syz1 |
| Sxx2 Syy2 Sxy2 Sxz2 Syz2 |
@@ -1639,9 +1655,7 @@
| . . . . . |
| SxxN SyyN SxyN SxzN SyzN |
- This is the default unitary basis set (selected when basis_set is 0).
Alternatively a geometric
- basis set consisting of the stretching and skewing parameters Szz and
Sxx-yy respectively
- replacing Sxx and Syy can be chosen by setting basis_set to 1. The matrix
in this case is::
+ Or if the selected basis set is 'geometric 5D', the stretching and skewing
parameters Szz and Sxx-yy will be used instead and the matrix is::
| Szz1 Sxxyy1 Sxy1 Sxz1 Syz1 |
| Szz2 Sxxyy2 Sxy2 Sxz2 Syz2 |
@@ -1656,14 +1670,19 @@
Szz = - Sxx - Syy,
Sxxyy = Sxx - Syy,
- The SVD values and condition number are dependendent upon the basis set
chosen.
-
-
- @param basis_set: The basis set to create the 5 by n matrix on which to
perform SVD.
- @type basis_set: int
- @param tensors: An array of tensors to apply SVD to. If None, all
tensors will be used.
- @type tensors: None or array of str
- """
+ The SVD values and condition number are dependant upon the basis set
chosen.
+
+
+ @param basis_set: The basis set to use for the SVD. This can be one of
'unitary 9D', 'unitary 5D' or 'geometric 5D'.
+ @type basis_set: str
+ @param tensors: The list of alignment tensor IDs to calculate
inter-matrix angles between. If None, all tensors will be used.
+ @type tensors: None or list of str
+ """
+
+ # Argument check.
+ allowed = ['unitary 9D', 'unitary 5D', 'geometric 5D']
+ if basis_set not in allowed:
+ raise RelaxError("The basis set of '%s' is not one of %s." %
(basis_set, allowed))
# Test that alignment tensor data exists.
if not hasattr(cdp, 'align_tensors') or len(cdp.align_tensors) == 0:
@@ -1677,7 +1696,10 @@
tensor_num = tensor_num + 1
# Create the matrix to apply SVD on.
- matrix = zeros((tensor_num, 5), float64)
+ if basis_set in ['unitary 9D']:
+ matrix = zeros((tensor_num, 9), float64)
+ else:
+ matrix = zeros((tensor_num, 5), float64)
# Pack the elements.
i = 0
@@ -1686,16 +1708,28 @@
if tensors and tensor.name not in tensors:
continue
- # Unitary basis set.
- if basis_set == 0:
+ # 5D unitary basis set.
+ if basis_set == 'unitary 9D':
+ matrix[i, 0] = tensor.Sxx
+ matrix[i, 1] = tensor.Sxy
+ matrix[i, 2] = tensor.Sxz
+ matrix[i, 3] = tensor.Sxy
+ matrix[i, 4] = tensor.Syy
+ matrix[i, 5] = tensor.Syz
+ matrix[i, 6] = tensor.Sxz
+ matrix[i, 7] = tensor.Syz
+ matrix[i, 8] = tensor.Szz
+
+ # 5D unitary basis set.
+ elif basis_set == 'unitary 5D':
matrix[i, 0] = tensor.Sxx
matrix[i, 1] = tensor.Syy
matrix[i, 2] = tensor.Sxy
matrix[i, 3] = tensor.Sxz
matrix[i, 4] = tensor.Syz
- # Geometric basis set.
- elif basis_set == 1:
+ # 5D geometric basis set.
+ elif basis_set == 'geometric 5D':
matrix[i, 0] = tensor.Szz
matrix[i, 1] = tensor.Sxxyy
matrix[i, 2] = tensor.Sxy
@@ -1715,12 +1749,12 @@
cdp.align_tensors.cond_num = s[0] / s[-1]
# Print out.
- sys.stdout.write("Basis set ")
- if basis_set == 0:
- sys.stdout.write("{Sxx, Syy, Sxy, Sxz, Syz}.\n")
- elif basis_set == 1:
- sys.stdout.write("{Szz, Sxx-yy, Sxy, Sxz, Syz}.\n")
- sys.stdout.write("Data pipe: %s\n" % pipes.cdp_name())
+ if basis_set == 'unitary 9D':
+ sys.stdout.write("SVD for the unitary 9D vectors {Sxx, Sxy, Sxz, Syx,
Syy, Syz, Szx, Szy, Szz}.\n")
+ elif basis_set == 'unitary 5D':
+ sys.stdout.write("SVD for the unitary 5D vectors {Sxx, Syy, Sxy, Sxz,
Syz}.\n")
+ elif basis_set == 'geometric 5D':
+ sys.stdout.write("SVD for the geometric 5D vectors {Szz, Sxx-yy, Sxy,
Sxz, Syz}.\n")
sys.stdout.write("\nSingular values:\n")
for val in s:
sys.stdout.write(" %.4e\n" % val)
Modified: trunk/test_suite/system_tests/scripts/n_state_model/5_state_xz.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/scripts/n_state_model/5_state_xz.py?rev=26618&r1=26617&r2=26618&view=diff
==============================================================================
--- trunk/test_suite/system_tests/scripts/n_state_model/5_state_xz.py
(original)
+++ trunk/test_suite/system_tests/scripts/n_state_model/5_state_xz.py Tue Nov
18 17:22:02 2014
@@ -28,8 +28,8 @@
self._execute_uf(uf_name='align_tensor.init', tensor='chi5 C-dom',
align_id='5', domain='C', params=(-1/2., -1/2., 3/8., 0., 0.))
# Calculate the singular values.
-self._execute_uf(uf_name='align_tensor.svd', basis_set=0, tensors=['chi1
C-dom', 'chi2 C-dom', 'chi3 C-dom', 'chi4 C-dom', 'chi5 C-dom'])
-self._execute_uf(uf_name='align_tensor.svd', basis_set=1, tensors=['chi1
C-dom', 'chi2 C-dom', 'chi3 C-dom', 'chi4 C-dom', 'chi5 C-dom'])
+self._execute_uf(uf_name='align_tensor.svd', basis_set='unitary 5D',
tensors=['chi1 C-dom', 'chi2 C-dom', 'chi3 C-dom', 'chi4 C-dom', 'chi5 C-dom'])
+self._execute_uf(uf_name='align_tensor.svd', basis_set='geometric 5D',
tensors=['chi1 C-dom', 'chi2 C-dom', 'chi3 C-dom', 'chi4 C-dom', 'chi5 C-dom'])
# Calculate the angles between the matrices.
self._execute_uf(uf_name='align_tensor.matrix_angles', basis_set='unitary 5D',
tensors=['chi1 C-dom', 'chi2 C-dom', 'chi3 C-dom', 'chi4 C-dom', 'chi5 C-dom'])
@@ -51,8 +51,8 @@
self._execute_uf(uf_name='align_tensor.reduction', full_tensor='chi5 C-dom',
red_tensor='chi5 N-dom')
# Calculate the singular values.
-self._execute_uf(uf_name='align_tensor.svd', basis_set=0, tensors=['chi1
N-dom', 'chi2 N-dom', 'chi3 N-dom', 'chi4 N-dom', 'chi5 N-dom'])
-self._execute_uf(uf_name='align_tensor.svd', basis_set=1, tensors=['chi1
N-dom', 'chi2 N-dom', 'chi3 N-dom', 'chi4 N-dom', 'chi5 N-dom'])
+self._execute_uf(uf_name='align_tensor.svd', basis_set='unitary 5D',
tensors=['chi1 N-dom', 'chi2 N-dom', 'chi3 N-dom', 'chi4 N-dom', 'chi5 N-dom'])
+self._execute_uf(uf_name='align_tensor.svd', basis_set='geometric 5D',
tensors=['chi1 N-dom', 'chi2 N-dom', 'chi3 N-dom', 'chi4 N-dom', 'chi5 N-dom'])
# Calculate the angles between the matrices.
self._execute_uf(uf_name='align_tensor.matrix_angles', basis_set='unitary 5D',
tensors=['chi1 N-dom', 'chi2 N-dom', 'chi3 N-dom', 'chi4 N-dom', 'chi5 N-dom'])
Modified: trunk/test_suite/unit_tests/_prompt/test_align_tensor.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_prompt/test_align_tensor.py?rev=26618&r1=26617&r2=26618&view=diff
==============================================================================
--- trunk/test_suite/unit_tests/_prompt/test_align_tensor.py (original)
+++ trunk/test_suite/unit_tests/_prompt/test_align_tensor.py Tue Nov 18
17:22:02 2014
@@ -329,12 +329,12 @@
# Loop over the data types.
for data in DATA_TYPES:
- # Catch the int and bin arguments, and skip them.
- if data[0] == 'int' or data[0] == 'bin':
- continue
-
- # The argument test.
- self.assertRaises(RelaxIntError, self.align_tensor_fns.svd,
basis_set=data[1])
+ # Catch the str argument, and skip it.
+ if data[0] == 'str':
+ continue
+
+ # The argument test.
+ self.assertRaises(RelaxStrError, self.align_tensor_fns.svd,
basis_set=data[1])
def test_svd_argfail_basis_tensors(self):
Modified: trunk/test_suite/unit_tests/align_tensor_testing_base.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/align_tensor_testing_base.py?rev=26618&r1=26617&r2=26618&view=diff
==============================================================================
--- trunk/test_suite/unit_tests/align_tensor_testing_base.py (original)
+++ trunk/test_suite/unit_tests/align_tensor_testing_base.py Tue Nov 18
17:22:02 2014
@@ -300,7 +300,7 @@
self.align_tensor_fns.init(align_id='5', params=(0, 0, 0, 0, 1),
param_types=0)
# SVD.
- self.align_tensor_fns.svd()
+ self.align_tensor_fns.svd(basis_set='unitary 5D')
# Test the values
self.assertEqual(dp.align_tensors.singular_vals[0], 1.0)
Modified: trunk/user_functions/align_tensor.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/user_functions/align_tensor.py?rev=26618&r1=26617&r2=26618&view=diff
==============================================================================
--- trunk/user_functions/align_tensor.py (original)
+++ trunk/user_functions/align_tensor.py Tue Nov 18 17:22:02 2014
@@ -415,13 +415,13 @@
uf.display = True
uf.add_keyarg(
name = "basis_set",
- default = 0,
- py_type = "int",
+ default = "unitary 9D",
+ py_type = "str",
desc_short = "basis set",
desc = "The basis set to operate with.",
wiz_element_type = "combo",
- wiz_combo_choices = ["{Sxx, Syy, Sxy, Sxz, Syz}", "{Szz, Sxxyy, Sxy, Sxz,
Syz}"],
- wiz_combo_data = [0, 1]
+ wiz_combo_choices = ["Unitary 9D {Sxx, Sxy, Sxz, ..., Szz}", "Unitary 5D
{Sxx, Syy, Sxy, Sxz, Syz}", "Geometric 5D {Szz, Sxxyy, Sxy, Sxz, Syz}"],
+ wiz_combo_data = ["unitary 9D", "unitary 5D", "geometric 5D"]
)
uf.add_keyarg(
name = "tensors",
@@ -435,32 +435,45 @@
)
# Description.
uf.desc.append(Desc_container())
-uf.desc[-1].add_paragraph("This will perform a singular value decomposition of
all tensors loaded for the current data pipe. If the basis set is set to the
default of 0, the matrix on which SVD will be performed is composed of the
unitary basis set {Sxx, Syy, Sxy, Sxz, Syz} layed out as:")
-uf.desc[-1].add_verbatim("""
+uf.desc[-1].add_paragraph("This will perform a singular value decomposition of
all tensors loaded for the current data pipe. The values are highly dependent
on the chosen basis set. This can be one of:")
+uf.desc[-1].add_item_list_element("'unitary 9D'", "The unitary 9D basis set
{Sxx, Sxy, Sxz, Syx, Syy, Syz, Szx, Szy, Szz}. The is the only basis set which
is a linear map, hence angles are preserved.")
+uf.desc[-1].add_item_list_element("'unitary 5D'", "The unitary 5D basis set
{Sxx, Syy, Sxy, Sxz, Syz}.")
+uf.desc[-1].add_item_list_element("'geometric 5D'", "The geometric 5D basis
set {Szz, Sxxyy, Sxy, Sxz, Syz}. This is also the Pales standard notation.")
+uf.desc[-1].add_paragraph("If the selected basis set is the default of
'unitary 9D', the matrix on which SVD will be performed will be:")
+uf.desc[-1].add_verbatim("""\
+ | Sxx1 Sxy1 Sxz1 Syx1 Syy1 Syz1 Szx1 Szy1 Szz1 |
+ | Sxx2 Sxy2 Sxz2 Syx2 Syy2 Syz2 Szx2 Szy2 Szz2 |
+ | Sxx3 Sxy3 Sxz3 Syx3 Syy3 Syz3 Szx3 Szy3 Szz3 |
+ | . . . . . . . . . |
+ | . . . . . . . . . |
+ | . . . . . . . . . |
+ | SxxN SxyN SxzN SyxN SyyN SyzN SzxN SzyN SzzN |\
+""")
+uf.desc[-1].add_paragraph("Otherwise if the selected basis set is 'unitary
5D', the matrix for SVD is:")
+uf.desc[-1].add_verbatim("""\
| Sxx1 Syy1 Sxy1 Sxz1 Syz1 |
| Sxx2 Syy2 Sxy2 Sxz2 Syz2 |
| Sxx3 Syy3 Sxy3 Sxz3 Syz3 |
| . . . . . |
| . . . . . |
| . . . . . |
- | SxxN SyyN SxyN SxzN SyzN |
+ | SxxN SyyN SxyN SxzN SyzN |\
""")
-uf.desc[-1].add_paragraph("If basis_set is set to 1, the geometric basis set
consisting of the stretching and skewing parameters Szz and Sxx-yy respectively
{Szz, Sxxyy, Sxy, Sxz, Syz} will be used instead. The matrix is:")
-uf.desc[-1].add_verbatim("""
+uf.desc[-1].add_paragraph("Or if the selected basis set is 'geometric 5D', the
stretching and skewing parameters Szz and Sxx-yy will be used instead and the
matrix is:")
+uf.desc[-1].add_verbatim("""\
| Szz1 Sxxyy1 Sxy1 Sxz1 Syz1 |
| Szz2 Sxxyy2 Sxy2 Sxz2 Syz2 |
| Szz3 Sxxyy3 Sxy3 Sxz3 Syz3 |
| . . . . . |
| . . . . . |
| . . . . . |
- | SzzN SxxyyN SxyN SxzN SyzN |
+ | SzzN SxxyyN SxyN SxzN SyzN |\
""")
uf.desc[-1].add_paragraph("The relationships between the geometric and unitary
basis sets are:")
-uf.desc[-1].add_verbatim("""
+uf.desc[-1].add_verbatim("""\
Szz = - Sxx - Syy,
- Sxxyy = Sxx - Syy,
+ Sxxyy = Sxx - Syy.\
""")
-uf.desc[-1].add_paragraph("The SVD values and condition number are dependent
upon the basis set chosen.")
uf.backend = align_tensor.svd
uf.menu_text = "s&vd"
uf.gui_icon = "oxygen.categories.applications-education"
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits