15
15
@pytest .mark .mpl_image_compare
16
16
def test_meca_spec_dictionary ():
17
17
"""
18
- Test supplying a dictionary containing a single focal mechanism to the
19
- `spec` argument.
18
+ Test supplying a dictionary containing a single focal mechanism to the spec
19
+ argument.
20
20
"""
21
-
22
21
fig = Figure ()
23
-
24
22
# Right lateral strike slip focal mechanism
25
23
fig .meca (
26
24
dict (strike = 0 , dip = 90 , rake = 0 , magnitude = 5 ),
@@ -32,24 +30,20 @@ def test_meca_spec_dictionary():
32
30
projection = "M14c" ,
33
31
frame = 2 ,
34
32
)
35
-
36
33
return fig
37
34
38
35
39
36
@pytest .mark .mpl_image_compare
40
37
def test_meca_spec_dict_list ():
41
38
"""
42
- Test supplying a dictionary containing a list of focal mechanism to the
43
- `spec` argument.
39
+ Test supplying a dictionary containing a list of focal mechanism to the spec
40
+ argument.
44
41
"""
45
-
46
42
fig = Figure ()
47
-
48
43
# supply focal mechanisms as a dict of lists
49
44
focal_mechanisms = dict (
50
45
strike = [330 , 350 ], dip = [30 , 50 ], rake = [90 , 90 ], magnitude = [3 , 2 ]
51
46
)
52
-
53
47
fig .meca (
54
48
focal_mechanisms ,
55
49
longitude = [- 124.3 , - 124.4 ],
@@ -59,15 +53,14 @@ def test_meca_spec_dict_list():
59
53
scale = "2c" ,
60
54
projection = "M14c" ,
61
55
)
62
-
63
56
return fig
64
57
65
58
66
59
@pytest .mark .mpl_image_compare
67
60
def test_meca_spec_dataframe ():
68
61
"""
69
- Test supplying a pandas DataFrame containing focal mechanisms and locations
70
- to the ` spec` argument.
62
+ Test supplying a pandas. DataFrame containing focal mechanisms and locations
63
+ to the spec argument.
71
64
"""
72
65
73
66
fig = Figure ()
@@ -83,21 +76,17 @@ def test_meca_spec_dataframe():
83
76
depth = [12 , 11.0 ],
84
77
)
85
78
spec_dataframe = pd .DataFrame (data = focal_mechanisms )
86
-
87
79
fig .meca (spec_dataframe , region = [- 125 , - 122 , 47 , 49 ], scale = "2c" , projection = "M14c" )
88
-
89
80
return fig
90
81
91
82
92
83
@pytest .mark .mpl_image_compare
93
84
def test_meca_spec_1d_array ():
94
85
"""
95
86
Test supplying a 1D numpy array containing focal mechanisms and locations
96
- to the ` spec` argument.
87
+ to the spec argument.
97
88
"""
98
-
99
89
fig = Figure ()
100
-
101
90
# supply focal mechanisms to meca as a 1D numpy array, here we are using
102
91
# the Harvard CMT zero trace convention but the focal mechanism
103
92
# parameters may be specified any of the available conventions. Since we
@@ -118,7 +107,6 @@ def test_meca_spec_1d_array():
118
107
0 , # plot_lat, 0 to plot at event location
119
108
]
120
109
focal_mech_array = np .asarray (focal_mechanism )
121
-
122
110
fig .meca (
123
111
focal_mech_array ,
124
112
convention = "mt" ,
@@ -127,19 +115,16 @@ def test_meca_spec_1d_array():
127
115
scale = "2c" ,
128
116
projection = "M14c" ,
129
117
)
130
-
131
118
return fig
132
119
133
120
134
121
@pytest .mark .mpl_image_compare
135
122
def test_meca_spec_2d_array ():
136
123
"""
137
124
Test supplying a 2D numpy array containing focal mechanisms and locations
138
- to the ` spec` argument.
125
+ to the spec argument.
139
126
"""
140
-
141
127
fig = Figure ()
142
-
143
128
# supply focal mechanisms to meca as a 2D numpy array, here we are using
144
129
# the GCMT convention but the focal mechanism parameters may be
145
130
# specified any of the available conventions. Since we are not using a
@@ -163,29 +148,25 @@ def test_meca_spec_2d_array():
163
148
[- 127.50 , 40.88 , 12.0 , 168 , 40 , - 115 , 20 , 54 , - 70 , 4.0 , 23 , 0 , 0 ],
164
149
]
165
150
focal_mechs_array = np .asarray (focal_mechanisms )
166
-
167
151
fig .meca (
168
152
focal_mechs_array ,
169
153
convention = "gcmt" ,
170
154
region = [- 128 , - 127 , 40 , 41 ],
171
155
scale = "2c" ,
172
156
projection = "M14c" ,
173
157
)
174
-
175
158
return fig
176
159
177
160
178
161
@pytest .mark .mpl_image_compare
179
162
def test_meca_spec_file ():
180
163
"""
181
- Test supplying a file containing focal mechanisms and locations to the
182
- `spec` argument.
164
+ Test supplying a file containing focal mechanisms and locations to the spec
165
+ argument.
183
166
"""
184
167
185
168
fig = Figure ()
186
-
187
169
focal_mechanism = [- 127.43 , 40.81 , 12 , - 3.19 , 1.16 , 3.93 , - 1.02 , - 3.93 , - 1.02 , 23 ]
188
-
189
170
# writes temp file to pass to gmt
190
171
with GMTTempFile () as temp :
191
172
with open (temp .name , mode = "w" ) as temp_file :
@@ -199,7 +180,6 @@ def test_meca_spec_file():
199
180
scale = "2c" ,
200
181
projection = "M14c" ,
201
182
)
202
-
203
183
return fig
204
184
205
185
@@ -209,22 +189,17 @@ def test_meca_loc_array():
209
189
Test supplying lists and np.ndarrays as the event location (longitude,
210
190
latitude, and depth).
211
191
"""
212
-
213
192
fig = Figure ()
214
-
215
193
# specify focal mechanisms
216
194
focal_mechanisms = dict (
217
195
strike = [327 , 350 ], dip = [41 , 50 ], rake = [68 , 90 ], magnitude = [3 , 2 ]
218
196
)
219
-
220
197
# longitude, latitude, and depth may be specified as an int, float,
221
198
# list, or 1d numpy array
222
199
longitude = np .array ([- 123.3 , - 124.4 ])
223
200
latitude = np .array ([48.4 , 48.2 ])
224
201
depth = [12.0 , 11.0 ] # to test mixed data types as inputs
225
-
226
202
scale = "2c"
227
-
228
203
fig .meca (
229
204
focal_mechanisms ,
230
205
scale ,
@@ -234,5 +209,4 @@ def test_meca_loc_array():
234
209
region = [- 125 , - 122 , 47 , 49 ],
235
210
projection = "M14c" ,
236
211
)
237
-
238
212
return fig
0 commit comments