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

Source Code for Module test_suite.system_tests.diffusion_tensor

   1  ############################################################################### 
   2  #                                                                             # 
   3  # Copyright (C) 2006-2012,2014,2019 Edward d'Auvergne                         # 
   4  # Copyright (C) 2008 Sebastien Morin                                          # 
   5  #                                                                             # 
   6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
   7  #                                                                             # 
   8  # This program is free software: you can redistribute it and/or modify        # 
   9  # it under the terms of the GNU General Public License as published by        # 
  10  # the Free Software Foundation, either version 3 of the License, or           # 
  11  # (at your option) any later version.                                         # 
  12  #                                                                             # 
  13  # This program is distributed in the hope that it will be useful,             # 
  14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
  15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
  16  # GNU General Public License for more details.                                # 
  17  #                                                                             # 
  18  # You should have received a copy of the GNU General Public License           # 
  19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
  20  #                                                                             # 
  21  ############################################################################### 
  22   
  23  # Python module imports. 
  24  from math import pi 
  25  from numpy import array, dot, float64, transpose, zeros 
  26  from os import close, sep 
  27  from tempfile import mkstemp 
  28   
  29  # relax module imports. 
  30  from data_store import Relax_data_store; ds = Relax_data_store() 
  31  from pipe_control.pipes import get_pipe 
  32  from pipe_control.reset import reset 
  33  from lib.geometry.coord_transform import spherical_to_cartesian 
  34  from lib.geometry.rotations import axis_angle_to_R, euler_to_R_zyz, two_vect_to_R 
  35  from lib.io import delete 
  36  from status import Status; status = Status() 
  37  from test_suite.system_tests.base_classes import SystemTestCase 
  38   
  39   
40 -class Diffusion_tensor(SystemTestCase):
41 """Class for testing various aspects specific to the diffusion tensor.""" 42
43 - def setUp(self):
44 """Function for initialising a spherical, spheroidal, and ellipsoidal diffusion tensor.""" 45 46 # The status object. 47 status = Status() 48 49 # Create three data pipes for spherical, spheroidal, and ellipsoidal diffusion. 50 self.interpreter.pipe.create('sphere', 'mf') 51 self.interpreter.pipe.create('spheroid', 'mf') 52 self.interpreter.pipe.create('ellipsoid', 'mf') 53 54 # Sphere tensor initialization. 55 self.interpreter.pipe.switch('sphere') 56 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1) 57 self.interpreter.sequence.read(file='Ap4Aase.seq', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep, res_num_col=1, res_name_col=2) 58 self.interpreter.diffusion_tensor.init(10e-9, fixed=True) 59 self.tmpfile_sphere_handle, self.tmpfile_sphere = mkstemp(suffix='.pdb') 60 61 # Spheroid tensor initialization. 62 self.interpreter.pipe.switch('spheroid') 63 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1) 64 self.interpreter.sequence.read(file='Ap4Aase.seq', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep, res_num_col=1, res_name_col=2) 65 self.interpreter.diffusion_tensor.init((5e-09, -10000000., 1.6, 2.7), angle_units='rad', spheroid_type='oblate', fixed=True) 66 self.tmpfile_spheroid_handle, self.tmpfile_spheroid = mkstemp(suffix='.pdb') 67 68 # Ellipsoid tensor initialization. 69 self.interpreter.pipe.switch('ellipsoid') 70 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1) 71 self.interpreter.sequence.read(file='Ap4Aase.seq', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep, res_num_col=1, res_name_col=2) 72 self.interpreter.diffusion_tensor.init((9e-8, 5e6, 0.3, 60+360, 290, 100), fixed=False) 73 self.tmpfile_ellipsoid_handle, self.tmpfile_ellipsoid = mkstemp(suffix='.pdb') 74 75 76 # Some fake MC simulations (for the sphere). 77 self.interpreter.pipe.switch('sphere') 78 cdp.diff_tensor.set(param='tm', value=10e-11, category='err') 79 cdp.diff_tensor.set_sim_num(5) 80 tm_sim = [8.98e-8, 8.99e-8, 9.00e-7, 9.01e-8, 9.02e-8] 81 for i in range(5): 82 cdp.diff_tensor.set(param='tm', value=tm_sim[i], category='sim', sim_index=i) 83 84 # Reset some values. 85 cdp.diff_tensor.set(param='tm', value=9.00e-8, category='sim', sim_index=0) 86 87 88 # Some fake MC simulations (for the spheroid). 89 self.interpreter.pipe.switch('spheroid') 90 91 # Set some errors. 92 cdp.diff_tensor.set(param='Da', value=1000000, category='err') 93 cdp.diff_tensor.set(param='theta', value=0.01, category='err') 94 cdp.diff_tensor.set(param='tm', value=1e-11, category='err') 95 cdp.diff_tensor.set(param='phi', value=0.01, category='err') 96 97 # The sim data. 98 cdp.diff_tensor.set_sim_num(5) 99 Da_sim = [-12000000., -11000000., -10000000., -9000000., -8000000.] 100 theta_sim = [1.70, 1.65, 1.6, 1.55, 1.50] 101 tm_sim = [5.4e-09, 4.8e-09, 5e-09, 5.4e-09, 5.8e-09] 102 phi_sim = [2.5, 2.6, 2.7, 2.8, 100] 103 for i in range(5): 104 cdp.diff_tensor.set(param='Da', value=Da_sim[i], category='sim', sim_index=i) 105 cdp.diff_tensor.set(param='theta', value=theta_sim[i], category='sim', sim_index=i) 106 cdp.diff_tensor.set(param='tm', value=tm_sim[i], category='sim', sim_index=i) 107 cdp.diff_tensor.set(param='phi', value=phi_sim[i], category='sim', sim_index=i) 108 109 # Reset some values. 110 cdp.diff_tensor.set(param='tm', value=4.4e-9, category='sim', sim_index=0) 111 cdp.diff_tensor.set(param='phi', value=2.9, category='sim', sim_index=4) 112 113 114 # Some fake MC simulations (for the ellipsoid). 115 self.interpreter.pipe.switch('ellipsoid') 116 117 # The sim data. 118 cdp.diff_tensor.set_sim_num(5) 119 Dr_sim = [0.28, 0.29, 0.3, 0.31, 0.32] 120 tm_sim = [8.97e-8, 8.99e-8, 9.00e-8, 9.01e-8, 9.02e-8] 121 Da_sim = [5.02e6, 5.01e6, 5.00e6, 4.99e6, 4.98e6] 122 alpha_sim = [80.0/360*2*pi, 70.0/360*2*pi, 60.0/360*2*pi, 50.0/360*2*pi, 40.0/360*2*pi] 123 beta_sim = [295.0/360*2*pi, 292.5/360*2*pi, 290.0/360*2*pi, 289.5/360*2*pi, 288.0/360*2*pi] 124 gamma_sim = [102.0/360*2*pi, 101.0/360*2*pi, 0, 99.0/360*2*pi, 98.0/360*2*pi] 125 for i in range(5): 126 cdp.diff_tensor.set(param='Dr', value=Dr_sim[i], category='sim', sim_index=i) 127 cdp.diff_tensor.set(param='tm', value=tm_sim[i], category='sim', sim_index=i) 128 cdp.diff_tensor.set(param='Da', value=Da_sim[i], category='sim', sim_index=i) 129 cdp.diff_tensor.set(param='alpha', value=alpha_sim[i], category='sim', sim_index=i) 130 cdp.diff_tensor.set(param='beta', value=beta_sim[i], category='sim', sim_index=i) 131 cdp.diff_tensor.set(param='gamma', value=gamma_sim[i], category='sim', sim_index=i) 132 133 # Reset some values. 134 cdp.diff_tensor.set(param='tm', value=8.98e-8, category='sim', sim_index=0) 135 cdp.diff_tensor.set(param='gamma', value=100.0/360*2*pi, category='sim', sim_index=2)
136 137
138 - def tearDown(self):
139 """Reset the relax data storage object.""" 140 141 # Reset relax. 142 reset() 143 144 # Close the open file handles on the OS level. 145 close(self.tmpfile_sphere_handle) 146 close(self.tmpfile_spheroid_handle) 147 close(self.tmpfile_ellipsoid_handle) 148 149 # Delete the temporary files. 150 delete(self.tmpfile_sphere, fail=False) 151 delete(self.tmpfile_spheroid, fail=False) 152 delete(self.tmpfile_ellipsoid, fail=False)
153 154
155 - def check_ellipsoid(self, Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R):
156 """Check if the ellipsoid in the cdp has the same values as given.""" 157 158 # Print outs. 159 print("The relax data store diffusion tensor:\n\n%s\n\n" % cdp.diff_tensor) 160 print("\nThe real tensor:\n%s" % D) 161 print("\nThe tensor in relax:\n%s" % cdp.diff_tensor.tensor) 162 print("\nThe real tensor (in eig frame):\n%s" % D_prime) 163 print("\nThe tensor in relax (in eig frame):\n%s" % cdp.diff_tensor.tensor_diag) 164 165 # Check the Euler angles. 166 self.assertAlmostEqual(Dx * 1e-7, cdp.diff_tensor.Dx * 1e-7) 167 self.assertAlmostEqual(Dy * 1e-7, cdp.diff_tensor.Dy * 1e-7) 168 self.assertAlmostEqual(Dz * 1e-7, cdp.diff_tensor.Dz * 1e-7) 169 self.assertAlmostEqual(Diso * 1e-7, cdp.diff_tensor.Diso * 1e-7) 170 self.assertAlmostEqual(Da * 1e-7, cdp.diff_tensor.Da * 1e-7) 171 self.assertAlmostEqual(Dr * 1e-7, cdp.diff_tensor.Dr * 1e-7) 172 self.assertAlmostEqual(alpha, cdp.diff_tensor.alpha) 173 self.assertAlmostEqual(beta, cdp.diff_tensor.beta) 174 self.assertAlmostEqual(gamma, cdp.diff_tensor.gamma) 175 176 # Check the elements. 177 for i in range(3): 178 for j in range(3): 179 self.assertAlmostEqual(cdp.diff_tensor.tensor[i, j] * 1e-7, D[i, j] * 1e-7) 180 self.assertAlmostEqual(cdp.diff_tensor.tensor_diag[i, j] * 1e-7, D_prime[i, j] * 1e-7) 181 self.assertAlmostEqual(cdp.diff_tensor.rotation[i, j], R[i, j])
182 183
184 - def check_spheroid(self, tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type=None):
185 """Check if the spheroid in the cdp has the same values as given.""" 186 187 # Print outs. 188 print("The relax data store diffusion tensor:\n\n%s\n\n" % cdp.diff_tensor) 189 print("\nThe real tensor:\n%s" % D) 190 print("\nThe tensor in relax:\n%s" % cdp.diff_tensor.tensor) 191 print("\nThe real tensor (in eig frame):\n%s" % D_prime) 192 print("\nThe tensor in relax (in eig frame):\n%s" % cdp.diff_tensor.tensor_diag) 193 print("\nThe real rotation matrix:\n%s" % R) 194 print("\nThe rotation matrix in relax:\n%s" % cdp.diff_tensor.rotation) 195 196 # Check the Euler angles. 197 self.assertAlmostEqual(tm * 1e8, cdp.diff_tensor.tm * 1e8) 198 self.assertAlmostEqual(Dpar * 1e-7, cdp.diff_tensor.Dpar * 1e-7) 199 self.assertAlmostEqual(Dper * 1e-7, cdp.diff_tensor.Dper * 1e-7) 200 self.assertAlmostEqual(Diso * 1e-7, cdp.diff_tensor.Diso * 1e-7) 201 self.assertAlmostEqual(Da * 1e-7, cdp.diff_tensor.Da * 1e-7) 202 self.assertAlmostEqual(Dratio, cdp.diff_tensor.Dratio) 203 self.assertAlmostEqual(theta, cdp.diff_tensor.theta) 204 self.assertAlmostEqual(phi, cdp.diff_tensor.phi) 205 206 # Check the diagonalised tensor. 207 for i in range(3): 208 for j in range(3): 209 self.assertAlmostEqual(cdp.diff_tensor.tensor_diag[i, j] * 1e-7, D_prime[i, j] * 1e-7) 210 211 # Check the orientation. 212 vects = [] 213 vects.append([1, 0, 0]) 214 vects.append([0, 1, 0]) 215 vects.append([0, 0, 1]) 216 vects = array(vects) 217 for vect in vects: 218 # The projections. 219 proj1 = dot(vect, dot(cdp.diff_tensor.tensor, vect)) 220 proj2 = dot(vect, dot(D, vect)) 221 222 # Compare projections. 223 self.assertAlmostEqual(proj1, proj2) 224 225 # Check the type. 226 if spheroid_type: 227 self.assertEqual(spheroid_type, cdp.diff_tensor.spheroid_type)
228 229
230 - def check_spheroid_as_ellipsoid(self, tm, Dx, Dy, Dz, Diso, Da, D, D_prime, R):
231 """Check if the ellipsoid in the cdp has the same values as given spheroid.""" 232 233 # Print outs. 234 print("The relax data store diffusion tensor:\n\n%s\n\n" % cdp.diff_tensor) 235 print("\nThe real tensor:\n%s" % D) 236 print("\nThe tensor in relax:\n%s" % cdp.diff_tensor.tensor) 237 print("\nThe real tensor (in eig frame):\n%s" % D_prime) 238 print("\nThe tensor in relax (in eig frame):\n%s" % cdp.diff_tensor.tensor_diag) 239 print("\nThe real rotation matrix:\n%s" % R) 240 print("\nThe rotation matrix in relax:\n%s" % cdp.diff_tensor.rotation) 241 242 # Check the Euler angles. 243 self.assertAlmostEqual(tm * 1e8, cdp.diff_tensor.tm * 1e8) 244 self.assertAlmostEqual(Dx * 1e-7, cdp.diff_tensor.Dx * 1e-7) 245 self.assertAlmostEqual(Dy * 1e-7, cdp.diff_tensor.Dy * 1e-7) 246 self.assertAlmostEqual(Dz * 1e-7, cdp.diff_tensor.Dz * 1e-7) 247 self.assertAlmostEqual(Diso * 1e-7, cdp.diff_tensor.Diso * 1e-7) 248 249 # Check the diagonalised tensor. 250 for i in range(3): 251 for j in range(3): 252 self.assertAlmostEqual(cdp.diff_tensor.tensor_diag[i, j] * 1e-7, D_prime[i, j] * 1e-7) 253 254 # Check the orientation. 255 vects = [] 256 vects.append([1, 0, 0]) 257 vects.append([0, 1, 0]) 258 vects.append([0, 0, 1]) 259 vects = array(vects) 260 for vect in vects: 261 # The projections. 262 proj1 = dot(vect, dot(cdp.diff_tensor.tensor, vect)) 263 proj2 = dot(vect, dot(D, vect)) 264 265 # Print out. 266 print("\nVector: %s" % vect) 267 print("Real proj: %s" % proj1) 268 print("Proj in relax: %s" % proj2) 269 270 # Compare projections. 271 self.assertAlmostEqual(proj1, proj2)
272 273
274 - def get_ellipsoid(self):
275 """Return all the diffusion tensor info about the {Dx, Dy, Dz, alpha, beta, gamma} = {1e7, 2e7, 3e7, 1, 2, 0.5} ellipsoid tensor.""" 276 277 # The tensor info. 278 Dx = 1e7 279 Dy = 2e7 280 Dz = 3e7 281 Diso = 2e7 282 Da = 1.5e7 283 Dr = 1.0/3.0 284 alpha = 1.0 285 beta = 2.0 286 gamma = 0.5 287 288 # The actual tensor in the PDB frame. 289 D = array([[ 22758858.4088357, -7267400.1700938, 6272205.75829415], 290 [ -7267400.1700938, 17923072.3436445, 1284270.53726401], 291 [ 6272205.75829415, 1284270.53726401, 19318069.2475198 ]], float64) 292 293 # The tensor in the eigenframe. 294 D_prime = zeros((3, 3), float64) 295 D_prime[0, 0] = Dx 296 D_prime[1, 1] = Dy 297 D_prime[2, 2] = Dz 298 299 # The rotation matrix. 300 R = zeros((3, 3), float64) 301 euler_to_R_zyz(gamma, beta, alpha, R) 302 R = transpose(R) 303 304 # Return the data. 305 return Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R
306 307
308 - def get_spheroid(self, Dpar=None, Dper=None, theta=None, phi=None):
309 """Return all the diffusion tensor info about the given spheroid tensor.""" 310 311 # The tensor info. 312 Diso = (Dpar + 2*Dper) / 3.0 313 tm = 1.0/(6.0 * Diso) 314 Da = Dpar - Dper 315 Dratio = Dpar / Dper 316 317 # The eigenvalues and unique axis in the eigenframe. 318 if Dpar > Dper: 319 Dx, Dy, Dz = Dper, Dper, Dpar 320 axis = array([0, 0, 1], float64) 321 else: 322 Dx, Dy, Dz = Dpar, Dper, Dper 323 axis = array([1, 0, 0], float64) 324 325 # The actual tensor in the PDB frame. 326 R = zeros((3, 3), float64) 327 spher_vect = array([1, theta, phi], float64) 328 diff_axis = zeros(3, float64) 329 spherical_to_cartesian(spher_vect, diff_axis) 330 two_vect_to_R(diff_axis, axis, R) 331 332 # The tensor in the eigenframe. 333 D_prime = zeros((3, 3), float64) 334 D_prime[0, 0] = Dx 335 D_prime[1, 1] = Dy 336 D_prime[2, 2] = Dz 337 338 # Rotate a little about the unique axis! 339 twist = zeros((3, 3), float64) 340 axis_angle_to_R(axis, 0.3, twist) 341 D = dot(twist, dot(D_prime, transpose(twist))) 342 343 # The tensor in the PDB frame. 344 D = dot(R, dot(D, transpose(R))) 345 346 # Return the data. 347 return tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R
348 349
350 - def test_back_calc_ellipsoid(self):
351 """Check the back-calculation of relaxation data for the spherical diffusion tensor.""" 352 353 # Reset relax. 354 reset() 355 356 # The diffusion type (used by the script). 357 ds.diff_dir = 'ellipsoid' 358 ds.diff_type = 'ellipsoid' 359 360 # Execute the script. 361 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'diff_tensor'+sep+'ri_back_calc.py') 362 363 # Loop over all spins. 364 for i in range(len(cdp.mol[0].res)): 365 # Alias. 366 spin = cdp.mol[0].res[i].spin[0] 367 368 # Check the values. 369 for ri_id in cdp.ri_ids: 370 self.assertAlmostEqual(spin.ri_data_bc[ri_id], spin.ri_data[ri_id])
371 372
373 - def test_back_calc_sphere(self):
374 """Check the back-calculation of relaxation data for the spherical diffusion tensor.""" 375 376 # Reset relax. 377 reset() 378 379 # The diffusion type (used by the script). 380 ds.diff_dir = 'sphere' 381 ds.diff_type = 'sphere' 382 383 # Execute the script. 384 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'diff_tensor'+sep+'ri_back_calc.py') 385 386 # Loop over all spins. 387 for i in range(len(cdp.mol[0].res)): 388 # Alias. 389 spin = cdp.mol[0].res[i].spin[0] 390 391 # Check the values. 392 for ri_id in cdp.ri_ids: 393 self.assertAlmostEqual(spin.ri_data_bc[ri_id], spin.ri_data[ri_id])
394 395
396 - def test_back_calc_spheroid(self):
397 """Check the back-calculation of relaxation data for the spherical diffusion tensor.""" 398 399 # Reset relax. 400 reset() 401 402 # The diffusion type (used by the script). 403 ds.diff_dir = 'spheroid_prolate' 404 ds.diff_type = 'spheroid' 405 406 # Execute the script. 407 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'diff_tensor'+sep+'ri_back_calc.py') 408 409 # Loop over all spins. 410 for i in range(len(cdp.mol[0].res)): 411 # Alias. 412 spin = cdp.mol[0].res[i].spin[0] 413 414 # Check the values. 415 for ri_id in cdp.ri_ids: 416 self.assertAlmostEqual(spin.ri_data_bc[ri_id], spin.ri_data[ri_id])
417 418
420 """Catch U{bug #21561<https://web.archive.org/web/https://gna.org/bugs/?21561>} reported by Martin Ballaschk, the failure of the diffusion tensor PDB creation when Monte Carlo simulations are not present.""" 421 422 # Create a data pipe. 423 self.interpreter.pipe.create('diff PDB', 'mf') 424 425 # Initialise a diffusion tensor. 426 self.interpreter.diffusion_tensor.init((2e-8, 1.3, 60, 290), spheroid_type='prolate', param_types=2, fixed=True) 427 428 # Load a random protein structure. 429 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' 430 self.interpreter.structure.read_pdb('Ap4Aase_res1-12.pdb', dir=path) 431 432 # Generate the tensor PDB without MC sims. 433 self.interpreter.structure.create_diff_tensor_pdb(file=self.tmpfile_spheroid, force=True)
434 435
436 - def test_copy(self):
437 """The user function diffusion_tensor.copy().""" 438 439 # Create three additional data pipes for copying the spherical, spheroidal, and ellipsoidal diffusion data. 440 self.interpreter.pipe.create('sphere2', 'mf') 441 self.interpreter.pipe.create('spheroid2', 'mf') 442 self.interpreter.pipe.create('ellipsoid2', 'mf') 443 444 # Copy the data. 445 self.interpreter.diffusion_tensor.copy('sphere', 'sphere2') 446 self.interpreter.diffusion_tensor.copy('spheroid', 'spheroid2') 447 self.interpreter.diffusion_tensor.copy('ellipsoid', 'ellipsoid2') 448 449 # Get the data pipes. 450 sphere_pipe = get_pipe('sphere') 451 sphere2_pipe = get_pipe('sphere2') 452 453 # Check that this is indeed a copy. 454 self.assertEqual(sphere2_pipe.diff_tensor.tm_sim[4], 9.02e-8) 455 self.assertEqual(sphere2_pipe.diff_tensor.Diso_sim[4], 1/(6*9.02e-8)) 456 sphere_pipe.diff_tensor.set(param='tm', value=8.88e-8, category='sim', sim_index=4) 457 self.assertEqual(sphere_pipe.diff_tensor.tm_sim[4], 8.88e-8) 458 self.assertEqual(sphere_pipe.diff_tensor.Diso_sim[4], 1/(6*8.88e-8)) 459 self.assertEqual(sphere2_pipe.diff_tensor.tm_sim[4], 9.02e-8) 460 self.assertEqual(sphere2_pipe.diff_tensor.Diso_sim[4], 1/(6*9.02e-8))
461 462
463 - def test_delete(self):
464 """The user function diffusion_tensor.delete().""" 465 466 # Delete the data. 467 self.interpreter.pipe.switch('sphere') 468 self.interpreter.diffusion_tensor.delete() 469 self.interpreter.pipe.switch('spheroid') 470 self.interpreter.diffusion_tensor.delete() 471 self.interpreter.pipe.switch('ellipsoid') 472 self.interpreter.diffusion_tensor.delete()
473 474
475 - def test_display(self):
476 """The user function diffusion_tensor.display().""" 477 478 # Display the data. 479 self.interpreter.pipe.switch('sphere') 480 self.interpreter.diffusion_tensor.display() 481 self.interpreter.pipe.switch('spheroid') 482 self.interpreter.diffusion_tensor.display() 483 self.interpreter.pipe.switch('ellipsoid') 484 self.interpreter.diffusion_tensor.display()
485 486
488 """Test the user function structure.create_diff_tensor_pdb() for the ellipsoid.""" 489 490 # First copy the data (a more vigorous copy test!). 491 self.interpreter.pipe.copy('ellipsoid', 'ellipsoid2') 492 self.interpreter.pipe.switch('ellipsoid2') 493 self.interpreter.diffusion_tensor.delete() 494 self.interpreter.diffusion_tensor.copy('ellipsoid', 'ellipsoid2') 495 496 # Create the diffusion tensor objects. 497 self.interpreter.structure.create_diff_tensor_pdb(file=self.tmpfile_ellipsoid, scale=1e-05, force=True) 498 499 # Open the temp file. 500 file = open(self.tmpfile_ellipsoid) 501 new_data = file.readlines() 502 file.close() 503 504 # Open the real file. 505 file = open(status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'diff_tensors'+sep+'ellipsoid.pdb') 506 real_data = file.readlines() 507 file.close() 508 509 # Strip out all remark lines. 510 new_data_stripped = [] 511 for line in new_data: 512 if line[:6] != 'REMARK': 513 new_data_stripped.append(line) 514 real_data_stripped = [] 515 for line in real_data: 516 if line[:6] != 'REMARK': 517 real_data_stripped.append(line) 518 519 # Check the data. 520 self.assertEqual(len(real_data_stripped), len(new_data_stripped)) 521 for i in range(len(real_data_stripped)): 522 # Print the PDB line, for debugging. 523 print(real_data_stripped[i][0:-1]) 524 525 # Check the line. 526 self.assertEqual(real_data_stripped[i], new_data_stripped[i])
527 528
530 """Test the user function structure.create_diff_tensor_pdb() for the sphere.""" 531 532 # First copy the data (a more vigorous copy test!). 533 self.interpreter.pipe.copy('sphere', 'sphere2') 534 self.interpreter.pipe.switch('sphere2') 535 self.interpreter.diffusion_tensor.delete() 536 self.interpreter.diffusion_tensor.copy('sphere', 'sphere2') 537 538 # Create the diffusion tensor objects. 539 self.interpreter.structure.create_diff_tensor_pdb(file=self.tmpfile_sphere, force=True) 540 541 # Open the temp file. 542 file = open(self.tmpfile_sphere) 543 new_data = file.readlines() 544 file.close() 545 546 # Open the real file. 547 file = open(status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'diff_tensors'+sep+'sphere.pdb') 548 real_data = file.readlines() 549 file.close() 550 551 # Strip out all remark lines. 552 new_data_stripped = [] 553 for line in new_data: 554 if line[:6] != 'REMARK': 555 new_data_stripped.append(line) 556 real_data_stripped = [] 557 for line in real_data: 558 if line[:6] != 'REMARK': 559 real_data_stripped.append(line) 560 561 # Check the data. 562 self.assertEqual(len(real_data_stripped), len(new_data_stripped)) 563 for i in range(len(real_data_stripped)): 564 # Print the PDB line, for debugging. 565 print(real_data_stripped[i][0:-1]) 566 567 # Check the line. 568 self.assertEqual(real_data_stripped[i], new_data_stripped[i])
569 570
572 """Test the user function structure.create_diff_tensor_pdb() for the spheroid.""" 573 574 # First copy the data (a more vigorous copy test!). 575 self.interpreter.pipe.copy('spheroid', 'spheroid2') 576 self.interpreter.pipe.switch('spheroid2') 577 self.interpreter.diffusion_tensor.delete() 578 self.interpreter.diffusion_tensor.copy('spheroid', 'spheroid2') 579 580 # Create the diffusion tensor objects. 581 self.interpreter.structure.create_diff_tensor_pdb(file=self.tmpfile_spheroid, force=True) 582 583 # Open the temp file. 584 file = open(self.tmpfile_spheroid) 585 new_data = file.readlines() 586 file.close() 587 588 # Open the real file. 589 file = open(status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures'+sep+'diff_tensors'+sep+'spheroid.pdb') 590 real_data = file.readlines() 591 file.close() 592 593 # Strip out all remark lines. 594 new_data_stripped = [] 595 for line in new_data: 596 if line[:6] != 'REMARK': 597 new_data_stripped.append(line) 598 real_data_stripped = [] 599 for line in real_data: 600 if line[:6] != 'REMARK': 601 real_data_stripped.append(line) 602 603 # Check the data. 604 self.assertEqual(len(real_data_stripped), len(new_data_stripped)) 605 for i in range(len(real_data_stripped)): 606 # Print the PDB line, for debugging. 607 print(real_data_stripped[i][0:-1]) 608 609 # Check the line. 610 self.assertEqual(real_data_stripped[i], new_data_stripped[i])
611 612
614 """Test the initialisation of the ellipsoid diffusion tensor using parameter set 0.""" 615 616 # Get the ellipsoid data. 617 Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R = self.get_ellipsoid() 618 619 # Create a new data pipe. 620 self.interpreter.pipe.create('ellipsoid2', 'mf') 621 622 # Tensor initialization. 623 self.interpreter.diffusion_tensor.init((1/(6.0*Diso), Da, Dr, alpha, beta, gamma), param_types=0, angle_units='rad') 624 625 # Check the ellipsoid. 626 self.check_ellipsoid(Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R)
627 628
630 """Test the initialisation of the ellipsoid diffusion tensor using parameter set 0.""" 631 632 # Get the ellipsoid data. 633 Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R = self.get_ellipsoid() 634 635 # Create a new data pipe. 636 self.interpreter.pipe.create('ellipsoid2', 'mf') 637 638 # Tensor initialization. 639 self.interpreter.diffusion_tensor.init((Diso, Da, Dr, alpha, beta, gamma), param_types=1, angle_units='rad') 640 641 # Check the ellipsoid. 642 self.check_ellipsoid(Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R)
643 644
646 """Test the initialisation of the ellipsoid diffusion tensor using parameter set 0.""" 647 648 # Get the ellipsoid data. 649 Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R = self.get_ellipsoid() 650 651 # Create a new data pipe. 652 self.interpreter.pipe.create('ellipsoid2', 'mf') 653 654 # Tensor initialization. 655 self.interpreter.diffusion_tensor.init((Dx, Dy, Dz, alpha, beta, gamma), param_types=2, angle_units='rad') 656 657 # Check the ellipsoid. 658 self.check_ellipsoid(Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R)
659 660
662 """Test the initialisation of the ellipsoid diffusion tensor using parameter set 0.""" 663 664 # Get the ellipsoid data. 665 Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R = self.get_ellipsoid() 666 667 # Create a new data pipe. 668 self.interpreter.pipe.create('ellipsoid2', 'mf') 669 670 # Tensor initialization. 671 self.interpreter.diffusion_tensor.init((D[0, 0], D[1, 1], D[2, 2], D[0, 1], D[0, 2], D[1, 2]), param_types=3) 672 673 # Check the ellipsoid. 674 self.check_ellipsoid(Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R)
675 676
678 """Test the initialisation of the spheroid diffusion tensor using parameter set 4.""" 679 680 # Get the spheroid data. 681 Dpar, Dper, theta, phi = 1e7, 4e7, pi/4.0, 0.0 682 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 683 684 # Create a new data pipe. 685 self.interpreter.pipe.create('spheroid2', 'mf') 686 687 # Tensor initialization. 688 self.interpreter.diffusion_tensor.init((D[0, 0], D[1, 1], D[2, 2], D[0, 1], D[0, 2], D[1, 2]), param_types=3) 689 690 # Check the ellipsoid. 691 self.check_spheroid_as_ellipsoid(tm, Dx, Dy, Dz, Diso, Da, D, D_prime, R)
692 693
695 """Test the initialisation of the oblate spheroid diffusion tensor using parameter set 0.""" 696 697 # Get the spheroid data. 698 Dpar, Dper, theta, phi = 1e7, 4e7, 0.5, 1.0 699 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 700 701 # Create a new data pipe. 702 self.interpreter.pipe.create('spheroid2', 'mf') 703 704 # Tensor initialization. 705 self.interpreter.diffusion_tensor.init((tm, Da, theta, phi), param_types=0, angle_units='rad') 706 707 # Check the spheroid. 708 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='oblate')
709 710
712 """Test the initialisation of the oblate spheroid diffusion tensor using parameter set 1.""" 713 714 # Get the spheroid data. 715 Dpar, Dper, theta, phi = 1e7, 4e7, 0.5, 1.0 716 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 717 718 # Create a new data pipe. 719 self.interpreter.pipe.create('spheroid2', 'mf') 720 721 # Tensor initialization. 722 self.interpreter.diffusion_tensor.init((Diso, Da, theta, phi), param_types=1, angle_units='rad') 723 724 # Check the spheroid. 725 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='oblate')
726 727
729 """Test the initialisation of the oblate spheroid diffusion tensor using parameter set 1, and angles in deg.""" 730 731 # Get the spheroid data. 732 Dpar, Dper, theta, phi = 1e7, 4e7, 0.5, 1.0 733 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 734 735 # Create a new data pipe. 736 self.interpreter.pipe.create('spheroid2', 'mf') 737 738 # Tensor initialization. 739 self.interpreter.diffusion_tensor.init((Diso, Da, theta/2.0/pi*360.0, phi/2.0/pi*360.0), param_types=1, angle_units='deg') 740 741 # Check the spheroid. 742 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='oblate')
743 744
746 """Test the initialisation of the oblate spheroid diffusion tensor using parameter set 2.""" 747 748 # Get the spheroid data. 749 Dpar, Dper, theta, phi = 1e7, 4e7, 0.5, 1.0 750 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 751 752 # Create a new data pipe. 753 self.interpreter.pipe.create('spheroid2', 'mf') 754 755 # Tensor initialization. 756 self.interpreter.diffusion_tensor.init((tm, Dratio, theta, phi), param_types=2, angle_units='rad') 757 758 # Check the spheroid. 759 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='oblate')
760 761
763 """Test the initialisation of the oblate spheroid diffusion tensor using parameter set 3.""" 764 765 # Get the spheroid data. 766 Dpar, Dper, theta, phi = 1e7, 4e7, 0.5, 1.0 767 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 768 769 # Create a new data pipe. 770 self.interpreter.pipe.create('spheroid2', 'mf') 771 772 # Tensor initialization. 773 self.interpreter.diffusion_tensor.init((Dpar, Dper, theta, phi), param_types=3, angle_units='rad') 774 775 # Check the spheroid. 776 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='oblate')
777 778
780 """Test the initialisation of the oblate spheroid diffusion tensor using parameter set 4.""" 781 782 # Get the spheroid data. 783 Dpar, Dper, theta, phi = 1e7, 4e7, 0.5, 1.0 784 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 785 786 # Create a new data pipe. 787 self.interpreter.pipe.create('spheroid2', 'mf') 788 789 # Tensor initialization. 790 self.interpreter.diffusion_tensor.init((Diso, Dratio, theta, phi), param_types=4, angle_units='rad') 791 792 # Check the spheroid. 793 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='oblate')
794 795
797 """Test the initialisation of the spheroid diffusion tensor using parameter set 4.""" 798 799 # Get the spheroid data. 800 Dpar, Dper, theta, phi = 4e7, 2e7, 0.5, 1.0 801 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 802 803 # Create a new data pipe. 804 self.interpreter.pipe.create('spheroid2', 'mf') 805 806 # Tensor initialization. 807 self.interpreter.diffusion_tensor.init((D[0, 0], D[1, 1], D[2, 2], D[0, 1], D[0, 2], D[1, 2]), param_types=3) 808 809 # Check the ellipsoid. 810 self.check_spheroid_as_ellipsoid(tm, Dx, Dy, Dz, Diso, Da, D, D_prime, R)
811 812
814 """Test the initialisation of the prolate spheroid diffusion tensor using parameter set 0.""" 815 816 # Get the spheroid data. 817 Dpar, Dper, theta, phi = 8e7, 4e7, 0.5, 1.0 818 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 819 820 # Create a new data pipe. 821 self.interpreter.pipe.create('spheroid2', 'mf') 822 823 # Tensor initialization. 824 self.interpreter.diffusion_tensor.init((tm, Da, theta, phi), spheroid_type='prolate', param_types=0, angle_units='rad') 825 826 # Check the spheroid. 827 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='prolate')
828 829
831 """Test the initialisation of the prolate spheroid diffusion tensor using parameter set 0.""" 832 833 # Get the spheroid data. 834 Dpar, Dper, theta, phi = 8e7, 8e7, 0.5, 1.0 835 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 836 837 # Create a new data pipe. 838 self.interpreter.pipe.create('spheroid2', 'mf') 839 840 # Tensor initialization. 841 self.interpreter.diffusion_tensor.init((tm, Da, theta, phi), spheroid_type='prolate', param_types=0, angle_units='rad') 842 843 # Check the spheroid. 844 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='prolate')
845 846
848 """Test the initialisation of the prolate spheroid diffusion tensor using parameter set 1.""" 849 850 # Get the spheroid data. 851 Dpar, Dper, theta, phi = 8e7, 4e7, 0.5, 1.0 852 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 853 854 # Create a new data pipe. 855 self.interpreter.pipe.create('spheroid2', 'mf') 856 857 # Tensor initialization. 858 self.interpreter.diffusion_tensor.init((Diso, Da, theta, phi), param_types=1, angle_units='rad') 859 860 # Check the spheroid. 861 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='prolate')
862 863
865 """Test the initialisation of the prolate spheroid diffusion tensor using parameter set 1, and angles in deg.""" 866 867 # Get the spheroid data. 868 Dpar, Dper, theta, phi = 8e7, 4e7, 0.5, 1.0 869 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 870 871 # Create a new data pipe. 872 self.interpreter.pipe.create('spheroid2', 'mf') 873 874 # Tensor initialization. 875 self.interpreter.diffusion_tensor.init((Diso, Da, theta/2.0/pi*360.0, phi/2.0/pi*360.0), param_types=1, angle_units='deg') 876 877 # Check the spheroid. 878 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='prolate')
879 880
882 """Test the initialisation of the prolate spheroid diffusion tensor using parameter set 2.""" 883 884 # Get the spheroid data. 885 Dpar, Dper, theta, phi = 8e7, 4e7, 0.5, 1.0 886 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 887 888 # Create a new data pipe. 889 self.interpreter.pipe.create('spheroid2', 'mf') 890 891 # Tensor initialization. 892 self.interpreter.diffusion_tensor.init((tm, Dratio, theta, phi), param_types=2, angle_units='rad') 893 894 # Check the spheroid. 895 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='prolate')
896 897
899 """Test the initialisation of the prolate spheroid diffusion tensor using parameter set 3.""" 900 901 # Get the spheroid data. 902 Dpar, Dper, theta, phi = 8e7, 4e7, 0.5, 1.0 903 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 904 905 # Create a new data pipe. 906 self.interpreter.pipe.create('spheroid2', 'mf') 907 908 # Tensor initialization. 909 self.interpreter.diffusion_tensor.init((Dpar, Dper, theta, phi), param_types=3, angle_units='rad') 910 911 # Check the spheroid. 912 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='prolate')
913 914
916 """Test the initialisation of the prolate spheroid diffusion tensor using parameter set 4.""" 917 918 # Get the spheroid data. 919 Dpar, Dper, theta, phi = 8e7, 4e7, 0.5, 1.0 920 tm, Dx, Dy, Dz, Diso, Da, Dratio, D, D_prime, R = self.get_spheroid(Dpar=Dpar, Dper=Dper, theta=theta, phi=phi) 921 922 # Create a new data pipe. 923 self.interpreter.pipe.create('spheroid2', 'mf') 924 925 # Tensor initialization. 926 self.interpreter.diffusion_tensor.init((Diso, Dratio, theta, phi), param_types=4, angle_units='rad') 927 928 # Check the spheroid. 929 self.check_spheroid(tm, Dpar, Dper, Diso, Da, Dratio, theta, phi, D, D_prime, R, spheroid_type='prolate')
930 931
932 - def test_opt_ellipsoid(self):
933 """Check that the ellipsoid diffusion tensor optimisation functions correctly.""" 934 935 # Reset relax. 936 reset() 937 938 # The diffusion type (used by the script). 939 ds.diff_dir = 'ellipsoid' 940 ds.diff_type = 'ellipsoid' 941 942 # Execute the script. 943 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'diff_tensor'+sep+'tensor_opt.py') 944 945 # Print out. 946 print(cdp.diff_tensor) 947 948 # The real data. 949 Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R = self.get_ellipsoid() 950 951 # Check the values. 952 self.assertAlmostEqual(cdp.chi2, 0.0) 953 self.assertEqual(cdp.diff_tensor.fixed, False) 954 self.assertEqual(cdp.diff_tensor.type, 'ellipsoid') 955 956 # Check the ellipsoid. 957 self.check_ellipsoid(Dx, Dy, Dz, Diso, Da, Dr, alpha, beta, gamma, D, D_prime, R)
958 959
960 - def test_opt_sphere(self):
961 """Check that the sphere diffusion tensor optimisation functions correctly.""" 962 963 # Reset relax. 964 reset() 965 966 # The diffusion type (used by the script). 967 ds.diff_dir = 'sphere' 968 ds.diff_type = 'sphere' 969 970 # Execute the script. 971 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'diff_tensor'+sep+'tensor_opt.py') 972 973 # Check the values. 974 self.assertAlmostEqual(cdp.chi2, 0.0) 975 self.assertEqual(cdp.diff_tensor.fixed, False) 976 self.assertEqual(cdp.diff_tensor.type, 'sphere') 977 self.assertAlmostEqual(cdp.diff_tensor.tm * 1e9, 1.0/(6.0*2e7) * 1e9) 978 self.assertEqual(cdp.diff_tensor.rotation[0, 0], 1.0) 979 self.assertEqual(cdp.diff_tensor.rotation[1, 1], 1.0) 980 self.assertEqual(cdp.diff_tensor.rotation[2, 2], 1.0) 981 self.assertEqual(cdp.diff_tensor.rotation[0, 1], 0.0) 982 self.assertEqual(cdp.diff_tensor.rotation[0, 2], 0.0) 983 self.assertEqual(cdp.diff_tensor.rotation[1, 2], 0.0) 984 self.assertEqual(cdp.diff_tensor.rotation[1, 0], 0.0) 985 self.assertEqual(cdp.diff_tensor.rotation[2, 0], 0.0) 986 self.assertEqual(cdp.diff_tensor.rotation[2, 1], 0.0)
987 988
989 - def test_opt_spheroid(self):
990 """Check that the spheroid diffusion tensor optimisation functions correctly.""" 991 992 # Reset relax. 993 reset() 994 995 # The diffusion type (used by the script). 996 ds.diff_dir = 'spheroid_prolate' 997 ds.diff_type = 'spheroid' 998 999 # Execute the script. 1000 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'diff_tensor'+sep+'tensor_opt.py') 1001 1002 # Check the values. 1003 self.assertAlmostEqual(cdp.chi2, 0.0) 1004 self.assertEqual(cdp.diff_tensor.fixed, False) 1005 self.assertEqual(cdp.diff_tensor.type, 'spheroid') 1006 self.assertAlmostEqual(cdp.diff_tensor.tm * 1e9, 1.0/(6.0*7e7/3.0) * 1e9) 1007 self.assertAlmostEqual(cdp.diff_tensor.Da * 1e-7, 1.0) 1008 self.assertAlmostEqual(cdp.diff_tensor.theta, 2.0) 1009 self.assertAlmostEqual(cdp.diff_tensor.phi, pi-0.5)
1010