numpy.arcsin

Here are the examples of the python api numpy.arcsin taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

157 Examples 7

5 Source : basic.py
with MIT License
from dmitriy-serdyuk

    def impl(self, x):
        # If x is an int8 or uint8, numpy.arcsin will compute the result in
        # half-precision (float16), where we want float32.
        x_dtype = str(getattr(x, 'dtype', ''))
        if x_dtype in ('int8', 'uint8'):
            return numpy.arcsin(x, sig='f')
        return numpy.arcsin(x)

    def grad(self, inputs, gout):

3 Source : rayleigh.py
with GNU General Public License v3.0
from acolite

def sky_refl(theta, n_w=1.34):
    from numpy import arcsin, sin, tan, power
    # angle of transmittance theta_t for air incident rays (Mobley, 1994 p156)
    theta_t = arcsin(1./n_w*sin(theta))
    r_int=0.5*(power(sin(theta-theta_t)/sin(theta+theta_t),2)+\
              power(tan(theta-theta_t)/tan(theta+theta_t),2))
    return r_int


# function ray_phase_nosky
# computes Rayleigh phase function for given geometry (no diffuse sky reflectance)
# QV 2016-12-14

def ray_phase_nosky(theta_0,theta_v,phi_0, phi_v):

3 Source : calculator.py
with MIT License
from aerospaceresearch

def get_geo_coordinates(x, y, z):
    R = np.sqrt(x**2 + y**2 + z**2)
    lat = np.arcsin(z / R)
    lon = np.arctan2(y, x)

    return np.rad2deg(lon), np.rad2deg(lat), R


def calculate_position(all_seen_planes, data):

3 Source : test_interpretations.py
with Apache License 2.0
from aig-upf

def test_arcsin():
    import numpy as np
    from tarski.syntax.arithmetic.special import asin
    lang = tarski.fstrips.language(theories=[Theory.ARITHMETIC, Theory.SPECIAL])
    model = Model(lang)
    model.evaluator = evaluate
    reals = lang.Real
    alpha = lang.constant(0.5, reals)
    assert model[asin(alpha)].symbol == np.arcsin(0.5)


def test_blocksworld_add():

3 Source : entities_factory.py
with GNU Affero General Public License v3.0
from andrea-bistacchi

    def points_map_dip(self):
        """Returns dip as Numpy array for map plotting if points have Normals property."""
        if "Normals" in self.point_data_keys:
            map_dip = 90 - np.arcsin(-self.get_point_data("Normals")[:, 2]) * 180 / np.pi
            return map_dip
        else:
            return None

    @property

3 Source : entities_factory.py
with GNU Affero General Public License v3.0
from andrea-bistacchi

    def points_map_plunge(self):
        """Returns plunge as Numpy array for map plotting if points have Lineations property."""
        if "Lineations" in self.point_data_keys:
            map_plunge = np.arcsin(-self.get_point_data("Lineations")[:, 2]) * 180 / np.pi
            return map_plunge
        else:
            return None

    @property

3 Source : leastsqbound.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere

def _external2internal_lambda(bound):
    """
    Make a lambda function which converts an single external (constrained)
    parameter to a internal (unconstrained) parameter.
    """
    lower, upper = bound

    if lower is None and upper is None:  # no constraints
        return lambda x: x
    elif upper is None:     # only lower bound
        return lambda x: sqrt((x - lower + 1.) ** 2 - 1)
    elif lower is None:     # only upper bound
        return lambda x: sqrt((upper - x + 1.) ** 2 - 1)
    else:
        return lambda x: arcsin((2. * (x - lower) / (upper - lower)) - 1.)


def leastsqbound(func, x0, args=(), bounds=None, Dfun=None, full_output=0,

3 Source : evaluation_metrics.py
with MIT License
from andresperezlopez

def distance_between_cartesian_coordinates(x1, y1, z1, x2, y2, z2):
    """
    Angular distance between two cartesian coordinates
    MORE: https://en.wikipedia.org/wiki/Great-circle_distance
    Check 'From chord length' section

    :return: angular distance in degrees
    """
    dist = np.sqrt((x1-x2) ** 2 + (y1-y2) ** 2 + (z1-z2) ** 2)
    dist = 2 * np.arcsin(dist / 2.0) * 180/np.pi
    return dist


def sph2cart(azimuth, elevation, r):

3 Source : 2vcf.py
with MIT License
from aryarm

def eqbin_mean(grp, log=True, pseudo=True, discards_ok=False, inverse=False):
    if inverse:
        return np.arcsin(grp.mean())
    else:
        if log:
            if discards_ok or not pseudo:
                return phred(grp).mean()
            else:
                return phred(grp.sum()/(len(grp) + pseudo))
        else:
           return grp.mean()

def tpr_probs(df, bins=15, eqbin=True, log=True, pseudo=True, discards_ok=False, inverse=False):

3 Source : utils.py
with MIT License
from B-C-WANG

    def angle_of_two_unit_vector_use_sin(vector1, vector2):
        cos_angle = vector1.dot(vector2)
        return np.arcsin(cos_angle)


    @staticmethod

3 Source : panorama.py
with MIT License
from bertjiazheng

def xyz2uvN(xyz, planeID=1):
    ID1 = (int(planeID) - 1 + 0) % 3
    ID2 = (int(planeID) - 1 + 1) % 3
    ID3 = (int(planeID) - 1 + 2) % 3
    normXY = np.sqrt(xyz[:, [ID1]] ** 2 + xyz[:, [ID2]] ** 2)
    normXY[normXY   <   0.000001] = 0.000001
    normXYZ = np.sqrt(xyz[:, [ID1]] ** 2 + xyz[:, [ID2]] ** 2 + xyz[:, [ID3]] ** 2)
    v = np.arcsin(xyz[:, [ID3]] / normXYZ)
    u = np.arcsin(xyz[:, [ID1]] / normXY)
    valid = (xyz[:, [ID2]]  <  0) & (u >= 0)
    u[valid] = np.pi - u[valid]
    valid = (xyz[:, [ID2]]  <  0) & (u  < = 0)
    u[valid] = -np.pi - u[valid]
    uv = np.hstack([u, v])
    uv[np.isnan(uv[:, 0]), 0] = 0
    return uv


def computeUVN(n, in_, planeID):

3 Source : pano_lsd_align.py
with MIT License
from chengzhag

def xyz2uvN(xyz, planeID=1):
    ID1 = (int(planeID) - 1 + 0) % 3
    ID2 = (int(planeID) - 1 + 1) % 3
    ID3 = (int(planeID) - 1 + 2) % 3
    normXY = np.sqrt(xyz[:, [ID1]] ** 2 + xyz[:, [ID2]] ** 2)
    normXY[normXY   <   0.000001] = 0.000001
    normXYZ = np.sqrt(xyz[:, [ID1]] ** 2 + xyz[:, [ID2]] ** 2 + xyz[:, [ID3]] ** 2)
    v = np.arcsin(xyz[:, [ID3]] / normXYZ)
    u = np.arcsin(xyz[:, [ID1]] / normXY)
    valid = (xyz[:, [ID2]]  <  0) & (u >= 0)
    u[valid] = np.pi - u[valid]
    valid = (xyz[:, [ID2]]  <  0) & (u  < = 0)
    u[valid] = -np.pi - u[valid]
    uv = np.hstack([u, v])
    uv[np.isnan(uv[:, 0]), 0] = 0
    return uv


def uv2xyzN(uv, planeID=1):

3 Source : tess_stars2px.py
with MIT License
from christopherburke

    def cartToSphere(self, vec):
        ra = 0.0
        dec = 0.0
        norm = np.sqrt(np.sum(vec*vec))
        if (norm > 0.0):
            dec = np.arcsin(vec[2] / norm)
            if (not vec[0] == 0.0) or (not vec[1] == 0.0):
                ra = np.arctan2(vec[1], vec[0])
                ra = np.mod(ra, 2.0*np.pi)
        return ra, dec

    def star_in_fov(self, lng, lat):

3 Source : utils.py
with MIT License
from CVI-SZU

def get_theta_phi(gaze, headpose):
    # convert the gaze direction in the camera cooridnate system to the angle 
    # in the polar coordinate system
    gaze_theta = np.arcsin((-1) * gaze[1])  # vertical gaze angle
    gaze_phi = np.arctan2((-1) * gaze[0], (-1) * gaze[2])  # horizontal gaze angle

    # save as above, conver head pose to the polar coordinate system
    M = cv2.Rodrigues(headpose)[0]
    Zv = M[:, 2]
    headpose_theta = np.arcsin(Zv[1])  # vertical head pose angle
    headpose_phi = np.arctan2(Zv[0], Zv[2])  # horizontal head pose angle
    #     return gaze_theta, gaze_phi, headpose_theta, headpose_phi
    return np.array([gaze_theta, gaze_phi]), np.array([headpose_theta, headpose_phi])


def read_img(img_file, CLAHE=True, clahe=None):

3 Source : multiple_scattering.py
with Apache License 2.0
from DanPorter

    def th(self):
        return np.arcsin((self.kov() + self.trv())[0][:, 2] / self.ko) * 180 / np.pi


# ===============================================================================
#         Gareth Nisbet Diamond Light Source - 29 Nov 2013
# ===============================================================================

3 Source : shockwave.py
with GNU General Public License v3.0
from Davide-sd

def mimimum_beta_from_mach(M1):
    """
    Compute the minimum shock wave angle for a given upstream Mach number.

    Parameters
    ----------
    M : array_like
        Upstream Mach number. Must be >= 1.

    Returns
    -------
    beta: float
        Shock wave angle in degrees
    """
    return np.rad2deg(np.arcsin(1 / M1))

@check_shockwave

3 Source : apodize.py
with BSD 3-Clause "New" or "Revised" License
from deepanshs

def arcsin(csdm, arg, dimension=0):
    r"""Apodize the components along the `dimension` with :math:`\arcsin(a x)`.

    Args:
        csdm: A CSDM object.
        arg: String or Quantity object. The function argument :math:`a`.
        dimension: An integer or tuple of `m` integers cooresponding to the
                   index/indices of the dimensions along which the inverse sine of the
                   dependent variable components is performed.
    Return:
        A CSDM object with `d-m` dimensions, where `d` is the total
        number of dimensions from the original `csdm` object.
    """
    return _get_new_csdm_object_after_apodization(csdm, np.arcsin, arg, dimension)


def arccos(csdm, arg, dimension=0):

3 Source : element_wise_test.py
with BSD 3-Clause "New" or "Revised" License
from deepanshs

def test_arcsin():
    b = np.arcsin(a)
    assert np.allclose(b.dependent_variables[0].components[0], np.arcsin(data))


def test_arccos():

3 Source : test_gain_calc.py
with BSD 3-Clause Clear License
from ebu

def test_diverge_elevation(layout, gain_calc):
    run_test(layout, gain_calc,
             dict(position=dict(azimuth=0.0, elevation=elevation(cart(30, 30, 1) * [0, 1, 1]), distance=1.0),
                  objectDivergence=ObjectDivergence(1.0, azimuthRange=np.degrees(np.arcsin(cart(-30, 30, 1)[0])))),
             direct_gains=[("U+030", np.sqrt(0.5)), ("U-030", np.sqrt(0.5))])


def test_diverge_azimuth_elevation(layout, gain_calc):

3 Source : test_gain_calc.py
with BSD 3-Clause Clear License
from ebu

def test_diverge_azimuth_elevation(layout, gain_calc):
    run_test(layout, gain_calc,
             dict(position=dict(azimuth=70.0, elevation=elevation(cart(40, 30, 1) * [0, 1, 1]), distance=1.0),
                  objectDivergence=ObjectDivergence(1.0, azimuthRange=np.degrees(np.arcsin(cart(-40, 30, 1)[0])))),
             direct_gains=[("U+030", np.sqrt(0.5)), ("U+110", np.sqrt(0.5))])


def test_zone_front(layout, gain_calc):

3 Source : var.py
with Apache License 2.0
from gecrooks

def arcsin(x: Variable) -> Variable:
    if isinstance(x, sympy.Expr):
        return sympy.asin(x)
    return np.arcsin(x)


def arctan(x: Variable) -> Variable:

3 Source : SeismicRaypathApp.py
with MIT License
from geoscixyz

def refraction1_time_to_space(t, v1, v2, z1):
    """
    refraction off of first interface
    """

    theta1 = np.arcsin(v1 / v2)
    ti1 = 2 * z1 * np.cos(theta1) / v1
    x = (t - ti1) * v2
    return x


def refraction2_time_to_space(t, v1, v2, v3, z1, z2):

3 Source : SeismicRaypathApp.py
with MIT License
from geoscixyz

def refraction2_time_to_space(t, v1, v2, v3, z1, z2):
    theta1 = np.arcsin(v1 / v3)
    theta2 = np.arcsin(v2 / v3)
    ti1 = 2 * z1 * np.cos(theta1) / v1
    ti2 = 2 * z2 * np.cos(theta2) / v2
    x = (t - (ti2 + ti1)) * v3
    return x


def refraction1_space_to_time(x, v1, v2, z1):

3 Source : SeismicRaypathApp.py
with MIT License
from geoscixyz

def refraction1_space_to_time(x, v1, v2, z1):
    """
    refraction off of first interface
    """

    theta1 = np.arcsin(v1 / v2)
    ti1 = 2 * z1 * np.cos(theta1) / v1
    ref1 = 1.0 / v2 * x + ti1
    return ref1


def refraction2_space_to_time(x, v1, v2, v3, z1, z2):

3 Source : SeismicRaypathApp.py
with MIT License
from geoscixyz

def refraction2_space_to_time(x, v1, v2, v3, z1, z2):
    theta1 = np.arcsin(v1 / v3)
    theta2 = np.arcsin(v2 / v3)
    ti1 = 2 * z1 * np.cos(theta1) / v1
    ti2 = 2 * z2 * np.cos(theta2) / v2
    ref2 = 1.0 / v3 * x + ti2 + ti1
    return ref2


def reflection1_space_to_time(x, v1, z1):

3 Source : SeismicRaypathApp.py
with MIT License
from geoscixyz

def refraction_path_1(x_loc, v1, v2, z1):
    theta = np.arcsin(v1 / v2)
    d = np.tan(theta) * z1
    l = x_loc - 2 * d
    if l   <   0:
        return None, None
    x = [0, d, d + l, x_loc]
    y = [0, z1, z1, 0]
    return x, y


def refraction_path_2(x_loc, v1, v2, v3, z1, z2):

3 Source : SeismicRaypathApp.py
with MIT License
from geoscixyz

def refraction_path_2(x_loc, v1, v2, v3, z1, z2):
    theta1 = np.arcsin(v1 / v3)
    theta2 = np.arcsin(v2 / v3)
    d1 = np.tan(theta1) * z1
    d2 = np.tan(theta2) * z2
    l = x_loc - 2 * (d1 + d2)
    if l   <   0:
        return None, None
    x = [0, d1, d1 + d2, d1 + d2 + l, d1 + d2 + l + d2, x_loc]
    y = [0, z1, z2 + z1, z2 + z1, z1, 0]
    return x, y


def interact_refraction(v1, v2, v3, z1, z2, x_loc, t_star, show):

3 Source : SeismicRefraction.py
with MIT License
from geoscixyz

def refraction1(x, v1, v2, z1):
    """
    refraction off of first interface
    """

    theta1 = np.arcsin(v1 / v2)
    ti1 = 2 * z1 * np.cos(theta1) / v1
    xc1 = 2 * z1 * np.tan(theta1)
    if np.isscalar(x):
        ref1 = 1.0 / v2 * x + ti1
    else:
        act1 = x > xc1
        ref1 = np.ones_like(x) * np.nan
        ref1[act1] = 1.0 / v2 * x[act1] + ti1
    return ref1


def refraction2(x, v1, v2, v3, z1, z2):

3 Source : SeismicRefraction.py
with MIT License
from geoscixyz

def refraction2(x, v1, v2, v3, z1, z2):
    theta1 = np.arcsin(v1 / v3)
    theta2 = np.arcsin(v2 / v3)
    ti1 = 2 * z1 * np.cos(theta1) / v1
    ti2 = 2 * z2 * np.cos(theta2) / v2
    xc2 = 2 * (z2) * np.tan(theta2) + 2 * (z1) * np.tan(theta1)
    if np.isscalar(x):
        ref2 = 1.0 / v3 * x + ti2 + ti1
    else:
        act2 = x > xc2
        ref2 = np.ones_like(x) * np.nan
        ref2[act2] = 1.0 / v3 * x[act2] + ti2 + ti1
    return ref2


def reflection1(x, v1, z1):

3 Source : unitcell.py
with BSD 3-Clause "New" or "Revised" License
from HEXRD

    def CalcBraggAngle(self, hkl):
        glen = self.CalcLength(hkl, 'r')
        sth = self.wavelength * glen * 0.5
        return np.arcsin(sth)

    def ChooseSymmetric(self, hkllist, InversionSymmetry=True):

3 Source : Grouping.py
with MIT License
from Hippogriff

def transform(rot, trans, mean, image):
    M = cv2.getRotationMatrix2D((mean[0, 0], mean[1, 0]), np.arcsin(rot[0, 1]) * 180 / np.pi, 1)
    M[0, 2] += trans[0]
    M[1, 2] += trans[1]
    image = cv2.warpAffine(image.astype(np.float32), M, (64, 64))
    return image

3 Source : preprocess_mpiigaze.py
with MIT License
from hysts

def convert_gaze(vector: np.ndarray) -> np.ndarray:
    x, y, z = vector
    pitch = np.arcsin(-y)
    yaw = np.arctan2(-x, -z)
    return np.array([pitch, yaw]).astype(np.float32)


def get_eval_info(person_id: str, eval_dir: pathlib.Path) -> pd.DataFrame:

3 Source : OpenVerne.py
with MIT License
from istellartech

def lat_from_radius(radius):
    """ Return latitude[deg] from earth radius
    Args:
        radius (double) : earth radius[m]
    Return:
        (double) : latitude [deg]
    """
    lat_rad =  arcsin(sqrt(1/wgs84.e2 * (1 - (radius**2) / (wgs84.re_a**2))))
    return rad2deg(lat_rad)

class IIP:

3 Source : face_parts.py
with MIT License
from kenkyusha

    def vector_to_angle(vector: np.ndarray) -> np.ndarray:
        assert vector.shape == (3, )
        x, y, z = vector
        pitch = np.arcsin(-y)
        yaw = np.arctan2(-x, -z)
        return np.array([pitch, yaw])

3 Source : coordinate_utility.py
with MIT License
from knaidoo29

def perpendicular_distance_2_angle(distance):
    """Converts distances on a unit sphere to angular distances projected across a unit sphere.

    Parameters
    ----------
    distance : array
        Perpendicular distances across (i.e. going on the surface) of a unit sphere.

    Returns
    -------
    angular_distance : array
        The angular distance of points across a unit sphere.
    """
    angular_distance = 2. * np.arcsin(distance / 2.)
    return angular_distance

3 Source : pyrender.py
with BSD 2-Clause "Simplified" License
from martinResearch

def arcsinc(x):
    if abs(x) > 1e-6:
        return np.arcsin(x) / x
    else:
        return 1


def min_rotation(vec1, vec2):

3 Source : _arith.py
with MIT License
from michaelnowotny

def arcsin(x: ndarray):
    """
    Inverse sine, element-wise.
    """

    return _unary_function(x, af_func=af.asin, np_func=np.arcsin)


def arccos(x: ndarray):

3 Source : gdc.py
with MIT License
from mileyan

def filter_theta_mask(pc_rect, low, high):
    # though if we have to do this precisely, we should convert
    # point clouds to velodyne space, here we just use those in rect space,
    # since actually the velodyne and the cameras are very close to each other.

    x, y, z = pc_rect[:, 0], pc_rect[:, 1], pc_rect[:, 2]
    d = np.sqrt(x ** 2 + y ** 2 + z ** 2)
    theta = np.arcsin(y / d)
    return (theta >= low) * (theta   <   high)


def depth2ptc(depth, calib):

3 Source : twcenterpend.py
with GNU General Public License v3.0
from mlech26l

    def set_observations_for_lif(self,obs,observations):
        observations[0] = np.arcsin(float(obs[3]))
        # observations[0] = float(obs[4])
        observations[1] = float(obs[0])

    def run_one_episode(self,do_render=False):

3 Source : nn_run_env.py
with GNU General Public License v3.0
from mlech26l

    def preprocess_observations(self,obs):
        if(self.env_name == "invpend"):
            return np.array([np.arcsin(obs[3]),obs[0]])
        if(self.env_name == "mountaincar"):
            return np.array([obs[0],obs[1]])
        if(self.env_name == "cheetah"):
            return np.dot(obs,self.w_in)
        raise ValueError("This should not happen")

    def preprocess_actions(self,action):

3 Source : geometry.py
with GNU General Public License v3.0
from mricon

def xyztorads(pts,R=1):
    pts = pts.reshape([-1,3])
    pts = pts/R
    x = pts[:,0]
    y = pts[:,1]
    z = pts[:,2]

    lat = np.arcsin(z)
    lng = np.arctan2(y,x)

    return np.column_stack([lat,lng])


def greatArcAng(x,y):

3 Source : ExploitationFeatures.py
with MIT License
from ngageoint

    def GrazeAngle(self):
        """
        float: The angle between the ground plane and line of sight vector.
        """

        return numpy.rad2deg(numpy.arcsin(self.slant_x.dot(self.ETP)))

    @property

3 Source : functions.py
with GNU General Public License v3.0
from nrc-cnrc

def arcsin(x):
    """
    Returns the inverse sine of x where x can be float, complex, gummy or jummy.
    """
    return _bcallg(np.arcsin,x)

def arccos(x):

3 Source : mlp.py
with BSD 3-Clause "New" or "Revised" License
from RaulAstudillo06

    def Kdiag(self, X):
        """Compute the diagonal of the covariance matrix for X."""
        X_prod = self._comp_prod(X)
        return self.variance*four_over_tau*np.arcsin(X_prod/(X_prod+1.))

    def update_gradients_full(self, dL_dK, X, X2=None):

3 Source : test_expression.py
with BSD 3-Clause "New" or "Revised" License
from scikit-hep

def test_arcsin():
    aee(np.arcsin(Expression(IDs.SQRT, UC('2'))),
        Expression(IDs.ASIN, Expression(IDs.SQRT, UC('2'))))


def test_arccos():

3 Source : basics.py
with MIT License
from scottprahl

def critical_angle(n_core, n_clad):
    """
    Calculate the angle (from the normal) for total internal reflection.

    Args:
        n_core : the index of refraction of the fiber core  [--]
        n_core : the index of refraction of the fiber cladding  [--]

    Returns:
        angle of total internal reflection [radians]
    """
    return np.arcsin(n_clad / n_core)


def cutoff_wavelength(a, NA, ell=0, q=np.inf):

3 Source : fresnel.py
with MIT License
from scottprahl

def critical(m, n_i=1, deg=False):
    """
    Critical angle for total internal reflection at interface.

    Args:
        m:       complex index of refraction of medium    [-]
        n_i:     real refractive index of incident medium [-]
        deg:     theta_i is in degrees                    [True/False]
    Returns:
        critical angle from normal to surface             [radians/degrees]
    """
    if deg:
        return np.degrees(np.arcsin(m/n_i))
    return np.arcsin(m/n_i)

def _cosines(m, theta_i, n_i, deg=False):

3 Source : mueller.py
with MIT License
from scottprahl

def ellipse_ellipticity(S):
    """
    Return the ellipticity of the polarization ellipse.

    This parameter is often represented by Chi.
    """
    return 1/2 * np.arcsin(S[..., 3]/S[..., 0])


def ellipse_axes(S):

3 Source : sat.py
with GNU General Public License v3.0
from spel-uchile

    def getLat(self, rad2deg=180/pi):
        """
        Returns the last latitude of the satellite.
        """
        self.lat = arcsin(self.z/self.r)*rad2deg
        return self.lat

    def getLng(self, rad2deg=180/pi, twopi=2*pi, date=None):

3 Source : mc_utils.py
with Apache License 2.0
from SRI-International

def zeta_from_f(i, func, epsilon, degree, c):
    """
    Intermediate polynomial derived from f to serve as angle for controlled Ry gates.
    """
    rad = np.sqrt(c*(func(i) - 0.5) + 0.5)
    return np.arcsin(rad)



def simplex(n, k):

See More Examples