def initSubstrate(self, geometry=None, **kwargs): La = xu.materials.elements.La Al = xu.materials.elements.Al O = xu.materials.elements.O2m Sr = xu.materials.elements.Sr Ti = xu.materials.elements.Ti Ta = xu.materials.elements.Ta Y = xu.materials.elements.Y energy = 1240 / 0.154 if geometry is None: geometry = 'hi_lo' #self.self.substrateMat = [] while (self.substrateMat != 'LAO' and self.substrateMat != 'STO' and self.substrateMat != 'LSAT' and self.substrateMat != 'YAO'): self.substrateMat = input('Sample substrate (LAO, STO or LSAT)?') print(self.substrateMat) print('input valid substrate material') #[ipH, ipK, ipL] = input("Input in-plane direction of substrate without spaces (i.e. 100, 110, etc): ").split(' ') #ipHKL = [ipH, ipK, ipL] #[opH, opK, opL] = input("Input out-of-plane direction of substrate without spaces (i.e. 001, 110, 210 etc): ").split(' ') #opHKL = [opH, opK, opL] """ self.substrateMat = "LAO" ipHKL = (1, 0, 0) opHKL = (0, 0, 1) """ #self.iHKL = ipHKL #self.oHKL = opHKL if self.substrateMat == "LAO": substrate = xu.materials.Crystal("LaAlO3", xu.materials.SGLattice(221, 3.784, \ atoms=[La, Al, O], pos=['1a', '1b', '3c'])) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, geometry = geometry) elif self.substrateMat == "STO": substrate = xu.materials.SrTiO3 #substrate = xu.materials.Crystal("SrTiO3", xu.materials.SGLattice(221, 3.905, atoms=[Sr, Ti, O], \ #pos=['1a', '1b', '3c'])) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy) elif self.substrateMat == "LSAT": # need to make an alloy of LaAlO3 and Sr2AlTaO6 mat1 = xu.materials.Crystal("LaAlO3", xu.materials.SGLattice(221, 3.79, \ atoms=[La, Al, O], pos=['1a', '1b', '3c'])) mat2 = xu.materials.Crystal("Sr2AlTaO6", xu.materials.SGLattice(221, 3.898,\ atoms=[Sr, Al, Ta, O], pos=['8c', '4a', '4b', '24c'])) substrate = xu.materials.CubicAlloy(mat1, mat2, 0.71) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy) elif self.substrateMat == "YAO": substrate = xu.materials.Crystal("YAlO3", xu.materials.SGLattice(221, 3.720, \ atoms=[Y, Al, O], pos=['1a', '1b', '3c'])) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, **kwargs) return [substrate, hxrd]
class TestAlloyContentCalc(unittest.TestCase): matA = xu.materials.InAs matB = xu.materials.InP substrate = xu.materials.InAs x = numpy.random.rand() alloy = xu.materials.CubicAlloy(matA, matB, x) hxrd001 = xu.HXRD([1, 1, 0], [0, 0, 1]) [qxa, qza] = alloy.RelaxationTriangle([2, 2, 4], substrate, hxrd001) [qxs, qzs] = alloy.RelaxationTriangle([0, 0, 4], substrate, hxrd001) def test_ContentAsym(self): content, [ainp, aperp, abulk, eps_inp, eps_perp] = \ self.alloy.ContentBasym(self.qxa[0], self.qza[0], [2, 2, 4], [0, 0, 1]) self.assertAlmostEqual(content, self.x, places=6) content, [ainp, aperp, abulk, eps_inp, eps_perp] = \ self.alloy.ContentBasym(self.qxa[1], self.qza[1], [2, 2, 4], [0, 0, 1]) self.assertAlmostEqual(content, self.x, places=6) def test_ContentSym(self): content = self.alloy.ContentBsym(self.qzs[0], [0, 0, 4], [1, 1, 0], self.matA.lattice.a, 1.0) self.assertAlmostEqual(content, self.x, places=6) content = self.alloy.ContentBsym(self.qzs[1], [0, 0, 4], [1, 1, 0], self.matA.lattice.a, 0.0) self.assertAlmostEqual(content, self.x, places=6)
def setUpClass(cls): cls.qconv = xu.experiment.QConversion(['z+', 'y-', 'z-'], ['z+', 'y-'], [1, 0, 0]) cls.hxrd = xu.HXRD((1, 0, 0), (0, 0, 1), en=cls.energy, qconv=cls.qconv) cls.bounds = (0, (0, 90), 0, (-1, 90), (0, 90)) cls.qvec = numpy.array((0, 0, numpy.random.rand()))
def setUpClass(cls): cls.mat = xu.materials.Si cls.hxrd = xu.HXRD(cls.mat.Q(1, 1, 0), cls.mat.Q(0, 0, 1)) cls.nch = 9 cls.ncch = 4 cls.hxrd.Ang2Q.init_linear('z+', cls.ncch, cls.nch, 1.0, 50e-6, 0.) cls.hklsym = (0, 0, 4) cls.hklasym = (2, 2, 4)
def setUpClass(cls): cls.nch = 9 cls.ncch = 4 cls.nch2d = (9, 13) cls.ncch1 = 4 cls.ncch2 = 6 # standard 1S+1D goniometer qconv = xu.QConversion('x+', 'x+', (0, 1, 0)) cls.hxrd = xu.HXRD((1., 1., 0.), (0., 0., 1.), qconv=qconv) # comparable goniometer with translations qconv = xu.QConversion('x+', ['ty', 'tz'], (0, 1e-15, 0)) cls.hxrdtrans = xu.HXRD((1., 1., 0.), (0., 0., 1.), qconv=qconv, sampleor='z+') cls.hxrdtrans.Ang2Q.init_linear('z+', cls.ncch, cls.nch, 1e-15, 50e-6) cls.hxrdtrans.Ang2Q.init_area('z+', 'x+', cls.ncch1, cls.ncch2, cls.nch2d[0], cls.nch2d[1], 1e-15, 50e-6, 50e-6) cls.angle = numpy.random.rand() * 45
def initialise_substrate(self, geometry='hi_lo', **kwargs): La = xu.materials.elements.La Al = xu.materials.elements.Al O = xu.materials.elements.O2m Sr = xu.materials.elements.Sr Ti = xu.materials.elements.Ti Ta = xu.materials.elements.Ta Y = xu.materials.elements.Y energy = 1240 / 0.154 while (self.substrateMat != 'LAO' and self.substrateMat != 'STO' and self.substrateMat != 'LSAT' and self.substrateMat != 'YAO'): self.substrateMat = input('Sample substrate (LAO, STO or LSAT)?') print(self.substrateMat) print('input valid substrate material') if self.substrateMat == "LAO": substrate = xu.materials.Crystal("LaAlO3", xu.materials.SGLattice(221, 3.784, \ atoms=[La, Al, O], pos=['1a', '1b', '3c'])) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, geometry = geometry) elif self.substrateMat == "STO": substrate = xu.materials.SrTiO3 hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy) elif self.substrateMat == "LSAT": # need to make an alloy of LaAlO3 and Sr2AlTaO6 mat1 = xu.materials.Crystal("LaAlO3", xu.materials.SGLattice(221, 3.79, \ atoms=[La, Al, O], pos=['1a', '1b', '3c'])) mat2 = xu.materials.Crystal("Sr2AlTaO6", xu.materials.SGLattice(221, 3.898,\ atoms=[Sr, Al, Ta, O], pos=['8c', '4a', '4b', '24c'])) substrate = xu.materials.CubicAlloy(mat1, mat2, 0.71) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy) elif self.substrateMat == "YAO": substrate = xu.materials.Crystal("YAlO3", xu.materials.SGLattice(221, 3.720, \ atoms=[Y, Al, O], pos=['1a', '1b', '3c'])) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, **kwargs) return [substrate, hxrd]
def setUpClass(cls): cls.mat = xu.materials.Si cls.hxrd = xu.HXRD(cls.mat.Q(1, 1, 0), cls.mat.Q(0, 0, 1)) cls.nch = (9, 13) cls.ncch1 = 4 cls.ncch2 = 6 cls.distance = 0.5 cls.dpix = 50e-6 cls.hxrd.Ang2Q.init_area('z+', 'x+', cls.ncch1, cls.ncch2, cls.nch[0], cls.nch[1], cls.distance, cls.dpix, cls.dpix) cls.hklsym = (0, 0, 4) cls.hklasym = (2, 2, 4)
def test_area_calib_hkl(self): scannrs = (2, 4, 43, 44, 46, 47) sang, ang1, ang2 = [ numpy.empty(0), ] * 3 imghkl = numpy.empty((0, 3)) r = self.roi detdata = numpy.empty((0, r[1] - r[0], r[3] - r[2])) for scannr, scanhkl, sl in zip(scannrs, self.hkls, self.slices): (om, tth, tt), angles = xu.io.gettty08_scan(datfile, scannr, 'om', 'tth', 'tt') intensity = numpy.zeros( (len(angles[sl]), r[1] - r[0], r[3] - r[2])) # read images for i, nr in enumerate(angles[sl]['Number']): fname = ccdfile % (scannr, scannr, nr) intensity[i] = getimage(fname, self.hotpixelmap, roi=self.roi) if scanhkl == (0, 0, 0): sang = numpy.concatenate((sang, (0, ) * len(angles[sl]))) else: sang = numpy.concatenate((sang, om[sl])) ang1 = numpy.concatenate((ang1, tth[sl])) ang2 = numpy.concatenate((ang2, tt[sl])) detdata = numpy.concatenate((detdata, intensity)) imghkl = numpy.concatenate((imghkl, (scanhkl, ) * len(angles[sl]))) # start calibration GaAs = xu.materials.GaAs qconv = xu.experiment.QConversion(['z+', 'y-', 'x+', 'z-'], ['z+', 'y-'], [1, 0, 0]) hxrd = xu.HXRD(GaAs.Q(1, 1, 0), GaAs.Q(0, 0, 1), en=self.en, qconv=qconv) param, eps = xu.analysis.sample_align.area_detector_calib_hkl( sang, ang1, ang2, detdata, imghkl, hxrd, GaAs, ['z+', 'y-'], 'x+', start=(0, 0, 0, 0, 0, 0, xu.en2lam(self.en)), fix=(False, False, False, False, False, False, False), debug=False, plot=False) self.assertTrue(True)
def initialise_substrate(self, geometry='hi_lo', **kwargs): La = xu.materials.elements.La Al = xu.materials.elements.Al O = xu.materials.elements.O2m Sr = xu.materials.elements.Sr Ti = xu.materials.elements.Ti Ta = xu.materials.elements.Ta Y = xu.materials.elements.Y energy = 1240/0.154 if self.substrateMat == "LAO": substrate = xu.materials.Crystal("LaAlO3", xu.materials.SGLattice(221, 3.784, \ atoms=[La, Al, O], pos=['1a', '1b', '3c'])) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, geometry = geometry) elif self.substrateMat == "STO": substrate = xu.materials.SrTiO3 hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, geometry = geometry) elif self.substrateMat == "LSAT": # need to make an alloy of LaAlO3 and Sr2AlTaO6 mat1 = xu.materials.Crystal("LaAlO3", xu.materials.SGLattice(221, 3.79, \ atoms=[La, Al, O], pos=['1a', '1b', '3c'])) mat2 = xu.materials.Crystal("Sr2AlTaO6", xu.materials.SGLattice(221, 3.898,\ atoms=[Sr, Al, Ta, O], pos=['8c', '4a', '4b', '24c'])) substrate = xu.materials.CubicAlloy(mat1, mat2, 0.71) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, geometry = geometry) elif self.substrateMat == "YAO": print( "Warning: YAlO3 is an orthorhombic substrate. Remember to take this into account\ when inputting measured RSM reflections." ) substrate = xu.materials.Crystal("YAlO3", xu.materials.SGLattice(62, 5.18, 5.33, 7.37,\ atoms=[Y, Al, O], pos=['4c', '4b', '4c', '8d'])) hxrd = xu.HXRD(substrate.Q(int(self.iHKL[0]), int(self.iHKL[1]), int(self.iHKL[2])), \ substrate.Q(int(self.oHKL[0]), int(self.oHKL[1]), int(self.oHKL[2])), en=energy, geometry = geometry, **kwargs) return [substrate, hxrd]
class Test_analysis_linecuts(unittest.TestCase): exp = xu.HXRD([1, 0, 0], [0, 0, 1]) qmax = (2 * exp.k0) / math.sqrt(2) - 0.1 qyp, qzp = numpy.sort(numpy.random.rand(2) * (qmax - 2) + 2) width1 = 0.015 width2 = 0.002 qy = numpy.linspace(qyp - 0.1, qyp + 0.1, 601) qz = numpy.linspace(qzp - 0.1, qzp + 0.1, 617) Ncut = 450 QY, QZ = numpy.meshgrid(qy, qz) omp, _, _, ttp = exp.Q2Ang(0, qyp, qzp, trans=False) def test_radial_cut(self): omegaang = math.radians(self.omp - self.ttp / 2.) data = xu.math.Gauss2d(self.QY, self.QZ, self.qyp, self.qzp, self.width1, self.width2, 1, 0, omegaang) x, d, m = xu.analysis.get_radial_scan([self.QY, self.QZ], data, (self.qyp, self.qzp), self.Ncut, 1, intdir='2theta') x2, d2, m2 = xu.analysis.get_radial_scan([self.QY, self.QZ], data, (self.qyp, self.qzp), self.Ncut, 1, intdir='omega') self.assertEqual(x.size, self.Ncut) self.assertTrue(xu.math.fwhm_exp(x, d) > xu.math.fwhm_exp(x2, d2)) def test_omega_cut(self): radialang = math.radians((self.omp - self.ttp / 2.) - 90) data = xu.math.Gauss2d(self.QY, self.QZ, self.qyp, self.qzp, self.width1, self.width2, 1, 0, radialang) x, d, m = xu.analysis.get_omega_scan([self.QY, self.QZ], data, (self.qyp, self.qzp), self.Ncut, 1, intdir='2theta') x2, d2, m2 = xu.analysis.get_omega_scan([self.QY, self.QZ], data, (self.qyp, self.qzp), self.Ncut, 1, intdir='radial') self.assertEqual(x.size, self.Ncut) self.assertTrue(xu.math.fwhm_exp(x, d) > xu.math.fwhm_exp(x2, d2)) def test_ttheta_cut(self): omegaang = math.radians(self.omp - self.ttp / 2.) data = xu.math.Gauss2d(self.QY, self.QZ, self.qyp, self.qzp, self.width1, self.width2, 1, 0, omegaang) x, d, m = xu.analysis.get_ttheta_scan([self.QY, self.QZ], data, (self.qyp, self.qzp), self.Ncut, 1, intdir='radial') x2, d2, m2 = xu.analysis.get_ttheta_scan([self.QY, self.QZ], data, (self.qyp, self.qzp), self.Ncut, 1, intdir='omega') self.assertEqual(x.size, self.Ncut) self.assertTrue(xu.math.fwhm_exp(x, d) > xu.math.fwhm_exp(x2, d2)) def test_qz_cut(self): omegaang = math.radians(self.omp - self.ttp / 2.) data = xu.math.Gauss2d(self.QY, self.QZ, self.qyp, self.qzp, self.width1, self.width2, 1, 0, omegaang) x, d, m = xu.analysis.get_qz_scan([self.QY, self.QZ], data, self.qyp, self.Ncut, 1, intdir='2theta') x2, d2, m2 = xu.analysis.get_qz_scan([self.QY, self.QZ], data, self.qyp, self.Ncut, 1, intdir='omega') self.assertEqual(x.size, self.Ncut) self.assertTrue(xu.math.fwhm_exp(x, d) > xu.math.fwhm_exp(x2, d2)) def test_qy_cut(self): omegaang = math.radians(self.omp - self.ttp / 2.) data = xu.math.Gauss2d(self.QY, self.QZ, self.qyp, self.qzp, self.width1, self.width2, 1, 0, omegaang) x, d, m = xu.analysis.get_qy_scan([self.QY, self.QZ], data, self.qzp, self.Ncut, 1, intdir='2theta') x2, d2, m2 = xu.analysis.get_qy_scan([self.QY, self.QZ], data, self.qzp, self.Ncut, 1, intdir='omega') self.assertTrue(xu.math.fwhm_exp(x, d) > xu.math.fwhm_exp(x2, d2)) def test_qcut_width(self): data = xu.math.Gauss2d(self.QY, self.QZ, self.qyp, self.qzp, self.width1, self.width2, 1, 0, 0) x, d, m = xu.analysis.get_qz_scan([self.QY, self.QZ], data, self.qyp, self.Ncut, 0.1, intdir='q') self.assertEqual(x.size, self.Ncut) self.assertAlmostEqual(xu.math.fwhm_exp(x, d) / (2 * math.sqrt(2 * math.log(2))), self.width2, places=4) x, d, m = xu.analysis.get_qy_scan([self.QY, self.QZ], data, self.qzp, self.Ncut, 0.1, intdir='q') self.assertAlmostEqual(xu.math.fwhm_exp(x, d) / (2 * math.sqrt(2 * math.log(2))), self.width1, places=4) def test_arbitrary_cut(self): data = xu.math.Gauss2d(self.QY, self.QZ, self.qyp, self.qzp, self.width1, self.width2, 1, 0, 0) x, d, m = xu.analysis.get_arbitrary_line([self.QY, self.QZ], data, (self.qyp, self.qzp), (1, 0), self.Ncut, 0.01) x2, d2, m2 = xu.analysis.get_arbitrary_line([self.QY, self.QZ], data, (self.qyp, self.qzp), (0, 1), self.Ncut, 0.01) self.assertEqual(x.size, self.Ncut) self.assertAlmostEqual(x[numpy.argmax(d)], self.qyp, places=2) self.assertAlmostEqual(x2[numpy.argmax(d2)], self.qzp, places=2) self.assertAlmostEqual(xu.math.fwhm_exp(x, d) / (2 * math.sqrt(2 * math.log(2))), self.width1, places=4) self.assertAlmostEqual(xu.math.fwhm_exp(x2, d2) / (2 * math.sqrt(2 * math.log(2))), self.width2, places=4)
def setUpClass(cls): cls.mat = xu.materials.GeTe qconv = xu.QConversion(['x+', 'y+', 'z-'], 'x+', [0, 1, 0]) inp = numpy.cross(cls.mat.Q(1, -1, 0), cls.mat.Q(1, 1, 1)) cls.hxrd = xu.HXRD(inp, cls.mat.Q(1, 1, 1), qconv=qconv) cls.hkltest = (1, 3, 2)
# describes the sample rotations, the second the detector rotations and the # third the primary beam direction. # For this consider the following coordinate system (at least this is what i # use at ID01, feel free to use your conventions): # x: downstream (direction of primary beam) # y: out of the ring # z: upwards # these three axis form a right handed coordinate system. # The outer most sample rotation (so the one mounted on the floor) is one which # turns righthanded (+) around the z-direction -> z+ (at the moment this # rotation is called 'mu' in the spec-session) # The second sample rotation ('eta') is lefthanded (-) around y -> y- # define experimental geometry with respect to the crystalline directions # of the substrate hxrd = xu.HXRD((1, 0, 0), (0, 0, 1), en=energy, qconv=qconv) # tell bounds of angles / (min,max) pair for all motors # mu,eta,phi detector nu,del bounds = (0, (0, 90), 0, (-1, 90), (0, 90)) ############################# # call angle fit function ############################# ang = None tbegin = time.time() print("time error (code) qvec angles") for i in range(100): qvec = numpy.array((0, 0, i * 0.01))
# This file is part of xrayutilities. # # xrayutilities is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. # # Copyright (C) 2012 Dominik Kriegner <*****@*****.**> import xrayutilities as xu import numpy import os # import matplotlib.pyplot as plt # create material Calcite = xu.materials.Crystal.fromCIF(os.path.join("data", "Calcite.cif")) # experiment class with some weird directions expcal = xu.HXRD(Calcite.Q(-2, 1, 9), Calcite.Q(1, -1, 4)) powder_cal = xu.simpack.PowderDiffraction(Calcite) print(powder_cal)
def setUpClass(cls): cls.mat = xu.materials.Si cls.hxrd = xu.HXRD(cls.mat.Q(1, 1, 0), cls.mat.Q(0, 0, 1)) cls.hklsym = (0, 0, 4) cls.hklasym = (2, 2, 4)
import numpy import xrayutilities as xu Si = xu.materials.Si datadir = 'data' specfile = "si_align.spec" en = 15000 # eV wl = xu.en2lam(en) imgdir = os.path.join(datadir, "si_align_") # data path for CCD files filetmp = "si_align_12_%04d.edf.gz" qconv = xu.QConversion(['z+', 'y-'], ['z+', 'y-'], [1, 0, 0]) hxrd = xu.HXRD(Si.Q(1, 1, -2), Si.Q(1, 1, 1), wl=wl, qconv=qconv) # manually selected images s = xu.io.SPECFile(specfile, path=datadir) for num in [61, 62, 63, 20, 21, 26, 27, 28]: s[num].ReadData() try: imagenrs = numpy.append(imagenrs, s[num].data['ccd_n']) except: imagenrs = s[num].data['ccd_n'] # avoid images which do not have to full beam on the detector as well as # other which show signal due to cosmic radiation avoid_images = [37, 57, 62, 63, 65, 87, 99, 106, 110, 111, 126, 130, 175, 181, 183, 185, 204, 206, 207, 208, 211, 212, 233, 237, 261,
# # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. # # Copyright (C) 2016 Dominik Kriegner <*****@*****.**> import xrayutilities as xu from matplotlib.pylab import * from scipy.special import erf mpl.rcParams['font.size'] = 16.0 en = 'CuKa1' qz = linspace(4.3, 4.6, 4000) GaAs = xu.materials.GaAs exp = xu.HXRD(GaAs.Q(1, 1, 0), GaAs.Q(0, 0, 1), en=en) dm = xu.simpack.DarwinModelAlGaAs001( qz, experiment=exp, resolution_width=0.0005, I0=2e7, background=1e0) def period(xavg, xwell, wellratio, thick, sigmaup, sigmadown): """ chemical composition profile in the superlattice """ twell = wellratio*thick xb = (xavg*thick - twell*xwell)/(thick - twell) tb = (thick-twell)/2 print('using barrier Al-content, well thickness, barrier thickness/2: ' '%.3f %.1f %.1f' % (xb, twell, tb)) return lambda z: xb + (xwell-xb)*(erf((z-tb)/sigmaup) + erf(-(z-(tb+twell))/sigmadown))/2.
different incidence beam directions. The different definition changes the momentum transfer Q (only its orientation), however both yields the same HKL upon back and force conversion to angular and HKL-space. """ import xrayutilities as xu # material used in this example mat = xu.materials.Si H = 3 K = 3 L = 1 # define experiment geometry hxrd = xu.HXRD(mat.Q(1, 1, -2), mat.Q(1, 1, 1)) # calculate angles [om, chi, phi, tt] = hxrd.Q2Ang(mat.Q(H, K, L)) # perform conversion to reciprocal space print(hxrd.Transform(mat.Q(H, K, L))) print(hxrd.Ang2Q(om, tt)) # perform conversion to HKL coordinates if chi != 0 or phi != 0: print("Geometry not enough for full description -> HKL will be wrong") print(hxrd.Ang2HKL(om, tt, mat=mat)) print("--------------") # example with custom qconv
# "outside" (righthanded) # QConversion will set up the goniometer geometry. So the first argument # describes the sample rotations, the second the detector rotations and the # third the primary beam direction. # For this consider the following right handed coordinate system (feel free to # use your conventions): # x: downstream (direction of primary beam) # y: out of the ring # z: upwards # The outer most sample rotation (so the one mounted on the floor) is one # which turns left-handed (-) around the z-direction -> z- (mu) # The second sample rotation ('eta') is lefthanded (-) around y -> y- qconv = xu.experiment.QConversion(['z-', 'y-', 'z-'], ['z-', 'y-', 'ty', 'tz'], [1, 0, 0]) hxrd = xu.HXRD([1, 1, 0], [0, 0, 1], qconv=qconv, sampleor='z+') hxrd._A2QConversion.init_area('z-', 'y+', cch1=333.94, cch2=235.62, Nch1=516, Nch2=516, pwidth1=5.5000e-02, pwidth2=5.5000e-02, distance=0.53588*1000, detrot=-1.495, tiltazimuth=155.0, tilt=0.745, Nav=(2, 2)) # all in mm since mm are used for mpxy,z in the spec-file qx, qy, qz, gint, gridder = id01.gridmap(s, SCANNR, hxrd, nx, ny, nz) # ################################################ # for a 3D plot using python function I sugggest # to use mayavi's mlab package. the basic usage # is shown below. otherwise have a look at the # file xrayutilities_export_data2vtk.py in order learn # how you can get your data to a vtk file for further # processing.
def rawmap(self,scans, angdelta=[0,0,0,0,0], adframes=None, mask = None): """ read ad frames and and convert them in reciprocal space angular coordinates are taken from the spec file or read from the edf file header when no scan number is given (scannr=None) """ if mask is None: mask_was_none = True #mask = [True] * len(self.getImageToBeUsed()[scans[0]]) else: mask_was_none = False #sd = spec.SpecDataFile(self.specFile) intensity = np.array([]) # fourc goniometer in fourc coordinates # convention for coordinate system: # x: upwards; # y: along the incident beam; # z: "outboard" (makes coordinate system right-handed). # QConversion will set up the goniometer geometry. # So the first argument describes the sample rotations, the second the # detector rotations and the third the primary beam direction. qconv = xu.experiment.QConversion(self.getSampleCircleDirections(), \ self.getDetectorCircleDirections(), \ self.getPrimaryBeamDirection()) # define experimental class for angle conversion # # ipdir: inplane reference direction (ipdir points into the primary beam # direction at zero angles) # ndir: surface normal of your sample (ndir points in a direction # perpendicular to the primary beam and the innermost detector # rotation axis) en = self.getIncidentEnergy() hxrd = xu.HXRD(self.getInplaneReferenceDirection(), \ self.getSampleSurfaceNormalDirection(), \ en=en[self.getAvailableScans()[0]], \ qconv=qconv) # initialize area detector properties if (self.getDetectorPixelWidth() != None ) and \ (self.getDistanceToDetector() != None): hxrd.Ang2Q.init_area(self.getDetectorPixelDirection1(), \ self.getDetectorPixelDirection2(), \ cch1=self.getDetectorCenterChannel()[0], \ cch2=self.getDetectorCenterChannel()[1], \ Nch1=self.getDetectorDimensions()[0], \ Nch2=self.getDetectorDimensions()[1], \ pwidth1=self.getDetectorPixelWidth()[0], \ pwidth2=self.getDetectorPixelWidth()[1], \ distance=self.getDistanceToDetector(), \ Nav=self.getNumPixelsToAverage(), \ roi=self.getDetectorROI()) else: hxrd.Ang2Q.init_area(self.getDetectorPixelDirection1(), \ self.getDetectorPixelDirection2(), \ cch1=self.getDetectorCenterChannel()[0], \ cch2=self.getDetectorCenterChannel()[1], \ Nch1=self.getDetectorDimensions()[0], \ Nch2=self.getDetectorDimensions()[1], \ chpdeg1=self.getDetectorChannelsPerDegree()[0], \ chpdeg2=self.getDetectorChannelsPerDegree()[1], \ Nav=self.getNumPixelsToAverage(), roi=self.getDetectorROI()) angleNames = self.getAngles() scanAngle = {} for i in range(len(angleNames)): scanAngle[i] = np.array([]) offset = 0 imageToBeUsed = self.getImageToBeUsed() monitorName = self.getMonitorName() monitorScaleFactor = self.getMonitorScaleFactor() filterName = self.getFilterName() filterScaleFactor = self.getFilterScaleFactor() for scannr in scans: if self.haltMap: raise ProcessCanceledException("Process Canceled") scan = self.sd.scans[str(scannr)] angles = self.getGeoAngles(scan, angleNames) scanAngle1 = {} scanAngle2 = {} for i in range(len(angleNames)): scanAngle1[i] = angles[:,i] scanAngle2[i] = [] if monitorName != None: monitor_data = scan.data.get(monitorName) if monitor_data is None: raise IOError("Did not find Monitor source '" + \ monitorName + \ "' in the Spec file. Make sure " + \ "monitorName is correct in the " + \ "instrument Config file") if filterName != None: filter_data = scan.data.get(filterName) if filter_data is None: raise IOError("Did not find filter source '" + \ filterName + \ "' in the Spec file. Make sure " + \ "filterName is correct in the " + \ "instrument Config file") # read in the image data arrayInitializedForScan = False foundIndex = 0 if mask_was_none: mask = [True] * len(self.getImageToBeUsed()[scannr]) for ind in range(len(scan.data[list(scan.data.keys())[0]])): if imageToBeUsed[scannr][ind] and mask[ind]: # read tif image im = Image.open(self.imageFileTmp % (scannr, scannr, ind)) img = np.array(im.getdata()).reshape(im.size[1],im.size[0]).T img = self.hotpixelkill(img) ff_data = self.getFlatFieldData() if not (ff_data is None): img = img * ff_data # reduce data siz img2 = xu.blockAverage2D(img, self.getNumPixelsToAverage()[0], \ self.getNumPixelsToAverage()[1], \ roi=self.getDetectorROI()) # apply intensity corrections if monitorName != None: img2 = img2 / monitor_data[ind] * monitorScaleFactor if filterName != None: img2 = img2 / filter_data[ind] * filterScaleFactor # initialize data array if not arrayInitializedForScan: imagesToProcess = [imageToBeUsed[scannr][i] and mask[i] for i in range(len(imageToBeUsed[scannr]))] if not intensity.shape[0]: intensity = np.zeros((np.count_nonzero(imagesToProcess),) + img2.shape) arrayInitializedForScan = True else: offset = intensity.shape[0] intensity = np.concatenate( (intensity, (np.zeros((np.count_nonzero(imagesToProcess),) + img2.shape))), axis=0) arrayInitializedForScan = True # add data to intensity array intensity[foundIndex+offset,:,:] = img2 for i in range(len(angleNames)): # logger.debug("appending angles to angle2 " + # str(scanAngle1[i][ind])) scanAngle2[i].append(scanAngle1[i][ind]) foundIndex += 1 if len(scanAngle2[0]) > 0: for i in range(len(angleNames)): scanAngle[i] = \ np.concatenate((scanAngle[i], np.array(scanAngle2[i])), \ axis=0) # transform scan angles to reciprocal space coordinates for all detector pixels angleList = [] for i in range(len(angleNames)): angleList.append(scanAngle[i]) if self.ubMatrix[scans[0]] is None: qx, qy, qz = hxrd.Ang2Q.area(*angleList, \ roi=self.getDetectorROI(), Nav=self.getNumPixelsToAverage()) else: qx, qy, qz = hxrd.Ang2Q.area(*angleList, \ roi=self.getDetectorROI(), Nav=self.getNumPixelsToAverage(), \ UB = self.ubMatrix[scans[0]]) # apply selected transform qxTrans, qyTrans, qzTrans = \ self.transform.do3DTransform(qx, qy, qz) return qxTrans, qyTrans, qzTrans, intensity
# You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. # # Copyright (C) 2012-2020 Dominik Kriegner <*****@*****.**> import matplotlib.pyplot as plt import numpy import xrayutilities as xu matA = xu.materials.InAs matB = xu.materials.InP substrate = xu.materials.Si alloy = xu.materials.CubicAlloy(matA, matB, 0) hxrd001 = xu.HXRD([1, 1, 0], [0, 0, 1]) qinp, qout = (3.02829203, 4.28265165) # draw two relaxation triangles for the given Alloy in the substrate [qxt0, qzt0] = alloy.RelaxationTriangle([2, 2, 4], substrate, hxrd001) alloy.x = 1. [qxt1, qzt1] = alloy.RelaxationTriangle([2, 2, 4], substrate, hxrd001) plt.figure() plt.plot(qxt0, qzt0, '-r') plt.plot(qxt1, qzt1, '-b') plt.plot(qinp, qout, 'ok') # print concentration of alloy B calculated from a reciprocal space point print(alloy.ContentBasym(qinp, qout, [2, 2, 4], [0, 0, 1]))
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. # # Copyright (C) 2013 Dominik Kriegner <*****@*****.**> import os import matplotlib.pyplot as plt import xrayutilities as xu # global setting for the experiment sample = "testnja" # sample name used also as file name for the data file hxrd = xu.HXRD((1, 1, 0), (0, 0, 1)) ################################# # read the data from the Seifert NJA files om, tt, psd = xu.io.getSeifert_map(sample + '_%02d.nja', [3, 4], path="data") # convert angular coordinates to reciprocal space + correct for offsets [qx, qy, qz] = hxrd.Ang2Q(om, tt) # calculate data on a regular grid of 200x201 points gridder = xu.Gridder2D(200, 600) gridder(qy, qz, psd) INT = xu.maplog(gridder.data.transpose(), 6, 0) # plot the intensity as contour plot plt.figure()
atoms=[In, In, P, P], pos=[('2a', 0), ('2b', 1 / 4.), ('2a', 3 / 16.), ('2b', 7 / 16.)])) for energy in [8041]: # eV lam = xu.en2lam(energy) # e in eV -> lam in angstrom print(' %d eV = %8.4f A' % (energy, lam)) print('------------------------------------------------------------------' '-----------------') print('material | peak | omega | 2theta | phi | ' 'tt-om | |F| ') print('------------------------------------------------------------------' '-----------------') exp111 = xu.HXRD(InP.Q(1, 1, -2), InP.Q(1, 1, 1), en=energy) exphex = xu.HXRD(InPWZ.Q(1, -1, 0), InPWZ.Q(0, 0, 1), en=energy) # InP ZB reflections reflections = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [3, 3, 1], [2, 2, 4], [1, 1, 5]] mat = InP for hkl in reflections: qvec = mat.Q(hkl) [om, chi, phi, tt] = exp111.Q2Ang(qvec, trans=True) F = mat.StructureFactor(qvec, exp111._en) F /= mat.lattice.UnitCellVolume() print('%8s | %15s | %8.4f | %8.4f | %8.4f | %8.4f | %8.2f ' % (mat.name, ' '.join(map(str, numpy.round( hkl, 2))), om, tt, phi, tt - om, numpy.abs(F)))
# plot settings for matplotlib mpl.rcParams['font.family'] = 'serif' mpl.rcParams['font.size'] = 20.0 mpl.rcParams['axes.labelsize'] = 'large' # global setting for the experiment sample = "rsm" # sample name used also as file name for the data file # substrate material used for Bragg peak calculation to correct for # experimental offsets Si = xu.materials.Si Ge = xu.materials.Ge SiGe = xu.materials.SiGe(1) # parameter x_Ge = 1 hxrd = xu.HXRD(Si.Q(1, 1, 0), Si.Q(0, 0, 1)) ################################# # Si/SiGe (004) reciprocal space map omalign = 34.3046 # experimental aligned values ttalign = 69.1283 # nominal values of the substrate peak [omnominal, dummy, dummy, ttnominal] = hxrd.Q2Ang(Si.Q(0, 0, 4)) # read the data from the xrdml files om, tt, psd = xu.io.getxrdml_map(sample + '_%d.xrdml.bz2', [1, 2, 3, 4, 5], path='data') # determine offset of substrate peak from experimental values (optional) omalign, ttalign, p, cov = xu.analysis.fit_bragg_peak(om, tt,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. # # Copyright (C) 2012 Dominik Kriegner <*****@*****.**> import numpy import xrayutilities as xu Si = xu.materials.Si # load material from materials submodule # initialize experimental class with directions from experiment exp = xu.HXRD(Si.Q(1, 1, -2), Si.Q(1, 1, 1)) # calculate angles and print them to the screen angs = exp.Q2Ang(Si.Q(1, 1, 1)) print("|F000|: %8.3f" % (numpy.abs(Si.StructureFactor(Si.Q(0, 0, 0), exp.energy)))) print("Si (111)") print("phi:%8.4f" % angs[2]) print("om: %8.4f" % angs[0]) print("tt: %8.4f" % angs[3]) print("|F|: %8.3f" % (numpy.abs(Si.StructureFactor(Si.Q(1, 1, 1), exp.energy)))) angs = exp.Q2Ang(Si.Q(2, 2, 4)) print("Si (224)")
chpdeg = 345.28 roi = [100, 1340] # region of interest of the detector # intensity normalizer function responsible for count time and absorber # correction normalizer_detcorr = xu.IntensityNormalizer( "MCA", mon="Monitor", time="Seconds", absfun=lambda d: d["detcorr"] / d["psd2"].astype(numpy.float)) # substrate material used for Bragg peak calculation to correct for # experimental offsets InP = xu.materials.InP hxrd = xu.HXRD(InP.Q(1, 1, -2), InP.Q(1, 1, 1), en=en) # configure linear detector hxrd.Ang2Q.init_linear('z-', center_ch, 1500., chpdeg=chpdeg, roi=roi) # read spec file and save to HDF5-file # since reading is much faster from HDF5 once the data are transformed h5file = os.path.join("data", sample + ".h5") try: # try if spec file object already exist from a previous run of the script # ("run -i" in ipython) s except NameError: s = xu.io.SPECFile(sample + ".spec.bz2", path="data") else: s.Update()
# define some convenience variables en = 9000.0 # x-ray energy in eV home = "\\homefolder" workdir = os.path.join(home, 'work') specdir = home # location of spec file sample = "sample" # sample name -> used as spec file name ccdfiletmp = "ccdfilename" # region of interest on the detector; useful to reduce the amount of data roi = [0, 516, 50, 300] # define experimental geometry and detector parameters # 2S+2D goniometer (simplified ID01 goniometer, sample mu,phi detector nu,del qconv = xu.experiment.QConversion(['z+', 'y-'], ['z+', 'y-'], [1, 0, 0]) # convention for coordinate system: x downstream; z upwards; y to the # "outside" (righthanded) hxrd = xu.HXRD([1, 1, 0], [0, 0, 1], en=en, qconv=qconv) hxrd.Ang2Q.init_area('z-', 'y+', cch1=200.07, cch2=297.75, Nch1=516, Nch2=516, pwidth1=9.4489e-05, pwidth2=9.4452e-05, distance=1., detrot=-0.801, tiltazimuth=30.3, tilt=1.611, roi=roi)
start=start_variable, fix=fix_variable, plotlog=True, debug=False) else: print('Data at Bragg peak detected') print('Using xu.analysis.area_detector_calib_hkl()') start_variable = (pixelsize, pixelsize, rough_sdd, 0, 0, 0, 0, 0, 0, wl) fix_variable = (True, True, False, False, False, False, False, False, False, False) wl = 12.398 / (en / 1000) # wavelength in angstroms beam_direction = [1, 0, 0] # beam along x qconv = xu.experiment.QConversion(['y-'], ['z+', 'y-'], r_i=beam_direction) # for ID01 # pwidth1,pwidth2,distance,tiltazimuth,tilt,detector_rotation,outerangle_offset,sampletilt,sampletiltazimuth,wavelength hxrd = xu.HXRD([1, 0, 0], [0, 0, 1], wl=wl, qconv=qconv) param, eps = xu.analysis.area_detector_calib_hkl(mgomega, gamma, delta, data, hkl, hxrd, material, ['z+', 'y-'], 'x+', start=start_variable, fix=fix_variable, plotlog=True, debug=False) plt.ioff() plt.show()
def rawmap(self, scans, angledelta=[0, 0, 0, 0], adframes=None, mask=None): logger.debug(METHOD_ENTER_STR) if mask is None: mask_was_none = True else: mask_was_none = False intensity = np.array([]) qconv = xu.experiment.QConversion(self.sampleCircleDirections, \ self.detectorCircleDirections, \ self.primaryBeamDirection) en = self.incidentEnergy hxrd = xu.HXRD(self.sampleInplaneReferenceDirection, \ self.sampleSurfaceNormalDirection, \ en=en[self.availableScans[0]], \ qconv=qconv) # initialize area detector properties if (self.detectorPixelWidth != None ) and \ (self.distanceToDetector != None): hxrd.Ang2Q.init_area(self.detectorPixelDirection1, \ self.detectorPixelDirection2, \ cch1=self.detectorCenterChannel[0], \ cch2=self.detectorCenterChannel[1], \ Nch1=self.detectorDimensions[0], \ Nch2=self.detectorDimensions[1], \ pwidth1=self.detectorPixelWidth[0], \ pwidth2=self.detectorPixelWidth[1], \ distance=self.distanceToDetector, \ Nav=self.numPixelsToAverage, \ roi=self.detectorROI) else: hxrd.Ang2Q.init_area(self.detectorPixelDirection1, \ self.detectorPixelDirection2, \ cch1=self.detectorCenterChannel[0], \ cch2=self.detectorCenterChannel[1], \ Nch1=self.detectorDimensions[0], \ Nch2=self.getDetectorDimensions[1], \ chpdeg1=self.detectorChannelsPerDegree[0], \ chpdeg2=self.detectorChannelsPerDegree[1], \ Nav=self.numPixelsToAverage, roi=self.detectorROI) angleNames = self.getAngles() scanAngle = {} for i in range(len(angleNames)): scanAngle[i] = np.array([]) offset = 0 imageToBeUsed = self.imageToBeUsed for scannr in scans: if self.haltMap: raise ProcessCanceledException("ProcessCanceled") angles = self.getGeoAngles(scannr) scanAngle1 = {} scanAngle2 = {} for i in range(len(angleNames)): scanAngle1[i] = angles[:, i] scanAngle2[i] = [] arrayInitializedForScan = False foundIndex = 0 logger.debug("imageDirName %s" % self.imageDirName) logger.debug(("fileParams[%d]" % scannr) + str(self.fileParams[scannr])) imageFilePrefix = os.path.join( self.imageDirName, self.fileParams[scannr][IMAGE_PREFIX] + "_" + self.fileParams[scannr][IMAGE_NUMBER] + "." + self.fileParams[scannr][FILE_EXT]) imageNameTemplate = str(imageFilePrefix) + '.frame%d.cor' if mask_was_none: mask = [True] * len(self.imageToBeUsed[scannr]) for ind in range(len(angles[:, 0])): if imageToBeUsed[scannr][ind] and mask[ind]: imageName = imageNameTemplate % (ind + 1) logger.debug("processing image file " + imageName) image = np.empty((self.detectorDimensions[0], self.detectorDimensions[1]), np.float32) with open(imageName) as f: image.data[:] = f.read() img2 = xu.blockAverage2D(image, self.getNumPixelsToAverage()[0], self.getNumPixelsToAverage()[1], roi=self.getDetectorROI()) if not arrayInitializedForScan: imagesToProcess = [imageToBeUsed[scannr][i] and mask[i] \ for i in range(len(imageToBeUsed[scannr]))] if not intensity.shape[0]: # For first scan intensity = np.zeros( \ (np.count_nonzero(imagesToProcess),) + \ img2.shape) arrayInitializedForScan = True else: # Need to expand for addditional scans offset = intensity.shape[0] intenstity = np.concatenate( \ (intensity, \ (np.zeros((np.count_nonzero(imagesToProcess),) + img2.shape))), \ axis=0) arrayInitializedForScan = True intensity[foundIndex + offset, :, :] = img2 for i in range(len(angleNames)): logger.debug("appending angles to angle2 " + str(scanAngle1[i][ind])) scanAngle2[i].append(scanAngle1[i][ind]) foundIndex += 1 if len(scanAngle2[0]) > 0: for i in range(len(angleNames)): scanAngle[i] = \ np.concatenate((scanAngle[i], \ np.array(scanAngle2[i])), \ axis=0) angleList = [] for i in range(len(angleNames)): angleList.append(scanAngle[i]) logger.debug("Before hxrd.Ang2Q.area %s" % str(angleList)) if self.ubMatrix[scans[0]] is None: qx, qy, qz = hxrd.Ang2Q.area(*angleList, \ roi=self.detectorROI, Nav=self.numPixelsToAverage) else: qx, qy, qz = hxrd.Ang2Q.area(*angleList, \ roi=self.detectorROI, Nav=self.numPixelsToAverage, \ UB = self.ubMatrix[scans[0]]) logger.debug("After hxrd.Ang2Q.area") # apply selected transform qxTrans, qyTrans, qzTrans = \ self.transform.do3DTransform(qx, qy, qz) logger.debug(METHOD_EXIT_STR) return qxTrans, qyTrans, qzTrans, intensity
# You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. # # Copyright (C) 2016 Dominik Kriegner <*****@*****.**> import xrayutilities as xu from matplotlib.pylab import * mpl.rcParams['font.size'] = 16.0 en = 8500 # eV resol = 0.0004 # resolution in q H, K, L = (1, 1, 1) qz = linspace(1.8, 2.2, 5000) Si = xu.materials.Si hxrd = xu.HXRD(Si.Q(1, 1, -2), Si.Q(1, 1, 1), en=en) sub = xu.simpack.Layer(Si, inf) lay = xu.simpack.Layer(xu.materials.SiGe(0.6), 150, relaxation=0.5) pls = xu.simpack.PseudomorphicStack111('pseudo', sub, lay) # calculate incidence angle for dynamical diffraction models qx = hxrd.Transform(Si.Q(H, K, L))[1] ai = xu.simpack.coplanar_alphai(qx, qz, en) resolai = abs( xu.simpack.coplanar_alphai(qx, mean(qz) + resol, en) - xu.simpack.coplanar_alphai(qx, mean(qz), en)) # comparison of different diffraction models # simplest kinematical diffraction model
def findImageQs(self, angles, ub, en): logger.debug(METHOD_ENTER_STR) logger.debug("sampleCircleDirections: " + \ str(self.sampleCircleDirections)) logger.debug("detectorCircleDirections: " + \ str(self.detectorCircleDirections)) logger.debug("primaryBeamDirection: " + \ str(self.primaryBeamDirection)) qconv = xu.experiment.QConversion(self.sampleCircleDirections, self.detectorCircleDirections, self.primaryBeamDirection) logger.debug("en: " + str(en)) logger.debug("qconv: " + str(qconv)) logger.debug("inplaneReferenceDirection: " + \ str(self.sampleInplaneReferenceDirection)) logger.debug("sampleSurfaceNormalDirection: " + \ str(self.sampleSurfaceNormalDirection)) hxrd = xu.HXRD(self.sampleInplaneReferenceDirection, self.sampleSurfaceNormalDirection, en=en, qconv=qconv) cch = self.detectorCenterChannel nav = self.numPixelsToAverage roi = self.detectorROI detDims = self.detectorDimensions logger.debug("pixelDirections: " + str((self.detectorPixelDirection1, self.detectorPixelDirection2))) logger.debug("distance to detector %f, pixel Size %s" % \ (self.distanceToDetector, str(self.detectorPixelWidth))) if self.detectorDistanceOverride == 0.0: detectorDistance = self.distanceToDetector else: detectorDistance = self.detectorDistanceOverride hxrd.Ang2Q.init_area(self.getDetectorPixelDirection1(), self.getDetectorPixelDirection2(), cch1=cch[0], cch2=cch[1], Nch1=detDims[0], Nch2=detDims[1], pwidth1=self.detectorPixelWidth[0], pwidth2=self.detectorPixelWidth[1], distance=detectorDistance, Nav=nav, roi=roi) maxImageMem = self.appConfig.getMaxImageMemory() imageSize = detDims[0] * detDims[1] numImages = len(angles) if imageSize * 4 * numImages <= maxImageMem: self.progressMax = len(self.scans) * 100 self.progressInc = 1.0 * 100.0 if self.progressUpdater is not None: self.progressUpdater(self.progress, self.progressMax) self.progress += self.progressInc angleList = [] for i in range(len(angles[0])): angleList.append(angles[:, i]) if ub is None: qx, qy, qz = hxrd.Ang2Q.area(*angleList, \ roi=roi, \ Nav=nav) else: qx, qy, qz = hxrd.Ang2Q.area(*angleList, \ roi=roi, \ Nav=nav, \ UB = ub) logger.debug("Before transform qx, qy, qz " + str((qx, qy, qz))) qxTrans, qyTrans, qzTrans = self.transform.do3DTransform( qx, qy, qz) logger.debug("After transform qx, qy, qz " + str((qxTrans, qyTrans, qzTrans))) idx = range(len(qxTrans)) xmin = [np.min(qxTrans[i]) for i in idx] xmax = [np.max(qxTrans[i]) for i in idx] ymin = [np.min(qyTrans[i]) for i in idx] ymax = [np.max(qyTrans[i]) for i in idx] zmin = [np.min(qzTrans[i]) for i in idx] zmax = [np.max(qzTrans[i]) for i in idx] else: nPasses = imageSize * 4 * numImages / maxImageMem + 1 xmin = [] xmax = [] ymin = [] ymax = [] zmin = [] zmax = [] for thisPass in range(nPasses): self.progressMax = len(self.scans) * 100.0 self.progressInc = 1.0 / nPasses * 100.0 if self.progressUpdater is not None: self.progressUpdater(self.progress, self.progressMax) self.progress += self.progressInc firstImageInPass = thisPass * numImages / nPasses lastImageInPass = (thisPass + 1) * numImages / nPasses logger.debug("firstImageInPass %d, lastImageInPass %d" % (firstImageInPass, lastImageInPass)) imageList = range(firstImageInPass, lastImageInPass) angleList = [] #logger.debug("angles " + str(angles) ) for i in range(len(angles[0])): angleList.append(angles[imageList, i]) logger.debug("angleList " + str(angleList)) logger.debug("roi " + str(roi)) logger.debug("nav " + str(nav)) if ub is None: qx, qy, qz = hxrd.Ang2Q.area(*angleList, \ roi=roi, \ Nav=nav) else: qx, qy, qz = hxrd.Ang2Q.area(*angleList , \ roi=roi, \ Nav=nav, \ UB = ub) logger.debug("Before transform qx, qy, qz " + str((qx, qy, qz))) qxTrans, qyTrans, qzTrans = self.transform.do3DTransform( qx, qy, qz) logger.debug("After transform qx, qy, qz " + str((qxTrans, qyTrans, qzTrans))) idx = range(len(qxTrans)) # Using Maps xmin.extend(map(np.min, qxTrans)) xmax.extend(map(np.max, qxTrans)) ymin.extend(map(np.min, qyTrans)) ymax.extend(map(np.max, qyTrans)) zmin.extend(map(np.min, qzTrans)) zmax.extend(map(np.max, qzTrans)) #### if self.progressUpdater is not None: self.progressUpdater(self.progressMax, self.progressMax) logger.debug(METHOD_EXIT_STR + str((xmin, xmax, ymin, ymax, zmin, zmax))) return (xmin, xmax, ymin, ymax, zmin, zmax)