Example #1
0
 def test_add_IPF_color(self, default, d):
     default.add_IPF_color(d, 'O')
     qu = default.place('O')
     crystal_structure = qu.dtype.metadata['lattice']
     c = Orientation(rotation=qu, lattice=crystal_structure)
     in_memory = np.uint8(c.IPF_color(np.array(d)) * 255)
     in_file = default.place('IPFcolor_({} {} {})'.format(*d))
     assert np.allclose(in_memory, in_file)
Example #2
0
 def test_add_IPF_color(self, default, d):
     default.add_IPF_color('O', d)
     loc = {
         'orientation': default.get_dataset_location('O'),
         'color':
         default.get_dataset_location('IPFcolor_[{} {} {}]'.format(*d))
     }
     qu = default.read_dataset(loc['orientation']).view(np.double).reshape(
         -1, 4)
     crystal_structure = default.get_crystal_structure()
     in_memory = np.empty((qu.shape[0], 3), np.uint8)
     for i, q in enumerate(qu):
         o = Orientation(q, crystal_structure).reduced
         in_memory[i] = np.uint8(o.IPF_color(np.array(d)) * 255)
     in_file = default.read_dataset(loc['color'])
     assert np.allclose(in_memory, in_file)
 def test_IPF_equivalent(self, set_of_quaternions, lattice, proper):
     direction = np.random.random(3) * 2.0 - 1.0
     o = Orientation(rotation=set_of_quaternions,
                     lattice=lattice).equivalent
     color = o.IPF_color(vector=direction, proper=proper)
     assert np.allclose(np.broadcast_to(color[0, ...], color.shape), color)
 def test_IPF_cubic(self, color, proper):
     cube = Orientation(lattice='cubic')
     for direction in set(permutations(np.array(color['direction']))):
         assert np.allclose(
             np.array(color['RGB']),
             cube.IPF_color(vector=np.array(direction), proper=proper))
Example #5
0
 def test_IPF_cubic(self, color, lattice):
     cube = Orientation(Rotation(), lattice)
     for direction in set(permutations(np.array(color['direction']))):
         assert np.allclose(cube.IPF_color(np.array(direction)),
                            np.array(color['RGB']))
Example #6
0
 def test_IPF_vectorize(self, set_of_quaternions, lattice):
     direction = np.random.random(3) * 2.0 - 1
     oris = Orientation(Rotation(set_of_quaternions), lattice)[:200]
     for i, color in enumerate(oris.IPF_color(direction)):
         assert np.allclose(color, IPF_color(oris[i], direction))