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


Python numpy.arctan函数代码示例

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


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

示例1: hertz_to_bark

def hertz_to_bark(cf):
    """
    ::

        Convert frequency in Hz to Bark band 
    """
    return 13 * np.arctan(0.00076 * cf) + 3.5 * np.arctan( (cf / 7500.)**2)
开发者ID:mbodhisattwa,项目名称:bregman,代码行数:7,代码来源:psychoacoustics.py

示例2: calc_theta

def calc_theta(x_predicted, y_predicted, x_true, y_true, x_ref, y_ref):
    """ Calculate the angle the predicted position and the true position, where the zero degree corresponds to the line joing the true halo position and the reference point given.
    Arguments:
        x_predicted, y_predicted: vector for predicted x- and y-positions (1 to 3 elements)
        x_true, y_true: vector for known x- and y-positions (1 to 3 elements)
        Note that the input of these are matched up so that the first elements of each
        vector are associated with one another
        x_ref, y_ref: scalars of the x,y coordinate of reference point
    Returns:
        Theta: A vector containing the angles of the predicted halo w.r.t the true halo
        with the vector joining the reference point and the halo as the zero line. 
    """

    num_halos=len(x_predicted)
    theta=np.zeros([num_halos+1],float) #Set up the array which will pass back the values
    psi = np.arctan( (y_true-y_ref)/(x_true-x_ref) ) # Angle at which the halo is at
                                                     #with respect to the reference poitn
    phi = np.arctan((y_predicted-y_true)/(x_predicted-x_true)) # Angle of the estimate
                                                               #wrt true halo centre

    #Before finding the angle with the zero line as the line joiing the halo and the reference
    #point I need to convert the angle produced by Python to an angle between 0 and 2pi
    phi =convert_to_360(phi, x_predicted-x_true,\
         y_predicted-y_true)
    psi = convert_to_360(psi, x_true-x_ref,\
                             y_true-y_ref)
    theta = phi-psi #The angle with the baseline as the line joing the ref and the halo

    
    theta[theta< 0.0]=theta[theta< 0.0]+2.0*mt.pi #If the angle of the true pos wrt the ref is
                                                  #greater than the angle of predicted pos
                                                  #and the true pos then add 2pi
    return theta
开发者ID:danfrankj,项目名称:DarkWorlds,代码行数:33,代码来源:DarkWorldsMetric.py

示例3: _fgreen3d

 def _fgreen3d(self, z, y, x):
     ''' Return the periodic integrated greens funcion on the 'original'
     domain
     Qiang, Lidia, Ryne,Limborg-Deprey, PRSTAB 10, 129901 (2007)
     Args:
         x,y,z: arrays, e.g. x, y, z = np.meshgrid(xx, yy, zz)
     '''
     abs_r = np.sqrt(x * x + y * y + z * z)
     inv_abs_r = 1./abs_r
     tmpfgreen =  (-(  +    z*z * np.arctan(x*y*inv_abs_r/z)
                   +   y*y * np.arctan(x*z*inv_abs_r/y)
                   +   x*x * np.arctan(y*z*inv_abs_r/x)
                )/2.
                 + y*z*np.log(x+abs_r)
                 + x*z*np.log(y+abs_r)
                 + x*y*np.log(z+abs_r))
     fgreen = np.zeros((2 * self.mesh.nz,
                        2 * self.mesh.ny,
                        2 * self.mesh.nx), dtype=np.complex128)
     # evaluate the indefinite integral per cell (int_a^b f = F(b) - F(a))
     fgreen[:self.mesh.nz, :self.mesh.ny, :self.mesh.nx] = (
              tmpfgreen[ 1:,  1:,  1:]
             -tmpfgreen[:-1,  1:,  1:]
             -tmpfgreen[ 1:, :-1,  1:]
             +tmpfgreen[:-1, :-1,  1:]
             -tmpfgreen[ 1:,  1:, :-1]
             +tmpfgreen[:-1,  1:, :-1]
             +tmpfgreen[ 1:, :-1, :-1]
             -tmpfgreen[:-1, :-1, :-1]
             ) * 1./self.mesh.volume_elem # divide by vol_elem to average!
     return fgreen
开发者ID:giadarol,项目名称:PyPIC,代码行数:31,代码来源:FFT_solver.py

示例4: _compute_static_prob

def _compute_static_prob(tri, com):
    """
    For an object with the given center of mass, compute
    the probability that the given tri would be the first to hit the
    ground if the object were dropped with a pose chosen uniformly at random.

    Parameters
    ----------
    tri: (3,3) float, the vertices of a triangle
    cm:  (3,) float, the center of mass of the object

    Returns
    -------
    prob: float, the probability in [0,1] for the given triangle
    """
    sv = [(v - com) / np.linalg.norm(v - com) for v in tri]

    # Use L'Huilier's Formula to compute spherical area
    a = np.arccos(min(1, max(-1, np.dot(sv[0], sv[1]))))
    b = np.arccos(min(1, max(-1, np.dot(sv[1], sv[2]))))
    c = np.arccos(min(1, max(-1, np.dot(sv[2], sv[0]))))
    s = (a + b + c) / 2.0

    # Prevents weirdness with arctan
    try:
        return 1.0 / np.pi * np.arctan(np.sqrt(np.tan(s / 2) * np.tan(
            (s - a) / 2) * np.tan((s - b) / 2) * np.tan((s - c) / 2)))
    except BaseException:
        s = s + 1e-8
        return 1.0 / np.pi * np.arctan(np.sqrt(np.tan(s / 2) * np.tan(
            (s - a) / 2) * np.tan((s - b) / 2) * np.tan((s - c) / 2)))
开发者ID:mikedh,项目名称:trimesh,代码行数:31,代码来源:poses.py

示例5: expected

def expected(scheme, angle_degrees):
    angle = angle_degrees * np.pi / 180.0

    cohesion = 10
    friction_degrees = 20
    tip_smoother = 4
    mean = -10
    friction = friction_degrees * np.pi / 180.0

    if (scheme == "native"):
        coh = cohesion
        fric = friction
    elif (scheme == "outer_tip"):
        coh = 2 * np.sqrt(3) * cohesion * np.cos(friction) / (3.0 - np.sin(friction))
        fric = np.arctan(2 * np.sin(friction) / np.sqrt(3) / (3.0 - np.sin(friction)))
    elif (scheme == "inner_tip"):
        coh = 2 * np.sqrt(3) * cohesion * np.cos(friction) / (3.0 + np.sin(friction))
        fric = np.arctan(2 * np.sin(friction) / np.sqrt(3) / (3.0 + np.sin(friction)))
    elif (scheme == "lode_zero"):
        coh = cohesion * np.cos(friction)
        fric = np.arctan(np.sin(friction) / 3.0)
    elif (scheme == "inner_edge"):
        coh = 3 * cohesion * np.cos(friction) / np.sqrt(9.0 + 3.0 * np.power(np.sin(friction), 2))
        fric = np.arctan(np.sin(friction) / np.sqrt(9.0 + 3.0 * np.power(np.sin(friction), 2)))

    bar = np.sqrt(np.power(coh - mean * 3.0 * np.tan(fric), 2) - np.power(tip_smoother, 2))
    x = bar * np.cos(angle)
    y = bar * np.sin(angle)
    return (x, y)
开发者ID:FHilty,项目名称:moose,代码行数:29,代码来源:small_deform2.py

示例6: deflections

    def deflections(self, xin, yin):
        from numpy import arctanh, arctan, arctan2, log, sin, cos

        #x,y = self.align_coords(xin,yin)
        x = xin - self.x
        y = yin - self.y
        b, rs = self.b, self.rs
        X = b / rs
        if X < 1.:
            amp = X**2 / (8 * arctanh(
                ((1 - X) / (1 + X))**0.5) / (1 - X**2)**0.5 + 4 * log(X / 2.))
        elif X == 1:
            amp = 0.25 / (1. + log(0.5))
        else:
            amp = X**2 / (8 * arctan(
                ((X - 1) / (1 + X))**0.5) / (X**2 - 1)**0.5 + 4 * log(X / 2.))

        r2 = (x**2 + y**2) / rs**2
        r = r2**0.5
        F = r * 0.
        F[r < 1.] = arctanh((1 - r2[r < 1.])**0.5) / (1 - r2[r < 1.])**0.5
        F[r == 1.] = 1.
        F[r > 1.] = arctan((r2[r > 1.] - 1.)**0.5) / (r2[r > 1.] - 1)**0.5

        dr = 4 * amp * rs * (log(r / 2) + F) / r
        A = arctan2(y, x)
        return dr * cos(A), dr * sin(A)
开发者ID:lindzlebean,项目名称:pylathon,代码行数:27,代码来源:MassProfiles.py

示例7: rotMatrixfromXYZ

def rotMatrixfromXYZ(station,mode='LBA'):
    """Return a rotation matrix which will rotate a station to (0,0,1)"""
    loc=station.antField.location[mode]
    longRotMat=rotationMatrix(0.,0.,-1.*n.arctan(loc[1]/loc[0]))
    loc0=n.dot(longRotMat,loc)
    latRotMat=rotationMatrix(0.,n.arctan(loc0[0,2]/loc0[0,0]),0.)
    return n.dot(latRotMat,longRotMat)
开发者ID:griffinfoster,项目名称:lss,代码行数:7,代码来源:lofarConfig.py

示例8: remap

    def remap(self):
        """
        warp the linear pixel coordinates to a spherical corrected representation.

        Function is called when the monitor object is initialized and populate
        the `deg_coord_x` and `deg_coord_y` attributes.
        """

        resolution = [0, 0]
        resolution[0] = self.resolution[0] / self.downsample_rate
        resolution[1] = self.resolution[1] / self.downsample_rate

        map_coord_x, map_coord_y = np.meshgrid(range(resolution[1]),
                                               range(resolution[0]))

        new_map_x = np.zeros(resolution, dtype=np.float32)
        new_map_y = np.zeros(resolution, dtype=np.float32)

        for j in range(resolution[1]):
            new_map_x[:, j] = ((180.0 / np.pi) *
                               np.arctan(self.lin_coord_x[0, j] / self.dis))
            dis2 = np.sqrt(np.square(self.dis) +
                           np.square(self.lin_coord_x[0, j]))

            for i in range(resolution[0]):
                new_map_y[i, j] = ((180.0 / np.pi) *
                                   np.arctan(self.lin_coord_y[i, 0] / dis2))

        self.deg_coord_x = new_map_x + self.center_coordinates[1]
        self.deg_coord_y = new_map_y + self.center_coordinates[0]
开发者ID:zhuangjun1981,项目名称:retinotopic_mapping,代码行数:30,代码来源:MonitorSetup.py

示例9:

def evalExactφ(sqp,sqpnext,sqpdesired):

	a=sqp/sqpdesired
	b=sqpnext/sqpdesired
	if(abs(a+1) > float("1e-12") and (a*a + b*b - 1)>0):

		φ1=2*np.arctan(     ( b -  (a*a + b*b - 1)**0.5 )/(a+1)    )
		φ2=2*np.arctan(     ( b +  (a*a + b*b - 1)**0.5 )/(a+1)    )

		if(np.isnan(φ1)):
			print("Ok nan found, locating butter chicken")
			print( (a*a + b*b -1) )
			print( (b + (a*a + b*b -1)**0.5 ) )

		φ1=np.arcsin(np.sin(φ1))
		φ2=np.arcsin(np.sin(φ2))
		if(abs(φ1)<abs(φ2)):
			print(φ1,φ2)
			return φ1
		else:
			print(φ2,φ1)
			return φ2
	else:
		print("Glaba, something went globular :P")
		return 0
开发者ID:toAtulArora,项目名称:ULB_repo,代码行数:25,代码来源:ghExactAdjacentAttempt[3_manyThingsWork_checkDec1documentation].py

示例10: extend_and_norm_feature

def extend_and_norm_feature(element, feature, command, num_elems):
    feature['element'] = element

    feature['tagname_edit'] = str_util.get_mean_distance_of_words(command, [feature['tagname']])

    # alt. str_util.get_normed_dist_for_words or str_util.get_mean_distance_of_words
    distance = str_util.new_dist
    feature['text_words_edit'] = distance(command, feature['text_words'])
    feature['sibling_text_words_edit'] = distance(command, feature['sibling_text_words'])

    feature['n_children'] = 1 - float(feature['n_children']) / num_elems

    w,h = feature['width'], feature['height']
    mx, my, sx, sy = 54.611, 25.206, 43.973, 6.467

    prior = 0.02
    likelihood_button, marginal = likelihood_and_marginal(w, h)

    if marginal != 0:
        feature['button_model'] = ((likelihood_button * prior) / marginal) - .147
    else:
        feature['button_model'] = 0

    # relative x and y can  be more than 1 because things can be beyond the edge of the window
    # so nudge things to be between -1 and 1
    feature['relative_x'] = np.arctan(1 * (feature['relative_x'] + 0.5)) / (np.pi / 2)
    feature['relative_y'] = np.arctan(1 * feature['relative_y']) / (np.pi / 2)

    # Feature ideas:
        # new on page?
        # position (relative to last action?)
        # color
        # relative tab index
        # text specificity
    return feature
开发者ID:sbirch,项目名称:webtalk,代码行数:35,代码来源:web.py

示例11: getPossibleCoordinates

def getPossibleCoordinates(fromPos, cvSize, a=None):
    a = DEFLECTIONBORDERLENGTH/2. if a is None else a
    counter = 0
    while(True):
        counter+=1
        if(counter==1000):
            print("Warning: needed 1000 attempts to find new coordinates for trajectory")
        newPos = [None, None]
        alpha = uniform(0, 2*np.pi)
        translationLength = uniform(TRANSLATIONLENGTH[0],TRANSLATIONLENGTH[1])
        
        if(a==0):
            x = math.floor(fromPos[0]+np.cos(alpha)*translationLength)
            y = math.floor(fromPos[1]-np.sin(alpha)*translationLength)
            return [x,y]
        else:
            if(fromPos[0] < cvSize[0]/2.):
                alpha1 = np.arctan(fromPos[0]/a)
                if(alpha < np.pi/2. + alpha1 or alpha > np.pi*3/2. - alpha1):
                    newPos[0] = math.floor(fromPos[0]+np.cos(alpha)*translationLength)
            else:
                alpha1 = np.arctan((cvSize[0]-fromPos[0])/a)
                if(alpha > np.pi/2. - alpha1 and alpha < np.pi*3/2. + alpha1):
                    newPos[0] = math.floor(fromPos[0]+np.cos(alpha)*translationLength)            
            if(fromPos[1]<cvSize[1]/2.):
                alpha2 = np.arctan(fromPos[1]/a)
                if(alpha < alpha2 or alpha > np.pi-alpha2):
                    newPos[1] = math.floor(fromPos[1]-np.sin(alpha)*translationLength)
            else:
                alpha2 = np.arctan((cvSize[1]-fromPos[1])/a) 
                if(alpha < np.pi+alpha2 or alpha > 2*np.pi - alpha2):
                    newPos[1] = math.floor(fromPos[1]-np.sin(alpha)*translationLength) 
            
            if(newPos[0] is not None and newPos[1] is not None and keepMiddlepointOnCanvas(cvSize, newPos)):
                return newPos
开发者ID:ImageSeriesDaniel,项目名称:ImageSeries,代码行数:35,代码来源:ImageSeriesSKImage.py

示例12: kep_eqtnP

def kep_eqtnP(del_t, p, mu=Earth.mu):
    """Parabolic solution to Kepler's Equation (Algorithm 3)
    
    A trigonometric approach to solving Kepler's Equation for 
    parabolic orbits. For reference, see Algorithm 3 in Vallado (Fourth 
    Edition), Section 2.2 (pg 69).
    
    Parameters
    ----------
    del_t: double
        Change in time
    p: double
        Semi-parameter
    mu: double, optional, default = Earth.mu
        Gravitational parameter; defaults to Earth
        
    Returns
    -------
    B: double
        Parabolic Anomaly (radians)
    """
    
    p3 = p**3
    n_p = 2.0*np.sqrt(mu/p3)
    s = 0.5*np.arctan(2.0/(3.0*n_p*del_t))
    w = np.arctan((np.tan(s))**(1/3.0))
    B = 2.0/np.tan(2.0*w)
    return B
开发者ID:xagriff,项目名称:vallado,代码行数:28,代码来源:kepler.py

示例13: calcMultipliers

def calcMultipliers(meanM, stdM, Cfactors, phiShifts, coeffs, intercept, T):
    
    K = int(len(coeffs)/2)
    C = np.zeros(K)
    phi = np.zeros(K)
    for k in range(K):
        C[k] = np.sqrt(coeffs[2*k]**2 + coeffs[2*k+1]**2)
        if coeffs[2*k] > 0:
            phi[k] = np.arctan(coeffs[2*k+1]/coeffs[2*k])
        elif coeffs[2*k] < 0:
            phi[k] = np.arctan(coeffs[2*k+1]/coeffs[2*k]) + math.pi
        else:
            phi[k] = math.pi/2
        
    y1 = np.zeros(T)
    y2 = np.zeros(T)
    for t in range(T):
        y1[t] = y1[t] + intercept
        y2[t] = y2[t] + intercept
        for k in range(K):
            y1[t] = y1[t] + C[k]*np.cos((2*math.pi*(k+1)*(t+1)/T)-phi[k])
            y2[t] = y2[t] + C[k]*Cfactors[k]*np.cos((2*math.pi*(k+1)*(t+1)/T)-(phi[k]-phiShifts[k]))
    
    meanMultipliers = meanM * y2 / y1    
    stdMultipliers = stdM * np.ones(len(meanMultipliers))
    
    return meanMultipliers, stdMultipliers
开发者ID:pslota,项目名称:Kirsch-Nowak_Streamflow_Generator,代码行数:27,代码来源:MonsoonalRescaling.py

示例14: _filter_small_slopes

def _filter_small_slopes(hgt, dx, min_slope=0):
    """Masks out slopes with NaN until the slope if all valid points is at 
    least min_slope (in degrees).
    """

    min_slope = np.deg2rad(min_slope)
    slope = np.arctan(-np.gradient(hgt, dx))  # beware the minus sign
    # slope at the end always OK
    slope[-1] = min_slope

    # Find the locs where it doesn't work and expand till we got everything
    slope_mask = np.where(slope >= min_slope, slope, np.NaN)
    r, nr = label(~np.isfinite(slope_mask))
    for objs in find_objects(r):
        obj = objs[0]
        i = 0
        while True:
            i += 1
            i0 = objs[0].start-i
            if i0 < 0:
                break
            ngap =  obj.stop - i0 - 1
            nhgt = hgt[[i0, obj.stop]]
            current_slope = np.arctan(-np.gradient(nhgt, ngap * dx))
            if i0 <= 0 or current_slope[0] >= min_slope:
                break
        slope_mask[i0:obj.stop] = np.NaN
    out = hgt.copy()
    out[~np.isfinite(slope_mask)] = np.NaN
    return out
开发者ID:JohannesUIBK,项目名称:oggm,代码行数:30,代码来源:geometry.py

示例15: calcAngle

def calcAngle(accel):
	angle = np.array([
					np.arctan(accel[0]/np.sqrt(accel[1]**2+accel[2]**2))+1.5707963267948966,
					np.arctan(accel[1]/np.sqrt(accel[0]**2+accel[2]**2))+1.5707963267948966,
					np.arctan(accel[2]/np.sqrt(accel[1]**2+accel[0]**2))+1.5707963267948966,
					])
	return angle
开发者ID:ananth95,项目名称:ananth95.github.io-simQuad,代码行数:7,代码来源:proscilloscope.py


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