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