Пример #1
0
def coords_for_profile(lon0,lat0,lon1,lat1):
    '''
    Determine the minpoint coordinates and the two azimuths for input into program to determine the tomography slice
    '''

    d1, az1, bz1 = gps2DistAzimuth(lat0,lon0,lat1,lon1)

    return az1
Пример #2
0
 def calc_sta_dist_azi(self):
     for i in range(len(self.sta_lat)):
         dist, az, baz = gps2DistAzimuth(self.cmtsource.latitude,
                                         self.cmtsource.longitude,
                                         self.sta_lat[i], self.sta_lon[i])
         self.sta_azi.append(az)
         self.sta_theta.append(az/180.0*np.pi)
         if self.mode == "regional":
             # if regional, then use original distance(in km)
             self.sta_dist.append(dist/1000.0)
         elif self.mode == "global":
             # if global, then use degree as unit
             self.sta_dist.append(dist/EARTH_HC)
Пример #3
0
def moment_tensor(sta_lat, sta_lon, sta_alt, n, e, u, eq_lat, eq_lon, eq_alt,timer,effhypodist,repi):
	l1=len(sta_lat)
	l2=1

	
	xrs = numpy.zeros([l1,1])
	yrs = numpy.zeros([l1,1])
	zrs = numpy.zeros([l1,1])
	azi = numpy.zeros([l1,1])
	backazi = numpy.zeros([l1,1])
	theta = numpy.zeros([l1,1])

	for j in range (0, l1):
		(x1,y1) = ll2utm(sta_lon[j],sta_lat[j], -71)
		
		(x2,y2) = ll2utm(eq_lon,eq_lat, -71)

		result = gps2DistAzimuth(sta_lat[j],sta_lon[j],eq_lat,eq_lon)
		backazi[j,0]=result[1]
		azi[j,0]=result[2]
		
		theta[j,0] = 90 - backazi[j,0] + 180


		xrs[j,0] = (x1-x2)
		yrs[j,0] = (y1-y2)
		zrs[j,0] = (sta_alt[j]+eq_alt*1000)






	U = numpy.zeros([3*l1,1])
	for i in range (0, l1):
		efftime = math.ceil(effhypodist[i])
		NN = n[i,efftime:efftime+10]
		EE = e[i,efftime:efftime+10]
		UU = u[i,efftime:efftime+10]
		a1 = numpy.where(n[i,efftime:efftime+10] > -999)[0]
		a1 = numpy.array(a1)
		if (len(a1) > 1):
			N = numpy.nanmean(NN[a1])
			E = numpy.nanmean(EE[a1])
			Z = numpy.nanmean(UU[a1])
			
			U[3*i,0]= N
			U[3*i+1,0]= E
			U[3*i+2,0]= -Z

		else:
			
			U[3*i,0]= 0
			U[3*i+1,0]= 0
			U[3*i+2,0]= 0


	
	G = okadapoint.greenF(yrs, xrs, -zrs) #Compute Green's function
	
	S = numpy.linalg.lstsq(G,U)[0]

	M12 = S[0,0]
	M13 = S[1,0]
	M33 = S[2,0]
	M23 = S[4,0]
	M11 = S[3,0]-0.5*S[2,0]
	M22 = -S[3,0]-0.5*S[2,0]
	
	M_devi = numpy.array([[M11,M12,M13],[M12,M22,M23],[M13,M23,M33]])
	eigenwtot, eigenvtot = numpy.linalg.eig(M_devi)
	eigenw1, eigenv1 = numpy.linalg.eig(M_devi)
	eigenw = numpy.real(numpy.take(eigenw1, numpy.argsort(abs(eigenwtot))))
        eigenv = numpy.real(numpy.take(eigenv1, numpy.argsort(abs(eigenwtot)), 1))
	eigenw_devi = numpy.real(numpy.take(eigenw1, numpy.argsort(abs(eigenw1))))
        eigenv_devi = numpy.real(numpy.take(eigenv1, numpy.argsort(abs(eigenw1)), 1))
	M0_devi = max(abs(eigenw_devi))
	F = -eigenw_devi[0] / eigenw_devi[2]
	M_DC_percentage = (1 - 2 * abs(F)) * 100
	
	

	Mo = math.pow(math.pow(M11,2)+math.pow(M22,2)+math.pow(M33,2)+2*math.pow(M12,2)+2*math.pow(M13,2)+2*math.pow(M23,2),0.5)/math.pow(2,0.5)
	if (Mo == 0):
		Mw = 0
	else:
		Mw = 2*math.log10(Mo)/3-6.03

	UP = numpy.dot(G,S)

	dms = U-UP
	
	VR = (1-numpy.sum(numpy.sqrt(numpy.power(dms,2)))/numpy.sum(numpy.sqrt(numpy.power(U,2))))*M_DC_percentage

	#VR = numpy.linalg.norm(dms)/M_DC_percentage*1000


	mt = obspy.imaging.beachball.MomentTensor(M33,M11,M22,M13,-M23,-M12,26)


	axes = obspy.imaging.beachball.MT2Axes(mt)
	plane1 = obspy.imaging.beachball.MT2Plane(mt)
	plane2 = obspy.imaging.beachball.AuxPlane(plane1.strike,plane1.dip,plane1.rake)
	T = {'azimuth':axes[0].strike,'plunge':axes[0].dip}
	N = {'azimuth':axes[1].strike,'plunge':axes[1].dip}
	P = {'azimuth':axes[2].strike,'plunge':axes[2].dip}
	NP1 = {'strike':plane1.strike,'dip':plane1.dip,'rake':plane1.rake}
	NP2 = {'strike':plane2[0],'dip':plane2[1],'rake':plane2[2]}



	return(S, VR, Mw, NP1, NP2)
Пример #4
0
m.fillcontinents()
m.drawparallels(np.arange(-90., 120., 30.))
m.drawmeridians(np.arange(0., 420., 60.))
m.drawmapboundary()

x, y = m(lons, lats)
m.scatter(x, y, 30, color="r", marker="^", edgecolor="k", linewidth='0.3', zorder=3)

focmecs = [moment_tensor,]
ax = plt.gca()
for i in range(len(focmecs)):
    b = Beach(focmecs[i], xy=(cmt_lon, cmt_lat), width=10, linewidth=1)
    b.set_zorder(10)
    ax.add_collection(b)

earth_hc, _ , _ = gps2DistAzimuth(0,0,0, 180)
##plot azimuth and distance distribution
theta=[]
radius=[]
for i in range(len(lons)):
    geo_info = gps2DistAzimuth(cmt_lat, cmt_lon, lats[i], lons[i])
    #geo_info = gps2DistAzimuth(lats[i], lons[i], cmt_loc[0], cmt_loc[1])
    #print geo_info
    theta.append(geo_info[1]/180.0*np.pi)
    radius.append(geo_info[0]/earth_hc)



ax = plt.subplot(223, polar=True)
c = plt.scatter(theta, radius, marker=u'^', c='r', s=10, edgecolor='k', linewidth='0.3')
c.set_alpha(0.75)
Пример #5
0
          color="r",
          marker="^",
          edgecolor="k",
          linewidth='0.3',
          zorder=3)

focmecs = [
    moment_tensor,
]
ax = plt.gca()
for i in range(len(focmecs)):
    b = Beach(focmecs[i], xy=(cmt_lon, cmt_lat), width=10, linewidth=1)
    b.set_zorder(10)
    ax.add_collection(b)

earth_hc, _, _ = gps2DistAzimuth(0, 0, 0, 180)
##plot azimuth and distance distribution
theta = []
radius = []
for i in range(len(lons)):
    geo_info = gps2DistAzimuth(cmt_lat, cmt_lon, lats[i], lons[i])
    #geo_info = gps2DistAzimuth(lats[i], lons[i], cmt_loc[0], cmt_loc[1])
    #print geo_info
    theta.append(geo_info[1] / 180.0 * np.pi)
    radius.append(geo_info[0] / earth_hc)

ax = plt.subplot(223, polar=True)
c = plt.scatter(theta,
                radius,
                marker=u'^',
                c='r',
Пример #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from obspy.core.util.geodetics.base import gps2DistAzimuth
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import numpy as np
import math
from obspy.imaging.beachball import Beach
import matplotlib.gridspec as gridspec

# earth half circle
EARTH_HC, _, _ = gps2DistAzimuth(0, 0, 0, 180)


class PlotUtil(object):

    def __init__(self, data_container=None, cmtsource=None, config=None,
                 nregions=12, new_cmtsource=None, bootstrap_mean=None,
                 bootstrap_std=None, var_reduction=0.0, mode="regional"):
        self.data_container = data_container
        self.cmtsource = cmtsource
        self.window = data_container.window
        self.config = config
        self.nregions = nregions

        self.new_cmtsource = new_cmtsource
        self.bootstrap_mean = bootstrap_mean
        self.bootstrap_std = bootstrap_std
        self.var_reduction = var_reduction

        self.moment_tensor = [cmtsource.m_rr, cmtsource.m_tt, cmtsource.m_pp,