def sigma(self, G=False, order=1, distribution="gaussian"): local_xtal_g = self.change_the_g(self.xtal.g) #print "g", self.xtal.g, local_xtal_g #lgn=Physics.normalize(local_xtal_g) local_xtal_gphi = Physics.atan2(local_xtal_g[1], local_xtal_g[0]) #local_xtal_gtheta = math.acos(lgn[2]) tB = self.xtal.keV2Bragg(self.photon.e) factor = 2.5 ang_fac = Physics.angular_factor(tB) cosine = abs(self.photon.k[2]/self.photon.knorm) Q = self.xtal.mat_facs[order]*ang_fac if G is None: G=self.g_needed(order) if distribution=="hat": Dtheta = Physics.anglebetween(G, local_xtal_g) # - 2.0 * Physics.anglebetween(self.xtal.g, local_xtal_g) eta = 2.4e-6 + (self.xtal.dim[2] * self.xtal.curvature) / factor weight=Physics.hat1(Dtheta, eta)*cosine/Q elif distribution=="gaussian": Dtheta = Physics.anglebetween(G, local_xtal_g) # - 2.0 * Physics.anglebetween(self.xtal.g, local_xtal_g) weight=Physics.gaussian(Dtheta, self.xtal.eta) else: return 0. return Q*weight/cosine
def gettB(self, OFFSET=0.): """Calculates Bragg angle for an X-ray source with a certain offset. NOTE: Assumes source azimuthal angle equal to zero!!!""" if OFFSET==0.: return math.pi/2-self.gtheta else: stheta=math.pi*(1.-OFFSET/60./180.) return Physics.anglebetween((math.sin(stheta),0.,math.cos(stheta)), self.gnormalized)-math.pi/2.
def sigma(self, G=False, order=1, distribution="gaussian"): """Interface to the sigma function from Physics.""" tB = self.xtal.keV2Bragg(self.photon.e) ang_fac = Physics.angular_factor(tB) Q = self.xtal.mat_facs[order]*ang_fac if G is None: G=self.g_needed(order) Dtheta = Physics.anglebetween(G, self.xtal.g) if distribution=="hat": weight=Physics.hat(Dtheta, Physics.eta2fwhm(self.xtal.eta)) elif distribution=="gaussian": weight=Physics.gaussian(Dtheta, self.xtal.eta) else: return 0. cosine = abs(self.photon.k[2]/self.photon.knorm) return Q*weight/cosine