-
Notifications
You must be signed in to change notification settings - Fork 10
/
1b_plot_eqLocs.py
81 lines (61 loc) · 2.51 KB
/
1b_plot_eqLocs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!python3.7
'''
Created on March 28th, 2019
- event selection
- plot earthquake catalog
TODO: - implement geo-referenced plotting with Basemap
@author: tgoebel
'''
#------------------------------------------------------------------------------
import matplotlib.pyplot as plt
import numpy as np
import os
os.environ["PROJ_LIB"] = f"{os.environ['HOME']}/opt/anaconda3/share/proj"
from mpl_toolkits.basemap import Basemap
#------------------------------my modules--------------------------------------
from src.EqCat import EqCat
eqCat = EqCat( )
#print( dir( dataUtils))
#=================================1==============================================
# dir, file, params
#================================================================================
dir_in = 'data'
file_in= 'hs_1981_2011_all.mat'
#xmin, xmax = -122, -114
#ymin, ymax = 34, 38
Mmin, Mmax = 3, None
tmin, tmax = 1990, 2012
#=================================2==============================================
# load data, select events
#================================================================================
os.chdir( dir_in)
eqCat.loadMatBin( file_in)
print( eqCat.methods)
print( grege)
print( 'total no. of events', eqCat.size())
eqCat.selectEvents( Mmin, Mmax, 'Mag')
eqCat.selectEvents( tmin, tmax, 'Time')
print( 'no. of events after initial selection', eqCat.size())
#=================================3==============================================
# test plot T
#================================================================================
projection = 'cyl'
xmin,xmax = eqCat.data['Lon'].min(), eqCat.data['Lon'].max()
ymin,ymax = eqCat.data['Lat'].min(), eqCat.data['Lat'].max()
# setup equi distance basemap.
m = Basemap( llcrnrlat = ymin,urcrnrlat = ymax,
llcrnrlon = xmin,urcrnrlon = xmax,
projection = projection,lat_0=(ymin+ymax)*.5,lon_0=(xmin+xmax)*.5,
resolution = 'l')
m.drawstates( linewidth = 1)
m.drawcoastlines( linewidth= 2)
a_x, a_y = m( eqCat.data['Lon'], eqCat.data['Lat'])
m.plot( a_x, a_y, 'ko', ms = 1)
sel7 = eqCat.data['Mag'] >=7
m.plot( a_x[sel7], a_y[sel7], 'ro', ms = 8, mew= 1.5, mfc = 'none')
m.drawmeridians( np.linspace( int(xmin), xmax, 4),labels=[False,False,False,True],
fontsize = 12, fmt = '%.1f')
m.drawparallels( np.linspace( int(ymin), ymax, 4),labels=[True,False,False,False],
fontsize = 12, fmt = '%.2f')
plt.savefig( file_in.replace( 'mat', 'png'))
plt.show()