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


Python numpy.angle方法代码示例

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


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

示例1: _retinotopic_field_sign_triangles

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _retinotopic_field_sign_triangles(m, retinotopy):
    t = m.tess if isinstance(m, geo.Mesh) or isinstance(m, geo.Topology) else m
    # get the polar angle and eccen data as a complex number in degrees
    if pimms.is_str(retinotopy):
        (x,y) = as_retinotopy(retinotopy_data(m, retinotopy), 'geographical')
    elif retinotopy is Ellipsis:
        (x,y) = as_retinotopy(retinotopy_data(m, 'any'),      'geographical')
    else:
        (x,y) = as_retinotopy(retinotopy,                     'geographical')
    # Okay, now we want to make some coordinates...
    coords = np.asarray([x, y])
    us = coords[:, t.indexed_faces[1]] - coords[:, t.indexed_faces[0]]
    vs = coords[:, t.indexed_faces[2]] - coords[:, t.indexed_faces[0]]
    (us,vs) = [np.concatenate((xs, np.full((1, t.face_count), 0.0))) for xs in [us,vs]]
    xs = np.cross(us, vs, axis=0)[2]
    xs[np.isclose(xs, 0)] = 0
    return np.sign(xs) 
开发者ID:noahbenson,项目名称:neuropythy,代码行数:19,代码来源:retinotopy.py

示例2: extract_chip_samples

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def extract_chip_samples(samples):
    a = array(samples)
    f = scipy.fft(a*a)
    p = find_clock_frequency(abs(f))
    if 0 == p:
        return []
    cycles_per_sample = (p*1.0)/len(f)
    clock_phase = 0.25 + numpy.angle(f[p])/(tau)
    if clock_phase <= 0.5:
        clock_phase += 1
    chip_samples = []
    for i in range(len(a)):
        if clock_phase >= 1:
            clock_phase -= 1
            chip_samples.append(a[i])
        clock_phase += cycles_per_sample
    return chip_samples

# input: complex valued samples, FFT bin number of chip rate
#        input signal must be centered at 0 frequency
# output: number of chips found in repetitive chip sequence 
开发者ID:mossmann,项目名称:clock-recovery,代码行数:23,代码来源:dsss-bpsk-reverse.py

示例3: _eigen_components

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _eigen_components(self):
        # projector onto subspace spanned by basis states with
        # Hamming weight != 2
        zero_component = np.diag(
            [int(bin(i).count('1') != 2) for i in range(16)])

        state_pairs = (('0110', '1001'), ('0101', '1010'), ('0011', '1100'))

        plus_minus_components = tuple(
            (-abs(weight) * sign / np.pi,
             state_swap_eigen_component(state_pair[0], state_pair[1], sign,
                                        np.angle(weight)))
            for weight, state_pair in zip(self.weights, state_pairs)
            for sign in (-1, 1))

        return ((0, zero_component),) + plus_minus_components 
开发者ID:quantumlib,项目名称:OpenFermion-Cirq,代码行数:18,代码来源:fermionic_simulation.py

示例4: test_get_coords_meshgrid

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def test_get_coords_meshgrid(nxy, inc, dxy, Dx, Dy, real_type, tol, acc_lib):

    ncol, nrow = nxy, nxy

    # create the referencemesh grid
    inc_cos = np.cos(inc)
    x = (np.linspace(0.5, -0.5 + 1./float(ncol), ncol, dtype=real_type)) * dxy * ncol
    y = (np.linspace(0.5, -0.5 + 1./float(nrow), nrow, dtype=real_type)) * dxy * nrow

    # we shrink the x axis, since PA is the angle East of North of the
    # the plane of the disk (orthogonal to the angular momentum axis)
    # PA=0 is a disk with vertical orbital node (aligned along North-South)
    x_m, y_m = np.meshgrid((x - Dx)/ inc_cos, y - Dy)
    R_m = np.sqrt(x_m ** 2. + y_m ** 2.)

    x_test, y_test, x_m_test, y_m_test, R_m_test = acc_lib.get_coords_meshgrid(nrow, ncol, dxy, inc, Dx=Dx, Dy=Dy, origin='upper')

    assert_allclose(x, x_test, atol=0, rtol=tol)
    assert_allclose(y, y_test, atol=0, rtol=tol)
    assert_allclose(x_m, x_m_test, atol=0, rtol=tol)
    assert_allclose(y_m, y_m_test, atol=0, rtol=tol)
    assert_allclose(R_m, R_m_test, atol=0, rtol=tol) 
开发者ID:mtazzari,项目名称:galario,代码行数:24,代码来源:test_galario.py

示例5: psi

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def psi(self):
        # psi angle 0 - horizontal, pi/2 - vertical
        with np.errstate(divide='ignore'):
            psi = np.arctan(self.s2 / self.s1) / 2

        idx1 = np.where((self.s1 < 0) & (self.s2 > 0))
        idx2 = np.where((self.s1 < 0) & (self.s2 < 0))
        if np.size(psi) == 1:
            # continue
            # psi = psi
            if np.size(idx1): psi += np.pi / 2
            if np.size(idx2): psi -= np.pi / 2
        else:
            psi[idx1] += np.pi / 2
            psi[idx2] -= np.pi / 2
        return psi 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:18,代码来源:wave.py

示例6: comp_angle_opening

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def comp_angle_opening(self):
    """Compute the average opening angle of the Slot

    Parameters
    ----------
    self : Slot
        A Slot object

    Returns
    -------
    alpha: float
        Average opening angle of the slot [rad]

    """

    line_list = self.build_geometry()
    Z1 = line_list[0].get_begin()
    Z2 = line_list[-1].get_end()

    return angle(Z2) - angle(Z1) 
开发者ID:Eomys,项目名称:pyleecan,代码行数:22,代码来源:comp_angle_opening.py

示例7: _griffin_lim

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _griffin_lim(S):
    angles = np.exp(2j * np.pi * np.random.rand(*S.shape))
    S_complex = np.abs(S).astype(np.complex)
    for i in range(hparams.griffin_lim_iters):
        if i > 0:
            angles = np.exp(1j * np.angle(_stft(y)))
        y = _istft(S_complex * angles)
    return y 
开发者ID:candlewill,项目名称:Griffin_lim,代码行数:10,代码来源:audio.py

示例8: calc_registration

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def calc_registration(preregistration_map, anchors,
                      max_steps=2000, max_step_size=0.05, method='random'):
    '''
    calc_registration is a calculator that creates the registration coordinates.
    '''
    # if max steps is a tuple (max, stride) then a trajectory is saved into
    # the registered_map meta-data
    pmap = preregistration_map
    if is_tuple(max_steps) or is_list(max_steps):
        (max_steps, stride) = max_steps
        traj = [preregistration_map.coordinates]
        x = preregistration_map.coordinates
        for s in np.arange(0, max_steps, stride):
            x = mesh_register(
                preregistration_map,
                [['edge',      'harmonic',      'scale', 1.0],
                 ['angle',     'infinite-well', 'scale', 1.0],
                 ['perimeter', 'harmonic'],
                 anchors],
                initial_coordinates=x,
                method=method,
                max_steps=stride,
                max_step_size=max_step_size)
            traj.append(x)
        pmap = pmap.with_meta(trajectory=np.asarray(traj))
    else:
        x = mesh_register(
            preregistration_map,
            [['edge',      'harmonic',      'scale', 1.0],
             ['angle',     'infinite-well', 'scale', 1.0],
             ['perimeter', 'harmonic'],
             anchors],
            method=method,
            max_steps=max_steps,
            max_step_size=max_step_size)
    return pmap.copy(coordinates=x) 
开发者ID:noahbenson,项目名称:neuropythy,代码行数:38,代码来源:retinotopy.py

示例9: wpcr

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def wpcr(a):
    if len(a) < 4:
        return []
    b = (a > midpoint(a)) * 1.0
    d = numpy.diff(b)**2
    if len(numpy.argwhere(d > 0)) < 2:
        return []
    f = scipy.fft(d, len(a))
    p = find_clock_frequency(abs(f))
    if p == 0:
        return []
    cycles_per_sample = (p*1.0)/len(f)
    clock_phase = 0.5 + numpy.angle(f[p])/(tau)
    if clock_phase <= 0.5:
        clock_phase += 1
    symbols = []
    for i in range(len(a)):
        if clock_phase >= 1:
            clock_phase -= 1
            symbols.append(a[i])
        clock_phase += cycles_per_sample
    if debug:
        print("peak frequency index: %d / %d" % (p, len(f)))
        print("samples per symbol: %f" % (1.0/cycles_per_sample))
        print("clock cycles per sample: %f" % (cycles_per_sample))
        print("clock phase in cycles between 1st and 2nd samples: %f" % (clock_phase))
        print("clock phase in cycles at 1st sample: %f" % (clock_phase - cycles_per_sample/2))
        print("symbol count: %d" % (len(symbols)))
    return symbols

# convert soft symbols into bits (assuming binary symbols) 
开发者ID:mossmann,项目名称:clock-recovery,代码行数:33,代码来源:wpcr.py

示例10: _slater_basis_change

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _slater_basis_change(qubits: Sequence[cirq.Qid],
                         transformation_matrix: numpy.ndarray,
                         initially_occupied_orbitals: Optional[Sequence[int]]
                         ) -> cirq.OP_TREE:
    n_qubits = len(qubits)

    if initially_occupied_orbitals is None:
        decomposition, diagonal = givens_decomposition_square(
                transformation_matrix)
        circuit_description = list(reversed(decomposition))
        # The initial state is not a computational basis state so the
        # phases left on the diagonal in the decomposition matter
        yield (cirq.rz(rads=numpy.angle(diagonal[j])).on(qubits[j])
               for j in range(n_qubits))
    else:
        initially_occupied_orbitals = cast(
                Sequence[int], initially_occupied_orbitals)
        transformation_matrix = transformation_matrix[
                list(initially_occupied_orbitals)]
        n_occupied = len(initially_occupied_orbitals)
        # Flip bits so that the first n_occupied are 1 and the rest 0
        initially_occupied_orbitals_set = set(initially_occupied_orbitals)
        yield (cirq.X(qubits[j]) for j in range(n_qubits)
               if (j < n_occupied) != (j in initially_occupied_orbitals_set))
        circuit_description = slater_determinant_preparation_circuit(
                transformation_matrix)

    yield _ops_from_givens_rotations_circuit_description(
            qubits, circuit_description) 
开发者ID:quantumlib,项目名称:OpenFermion-Cirq,代码行数:31,代码来源:bogoliubov_transform.py

示例11: _gaussian_basis_change

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _gaussian_basis_change(qubits: Sequence[cirq.Qid],
                           transformation_matrix: numpy.ndarray,
                           initially_occupied_orbitals: Optional[Sequence[int]]
                           ) -> cirq.OP_TREE:
    n_qubits = len(qubits)

    # Rearrange the transformation matrix because the OpenFermion routine
    # expects it to describe annihilation operators rather than creation
    # operators
    left_block = transformation_matrix[:, :n_qubits]
    right_block = transformation_matrix[:, n_qubits:]
    transformation_matrix = numpy.block(
            [numpy.conjugate(right_block), numpy.conjugate(left_block)])

    decomposition, left_decomposition, _, left_diagonal = (
        fermionic_gaussian_decomposition(transformation_matrix))

    if (initially_occupied_orbitals is not None and
            len(initially_occupied_orbitals) == 0):
        # Starting with the vacuum state yields additional symmetry
        circuit_description = list(reversed(decomposition))
    else:
        if initially_occupied_orbitals is None:
            # The initial state is not a computational basis state so the
            # phases left on the diagonal in the Givens decomposition matter
            yield (cirq.rz(rads=
                       numpy.angle(left_diagonal[j])).on(qubits[j])
                   for j in range(n_qubits))
        circuit_description = list(reversed(decomposition + left_decomposition))

    yield _ops_from_givens_rotations_circuit_description(
            qubits, circuit_description) 
开发者ID:quantumlib,项目名称:OpenFermion-Cirq,代码行数:34,代码来源:bogoliubov_transform.py

示例12: _arg

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _arg(x):
    if x == 0:
        return 0
    if cirq.is_parameterized(x):
        return sympy.arg(x)
    return np.angle(x) 
开发者ID:quantumlib,项目名称:OpenFermion-Cirq,代码行数:8,代码来源:fermionic_simulation.py

示例13: _signal_synchrony_hilbert

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _signal_synchrony_hilbert(signal1, signal2):

    hill1 = scipy.signal.hilbert(signal1)
    hill2 = scipy.signal.hilbert(signal2)

    phase1 = np.angle(hill1, deg=False)
    phase2 = np.angle(hill2, deg=False)
    synchrony = 1 - np.sin(np.abs(phase1 - phase2) / 2)

    return synchrony 
开发者ID:neuropsychology,项目名称:NeuroKit,代码行数:12,代码来源:signal_synchrony.py

示例14: test_discrete_bode

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def test_discrete_bode(self):
        # Create a simple discrete time system and check the calculation
        sys = TransferFunction([1], [1, 0.5], 1)
        omega = [1, 2, 3]
        mag_out, phase_out, omega_out = bode(sys, omega)
        H_z = list(map(lambda w: 1./(np.exp(1.j * w) + 0.5), omega))
        np.testing.assert_array_almost_equal(omega, omega_out)
        np.testing.assert_array_almost_equal(mag_out, np.absolute(H_z))
        np.testing.assert_array_almost_equal(phase_out, np.angle(H_z)) 
开发者ID:python-control,项目名称:python-control,代码行数:11,代码来源:discrete_test.py

示例15: _griffin_lim

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import angle [as 别名]
def _griffin_lim(S):
    '''librosa implementation of Griffin-Lim
    Based on https://github.com/librosa/librosa/issues/434
    '''
    angles = np.exp(2j * np.pi * np.random.rand(*S.shape))
    S_complex = np.abs(S).astype(np.complex)
    y = _istft(S_complex * angles)
    for i in range(hp.griffin_lim_iters):
        angles = np.exp(1j * np.angle(_stft(y)))
        y = _istft(S_complex * angles)
    return y 
开发者ID:soobinseo,项目名称:Tacotron-pytorch,代码行数:13,代码来源:data.py


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