Ejemplo n.º 1
0
    def __init__(self,
                 hkls,
                 *args,
                 **kwargs):

        self.phaseID = None
        self.__doTThSort = True
        self.__exclusions = None
        self.__tThMax = None
        #
        if len(args) == 4:
            lparms, laueGroup, wavelength, strainMag = args
            tThWidth = None
            self.__wavelength = processWavelength(wavelength)
            self.__lparms = self.__parseLParms(lparms)
        elif len(args) == 1 and hasattr(args[0],'getParams'):
            other = args[0]
            lparms, laueGroup, wavelength, strainMag, tThWidth = other.getParams()
            self.__wavelength = wavelength
            self.__lparms = lparms
            self.phaseID = other.phaseID
            self.__doTThSort = other.__doTThSort
            self.__exclusions = other.__exclusions
            self.__tThMax = other.__tThMax
            if hkls is None:
                hkls = other.__hkls
        else:
            raise NotImplementedError, 'args : '+str(args)

        self.__laueGroup = laueGroup
        self.__qsym = symmetry.quatOfLaueGroup(self.__laueGroup)
        self.__hkls = copy.deepcopy(hkls)
        self.__strainMag = strainMag
        self.tThWidth = tThWidth

        # ... need to implement tThMin too
        if kwargs.has_key('phaseID'):
            self.phaseID = kwargs.pop('phaseID')
        if kwargs.has_key('doTThSort'):
            self.__doTThSort = kwargs.pop('doTThSort')
        if kwargs.has_key('exclusions'):
            self.__exclusions = kwargs.pop('exclusions')
        if kwargs.has_key('tThMax'):
            self.__tThMax = toFloat(kwargs.pop('tThMax'), 'radians')
        if kwargs.has_key('tThWidth'):
            self.tThWidth = kwargs.pop('tThWidth')
        if len(kwargs) > 0:
            raise RuntimeError, 'have unparsed keyword arguments with keys: '+str(kwargs.keys())

        self.__calc()

        return
Ejemplo n.º 2
0
#vertical dispersion correction
vd_lin=0. #vol_strain/mm
vd_const= 0.#vol_strain


###############################################################################
#%% Load data
###############################################################################

mat_list = cpl.load(open(material_file_loc, 'r'))
mat_idx = np.where([mat_list[i].name == mat_name for i in range(len(mat_list))])[0]

# grab plane data, and useful things hanging off of it
pd = mat_list[mat_idx[0]].planeData
qsyms=sym.quatOfLaueGroup(pd.getLaueGroup())


num_grain_files=len(grain_file_locs)

grain_data_list=[None]*num_grain_files





for i in np.arange(num_grain_files):  
    
    grain_data_list[i]=np.loadtxt(os.path.join(grain_file_locs[i],'grains.out'))
    
    pos_0=grain_data_list[i][:,6:9]
Ejemplo n.º 3
0
                mis = np.zeros(grain_map_g.shape)

                q_mor = rot.quatOfExpMap(ori_mis.T)
                q_avg = rot.quatOfExpMap(ori_avg.T)

                material_file_loc = mat_file  # hexrd material file in cpickle format
                mat_name = 'ti7al'

                mat_list = cpl.load(open(material_file_loc, 'r'))
                mat_idx = np.where([
                    mat_list[i].name == mat_name for i in range(len(mat_list))
                ])[0]

                # grab plane data, and useful things hanging off of it
                pd = mat_list[mat_idx[0]].planeData
                qsyms = sym.quatOfLaueGroup(pd.getLaueGroup())

                for w in range(0, len(test[0])):
                    q2 = np.atleast_2d(q_mor[:, grain_map_g[test[0][w],
                                                            test[1][w],
                                                            test[2][w]]]).T
                    q1 = np.atleast_2d(q_avg[:, grain_id]).T
                    mis[test[0][w], test[1][w],
                        test[2][w]] = rot.misorientation(q1,
                                                         q2)[0] * 180. / np.pi

            #    plt.imshow(confidence_map_g[20,:,:],cmap='gray')
            #    plt.hold(True)
            #    plt.imshow(mis[20,:,:], alpha = 0.5)
            #    plt.colorbar()
            #==============================================================================
#==============================================================================

loaded_colors = np.arange(0, len(loaded_scans))
unloaded_colors = np.arange(0, len(no_load_scans))

loaded_colornums = np.arange(10, 256, 246 / len(loaded_colors))
unloaded_colornums = np.arange(10, 256, 246 / len(unloaded_colors))

cmap = plt.cm.inferno_r

cmaplist = [cmap(i) for i in range(cmap.N)]

#%%

symmetry_symbol = 'd6h'  #cubic high, d6h for hex high
crystal_symmetry = sym.quatOfLaueGroup(symmetry_symbol)

# grain = 97
# grain_id = int(grain_data['scan21'][grain,0])

# mis_ang = []
# rotmats_grain = []
# expmaps_grain = []
# Eulers_grain = np.zeros([len(no_load_scans),3])

quats_init = rot.quatOfExpMap(grain_data['scan21'][:, 3:6].T)

expmaps_init = grain_data['scan21'][:, 3:6].T

quats_final = rot.quatOfExpMap(
    (grain_data['scan%d' % no_load_scans[-1]][:, 3:6].T))