Package test_suite :: Package system_tests :: Module frame_order
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.frame_order

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax is free software; you can redistribute it and/or modify               # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation; either version 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax is distributed in the hope that it will be useful,                    # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from math import acos, pi 
 25  import platform 
 26  import numpy 
 27  from numpy import array, dot, float64, zeros 
 28  from numpy.linalg import norm 
 29  from re import search 
 30  from os import sep 
 31  import sys 
 32   
 33  # relax module imports. 
 34  from base_classes import SystemTestCase 
 35  from data import Relax_data_store; ds = Relax_data_store() 
 36  import dep_check 
 37  from maths_fns.coord_transform import spherical_to_cartesian 
 38  from maths_fns.rotation_matrix import euler_to_R_zyz 
 39  from physical_constants import N15_CSA, NH_BOND_LENGTH 
 40  from relax_io import DummyFileObject, open_read_file 
 41  from status import Status; status = Status() 
 42   
 43   
 44  # Get the platform information. 
 45  SYSTEM = platform.system() 
 46  RELEASE = platform.release() 
 47  VERSION = platform.version() 
 48  WIN32_VER = platform.win32_ver() 
 49  DIST = platform.dist() 
 50  ARCH = platform.architecture() 
 51  MACH = platform.machine() 
 52  PROC = platform.processor() 
 53  PY_VER = platform.python_version() 
 54  NUMPY_VER = numpy.__version__ 
 55  LIBC_VER = platform.libc_ver() 
 56   
 57  # Windows system name pain. 
 58  if SYSTEM == 'Windows' or SYSTEM == 'Microsoft': 
 59      # Set the system to 'Windows' no matter what. 
 60      SYSTEM = 'Windows' 
 61   
 62   
 63   
64 -class Frame_order(SystemTestCase):
65 """TestCase class for the functional tests of the frame order theories.""" 66
67 - def __init__(self, methodName='runTest'):
68 """Skip the tests if scipy is not installed. 69 70 @keyword methodName: The name of the test. 71 @type methodName: str 72 """ 73 74 # Missing module. 75 if not dep_check.scipy_module: 76 # Store in the status object. 77 status.skipped_tests.append([methodName, 'Scipy', 'system']) 78 79 # Execute the base class method. 80 super(Frame_order, self).__init__(methodName)
81 82
83 - def setUp(self):
84 """Set up for all the functional tests.""" 85 86 # Create the data pipe. 87 self.interpreter.pipe.create('test', 'frame order')
88 89
90 - def mesg_opt_debug(self):
91 """Method for returning a string to help debug the minimisation. 92 93 @return: The debugging string. 94 @rtype: str 95 """ 96 97 # Initialise the string. 98 string = 'Optimisation failure.\n\n' 99 100 # Create the string. 101 string = string + "%-18s%-25s\n" % ("System: ", SYSTEM) 102 string = string + "%-18s%-25s\n" % ("Release: ", RELEASE) 103 string = string + "%-18s%-25s\n" % ("Version: ", VERSION) 104 string = string + "%-18s%-25s\n" % ("Win32 version: ", (WIN32_VER[0] + " " + WIN32_VER[1] + " " + WIN32_VER[2] + " " + WIN32_VER[3])) 105 string = string + "%-18s%-25s\n" % ("Distribution: ", (DIST[0] + " " + DIST[1] + " " + DIST[2])) 106 string = string + "%-18s%-25s\n" % ("Architecture: ", (ARCH[0] + " " + ARCH[1])) 107 string = string + "%-18s%-25s\n" % ("Machine: ", MACH) 108 string = string + "%-18s%-25s\n" % ("Processor: ", PROC) 109 string = string + "%-18s%-25s\n" % ("Python version: ", PY_VER) 110 string = string + "%-18s%-25s\n" % ("Numpy version: ", NUMPY_VER) 111 string = string + "%-18s%-25s\n" % ("Libc version: ", (LIBC_VER[0] + " " + LIBC_VER[1])) 112 113 114 # Minimisation info. 115 string = string + "\n%-15s %30.17g\n" % ('ave_pos_alpha:', cdp.ave_pos_alpha) 116 string = string + "%-15s %30.17g\n" % ('ave_pos_beta:', cdp.ave_pos_beta) 117 string = string + "%-15s %30.17g\n" % ('ave_pos_gamma:', cdp.ave_pos_gamma) 118 string = string + "%-15s %30.17g\n" % ('chi2:', cdp.chi2) 119 string = string + "%-15s %30i\n" % ('iter:', cdp.iter) 120 string = string + "%-15s %30i\n" % ('f_count:', cdp.f_count) 121 string = string + "%-15s %30i\n" % ('g_count:', cdp.g_count) 122 string = string + "%-15s %30i\n" % ('h_count:', cdp.h_count) 123 string = string + "%-15s %30s\n" % ('warning:', cdp.warning) 124 125 # Return the string. 126 return string
127 128
129 - def space_probe(self, ref_chi2=None, params=None, delta=3.0 / 360.0 * 2.0 * pi):
130 """Probe the space around the supposed minimum.""" 131 132 # No function intros. 133 self.interpreter.intro_off() 134 135 # Check the minimum. 136 self.interpreter.calc() 137 print("%-20s %10.5f" % ("chi2 minimum", cdp.chi2)) 138 self.assertAlmostEqual(cdp.chi2, ref_chi2) 139 140 # Test around the minimum using small deviations. 141 for param in params: 142 print("\n\nParam: %s" % param) 143 print("%-20s %10.5f" % ("chi2 orig", ref_chi2)) 144 145 # Get the current value. 146 curr = getattr(cdp, param) 147 148 # Deviate upwards. 149 setattr(cdp, param, curr+delta) 150 self.interpreter.calc() 151 print("%-20s %10.5f" % ("chi2 up", cdp.chi2)) 152 self.assert_(cdp.chi2 > ref_chi2) 153 154 # Deviate downwards. 155 setattr(cdp, param, curr-delta) 156 self.interpreter.calc() 157 print("%-20s %10.5f" % ("chi2 down", cdp.chi2)) 158 self.assert_(cdp.chi2 > ref_chi2) 159 160 # Reset. 161 setattr(cdp, param, curr)
162 163
164 - def test_cam_free_rotor(self):
165 """Test the free rotor frame order model of CaM.""" 166 167 # Execute the script. 168 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'cam'+sep+'free_rotor.py') 169 170 # Check the average structure CoM matches that of the original position (the average structure is not defined along the rotation axis). 171 for i in range(3): 172 self.assertAlmostEqual(ds['ave pos'].CoM[i], ds['orig pos'].CoM[i], 0) 173 174 # The rotation axis. 175 self.interpreter.pipe.switch('frame order') 176 spherical_vect = zeros(3, float64) 177 spherical_vect[0] = 1.0 178 spherical_vect[1] = cdp.axis_theta 179 spherical_vect[2] = cdp.axis_phi 180 cart_vect = zeros(3, float64) 181 spherical_to_cartesian(spherical_vect, cart_vect) 182 183 # The original rotation axis. 184 pivot = array([ 37.254, 0.5, 16.7465]) 185 com = array([ 26.83678091, -12.37906417, 28.34154128]) 186 axis = pivot - com 187 axis = axis / norm(axis) 188 189 # The dot product. 190 angle = acos(dot(cart_vect, axis)) 191 192 # Check the angle. 193 if angle > 3 and angle < 4: 194 self.assertAlmostEqual(angle, pi, 1) 195 else: 196 self.assertAlmostEqual(angle, 0.0, 1)
197 198
199 - def test_cam_free_rotor2(self):
200 """Test the second free rotor frame order model of CaM.""" 201 202 # Execute the script. 203 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'cam'+sep+'free_rotor2.py') 204 205 # The base data. 206 pivot = array([ 37.254, 0.5, 16.7465]) 207 com = array([ 26.83678091, -12.37906417, 28.34154128]) 208 pivot_com_axis = com - pivot 209 rot_axis = array([ 0.62649633, 0.77455282, -0.08700742]) 210 211 # The average position CoM. 212 ave_pivot_com_axis = ds['ave pos'].CoM - pivot 213 214 # The projection of the CoMs onto the rotation axis. 215 orig_proj = dot(pivot_com_axis, rot_axis) 216 ave_proj = dot(ave_pivot_com_axis, rot_axis) 217 218 # Check that the projections are equal. 219 self.assertAlmostEqual(orig_proj, ave_proj, 0) 220 221 # The rotation axis. 222 self.interpreter.pipe.switch('frame order') 223 spherical_vect = zeros(3, float64) 224 spherical_vect[0] = 1.0 225 spherical_vect[1] = cdp.axis_theta 226 spherical_vect[2] = cdp.axis_phi 227 cart_vect = zeros(3, float64) 228 spherical_to_cartesian(spherical_vect, cart_vect) 229 print("\nReal rotation axis: %s" % repr(rot_axis)) 230 print("Fitted rotation axis: %s" % repr(cart_vect)) 231 232 # The dot product. 233 angle = acos(dot(cart_vect, rot_axis)) 234 if angle > pi/2: 235 angle = acos(dot(cart_vect, -rot_axis)) 236 237 # Check the angle. 238 self.assertAlmostEqual(angle, 0.0, 2)
239 240
242 """Test the isotropic cone, free rotor frame order model of CaM.""" 243 244 # Execute the script. 245 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'cam'+sep+'iso_cone_free_rotor.py') 246 247 # Check the average structure CoM matches that of the original position (the average structure is not defined along the rotation axis). 248 for i in range(3): 249 self.assertAlmostEqual(ds['ave pos'].CoM[i], ds['orig pos'].CoM[i], 0) 250 251 # Switch to the correct data pipe. 252 self.interpreter.pipe.switch('frame order') 253 254 # The base data. 255 pivot = array([ 37.254, 0.5, 16.7465]) 256 com = array([ 26.83678091, -12.37906417, 28.34154128]) 257 pivot_com_axis = com - pivot 258 rot_axis = pivot_com_axis / norm(pivot_com_axis) 259 260 # The average position checks. 261 ave_pivot_com_axis = ds['ave pos'].CoM - pivot 262 263 # The projection of the CoMs onto the rotation axis. 264 orig_proj = dot(pivot_com_axis, rot_axis) 265 ave_proj = dot(ave_pivot_com_axis, rot_axis) 266 print("\nReal projection of the central axis to the pivot-CoM: %s" % repr(orig_proj)) 267 print("Fitted projection of the central axis to the pivot-CoM: %s" % repr(ave_proj)) 268 269 # Check that the projections are equal. 270 self.assertAlmostEqual(orig_proj, ave_proj, 1) 271 272 # The rotation axis. 273 self.interpreter.pipe.switch('frame order') 274 spherical_vect = zeros(3, float64) 275 spherical_vect[0] = 1.0 276 spherical_vect[1] = cdp.axis_theta 277 spherical_vect[2] = cdp.axis_phi 278 axis = zeros(3, float64) 279 spherical_to_cartesian(spherical_vect, axis) 280 print("\nReal rotation axis: %s" % repr(rot_axis)) 281 print("Fitted rotation axis: %s" % repr(axis)) 282 283 # Check the angle between the real and fitted rotation axes. 284 angle = acos(dot(axis, rot_axis)) 285 if angle > pi/2: 286 angle = acos(dot(axis, -rot_axis)) 287 self.assertAlmostEqual(angle, 0.0, 2) 288 289 # Check the cone angle of 40 deg. 290 self.assertAlmostEqual(cdp.cone_theta * 2.0, 40.0 / 360.0 * 2.0 * pi, 1)
291 292
294 """Test the second isotropic cone, free rotor frame order model of CaM.""" 295 296 # Execute the script. 297 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'cam'+sep+'iso_cone_free_rotor2.py') 298 299 # Switch to the correct data pipe. 300 self.interpreter.pipe.switch('frame order') 301 302 # The base data. 303 pivot = array([ 37.254, 0.5, 16.7465]) 304 com = array([ 26.83678091, -12.37906417, 28.34154128]) 305 pivot_com_axis = com - pivot 306 rot_axis = array([-0.4043088, -0.49985692, 0.76594873]) 307 308 # The rotation axis. 309 self.interpreter.pipe.switch('frame order') 310 spherical_vect = zeros(3, float64) 311 spherical_vect[0] = 1.0 312 spherical_vect[1] = cdp.axis_theta 313 spherical_vect[2] = cdp.axis_phi 314 axis = zeros(3, float64) 315 spherical_to_cartesian(spherical_vect, axis) 316 print("\nReal rotation axis: %s" % repr(rot_axis)) 317 print("Fitted rotation axis: %s" % repr(axis)) 318 319 # Check the angle between the real and fitted rotation axes. 320 angle = acos(dot(axis, rot_axis)) 321 if angle > pi/2: 322 angle = acos(dot(axis, -rot_axis)) 323 self.assertAlmostEqual(angle, 0.0, 2) 324 325 # Check the cone angle of 40 deg. 326 self.assertAlmostEqual(cdp.cone_theta * 2.0, 40.0 / 360.0 * 2.0 * pi, 2)
327 328
329 - def test_cam_rigid(self):
330 """Test the rigid frame order model of CaM.""" 331 332 # Execute the script. 333 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'cam'+sep+'rigid.py') 334 335 # Check the average structure atomic positions (to only one decimal point as the PDB file accuracy isn't great). 336 ave_pos = ds['ave pos'].structure.structural_data[0].mol[0] 337 orig_pos = ds['orig pos'].structure.structural_data[0].mol[0] 338 for i in range(len(ave_pos.atom_name)): 339 self.assertAlmostEqual(ave_pos.x[i], orig_pos.x[i], 1) 340 self.assertAlmostEqual(ave_pos.y[i], orig_pos.y[i], 1) 341 self.assertAlmostEqual(ave_pos.z[i], orig_pos.z[i], 1)
342 343
344 - def test_cam_rotor(self):
345 """Test the rotor frame order model of CaM.""" 346 347 # Execute the script. 348 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'cam'+sep+'rotor.py') 349 350 # Switch to the correct data pipe. 351 self.interpreter.pipe.switch('frame order') 352 353 # The base data. 354 pivot = array([ 37.254, 0.5, 16.7465]) 355 com = array([ 26.83678091, -12.37906417, 28.34154128]) 356 pivot_com_axis = com - pivot 357 rot_axis = pivot_com_axis / norm(pivot_com_axis) 358 359 # The average position checks. 360 real_pos = array([[-0.31334613, -0.88922808, -0.33329811], 361 [ 0.93737972, -0.23341205, -0.2585306 ], 362 [ 0.15209688, -0.39343645, 0.90668313]], float64) 363 ave_pos = zeros((3, 3), float64) 364 euler_to_R_zyz(cdp.ave_pos_alpha, cdp.ave_pos_beta, cdp.ave_pos_gamma, ave_pos) 365 print("\nReal domain position:\n%s" % repr(real_pos)) 366 print("Fitted domain position:\n%s" % repr(ave_pos)) 367 for i in range(3): 368 for j in range(3): 369 self.assertAlmostEqual(ave_pos[i, j], real_pos[i, j], 3) 370 371 # The axis system. 372 axis = zeros(3, float64) 373 spherical_to_cartesian(array([1, cdp.axis_theta, cdp.axis_phi]), axis) 374 print("\nReal rotation axis: %s" % repr(rot_axis)) 375 print("Fitted rotation axis: %s" % repr(axis)) 376 377 # Check the angle between the real and fitted rotation axes. 378 angle = acos(dot(axis, rot_axis)) 379 if angle > pi/2: 380 angle = acos(dot(axis, -rot_axis)) 381 self.assertAlmostEqual(angle, 0.0, 2) 382 383 # Check the cone angle of 60 deg. 384 self.assertAlmostEqual(cdp.cone_sigma_max * 2.0, 60.0 / 360.0 * 2.0 * pi, 1)
385 386
387 - def test_cam_rotor2(self):
388 """Test the second rotor frame order model of CaM.""" 389 390 # Execute the script. 391 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'cam'+sep+'rotor2.py') 392 393 # Switch to the correct data pipe. 394 self.interpreter.pipe.switch('frame order') 395 396 # The base data. 397 pivot = array([ 37.254, 0.5, 16.7465]) 398 com = array([ 26.83678091, -12.37906417, 28.34154128]) 399 pivot_com_axis = com - pivot 400 rot_axis = array([ 0.40416535, 0.49967956, 0.76614014]) 401 402 # The average position checks. 403 real_pos = array([[-0.31334613, -0.88922808, -0.33329811], 404 [ 0.93737972, -0.23341205, -0.2585306 ], 405 [ 0.15209688, -0.39343645, 0.90668313]], float64) 406 ave_pos = zeros((3, 3), float64) 407 euler_to_R_zyz(cdp.ave_pos_alpha, cdp.ave_pos_beta, cdp.ave_pos_gamma, ave_pos) 408 print("\nReal domain position:\n%s" % repr(real_pos)) 409 print("Fitted domain position:\n%s" % repr(ave_pos)) 410 for i in range(3): 411 for j in range(3): 412 self.assertAlmostEqual(ave_pos[i, j], real_pos[i, j], 1) 413 414 # The axis system. 415 axis = zeros(3, float64) 416 spherical_to_cartesian(array([1, cdp.axis_theta, cdp.axis_phi]), axis) 417 print("\nReal rotation axis: %s" % repr(rot_axis)) 418 print("Fitted rotation axis: %s" % repr(axis)) 419 420 # Check the angle between the real and fitted rotation axes. 421 angle = acos(dot(axis, rot_axis)) 422 if angle > pi/2: 423 angle = acos(dot(axis, -rot_axis)) 424 self.assertAlmostEqual(angle, 0.0, 2) 425 426 # Check the cone angle of 60 deg. 427 self.assertAlmostEqual(cdp.cone_sigma_max * 2.0, 60.0 / 360.0 * 2.0 * pi, 1)
428 429
430 - def test_model_free_rotor(self):
431 """Test the free rotor frame order model.""" 432 433 # Execute the script. 434 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'free_rotor.py') 435 436 # Check the calculated chi2 value. 437 self.assertAlmostEqual(ds.chi2, 0.0216067401326)
438 439
441 """Test the free rotor frame order model in the eigenframe.""" 442 443 # Execute the script. 444 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'free_rotor_eigenframe.py') 445 446 # Check the calculated chi2 value. 447 self.assertAlmostEqual(ds.chi2, 0.00673210578744)
448 449
450 - def test_model_iso_cone(self):
451 """Test the isotropic cone frame order model.""" 452 453 # Execute the script. 454 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'iso_cone.py') 455 456 # The reference chi2 values. 457 chi2_ref = [] 458 chi2_ref.append(0.131890484593) 459 chi2_ref.append(0.0539383731611) 460 chi2_ref.append(0.0135056297016) 461 chi2_ref.append(0.0163432453475) 462 chi2_ref.append(0.0775570503917) 463 chi2_ref.append(0.0535055367493) 464 chi2_ref.append(0.0994746492483) 465 chi2_ref.append(0.174830826376) 466 chi2_ref.append(0.193036744906) 467 chi2_ref.append(0.181480810794) 468 chi2_ref.append(0.215863920824) 469 chi2_ref.append(0.170088692559) 470 chi2_ref.append(0.152634493383) 471 chi2_ref.append(0.168711907446) 472 chi2_ref.append(0.168405354086) 473 chi2_ref.append(0.247439860108) 474 chi2_ref.append(0.143487410228) 475 chi2_ref.append(0.148318989268) 476 477 # Check the calculated chi2 values. 478 for i in range(18): 479 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
480 481
483 """Test the free rotor isotropic cone frame order model.""" 484 485 # Execute the script. 486 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'iso_cone_free_rotor.py') 487 488 # The reference chi2 values. 489 chi2_ref = [] 490 chi2_ref.append(0.0177292447567 ) 491 chi2_ref.append(0.0187585146766 ) 492 chi2_ref.append(0.0440519894909 ) 493 chi2_ref.append(0.0225223798489 ) 494 chi2_ref.append(0.0239979046491 ) 495 chi2_ref.append(0.0161048633259 ) 496 chi2_ref.append(0.0267310958091 ) 497 chi2_ref.append(0.0219820914478 ) 498 chi2_ref.append(0.0194880630576 ) 499 chi2_ref.append(0.0348242343833 ) 500 chi2_ref.append(0.0401631858563 ) 501 chi2_ref.append(0.0327461783858 ) 502 chi2_ref.append(0.0391082177884 ) 503 chi2_ref.append(0.0467056691507 ) 504 chi2_ref.append(0.0407175857557 ) 505 chi2_ref.append(0.0441514158832 ) 506 chi2_ref.append(0.042078718831 ) 507 chi2_ref.append(0.0403856796359 ) 508 509 # Check the calculated chi2 values. 510 for i in range(18): 511 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
512 513
515 """Test the free rotor isotropic cone frame order model in the eigenframe.""" 516 517 # Execute the script. 518 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'iso_cone_free_rotor_eigenframe.py') 519 520 # The reference chi2 values. 521 chi2_ref = [] 522 chi2_ref.append(0.115175446978 ) 523 chi2_ref.append(0.156911214374 ) 524 chi2_ref.append(0.209198723492 ) 525 chi2_ref.append(0.155297079942 ) 526 chi2_ref.append(0.0684780584219) 527 chi2_ref.append(0.0781922435531) 528 chi2_ref.append(0.103777394815 ) 529 chi2_ref.append(0.173740596864 ) 530 chi2_ref.append(0.199867814969 ) 531 chi2_ref.append(0.297587241555 ) 532 chi2_ref.append(0.308539214325 ) 533 chi2_ref.append(0.2543934866 ) 534 chi2_ref.append(0.168985365277 ) 535 chi2_ref.append(0.190780393086 ) 536 chi2_ref.append(0.186482798104 ) 537 chi2_ref.append(0.153839910288 ) 538 chi2_ref.append(0.160863854198 ) 539 chi2_ref.append(0.157029368992 ) 540 541 # Check the calculated chi2 values. 542 for i in range(18): 543 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
544 545
547 """Test the pseudo-ellipse frame order model.""" 548 549 # Execute the script. 550 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'pseudo_ellipse.py') 551 552 # The reference chi2 values. 553 chi2_ref = [] 554 chi2_ref.append(0.0208490007203) 555 chi2_ref.append(0.00958146486076) 556 chi2_ref.append(0.0405488536626) 557 chi2_ref.append(0.0370142845551) 558 chi2_ref.append(0.0204537537661) 559 chi2_ref.append(0.0186122056988) 560 chi2_ref.append(0.0177783016875) 561 chi2_ref.append(0.0311747995923) 562 chi2_ref.append(0.0225532898175) 563 chi2_ref.append(0.0212562065194) 564 chi2_ref.append(0.018939663528) 565 chi2_ref.append(0.0224686987165) 566 chi2_ref.append(0.0201247095045) 567 chi2_ref.append(0.0215343817478) 568 chi2_ref.append(0.016509302331) 569 chi2_ref.append(0.0101988814638) 570 chi2_ref.append(0.00989431182393) 571 chi2_ref.append(0.0123400971524) 572 573 # Check the calculated chi2 values. 574 for i in range(18): 575 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
576 577
579 """Test the free rotor pseudo-elliptic cone frame order model.""" 580 581 # Execute the script. 582 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'pseudo_ellipse_free_rotor.py') 583 584 # The reference chi2 values. 585 chi2_ref = [[], []] 586 chi2_ref[0].append(0.0493245760341) 587 chi2_ref[0].append(0.0322727678945) 588 chi2_ref[0].append(0.0399505883966) 589 chi2_ref[0].append(0.0122539315721) 590 chi2_ref[0].append(0.0263840505182) 591 chi2_ref[0].append(0.0324871952484) 592 chi2_ref[0].append(0.0247369735031) 593 chi2_ref[0].append(0.0231896861006) 594 chi2_ref[0].append(0.0285947802273) 595 chi2_ref[0].append(0.0345542627808) 596 chi2_ref[0].append(0.0289869422491) 597 chi2_ref[0].append(0.0243038470127) 598 chi2_ref[0].append(0.0226686034191) 599 chi2_ref[0].append(0.0215714556045) 600 chi2_ref[0].append(0.0173836730495) 601 chi2_ref[0].append(0.0182530810025) 602 chi2_ref[0].append(0.0212669211551) 603 chi2_ref[0].append(0.0194359136977) 604 605 chi2_ref[1].append(0.0205287391277) 606 chi2_ref[1].append(0.0246463829816) 607 chi2_ref[1].append(0.0590186061204) 608 chi2_ref[1].append(0.0441193978727) 609 chi2_ref[1].append(0.0424299319779) 610 chi2_ref[1].append(0.032589994611) 611 chi2_ref[1].append(0.0523532207508) 612 chi2_ref[1].append(0.0488535879384) 613 chi2_ref[1].append(0.0424063218455) 614 chi2_ref[1].append(0.0553525984677) 615 chi2_ref[1].append(0.0495587286781) 616 chi2_ref[1].append(0.0446625345909) 617 chi2_ref[1].append(0.0470718361239) 618 chi2_ref[1].append(0.0493615476721) 619 chi2_ref[1].append(0.0492208206006) 620 chi2_ref[1].append(0.0429966323771) 621 chi2_ref[1].append(0.0442849187057) 622 chi2_ref[1].append(0.0436756306414) 623 624 # Check the calculated chi2 values. 625 for j in range(2): 626 for i in range(18): 627 self.assertAlmostEqual(ds.chi2[j][i], chi2_ref[j][i])
628 629
631 """Test the pseudo-ellipse frame order model.""" 632 633 # Execute the script. 634 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'pseudo_ellipse_torsionless.py') 635 636 # The reference chi2 values. 637 chi2_ref = [] 638 chi2_ref.append(0.340228489225) 639 chi2_ref.append(0.260847963487) 640 chi2_ref.append(0.250610744982) 641 chi2_ref.append(0.228947619476) 642 chi2_ref.append(0.251996758815) 643 chi2_ref.append(0.238724080817) 644 chi2_ref.append(0.182383602599) 645 chi2_ref.append(0.172830852017) 646 chi2_ref.append(0.159757813028) 647 chi2_ref.append(0.173833227524) 648 chi2_ref.append(0.156168102428) 649 chi2_ref.append(0.171406869781) 650 chi2_ref.append(0.202653838515) 651 chi2_ref.append(0.198919351788) 652 chi2_ref.append(0.169463187543) 653 chi2_ref.append(0.156867571611) 654 chi2_ref.append(0.146139931983) 655 chi2_ref.append(0.13307108095 ) 656 657 # Check the calculated chi2 values. 658 for i in range(18): 659 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
660 661
662 - def test_model_rotor(self):
663 """Test the rotor frame order model.""" 664 665 # Execute the script. 666 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'rotor.py') 667 668 # The reference chi2 values. 669 chi2_ref = [] 670 chi2_ref.append(0.00410277546707 ) 671 chi2_ref.append(0.00112443204411 ) 672 chi2_ref.append(0.00759196190331 ) 673 chi2_ref.append(0.0956596925692 ) 674 chi2_ref.append(0.223717470059 ) 675 chi2_ref.append(0.136723330704 ) 676 chi2_ref.append(0.0588253217034 ) 677 chi2_ref.append(0.0774693384156 ) 678 chi2_ref.append(0.0855477856492 ) 679 chi2_ref.append(0.198089516589 ) 680 chi2_ref.append(0.227537351664 ) 681 chi2_ref.append(0.202005777915 ) 682 chi2_ref.append(0.192550395736 ) 683 chi2_ref.append(0.126007906472 ) 684 chi2_ref.append(0.124053264662 ) 685 chi2_ref.append(0.18203965973 ) 686 chi2_ref.append(0.191062017006 ) 687 chi2_ref.append(0.13580013153 ) 688 689 # Check the calculated chi2 values. 690 for i in range(18): 691 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
692 693
695 """Test the rotor frame order model in the eigenframe.""" 696 697 # Execute the script. 698 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'model_calcs'+sep+'rotor_eigenframe.py') 699 700 # The reference chi2 values. 701 chi2_ref = [] 702 chi2_ref.append(0.00308229284128) 703 chi2_ref.append(0.0117874014708 ) 704 chi2_ref.append(0.0016108171487 ) 705 chi2_ref.append(0.00532862954549) 706 chi2_ref.append(0.097784753109 ) 707 chi2_ref.append(0.157147901966 ) 708 chi2_ref.append(0.182397051711 ) 709 chi2_ref.append(0.338977916543 ) 710 chi2_ref.append(0.208516866654 ) 711 chi2_ref.append(0.137660115226 ) 712 chi2_ref.append(0.0580816149373 ) 713 chi2_ref.append(0.0476543367845 ) 714 chi2_ref.append(0.0360689584006 ) 715 chi2_ref.append(0.0118024492136 ) 716 chi2_ref.append(0.0824307041139 ) 717 chi2_ref.append(0.0920614159956 ) 718 chi2_ref.append(0.0936464288916 ) 719 chi2_ref.append(0.0823025718101 ) 720 721 # Check the calculated chi2 values. 722 for i in range(18): 723 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
724 725
726 - def test_opendx_map(self):
727 """Test the mapping of the Euler angle parameters for OpenDx viewing.""" 728 729 # Execute the script. 730 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'opendx_euler_angle_map.py')
731 732
733 - def test_opt_rigid_no_rot(self):
734 """Test the 'rigid' model for unrotated tensors with no motion.""" 735 736 # Execute the script. 737 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'opt_rigid_no_rot.py') 738 739 # Get the debugging message. 740 self.mesg = self.mesg_opt_debug() 741 742 # Test the values. 743 self.assertEqual(cdp.iter, 92, msg=self.mesg) 744 self.assertEqual(cdp.chi2, 0.0, msg=self.mesg) 745 self.assertEqual(cdp.ave_pos_alpha, 0.0, msg=self.mesg) 746 self.assertEqual(cdp.ave_pos_beta, 0.0, msg=self.mesg) 747 self.assertEqual(cdp.ave_pos_gamma, 0.0, msg=self.mesg)
748 749
750 - def test_opt_rigid_rand_rot(self):
751 """Test the 'rigid' model for randomly rotated tensors with no motion.""" 752 753 # Execute the script. 754 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'opt_rigid_rand_rot.py') 755 756 # Get the debugging message. 757 self.mesg = self.mesg_opt_debug() 758 759 # Test the values. 760 self.assertAlmostEqual(cdp.chi2, 3.085356555118994e-26, msg=self.mesg) 761 self.assertAlmostEqual(cdp.ave_pos_alpha, 5.0700283197712777, msg=self.mesg) 762 self.assertAlmostEqual(cdp.ave_pos_beta, 2.5615753919522359, msg=self.mesg) 763 self.assertAlmostEqual(cdp.ave_pos_gamma, 0.64895449611163691, msg=self.mesg)
764 765
767 """Parametric restriction of the isotropic cone to the free rotor isotropic cone frame order model.""" 768 769 # Execute the script. 770 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'parametric_restriction'+sep+'iso_cone_to_iso_cone_free_rotor.py') 771 772 # The reference chi2 values. 773 chi2_ref = [] 774 chi2_ref.append(0.0177292447567 ) 775 chi2_ref.append(0.0187585146766 ) 776 chi2_ref.append(0.0440519894909 ) 777 chi2_ref.append(0.0225223798489 ) 778 chi2_ref.append(0.0239979046491 ) 779 chi2_ref.append(0.0161048633259 ) 780 chi2_ref.append(0.0267310958091 ) 781 chi2_ref.append(0.0219820914478 ) 782 chi2_ref.append(0.0194880630576 ) 783 chi2_ref.append(0.0348242343833 ) 784 chi2_ref.append(0.0401631858563 ) 785 chi2_ref.append(0.0327461783858 ) 786 chi2_ref.append(0.0391082177884 ) 787 chi2_ref.append(0.0467056691507 ) 788 chi2_ref.append(0.0407175857557 ) 789 chi2_ref.append(0.0441514158832 ) 790 chi2_ref.append(0.042078718831 ) 791 chi2_ref.append(0.0403856796359 ) 792 793 # Check the calculated chi2 values. 794 for i in range(18): 795 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
796 797
799 """Parametric restriction of the pseudo-ellipse to the isotropic cone frame order model.""" 800 801 # Execute the script. 802 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'parametric_restriction'+sep+'pseudo_ellipse_to_iso_cone.py') 803 804 # The reference chi2 values. 805 chi2_ref = [] 806 chi2_ref.append(0.131890484593) 807 chi2_ref.append(0.0539383731611) 808 chi2_ref.append(0.0135056297016) 809 chi2_ref.append(0.0163432453475) 810 chi2_ref.append(0.0775570503917) 811 chi2_ref.append(0.0535055367493) 812 chi2_ref.append(0.0994746492483) 813 chi2_ref.append(0.174830826376) 814 chi2_ref.append(0.193036744906) 815 chi2_ref.append(0.181480810794) 816 chi2_ref.append(0.215863920824) 817 chi2_ref.append(0.170088692559) 818 chi2_ref.append(0.152634493383) 819 chi2_ref.append(0.168711907446) 820 chi2_ref.append(0.168405354086) 821 chi2_ref.append(0.247439860108) 822 chi2_ref.append(0.143487410228) 823 chi2_ref.append(0.148318989268) 824 825 # Check the calculated chi2 values. 826 for i in range(18): 827 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
828 829
831 """Parametric restriction of the pseudo-ellipse to the free rotor isotropic cone frame order model.""" 832 833 # Execute the script. 834 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'parametric_restriction'+sep+'pseudo_ellipse_to_iso_cone_free_rotor.py') 835 836 # The reference chi2 values. 837 chi2_ref = [] 838 chi2_ref.append(0.0177292447567 ) 839 chi2_ref.append(0.0187585146766 ) 840 chi2_ref.append(0.0440519894909 ) 841 chi2_ref.append(0.0225223798489 ) 842 chi2_ref.append(0.0239979046491 ) 843 chi2_ref.append(0.0161048633259 ) 844 chi2_ref.append(0.0267310958091 ) 845 chi2_ref.append(0.0219820914478 ) 846 chi2_ref.append(0.0194880630576 ) 847 chi2_ref.append(0.0348242343833 ) 848 chi2_ref.append(0.0401631858563 ) 849 chi2_ref.append(0.0327461783858 ) 850 chi2_ref.append(0.0391082177884 ) 851 chi2_ref.append(0.0467056691507 ) 852 chi2_ref.append(0.0407175857557 ) 853 chi2_ref.append(0.0441514158832 ) 854 chi2_ref.append(0.042078718831 ) 855 chi2_ref.append(0.0403856796359 ) 856 857 # Check the calculated chi2 values. 858 for i in range(18): 859 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
860 861
863 """Parametric restriction of the pseudo-ellipse to the isotropic cone frame order model.""" 864 865 # Execute the script. 866 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'parametric_restriction'+sep+'pseudo_ellipse_free_rotor_to_iso_cone.py') 867 868 # The reference chi2 values. 869 chi2_ref = [] 870 chi2_ref.append(16957.4964577) 871 chi2_ref.append(15727.13869) 872 chi2_ref.append(13903.0982799) 873 chi2_ref.append(11719.9390681) 874 chi2_ref.append(9488.44060873) 875 chi2_ref.append(7425.57820642) 876 chi2_ref.append(5713.6467735) 877 chi2_ref.append(4393.3273949) 878 chi2_ref.append(3452.97770868) 879 chi2_ref.append(2771.90973598) 880 chi2_ref.append(2247.44444894) 881 chi2_ref.append(1788.58977266) 882 chi2_ref.append(1348.38250916) 883 chi2_ref.append(921.060703519) 884 chi2_ref.append(539.03217075) 885 chi2_ref.append(244.341444558) 886 chi2_ref.append(58.4566671195) 887 chi2_ref.append(0.148318989268) 888 889 # Check the calculated chi2 values. 890 for i in range(18): 891 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
892 893
895 """Parametric restriction of the free rotor pseudo-ellipse to the free rotor isotropic cone frame order model.""" 896 897 # Execute the script. 898 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'parametric_restriction'+sep+'pseudo_ellipse_free_rotor_to_iso_cone_free_rotor.py') 899 900 # The reference chi2 values. 901 chi2_ref = [] 902 chi2_ref.append(0.0177292447567 ) 903 chi2_ref.append(0.0187585146766 ) 904 chi2_ref.append(0.0440519894909 ) 905 chi2_ref.append(0.0225223798489 ) 906 chi2_ref.append(0.0239979046491 ) 907 chi2_ref.append(0.0161048633259 ) 908 chi2_ref.append(0.0267310958091 ) 909 chi2_ref.append(0.0219820914478 ) 910 chi2_ref.append(0.0194880630576 ) 911 chi2_ref.append(0.0348242343833 ) 912 chi2_ref.append(0.0401631858563 ) 913 chi2_ref.append(0.0327461783858 ) 914 chi2_ref.append(0.0391082177884 ) 915 chi2_ref.append(0.0467056691507 ) 916 chi2_ref.append(0.0407175857557 ) 917 chi2_ref.append(0.0441514158832 ) 918 chi2_ref.append(0.042078718831 ) 919 chi2_ref.append(0.0403856796359 ) 920 921 # Check the calculated chi2 values. 922 for i in range(18): 923 self.assertAlmostEqual(ds.chi2[i], chi2_ref[i])
924 925
926 - def test_pseudo_ellipse(self):
927 """Test the pseudo-ellipse target function.""" 928 929 # Execute the script. 930 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'pseudo_ellipse.py') 931 932 # The reference chi2 value. 933 chi2 = 0.015865464136741975 934 935 # Check the surrounding space. 936 self.space_probe(ref_chi2=chi2, params=['ave_pos_alpha', 'ave_pos_beta', 'ave_pos_gamma', 'eigen_alpha', 'eigen_beta', 'eigen_gamma', 'cone_theta_x', 'cone_theta_y', 'cone_sigma_max'])
937 938
940 """Test the torsionless pseudo-ellipse target function.""" 941 942 # Execute the script. 943 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'frame_order'+sep+'pseudo_ellipse_torsionless.py') 944 945 # The reference chi2 value. 946 chi2 = 2.8393866813588198 947 948 # Check the surrounding space. 949 self.space_probe(ref_chi2=chi2, params=['ave_pos_alpha', 'ave_pos_beta', 'ave_pos_gamma', 'eigen_alpha', 'eigen_beta', 'eigen_gamma', 'cone_theta_x', 'cone_theta_y'])
950