use central functionality

This commit is contained in:
Martin Diehl 2020-02-21 17:47:47 +01:00
parent 6a0760a13c
commit ffb80981b1
1 changed files with 6 additions and 10 deletions

View File

@ -14,6 +14,7 @@ from . import mechanics
from . import Rotation from . import Rotation
from . import Orientation from . import Orientation
from . import Environment from . import Environment
from . import grid_filters
class DADF5(): class DADF5():
""" """
@ -436,12 +437,7 @@ class DADF5():
def cell_coordinates(self): def cell_coordinates(self):
"""Return initial coordinates of the cell centers.""" """Return initial coordinates of the cell centers."""
if self.structured: if self.structured:
delta = self.size/self.grid*0.5 return grid_filters.cell_coord0(self.grid,self.size,self.origin)
z, y, x = np.meshgrid(np.linspace(delta[2],self.size[2]-delta[2],self.grid[2]),
np.linspace(delta[1],self.size[1]-delta[1],self.grid[1]),
np.linspace(delta[0],self.size[0]-delta[0],self.grid[0]),
)
return np.concatenate((x[:,:,:,None],y[:,:,:,None],z[:,:,:,None]),axis = 3).reshape([np.product(self.grid),3])
else: else:
with h5py.File(self.fname,'r') as f: with h5py.File(self.fname,'r') as f:
return f['geometry/x_c'][()] return f['geometry/x_c'][()]
@ -662,7 +658,7 @@ class DADF5():
def _add_IPFcolor(q,l): def _add_IPFcolor(q,l):
d = np.array(l) d = np.array(l)
d_unit = pole/np.linalg.norm(d) d_unit = d/np.linalg.norm(d)
m = util.scale_to_coprime(d) m = util.scale_to_coprime(d)
colors = np.empty((len(q['data']),3),np.uint8) colors = np.empty((len(q['data']),3),np.uint8)
@ -679,7 +675,7 @@ class DADF5():
'Unit': 'RGB (8bit)', 'Unit': 'RGB (8bit)',
'Lattice': lattice, 'Lattice': lattice,
'Description': 'Inverse Pole Figure (IPF) colors for direction/plane [{} {} {})'.format(*m), 'Description': 'Inverse Pole Figure (IPF) colors for direction/plane [{} {} {})'.format(*m),
'Creator': 'dadf5.py:addIPFcolor v{}'.format(version) 'Creator': 'dadf5.py:add_IPFcolor v{}'.format(version)
} }
} }