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


Python numpy.arctan方法代码示例

本文整理汇总了Python中numpy.arctan方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.arctan方法的具体用法?Python numpy.arctan怎么用?Python numpy.arctan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


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

示例1: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def __init__(self, **specs):
        
        # call prototype constructor
        SurveySimulation.__init__(self, **specs)
        
        TL = self.TargetList
        SU = self.SimulatedUniverse
        
        # reinitialize working angles and delta magnitudes used for integration
        self.WAint = np.zeros(TL.nStars)*u.arcsec
        self.dMagint = np.zeros(TL.nStars)
        
        # calculate estimates of shortest WAint and largest dMagint for each target
        for sInd in range(TL.nStars):
            pInds = np.where(SU.plan2star == sInd)[0]
            self.WAint[sInd] = np.arctan(np.min(SU.a[pInds])/TL.dist[sInd]).to('arcsec')
            phis = np.array([np.pi/2]*pInds.size)
            dMags = deltaMag(SU.p[pInds], SU.Rp[pInds], SU.a[pInds], phis)
            self.dMagint[sInd] = np.min(dMags)
        
        # populate outspec with arrays
        self._outspec['WAint'] = self.WAint.value
        self._outspec['dMagint'] = self.dMagint 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:25,代码来源:KnownRVSurvey.py

示例2: computeUVN_vec

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def computeUVN_vec(n, in_, planeID):
    '''
    vectorization version of computeUVN
    @n         N x 3
    @in_      MN x 1
    @planeID   N
    '''
    n = n.copy()
    if (planeID == 2).sum():
        n[planeID == 2] = np.roll(n[planeID == 2], 2, axis=1)
    if (planeID == 3).sum():
        n[planeID == 3] = np.roll(n[planeID == 3], 1, axis=1)
    n = np.repeat(n, in_.shape[0] // n.shape[0], axis=0)
    assert n.shape[0] == in_.shape[0]
    bc = n[:, [0]] * np.sin(in_) + n[:, [1]] * np.cos(in_)
    bs = n[:, [2]]
    out = np.arctan(-bc / (bs + 1e-9))
    return out 
开发者ID:sunset1995,项目名称:HorizonNet,代码行数:20,代码来源:pano_lsd_align.py

示例3: _plot_gaussian

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def _plot_gaussian(mean, covariance, color, zorder=0):
    """Plots the mean and 2-std ellipse of a given Gaussian"""
    plt.plot(mean[0], mean[1], color[0] + ".", zorder=zorder)

    if covariance.ndim == 1:
        covariance = np.diag(covariance)

    radius = np.sqrt(5.991)
    eigvals, eigvecs = np.linalg.eig(covariance)
    axis = np.sqrt(eigvals) * radius
    slope = eigvecs[1][0] / eigvecs[1][1]
    angle = 180.0 * np.arctan(slope) / np.pi

    plt.axes().add_artist(pat.Ellipse(
        mean, 2 * axis[0], 2 * axis[1], angle=angle,
        fill=False, color=color, linewidth=1, zorder=zorder
    )) 
开发者ID:aakhundov,项目名称:tf-example-models,代码行数:19,代码来源:tf_gmm_tools.py

示例4: phase_enhance_pred

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def phase_enhance_pred(mix_STFT,pred_file, mode='STFT'):
    if mode=='wav':
        T_pred, _ = librosa.load(pred_file,sr=16000)
        F_pred = fast_stft(T_pred)
    if mode =='STFT':
        F_pred = pred_file
    M = np.sqrt(np.square(F_pred[:,:,0])+np.square(F_pred[:,:,1]))     #magnitude
    print('shape M:',M.shape)
    P = np.arctan(np.divide(mix_STFT[:,:,0],mix_STFT[:,:,1]))          #phase
    print('shape p:',P.shape)
    F_enhance = np.zeros_like(F_pred)
    print('shape enhance',F_enhance.shape)
    F_enhance[:,:,0] = np.multiply(M,np.cos(P))
    F_enhance[:,:,1] = np.multiply(M,np.sin(P))
    print('shape enhance', F_enhance.shape)
    T_enhance = fast_istft(F_enhance)
    return T_enhance

## test code part 
开发者ID:bill9800,项目名称:speech_separation,代码行数:21,代码来源:utils.py

示例5: test_look_at_updates_for_children

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def test_look_at_updates_for_children():
    dist = 2.
    cam = StereoCameraGroup(distance=dist)
    point = np.array([0, 0, 0, 1]).reshape(-1, 1)
    point[2] = -1 #np.random.randint(1, 6)

    angle = np.arctan(point[2]/(cam.distance/2))[0]
    cam.right.rotation.y = -np.rad2deg(angle)
    cam.left.rotation.y = np.rad2deg(angle)
    point_view_mat_left = np.dot(cam.left.view_matrix, point)
    point_view_mat_right = np.dot(cam.right.view_matrix, point)
    assert (point_view_mat_left == point_view_mat_right).all()

    cam2 = StereoCameraGroup(distance=dist)
    cam2.look_at(*point[:3])
    point_view_mat_left2 = np.dot(cam2.left.view_matrix, point)
    point_view_mat_right2 = np.dot(cam2.right.view_matrix, point)
    assert (point_view_mat_left == point_view_mat_left2).all() and (point_view_mat_right == point_view_mat_right2).all() 
开发者ID:ratcave,项目名称:ratcave,代码行数:20,代码来源:test_camera.py

示例6: test_branch_cuts_complex64

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def test_branch_cuts_complex64(self):
        # check branch cuts and continuity on them
        _check_branch_cut(np.log,   -0.5, 1j, 1, -1, True, np.complex64)
        _check_branch_cut(np.log2,  -0.5, 1j, 1, -1, True, np.complex64)
        _check_branch_cut(np.log10, -0.5, 1j, 1, -1, True, np.complex64)
        _check_branch_cut(np.log1p, -1.5, 1j, 1, -1, True, np.complex64)
        _check_branch_cut(np.sqrt,  -0.5, 1j, 1, -1, True, np.complex64)

        _check_branch_cut(np.arcsin, [ -2, 2],   [1j, 1j], 1, -1, True, np.complex64)
        _check_branch_cut(np.arccos, [ -2, 2],   [1j, 1j], 1, -1, True, np.complex64)
        _check_branch_cut(np.arctan, [0-2j, 2j],  [1,  1], -1, 1, True, np.complex64)

        _check_branch_cut(np.arcsinh, [0-2j,  2j], [1,   1], -1, 1, True, np.complex64)
        _check_branch_cut(np.arccosh, [ -1, 0.5], [1j,  1j], 1, -1, True, np.complex64)
        _check_branch_cut(np.arctanh, [ -2,   2], [1j, 1j], 1, -1, True, np.complex64)

        # check against bogus branch cuts: assert continuity between quadrants
        _check_branch_cut(np.arcsin, [0-2j, 2j], [ 1,  1], 1, 1, False, np.complex64)
        _check_branch_cut(np.arccos, [0-2j, 2j], [ 1,  1], 1, 1, False, np.complex64)
        _check_branch_cut(np.arctan, [ -2,  2], [1j, 1j], 1, 1, False, np.complex64)

        _check_branch_cut(np.arcsinh, [ -2,  2, 0], [1j, 1j, 1], 1, 1, False, np.complex64)
        _check_branch_cut(np.arccosh, [0-2j, 2j, 2], [1,  1,  1j], 1, 1, False, np.complex64)
        _check_branch_cut(np.arctanh, [0-2j, 2j, 0], [1,  1,  1j], 1, 1, False, np.complex64) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:test_umath.py

示例7: test_against_cmath

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def test_against_cmath(self):
        import cmath

        points = [-1-1j, -1+1j, +1-1j, +1+1j]
        name_map = {'arcsin': 'asin', 'arccos': 'acos', 'arctan': 'atan',
                    'arcsinh': 'asinh', 'arccosh': 'acosh', 'arctanh': 'atanh'}
        atol = 4*np.finfo(complex).eps
        for func in self.funcs:
            fname = func.__name__.split('.')[-1]
            cname = name_map.get(fname, fname)
            try:
                cfunc = getattr(cmath, cname)
            except AttributeError:
                continue
            for p in points:
                a = complex(func(np.complex_(p)))
                b = cfunc(p)
                assert_(abs(a - b) < atol, "%s %s: %s; cmath: %s" % (fname, p, a, b)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_umath.py

示例8: slopes_of_elevation

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def slopes_of_elevation(fp, primitive_fps, primitive_arrays, slopes):
    """A function to be fed to `compute_array` when constructing a recipe"""
    arr = primitive_arrays['dem']
    kernel = [
        [0, 1, 0],
        [1, 1, 1],
        [0, 1, 0],
    ]
    arr = (
        scipy.ndimage.maximum_filter(arr, None, kernel) -
        scipy.ndimage.minimum_filter(arr, None, kernel)
    )
    arr = arr[1:-1, 1:-1]
    arr = np.arctan(arr / fp.pxsizex)
    arr = arr / np.pi * 180.
    return arr 
开发者ID:airware,项目名称:buzzard,代码行数:18,代码来源:part2.py

示例9: Hillshade

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def Hillshade(raster_file, azimuth, angle_altitude): 
    
    array = ReadRasterArrayBlocks(raster_file,raster_band=1)    
    
    x, y = np.gradient(array)
    slope = np.pi/2. - np.arctan(np.sqrt(x*x + y*y))
    aspect = np.arctan2(-x, y)
    azimuthrad = np.azimuth*np.pi / 180.
    altituderad = np.angle_altitude*np.pi / 180.
     
 
    shaded = np.sin(altituderad) * np.sin(slope)\
     + np.cos(altituderad) * np.cos(slope)\
     * np.cos(azimuthrad - aspect)
    return 255*(shaded + 1)/2
#============================================================================== 
开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:18,代码来源:LSDMappingTools.py

示例10: _cdf

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def _cdf(self, x, c):
        output = np.zeros(x.shape, dtype=x.dtype)
        val = (1.0+c)/(1.0-c)
        c1 = x < np.pi
        c2 = 1-c1
        xp = np.extract(c1, x)
        xn = np.extract(c2, x)
        if np.any(xn):
            valn = np.extract(c2, np.ones_like(x)*val)
            xn = 2*np.pi - xn
            yn = np.tan(xn/2.0)
            on = 1.0-1.0/np.pi*np.arctan(valn*yn)
            np.place(output, c2, on)
        if np.any(xp):
            valp = np.extract(c1, np.ones_like(x)*val)
            yp = np.tan(xp/2.0)
            op = 1.0/np.pi*np.arctan(valp*yp)
            np.place(output, c1, op)
        return output 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:21,代码来源:_continuous_distns.py

示例11: _evaluate

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def _evaluate(self, X, out, *args, **kwargs):
        g = self.g1(X)
        f0 = g * X[:, 0]
        f1 = g * np.sqrt(1.0 - np.power(f0 / g, 2.0))

        with np.errstate(divide='ignore'):
            atan = np.arctan(f1 / f0)

        g0 = f0 ** 2 + f1 ** 2 - np.power(1.7 - self.LA2(0.2, 2.0, 1.0, 1.0, atan), 2.0)
        t = 0.5 * np.pi - 2 * np.abs(atan - 0.25 * np.pi)
        g1 = np.power(1 + self.LA2(0.5, 6.0, 3.0, 1.0, t), 2.0) - f0 ** 2 - f1 ** 2
        g2 = np.power(1 - self.LA2(0.45, 6.0, 3.0, 1.0, t), 2.0) - f0 ** 2 - f1 ** 2
        out["F"] = np.column_stack([f0, f1])
        out["G"] = np.column_stack([g0, g1, g2]) 
开发者ID:msu-coinlab,项目名称:pymoo,代码行数:16,代码来源:mw.py

示例12: _calc_pareto_front

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def _calc_pareto_front(self, ref_dirs=None):
        if ref_dirs is None:
            F = np.zeros((100, 2))
            F[:, 0] = np.linspace(0, 1, 100)
        else:
            F = ref_dirs
        F[:, 1] = 1 - F[:, 0]
        F = F / np.sqrt(np.sum(F ** 2, axis=1) / 1.21).reshape((-1, 1))
        l = np.cos(6 * np.arctan(F[:, 1] / F[:, 0]) ** 4) ** 10
        c = 1 - (F[:, 0] / (1 + 0.15 * l)) ** 2 - (F[:, 1] / (1 + 0.75 * l)) ** 2
        return F[c >= 0] 
开发者ID:msu-coinlab,项目名称:pymoo,代码行数:13,代码来源:mw.py

示例13: g_r

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def g_r(grids_coor, site, l, mr, r, zona, x_axis = [1,0,0], z_axis = [0,0,1], unit = 'B'):
    r'''
    Evaluate the projection function g(r) or \Theta_{l,m_r}(\theta,\phi) on a grid
    ref: Chapter 3, wannier90 User Guide
    Attributes:
        grids_coor : a grids for the cell of interest
        site       : absolute coordinate (in Borh/Angstrom) of the g(r) in the cell
        l, mr      : l and mr value in the Table 3.1 and 3.2 of the ref
    Return:
        theta_lmr  : an array (ngrid, value) of g(r)

    '''

    unit_conv = 1
    if unit == 'A': unit_conv = param.BOHR


    r_vec = (grids_coor - site)
    r_vec = np.einsum('iv,uv ->iu', r_vec, transform(x_axis, z_axis))
    r_norm = np.linalg.norm(r_vec,axis=1)
    if (r_norm < 1e-8).any() == True:
        r_vec = (grids_coor - site - 1e-5)
        r_vec = np.einsum('iv,uv ->iu', r_vec, transform(x_axis, z_axis))
        r_norm = np.linalg.norm(r_vec,axis=1)
    cost = r_vec[:,2]/r_norm

    phi = np.empty_like(r_norm)
    for point in range(phi.shape[0]):
        if r_vec[point,0] > 1e-8:
            phi[point] = np.arctan(r_vec[point,1]/r_vec[point,0])
        elif r_vec[point,0] < -1e-8:
            phi[point] = np.arctan(r_vec[point,1]/r_vec[point,0]) + np.pi
        else:
            phi[point] = np.sign(r_vec[point,1]) * 0.5 * np.pi

    return theta_lmr(l, mr, cost, phi) * R_r(r_norm * unit_conv, r = r, zona = zona) 
开发者ID:pyscf,项目名称:pyscf,代码行数:38,代码来源:pywannier90.py

示例14: computeUVN

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def computeUVN(n, in_, planeID):
    '''
    compute v given u and normal.
    '''
    if planeID == 2:
        n = np.array([n[1], n[2], n[0]])
    elif planeID == 3:
        n = np.array([n[2], n[0], n[1]])
    bc = n[0] * np.sin(in_) + n[1] * np.cos(in_)
    bs = n[2]
    out = np.arctan(-bc / (bs + 1e-9))
    return out 
开发者ID:sunset1995,项目名称:HorizonNet,代码行数:14,代码来源:pano_lsd_align.py

示例15: np_xy2coor

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import arctan [as 别名]
def np_xy2coor(xy, z=50, coorW=1024, coorH=512, floorW=1024, floorH=512):
    '''
    xy: N x 2
    '''
    x = xy[:, 0] - floorW / 2 + 0.5
    y = xy[:, 1] - floorH / 2 + 0.5

    u = np.arctan2(x, -y)
    v = np.arctan(z / np.sqrt(x**2 + y**2))

    coorx = (u / (2 * PI) + 0.5) * coorW - 0.5
    coory = (-v / PI + 0.5) * coorH - 0.5

    return np.hstack([coorx[:, None], coory[:, None]]) 
开发者ID:sunset1995,项目名称:HorizonNet,代码行数:16,代码来源:post_proc.py


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