本文整理汇总了Python中Physics.makenormalvec方法的典型用法代码示例。如果您正苦于以下问题:Python Physics.makenormalvec方法的具体用法?Python Physics.makenormalvec怎么用?Python Physics.makenormalvec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics.makenormalvec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generator
# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import makenormalvec [as 别名]
def generator(self, Emin=1., Emax=1000., Exp=False, sphi=0., stheta=pi, deltasource=0):
'''Generates randomly a photon going onto the xtal.
Exp is the powerlaw spectral index -2.1 for Crab '''
# Defines the crystal angles using the angular coordinate of the
# reciprocal lattice vector g. The same crystal angles (with -sign)
# will be also appplied to the generated photon.
l = math.sqrt(self.photon.r[0]**2 + self.photon.r[1]**2)
#print "divergenza",self.photon.r[0], self.photon.r[1], l, self.divergence_stheta(l, deltasource)
#print "stheta", stheta
#stheta = stheta - self.divergence_stheta(l, deltasource)
#sphi = self.divergence_sphi(self.photon.r)
#print "stheta", stheta
# Set the photon intensity equal to 1. This function generate a probability
# for the photon, then it will be multplied by the requested intensity set
# in the macro
if self.photon.i !=1: self.photon.i=1.
# wavevector definition from source angular parameters
# stheta = pi and sphi = 0 means on-axis source while
# off-axis source is simply obtained by changing stheta.
# the k value is related to the energy from the relation k = 2 pi/lambda
# is the erandom function that make the k from module 1 to the correct module
# indeed erandom set the energy and follow that automatically k is set.
# Now photon.k has module 1, erandom will give the right normalization.
self.photon.k=Physics.makenormalvec(sphi, stheta)
# Energy calculation (powerlaw if Exp is False)
self.erandom((Emin, Emax), Exp=Exp)
示例2: generator
# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import makenormalvec [as 别名]
def generator(self, Emin=1., Emax=1000., Exp=False, sphi=0., stheta=pi):
'''Generates randomly a photon that will go on to xtal.
Exp is the powerlaw spectral index (-2.1 for the Crab Nebula).
'''
theta, phi = pi/2-self.xtal.gtheta, self.xtal.gphi
# lambda functions #
drag_out_xtal = lambda x: array(x) + array(self.xtal.r)
rot_out_xtal = lambda x: Physics.rot(x, (('y', -theta), ('z', -phi)))
# Puts a photon an EPSILON under the xtal surface in a random 2D point
random_pos_on_surface=[uniform(-x/2., x/2.) for x in self.xtal.dim[:2]]
random_pos_on_surface.append(-EPSILON)
self.photon.r=random_pos_on_surface
# The photon position in observer reference frame (rotation + translation)
self.photon.r=rot_out_xtal(self.photon.r)
self.photon.r=drag_out_xtal(self.photon.r)
if self.photon.i !=1: self.photon.i=1.
# wavevector definition from source angular parameters
self.photon.k=Physics.makenormalvec(sphi, stheta)
# Energy calculation (powerlaw if Exp is False)
self.erandom((Emin, Emax), Exp=Exp)