当前位置: 首页>>代码示例>>Python>>正文


Python scipy.arctan2函数代码示例

本文整理汇总了Python中scipy.arctan2函数的典型用法代码示例。如果您正苦于以下问题:Python arctan2函数的具体用法?Python arctan2怎么用?Python arctan2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了arctan2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pix2sky

def pix2sky(header,x,y):
	hdr_info = parse_header(header)
	x0 = x-hdr_info[1][0]+1.	# Plus 1 python->image
	y0 = y-hdr_info[1][1]+1.
	x0 = x0.astype(scipy.float64)
	y0 = y0.astype(scipy.float64)
	x = hdr_info[2][0,0]*x0 + hdr_info[2][0,1]*y0
	y = hdr_info[2][1,0]*x0 + hdr_info[2][1,1]*y0
	if hdr_info[3]=="DEC":
		a = x.copy()
		x = y.copy()
		y = a.copy()
		ra0 = hdr_info[0][1]
		dec0 = hdr_info[0][0]/raddeg
	else:
		ra0 = hdr_info[0][0]
		dec0 = hdr_info[0][1]/raddeg
	if hdr_info[5]=="TAN":
		r_theta = scipy.sqrt(x*x+y*y)/raddeg
		theta = arctan(1./r_theta)
		phi = arctan2(x,-1.*y)
	elif hdr_info[5]=="SIN":
		r_theta = scipy.sqrt(x*x+y*y)/raddeg
		theta = arccos(r_theta)
		phi = artan2(x,-1.*y)
	ra = ra0 + raddeg*arctan2(-1.*cos(theta)*sin(phi-pi),
				   sin(theta)*cos(dec0)-cos(theta)*sin(dec0)*cos(phi-pi))
	dec = raddeg*arcsin(sin(theta)*sin(dec0)+cos(theta)*cos(dec0)*cos(phi-pi))

	return ra,dec
开发者ID:MCTwo,项目名称:CodeCDF,代码行数:30,代码来源:wcs.py

示例2: detect_skew

def detect_skew(img, min_angle=-20, max_angle=20, quality='low'):
    img = sp.atleast_2d(img)
    rows, cols = img.shape
    min_min_angle = min_angle
    max_max_angle = max_angle

    if quality == 'low':
        resolution = sp.arctan2(2.0, cols) * 180.0 / sp.pi
        min_target_size = 100
        resize_order = 1
    elif quality == 'high':
        resolution = sp.arctan2(1.0, cols) * 180.0 / sp.pi
        min_target_size = 300
        resize_order = 3
    else:
        resolution = sp.arctan2(1.0, cols) * 180.0 / sp.pi
        min_target_size = 200
        resize_order = 2

    # resize the image so it's faster to work with
    min_size = min(rows, cols)
    target_size = min_target_size if min_size > min_target_size else min_size
    resize_ratio = float(target_size) / min_size
    img = imresize(img, resize_ratio)
    rows, cols = img.shape

    # pad the image and invert the colors
    img *= -1
    img += 255
    padded_img = sp.zeros((rows*2, cols*2))
    padded_img[rows//2:rows//2+rows, cols//2:cols//2+cols] = img
    img = padded_img

    # keep dividing the interval in half to achieve O(log(n))
    while True:
        current_resolution = (max_angle - min_angle) / 30.0
        best_angle = None
        best_variance = 0.0

        # rotate the image, sum the pixel values in each row for each rotation
        # then find the variance of all the sums, pick the highest variance
        for i in xrange(31):
            angle = min_angle + i * current_resolution
            rotated_img = rotate(img, angle, reshape=False, order=resize_order)
            num_black_pixels = sp.sum(rotated_img, axis=1)
            variance = sp.var(num_black_pixels)
            if variance > best_variance:
                best_angle = angle
                best_variance = variance

        if current_resolution < resolution:
            break

        # update the angle range
        min_angle = max(best_angle - current_resolution, min_min_angle)
        max_angle = min(best_angle + current_resolution, max_max_angle)

    return best_angle
开发者ID:sunnyrjuneja,项目名称:ai_tidbits,代码行数:58,代码来源:detect_skew1.py

示例3: update

 def update(self, order, dt=0.1):
   angle = self.X[0]
   V = 150*speed(self.X)
   order_stick = order + sp.arctan2(self.X[2], self.X[1])/sp.pi/2
   dx0 = self.k*(windForce(self.X, 400) +0.)*(order_stick-0.*sp.sin(sp.arctan2(self.X[2], self.X[1])-sp.pi/2))
   dx1 = -V*sp.sin(angle) + self.kdrift*order*sp.cos(angle) 
   dx2 = V*sp.cos(angle) + self.kdrift*order*sp.sin(angle)-30
   dX = dt*np.array([dx0[0], dx1[0], dx2[0]])
   self.X = self.X + dX
   self.X = np.array([self.X[0], self.X[1], np.max([0, self.X[2]])])
开发者ID:baptistelabat,项目名称:robokite,代码行数:10,代码来源:kinematic_kite_model.py

示例4: matrixToEuler

def matrixToEuler(m,order='Aerospace',inDegrees=True):
    if order == 'Aerospace' or order == 'ZYX':
        sp = -m[2,0]
        if sp < (1-EPS):
            if sp > (-1+EPS):
                p = arcsin(sp)
                r = arctan2(m[2,1],m[2,2])
                y = arctan2(m[1,0],m[0,0])
            else:
                p = -pi/2.
                r = 0
                y = pi-arctan2(-m[0,1],m[0,2])
        else:
            p = pi/2.
            y = arctan2(-m[0,1],m[0,2])
            r = 0
        
        if inDegrees:
            return degrees((y,p,r))
        else:
            return (y,p,r)
    elif order == 'BVH' or order == 'ZXY':
        sx = m[2,1]
        if sx < (1-EPS):
            if sx > (-1+EPS):
                x = arcsin(sx)
                z = arctan2(-m[0,1],m[1,1])
                y = arctan2(-m[2,0],m[2,2])
            else:
                x = -pi/2
                y = 0
                z = -arctan2(m[0,2],m[0,0])
        else:
            x = pi/2
            y = 0
            z = arctan2(m[0,2],m[0,0])
        if inDegrees:
            return degrees((z,x,y))
        else:
            return (z,x,y)

    elif order == "ZXZ":
        x = arccos(m[2,2])
        z2 = arctan2(m[2,0],m[2,1])
        z1 = arctan2(m[0,2],-m[1,2])
        if inDegrees:
            return degrees((z1,x,z2))
        else:
            return (z1,x,z2)
开发者ID:buguen,项目名称:minf,代码行数:49,代码来源:quat.py

示例5: detect_skew

def detect_skew(img, min_angle=-20, max_angle=20, quality='low'):
    img = sp.atleast_2d(img)
    rows, cols = img.shape
    min_min_angle = min_angle
    max_max_angle = max_angle

    if quality == 'low':
        resolution = sp.arctan2(2.0, cols) * 180.0 / sp.pi
        min_target_size = 100
        resize_order = 1
    elif quality == 'high':
        resolution = sp.arctan2(1.0, cols) * 180.0 / sp.pi
        min_target_size = 300
        resize_order = 3
    else:
        resolution = sp.arctan2(1.0, cols) * 180.0 / sp.pi
        min_target_size = 200
        resize_order = 2

    # resize the image so it's faster to work with
    min_size = min(rows, cols)
    target_size = min_target_size if min_size > min_target_size else min_size
    resize_ratio = float(target_size) / min_size
    img = imresize(img, resize_ratio)
    rows, cols = img.shape

    img *= -1
    img += 255

    while True:
        current_resolution = (max_angle - min_angle) / 30.0
        angles = sp.linspace(min_angle, max_angle, 31)

        # do the hough transfer
        hough_out = _hough_transform(img, angles * sp.pi / 180)
        
        # determine which angle gives max variance
        variances = sp.var(hough_out, axis=0)
        max_variance_index = sp.argmax(variances)
        best_angle = min_angle + max_variance_index * current_resolution

        if current_resolution < resolution:
            break

        # update the angle range
        min_angle = max(best_angle - current_resolution, min_min_angle)
        max_angle = min(best_angle + current_resolution, max_max_angle)

    return best_angle
开发者ID:sunnyrjuneja,项目名称:ai_tidbits,代码行数:49,代码来源:detect_skew2.py

示例6: xyz2lbr

def xyz2lbr (x, y, z, d0=dsun):
    """ convert galactic xyz into sun-centered lbr coordinates; derived from stCoords.c"""
    #if len(xyz.shape) > 1:  x, y, z = xyz[:,0], xyz[:,1], xyz[:,2]
    #else:                   x, y, z = xyz[0], xyz[1], xyz[2]
    xsun = x + d0
    temp = (xsun*xsun) + (y*y)
    l = sc.arctan2(y, xsun) * deg
    b = sc.arctan2(z, sc.sqrt(temp)) * deg
    r = sc.sqrt(temp + (z*z))
    if type(l) == type(arr):
        for i in range(len(l)):
            if l[i] < 0.0:  l[i] = l[i] + 360.0
    else:
        if l < 0.0:  l = l + 360.0
    return l,b,r
开发者ID:weissj3,项目名称:Newby-tools,代码行数:15,代码来源:astro_coordinates.py

示例7: rect_to_cyl

def rect_to_cyl(X,Y,Z):
    """
    NAME:

       rect_to_cyl

    PURPOSE:

       convert from rectangular to cylindrical coordinates

    INPUT:

       X, Y, Z - rectangular coordinates

    OUTPUT:

       R,phi,z

    HISTORY:

       2010-09-24 - Written - Bovy (NYU)

    """
    R= sc.sqrt(X**2.+Y**2.)
    phi= sc.arctan2(Y,X)
    if isinstance(phi,nu.ndarray): phi[phi<0.]+= 2.*nu.pi
    elif phi < 0.: phi+= 2.*nu.pi
    return (R,phi,Z)
开发者ID:Fernandez-Trincado,项目名称:galpy,代码行数:28,代码来源:bovy_coords.py

示例8: rect_to_cyl

def rect_to_cyl(X,Y,Z):
    """
    NAME:

       rect_to_cyl

    PURPOSE:

       convert from rectangular to cylindrical coordinates

    INPUT:

       X, Y, Z - rectangular coordinates

    OUTPUT:

       R,phi,z

    HISTORY:

       2010-09-24 - Written - Bovy (NYU)

    """
    R= sc.sqrt(X**2.+Y**2.)
    phi= sc.arctan2(Y,X)
    return (R,phi,Z)
开发者ID:jaekor91,项目名称:unWISE-BOSS,代码行数:26,代码来源:equ2galactic.py

示例9: ecef2geodetic

def ecef2geodetic(x, y, z):
    """Convert ECEF coordinates to geodetic.
    J. Zhu, "Conversion of Earth-centered Earth-fixed coordinates \
    to geodetic coordinates," IEEE Transactions on Aerospace and \
    Electronic Systems, vol. 30, pp. 957-961, 1994."""
    a = 6378.137
    b = 6356.7523142
    esq = 6.69437999014 * 0.001
    e1sq = 6.73949674228 * 0.001

    # return h in kilo
    r = sqrt(x * x + y * y)
    Esq = a * a - b * b
    F = 54 * b * b * z * z
    G = r * r + (1 - esq) * z * z - esq * Esq
    C = (esq * esq * F * r * r) / (pow(G, 3))
    S = sqrt(1 + C + sqrt(C * C + 2 * C))
    P = F / (3 * pow((S + 1 / S + 1), 2) * G * G)
    Q = sqrt(1 + 2 * esq * esq * P)
    r_0 =  -(P * esq * r) / (1 + Q) + sqrt(0.5 * a * a*(1 + 1.0 / Q) - \
        P * (1 - esq) * z * z / (Q * (1 + Q)) - 0.5 * P * r * r)
    U = sqrt(pow((r - esq * r_0), 2) + z * z)
    V = sqrt(pow((r - esq * r_0), 2) + (1 - esq) * z * z)
    Z_0 = b * b * z / (a * V)
    h = U * (1 - b * b / (a * V))
    lat = arctan((z + e1sq * Z_0) / r)
    lon = arctan2(y, x)
    return degrees(lat), degrees(lon), h
开发者ID:Ezpy,项目名称:MaxElevation,代码行数:28,代码来源:gps.py

示例10: _update_strain

 def _update_strain(self):
     self.e = (self.exy - self.eyx) / 2
     self.k = (self.exx + self.eyy) * 1000000. / 2
     self.strain = scipy.sqrt((self.exx - self.eyy) * (self.exx - self.eyy) + (self.exy + self.eyx) * (self.exy + self.eyx)) * 1000000.
     self.k_max = self.k + self.strain / 2
     self.k_min = self.k - self.strain / 2
     self.az = scipy.degrees(2 * scipy.arctan2(self.exy + self.eyx, self.eyy - self.exx))
开发者ID:demanasta,项目名称:GeoToolbox,代码行数:7,代码来源:strain.py

示例11: north_direction

def north_direction(lat):
    '''get the north direction relative to image positive y coordinate'''
    dlatdx = nd.filters.sobel(lat,axis=1,mode='constant',cval=sp.nan) #gradient in x-direction
    dlatdy = nd.filters.sobel(lat,axis=0,mode='constant',cval=sp.nan)
    ydir = lat[-1,0] -lat[0,0] # check if latitude is ascending or descending in y axis
    # same step might have to be done with x direction.
    return sp.arctan2(dlatdx,dlatdy*sp.sign(ydir) )*180/sp.pi
开发者ID:johannesro,项目名称:waveverification,代码行数:7,代码来源:dataanalysis.py

示例12: xyz2longlat

def xyz2longlat(x,y,z):
    """ converts cartesian x,y,z coordinates into spherical longitude and latitude """
    r = sc.sqrt(x*x + y*y + z*z)
    long = sc.arctan2(y,x)
    d = sc.sqrt(x*x + y*y)
    lat = sc.arcsin(z/r)
    return long*deg, lat*deg, r
开发者ID:weissj3,项目名称:Newby-tools,代码行数:7,代码来源:astro_coordinates.py

示例13: two_d_ellipse

    def two_d_ellipse(self,proj_vars,p,**kwargs):
        """Return the 2d projection as a matplotlib Ellipse object for the given p values
        Parameters
        ----------
        proj_vars : array that is 1 for the projection dimension, and 0 other wise
                    i.e. array([0,0,1,0,1]) will project 5d ellipsoid onto the plane
                    span by the 3rd and 5th variable.
        p         : the percent of points contained in the ellipsoid, either a single
                     value of a list of values i.e. 0.68 or [0.68,0.955],

                     if p is a list then a list of Ellipse objects will be returned, one for each p value
        Keywords
        --------
        kwargs : keywords to be passed into the matplotlib Ellipse object

        Return
        ------
        ells : matplotlib Ellipse object
        """
        mu,u,s=self.proj(proj_vars) #get the mean, eigenvectors, and eigenvales for projected array
        try: #if a list get the length
            l=len(p)
        except: #if not then make it a list of length 1
            l=1
            p=[p]
        invp=st.chi.ppf(p,self.dim) #scale it using a chi distribution (see, now we scale it)
        angle=rad2deg(arctan2(u[0,1],u[0,0])) #angle the first eignevector makes with the x-axis
        ells=[] #list to hold the Ellipse objects
        for i in invp:
            ells.append(Ellipse(xy=mu,width=s[0]*i*2,height=s[1]*i*2,angle=angle,**kwargs))#make the Ellipse objects, the *2 is needed since Ellipse takes the full axis vector
        if l==1: #if only one p values was given return the Ellipse object (not as a list)
            return ells[0]
        else: #else return the list of Ellipse objects
            return ells
开发者ID:cmp346,项目名称:densityplot,代码行数:34,代码来源:error_ellipse.py

示例14: resolve_tri

def resolve_tri(A,B,a,b,up=True):
    AB=A-B
    c=l.norm(AB)
    aa=s.arctan2(AB[1],AB[0])
    bb=s.arccos((b**2+c**2-a**2)/(2*b*c))
    if up: return B+b*s.array((s.cos(aa+bb),s.sin(aa+bb)))
    else: return B+b*s.array((s.cos(aa-bb),s.sin(aa-bb)))
开发者ID:elcerdo,项目名称:jansen,代码行数:7,代码来源:jansen.py

示例15: __init__

 def __init__(self, output='out', input='in', \
              mag=None, phase=None, coh=None, \
              freqlim=[], maglim=[], phaselim=[], \
              averaged='not specified', \
              seedfreq=-1, seedphase=0,
              labels=[], legloc=-1, compin=[]):
     self.output = output
     self.input = input
     if len(compin) > 0:
        if mag is None:
           self.mag = squeeze(colwise(abs(compin)))
        if phase is None:
           self.phase = squeeze(colwise(arctan2(imag(compin),real(compin))*180.0/pi))
     else:
         self.mag = squeeze(mag)
         self.phase = squeeze(phase)
     self.coh = coh
     self.averaged = averaged
     self.seedfreq = seedfreq
     self.seedphase = seedphase
     self.freqlim = freqlim
     self.maglim = maglim
     self.phaselim = phaselim
     self.labels = labels
     self.legloc = legloc
开发者ID:ryanGT,项目名称:research,代码行数:25,代码来源:rwkbode.py


注:本文中的scipy.arctan2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。