def test_directional(self): first, second = smath.line(30, 270), smath.line(40, 90) dist = smath.angular_distance(first, second, bidirectional=True) assert np.allclose(dist, 70) dist = smath.angular_distance(first, second, bidirectional=False) assert np.allclose(dist, 110)
def test_directional(self): first, second = smath.line(30, 270), smath.line(40, 90) dist = smath.angular_distance(first, second, bidirectional=True) assert np.allclose(dist, 70) dist = smath.angular_distance(first, second, bidirectional=False) assert np.allclose(dist, 110)
def normal(orientation, *args, **kwargs): ax = kwargs.pop("ax",current_axes()) levels = kwargs.pop("levels",[1]) normal = kwargs.pop("normal",False) kwargs["linewidth"] = 0 a = kwargs.pop("alpha",0.7) if len(a) != len(levels): a = [a]*len(levels) for i,level in enumerate(levels): _ = orientation.error_ellipse(vector=True, level=level) el = [N.degrees(i) for i in _] lat,lon = line(el[1], el[0]) e = Polygon(zip(lat,lon), alpha=a[i], **kwargs) ax.add_patch(e)
def trend_plunge(orientation, *args, **kwargs): ax = kwargs.pop("ax",current_axes()) levels = kwargs.pop("levels",[1]) #kwargs["linewidth"] = 0 defaults = dict( linewidth=0) kwargs.update({k:kwargs.pop(k,v) for k,v in defaults.items()}) a = kwargs.pop("alpha",[0.7]) if len(a) != len(levels): a = [a]*len(levels) for i,level in enumerate(levels): el = [N.degrees(i) for i in orientation.error_ellipse(vector=True, level=level)] lat,lon = line(el[1], el[0]) e = Polygon(zip(lat,lon), alpha=a[i], **kwargs) ax.add_patch(e)
def strike_dip(orientation, *args, **kwargs): ax = kwargs.pop("ax",current_axes()) levels = kwargs.pop("levels",[1]) spherical = kwargs.pop("spherical", False) kwargs["linewidth"] = 0 a = kwargs.pop("alpha",[1]) if len(a) != len(levels): a = [a]*len(levels) for i,level in enumerate(levels): el = [N.degrees(ell) for ell in orientation.error_ellipse( level=level, spherical=spherical)] if spherical: lat,lon = line(el[0], el[1]) else: lat = el[0] lon = 90-el[1] e = Polygon(list(zip(lat,lon)), alpha=a[i], **kwargs) ax.add_patch(e)
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]])
label='Planar sliding partially possible [{}]'.format(sum(secP))) # Plot flexural toppling data ax2.pole(jstrikes, jdips, c='k', ms=1, label='Discontinuities (Poles) [{}]'.format(len(jstrikes))) ax2.pole(jstrikes[mainT], jdips[mainT], c='r', ms=2, label='Toppling possible [{}]'.format(sum(mainT))) # Plot wedge sliding data ax3.plot(*stereonet_math.line(iplunges, ibearings), 'ok', ms=1, label='Discontinuity intersections (Lines) [{}]'.format( len(iplunges))) ax3.plot(*stereonet_math.line(iplunges[mainW], ibearings[mainW]), 'or', ms=2, label='Wedge sliding possible [{}]'.format(sum(mainW))) ax3.plot(*stereonet_math.line(iplunges[secW], ibearings[secW]), 'oc', ms=2, label='Wedge sliding possible on single plane [{}]'.format(sum(secW))) for ax in [ax1, ax2, ax3]: ax.set_azimuth_ticks([0, 90, 180, 270], labels=['N', 'E', 'S', 'W'])
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 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
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