Example #1
0
    def test_multiple_rakes(self):
        strike, dip, rake = np.array(self.data).T

        lon, lat = smath.rake(strike, dip, rake)
        plunge, bearing = smath.geographic2plunge_bearing(lon, lat)
        newrake = smath.project_onto_plane(strike, dip, plunge, bearing)
        assert np.allclose(rake, newrake)
    def test_multiple_rakes(self):
        strike, dip, rake = np.array(self.data).T

        lon, lat = smath.rake(strike, dip, rake)
        plunge, bearing = smath.geographic2plunge_bearing(lon, lat)
        newrake = smath.project_onto_plane(strike, dip, plunge, bearing)
        assert np.allclose(rake, newrake)
Example #3
0
    def test_offset_back_to_rake(self):
        for strike, dip, rake in self.data:
            # Displace the line perpendicular to the plane...
            line = smath.sph2cart(*smath.rake(strike, dip, rake))
            norm = smath.sph2cart(*smath.pole(strike, dip))
            line = np.array(line) + 0.5 * np.array(norm)

            # Project the "displaced" line back onto the plane...
            lon, lat = smath.cart2sph(*line)
            plunge, bearing = smath.geographic2plunge_bearing(lon, lat)
            newrake = smath.project_onto_plane(strike, dip, plunge, bearing)
            assert np.allclose(rake, newrake)
    def test_offset_back_to_rake(self):
        for strike, dip, rake in self.data:
            # Displace the line perpendicular to the plane...
            line = smath.sph2cart(*smath.rake(strike, dip, rake))
            norm = smath.sph2cart(*smath.pole(strike, dip))
            line = np.array(line) + 0.5 * np.array(norm)

            # Project the "displaced" line back onto the plane...
            lon, lat = smath.cart2sph(*line)
            plunge, bearing = smath.geographic2plunge_bearing(lon, lat)
            newrake = smath.project_onto_plane(strike, dip, plunge, bearing)
            assert np.allclose(rake, newrake)
    def test_wedge_sliding(self):
        wedge_analysis = kinematic.WedgeSliding(0, 75)
        line1 = smath.geographic2plunge_bearing(np.radians(55), np.radians(40))
        data = [
            # plunge, bearing   main, sec
            [(75, 90), (True, False)],  # just daylights
            [(35, 60), (True, False)],  # just at friction cone
            [(45, 120), (True, False)],
            [line1, (False, True)],  # just at "friction plane"
            [(30, 150), (False, True)],
            [(30, 30), (False, True)],
            [(80, 90), (False, False)],
            [(0, 90), (False, False)],
            [(20, 280), (False, False)],
        ]

        for plunge_bearing, correct in data:
            p, b = plunge_bearing
            results = wedge_analysis.check_failure(b, p)
            assert results == correct
Example #6
0
 def test_geographic2plunge_bearing(self):
     for (bearing, plunge) in self.strike_dip:
         lon, lat = smath.line(plunge, bearing)
         assert np.allclose(smath.geographic2plunge_bearing(lon, lat),
                            [[plunge], [bearing]])
Example #7
0
 def test_rake_back_to_rakes(self):
     for strike, dip, rake in self.data:
         lon, lat = smath.rake(strike, dip, rake)
         plunge, bearing = smath.geographic2plunge_bearing(lon, lat)
         newrake = smath.project_onto_plane(strike, dip, plunge, bearing)
         assert np.allclose(rake, newrake)
 def test_geographic2plunge_bearing(self):
     for (bearing, plunge) in self.strike_dip:
         lon, lat = smath.line(plunge, bearing)
         assert np.allclose(smath.geographic2plunge_bearing(lon, lat),
                            [[plunge], [bearing]])
 def test_rake_back_to_rakes(self):
     for strike, dip, rake in self.data:
         lon, lat = smath.rake(strike, dip, rake)
         plunge, bearing = smath.geographic2plunge_bearing(lon, lat)
         newrake = smath.project_onto_plane(strike, dip, plunge, bearing)
         assert np.allclose(rake, newrake)
Example #10
0
def proyAnEllipse2LongLat(x, y, axis2rot, angles2rot):
    '''Pojects just an ellipse from the :math:`\\mathbb{R}^2` coordinates of
    the :math:`\\mathscr{P}-` plane that contains it to the real position on
    the stereographic projection through some rotations from an initial
    position at the nadir of the semi-sphere.

    Parameters:
        x (`numpy.ndarray` or `list`): Abscises of just one ellipse's boundary
            on the :math:`\\mathscr{P}-` plane. It is obtained from the
            ``confRegions2PPlanes`` function.
        y (`numpy.ndarray` or `list`): Ordinates of just one ellipse's
            boundary on the :math:`\\mathscr{P}-` plane. It is obtained from
            the ``confRegions2PPlanes`` function.
        axis2rot (`list`): Strings with the axis-names of the **NED** system
            around which will be done the rotatios to project the confidence
            ellipse. It is obtained from the ``rotateaxis2proyectellipses``
            function.
        angles2rot (`list`): List of the angles in degrees for rotating a
            ellipse once it is placed orthogonal to the nadir. It is obtained
            from the ``rotateaxis2proyectellipses`` function.

    Returns:
        Two elements are returned; they are described below.

            - **ellipLong** (`numpy.ndarray`): Longitudes of the ellipse's\
                boundary after being rotated to its right position in the\
                stereographic projection.
            - **ellipLat** (`numpy.ndarray`): Latitudes of the ellipse's\
                boundary after being rotated to its right position in the\
                stereographic projection.

    Examples:
        >>> from numpy import array
        >>> from jelinekstat.tools import confRegions2PPlanes
        >>> majorAxis = array([ 0.66888885,  0.66949335,  0.13745895])
        >>> minorAxis = array([ 0.09950548,  0.09615434,  0.04640122])
        >>> theta = array([-0.01949436, -1.51693959, -0.81162812])
        >>> x, y = confRegions2PPlanes(majorAxis, minorAxis, theta, False,
        >>>                            0.95)
        >>> ellipLong, ellipLat = proyAnEllipse2LongLat(
        >>>     x[0], y[0], ['E', 'D', 'N', 'D'], [-180, 116.37, 70.93, 77.98])
    '''
    import numpy as np
    from mplstereonet.stereonet_math import geographic2plunge_bearing, line
    from mplstereonet.stereonet_math import _rotate as rot

    # transform NED to xyz-mplstereonet axes notation
    for i in range(len(axis2rot)):
        if axis2rot[i] == 'N':
            axis2rot[i] = 'z'
        elif axis2rot[i] == 'E':
            axis2rot[i] = 'y'
        elif axis2rot[i] == 'D':
            axis2rot[i] = 'x'
    vectOnes = np.ones(len(x))
    ellipNED = np.array([y, x, vectOnes]).T
    ellipPlgTrd = np.array(list(map(vector2plungetrend, ellipNED)))
    ellipPlg = ellipPlgTrd[:, 0]
    ellipTrd = ellipPlgTrd[:, 1]
    ellipLong, ellipLat = line(ellipPlg, ellipTrd)
    for i in range(len(angles2rot)):
        ellipLong, ellipLat = rot(np.degrees(ellipLong),
                                  np.degrees(ellipLat),
                                  angles2rot[i],
                                  axis=axis2rot[i])
    ellipPlg, ellipTrd = geographic2plunge_bearing(ellipLong, ellipLat)
    ellipLong, ellipLat = line(ellipPlg, ellipTrd)
    return ellipLong, ellipLat
Example #11
0
def rotateaxis2proyectellipses(axisN, axisE, axisD):
    '''Since it is easier, the projection of an ellpise (confidence region) on
    the stereogrpahic net is thought as a serie of rotations from the bottom of
    the semi-sphere, *i.e.*, the *nadir*.

    This function determines the axes names around which is necesary to rotate
    a confidence ellipse once it is placed at nadir of a semi-sphere to poject
    her from the nadir to the real position on the semi-sphere. Besides, it
    determines the angles to rotate at each axis name.

    The ``mplstereonet`` reference system has the :math:`x, y` and :math:`z`
    vectors as its base, and they correspond to the *nadir*, *east* and *north*
    vectors in the **NED** reference system of the semi-spherical space of the
    Stereographic Projection.

    It is implicit that the three input vectors are orthogonal to each other
    due to they correspond to the principal vectors of :math:`\\boldsymbol{k}`.

    Parameters:
        axisN (`numpy.ndarray`): Array with the coordinates :math:`x, y, z`
            of the eigenvector that will point to the north-axis once the
            ellipse is placed at nadir of the semi-sphere, *i.e.*, its
            othogonal eigenvector associated points downward.
        axisE (`numpy.ndarray`): Array with the coordinates :math:`x, y, z`
            of the eigenvector that will point to the east-axis once the
            ellipse is placed at nadir of the semi-sphere, *i.e.*, its
            othogonal eigenvector associated points downward.
        axisD (`numpy.ndarray`): Array with the coordinates :math:`x, y, z`
            of the eigenvector that is othogonal to the ellipse.

    Returns:
        Two elements are returned; they are described below.

            - **axis2rot** (`list`): Strings with the axis-names of the\
                **NED** system around which will be done the rotatios to\
                project the confidence ellipse.
            - **angles2rot** (`list`): List of the angles in degrees for\
                rotating a ellipse once it is placed orthogonal to the nadir.

    Examples:
        >>> from numpy import array
        >>> from jelinekstat.tools import rotateaxis2proyectellipses
        >>> axis2rot, angles2rot = rotateaxis2proyectellipses(
        >>>     array([2, 2, 1]), array([-2, 1, 2]), array([1, -2, 2]))
        >>> axis2rot
        ['E', 'D', 'N', 'D']
        >>> angles2rot
        [-180, 26.565051177077976, 48.189685104221404, 206.56505117707798]
    '''
    import numpy as np
    from mplstereonet.stereonet_math import geographic2plunge_bearing, line
    from mplstereonet.stereonet_math import _rotate as rot

    # Nadir axis
    axisDplg, axisDtrd = vector2plungetrend(axisD)
    axisDlong, axisDlat = line(axisDplg, axisDtrd)
    # East axis
    axisEplg, axisEtrd = vector2plungetrend(axisE)
    axisElong, axisElat = line(axisEplg, axisEtrd)
    # North axis
    axisNplg, axisNtrd = vector2plungetrend(axisN)
    axisNlong, axisNlat = line(axisNplg, axisNtrd)

    # rotation around the nadir axis to put axisD on the E-W line
    angle1 = 90 - axisDtrd
    rot1long, rot1lat = rot(np.degrees([axisNlong, axisElong, axisDlong]),
                            np.degrees([axisNlat, axisElat, axisDlat]),
                            angle1,
                            axis='x')
    rot1plg, rot1trd = geographic2plunge_bearing(rot1long, rot1lat)

    # rotation around the north axis to put axisD on the nadir axis
    angle2 = np.degrees(rot1long[2][0])
    if rot1long[2] > 0:
        angle2 *= -1
    rot2long, rot2lat = rot(np.degrees(rot1long),
                            np.degrees(rot1lat),
                            angle2,
                            axis='z')
    rot2plg, rot2trd = geographic2plunge_bearing(rot2long, rot2lat)

    # rotation around the nadir axis to put axisE on the east axis
    angle3 = 90 - rot2trd[1][0]
    rot3long, rot3lat = rot(np.degrees(rot2long),
                            np.degrees(rot2lat),
                            angle3,
                            axis='x')
    rot3plg, rot3trd = geographic2plunge_bearing(rot3long, rot3lat)

    # rotation around the east axis to put axisN on the north axis
    if rot3lat[0] < 0:
        angle4 = 180
    else:
        angle4 = 0
    rot4long, rot4lat = rot(np.degrees(rot3long),
                            np.degrees(rot3lat),
                            angle4,
                            axis='y')
    rot4plg, rot4trd = geographic2plunge_bearing(rot4long, rot4lat)

    axis2rot = ['E', 'D', 'N', 'D']  # ['y', 'x', 'z', 'x'] sensu mplstereonet
    angles2rot = [-angle4, -angle3, -angle2, -angle1]
    return axis2rot, angles2rot