How to use the quadpy.sphere function in quadpy

To help you get started, we’ve selected a few quadpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / quadpy / test / test_sphere.py View on Github external
        (quadpy.sphere.heo_xu_21_3(), 1.0e-6),
        (quadpy.sphere.heo_xu_21_4(), 1.0e-6),
        (quadpy.sphere.heo_xu_21_5(), 1.0e-6),
        (quadpy.sphere.heo_xu_21_6(), 1.0e-6),
        (quadpy.sphere.heo_xu_23_1(), 1.0e-6),
        (quadpy.sphere.heo_xu_23_2(), 1.0e-6),
        (quadpy.sphere.heo_xu_23_3(), 1.0e-6),
        (quadpy.sphere.heo_xu_25_1(), 1.0e-6),
        (quadpy.sphere.heo_xu_25_2(), 1.0e-6),
        (quadpy.sphere.heo_xu_27_1(), 1.0e-6),
        (quadpy.sphere.heo_xu_27_2(), 1.0e-6),
        (quadpy.sphere.heo_xu_27_3(), 1.0e-6),
        (quadpy.sphere.heo_xu_29(), 1.0e-6),
        (quadpy.sphere.heo_xu_31(), 1.0e-6),
        (quadpy.sphere.heo_xu_33(), 1.0e-6),
        (quadpy.sphere.heo_xu_35(), 1.0e-6),
        (quadpy.sphere.heo_xu_37(), 1.0e-6),
github nschloe / quadpy / test / test_sphere.py View on Github external
        (quadpy.sphere.lebedev_029(), 1.0e-11),
        (quadpy.sphere.lebedev_031(), 1.0e-11),
        (quadpy.sphere.lebedev_035(), 1.0e-11),
        (quadpy.sphere.lebedev_041(), 1.0e-11),
        (quadpy.sphere.lebedev_047(), 1.0e-11),
        (quadpy.sphere.lebedev_053(), 1.0e-11),
        (quadpy.sphere.lebedev_059(), 1.0e-11),
        (quadpy.sphere.lebedev_065(), 1.0e-11),
        (quadpy.sphere.lebedev_071(), 1.0e-11),
        (quadpy.sphere.lebedev_077(), 1.0e-11),
        (quadpy.sphere.lebedev_083(), 1.0e-11),
        (quadpy.sphere.lebedev_089(), 1.0e-11),
        (quadpy.sphere.lebedev_095(), 1.0e-11),
        (quadpy.sphere.lebedev_101(), 1.0e-11),
        (quadpy.sphere.lebedev_107(), 1.0e-11),
        (quadpy.sphere.lebedev_113(), 1.0e-11),
        (quadpy.sphere.lebedev_119(), 1.0e-11),
github nschloe / quadpy / test / test_sphere.py View on Github external
        (quadpy.sphere.lebedev_003c(), 1.0e-11),
        (quadpy.sphere.lebedev_005(), 1.0e-11),
        (quadpy.sphere.lebedev_007(), 1.0e-11),
        (quadpy.sphere.lebedev_009(), 1.0e-11),
        (quadpy.sphere.lebedev_011(), 1.0e-11),
        (quadpy.sphere.lebedev_013(), 1.0e-11),
        (quadpy.sphere.lebedev_015(), 1.0e-11),
        (quadpy.sphere.lebedev_017(), 1.0e-11),
        (quadpy.sphere.lebedev_019(), 1.0e-11),
    ]
    + [
        (quadpy.sphere.stroud_u3_3_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_2(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_3(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_4(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_5(), 1.0e-13),
github nschloe / quadpy / test / test_sphere.py View on Github external
        (quadpy.sphere.stroud_u3_8_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_9_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_9_2(), 1.0e-13),
        (quadpy.sphere.stroud_u3_9_3(), 1.0e-13),
        (quadpy.sphere.stroud_u3_11_1(), 1.0e-13),
        # TODO fix equation system in 11_2 for higher precision
        (quadpy.sphere.stroud_u3_11_2(), 1.0e-12),
        (quadpy.sphere.stroud_u3_11_3(), 1.0e-13),
        (quadpy.sphere.stroud_u3_14_1(), 1.0e-13),
    ],
)
def test_scheme_cartesian(scheme, tol):
    def sph_tree_cartesian(x):
        azimuthal, polar = cartesian_to_spherical(x.T).T
        return numpy.concatenate(
            orthopy.sphere.tree_sph(
                polar, azimuthal, scheme.degree + 1, standardization="quantum mechanic"
github nschloe / quadpy / test / test_sphere.py View on Github external
        (quadpy.sphere.heo_xu_21_6(), 1.0e-6),
        (quadpy.sphere.heo_xu_23_1(), 1.0e-6),
        (quadpy.sphere.heo_xu_23_2(), 1.0e-6),
        (quadpy.sphere.heo_xu_23_3(), 1.0e-6),
        (quadpy.sphere.heo_xu_25_1(), 1.0e-6),
        (quadpy.sphere.heo_xu_25_2(), 1.0e-6),
        (quadpy.sphere.heo_xu_27_1(), 1.0e-6),
        (quadpy.sphere.heo_xu_27_2(), 1.0e-6),
        (quadpy.sphere.heo_xu_27_3(), 1.0e-6),
        (quadpy.sphere.heo_xu_29(), 1.0e-6),
        (quadpy.sphere.heo_xu_31(), 1.0e-6),
        (quadpy.sphere.heo_xu_33(), 1.0e-6),
        (quadpy.sphere.heo_xu_35(), 1.0e-6),
        (quadpy.sphere.heo_xu_37(), 1.0e-6),
        (quadpy.sphere.heo_xu_39_1(), 1.0e-6),
        (quadpy.sphere.heo_xu_39_2(), 1.0e-6),
    ]
github nschloe / quadpy / test / test_sphere.py View on Github external
        (quadpy.sphere.lebedev_095(), 1.0e-11),
        (quadpy.sphere.lebedev_101(), 1.0e-11),
        (quadpy.sphere.lebedev_107(), 1.0e-11),
        (quadpy.sphere.lebedev_113(), 1.0e-11),
        (quadpy.sphere.lebedev_119(), 1.0e-11),
        (quadpy.sphere.lebedev_125(), 1.0e-11),
        (quadpy.sphere.lebedev_131(), 1.0e-11),
    ]
    + [
        (quadpy.sphere.stroud_u3_3_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_2(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_3(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_4(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_5(), 1.0e-13),
        (quadpy.sphere.stroud_u3_7_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_7_2(), 1.0e-13),
github nschloe / quadpy / test / test_sphere.py View on Github external
        (quadpy.sphere.lebedev_003b(), 1.0e-11),
        (quadpy.sphere.lebedev_003c(), 1.0e-11),
        (quadpy.sphere.lebedev_005(), 1.0e-11),
        (quadpy.sphere.lebedev_007(), 1.0e-11),
        (quadpy.sphere.lebedev_009(), 1.0e-11),
        (quadpy.sphere.lebedev_011(), 1.0e-11),
        (quadpy.sphere.lebedev_013(), 1.0e-11),
        (quadpy.sphere.lebedev_015(), 1.0e-11),
        (quadpy.sphere.lebedev_017(), 1.0e-11),
        (quadpy.sphere.lebedev_019(), 1.0e-11),
    ]
    + [
        (quadpy.sphere.stroud_u3_3_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_1(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_2(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_3(), 1.0e-13),
        (quadpy.sphere.stroud_u3_5_4(), 1.0e-13),
github nschloe / quadpy / tools / improve_precision.py View on Github external
b = numpy.zeros(A.shape[0])
        # b[0] = numpy.sqrt(4 * numpy.pi)
        b[0] = 1.0 / (2 * numpy.sqrt(numpy.pi))

        # solve linear least-squares problem for the weights
        res = lsq_linear(A, b, tol=1.0e-15)
        return res.x, res.fun

    def f(x):
        azimuthal, polar = x.reshape(2, -1)
        _, err = weights_from_points(azimuthal, polar)
        v = numpy.sqrt(err.real ** 2 + err.imag ** 2)
        return v

    scheme = quadpy.sphere.heo_xu_13()
    print(scheme.points)

    # x0 = numpy.column_stack([scheme.weights, scheme.points]).T.reshape(-1)
    x0 = scheme.azimuthal_polar.T.reshape(-1)
    # x0 += 1.0e-10 * numpy.random.rand(*x0.shape)

    out = least_squares(f, x0, gtol=1.0e-16, xtol=1.0e-16)
    # print(out.x)
    # print(out.status, out.nfev, out.njev)
    # print(out.message)
    assert out.success

    azimuthal, polar = out.x.reshape(2, -1)
    w, _ = weights_from_points(azimuthal, polar)
    assert numpy.all(numpy.imag(w) < 1.0e-14)
    w = numpy.real(w)
github nschloe / quadpy / tools / improve_precision.py View on Github external
b = numpy.zeros(A.shape[0])
        # b[0] = numpy.sqrt(4 * numpy.pi)
        b[0] = 1.0 / (2 * numpy.sqrt(numpy.pi))

        # solve linear least-squares problem for the weights
        res = lsq_linear(A, b, tol=1.0e-15)
        return res.x, res.fun

    def f(x):
        azimuthal, polar = x.reshape(2, -1)
        _, err = weights_from_points(azimuthal, polar)
        v = numpy.sqrt(err.real ** 2 + err.imag ** 2)
        return v

    scheme = quadpy.sphere.heo_xu_13()
    print(scheme.points)

    # x0 = numpy.column_stack([scheme.weights, scheme.points]).T.reshape(-1)
    x0 = scheme.azimuthal_polar.T.reshape(-1)
    # x0 += 1.0e-10 * numpy.random.rand(*x0.shape)

    out = least_squares(f, x0, gtol=1.0e-16, xtol=1.0e-16)
    # print(out.x)
    # print(out.status, out.nfev, out.njev)
    # print(out.message)
    assert out.success

    azimuthal, polar = out.x.reshape(2, -1)
    w, _ = weights_from_points(azimuthal, polar)
    assert numpy.all(numpy.imag(w) < 1.0e-14)
    w = numpy.real(w)
github spatialaudio / sfa-numpy / micarray / modal / angular.py View on Github external
def available_quadrature(d):
        """Get smallest availabe quadrature of of degree d.

        see:
        https://people.sc.fsu.edu/~jburkardt/datasets/sphere_lebedev_rule/sphere_lebedev_rule.html
        """
        l = list(range(1, 32, 2)) + list(range(35, 132, 6))
        matches = [x for x in l if x >= d]
        return matches[0]

    if n > 65:
        raise ValueError("Maximum available Lebedev grid order is 65. "
                         "(requested: {})".format(n))

    # this needs https://pypi.python.org/pypi/quadpy
    q = quadpy.sphere.Lebedev(degree=available_quadrature(2*n))
    if np.any(q.weights < 0):
        warn("Lebedev grid of order {} has negative weights.".format(n))
    azi = q.azimuthal_polar[:, 0]
    colat = q.azimuthal_polar[:, 1]
    return azi, colat, 4*np.pi*q.weights