forked from kwschultz/PyVC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyvc_tests.py
executable file
·203 lines (173 loc) · 6.73 KB
/
pyvc_tests.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env python
from pyvc import vcplots
from pyvc import *
import time
sim_data_file = 'example_simulation.h5'
kwargs1 = {
'event_range': {'type':'year','filter':(100,900)}
}
kwargs2 = {
'event_range': {'type':'year','filter':(100,900)},
'magnitude_filter': '>= 6.0',
}
kwargs3 = {
'event_range': {'type':'year','filter':(100,900)},
'magnitude_filter': '>= 6.0',
'section_filter': {'type':'section_id','filter':[1,2,3,4,5,6,7,8,9,10]}
}
with VCSimData() as sim_data:
sim_data.open_file(sim_data_file)
events = VCEvents(sim_data)
print 'Getting event data \'event_year\' and \'event_magnitude\''
print ' No filters'
start_time = time.time()
event_data = events.get_event_data(['event_year', 'event_magnitude'])
end_time = time.time() - start_time
print ' {} events'.format(len(event_data['event_year']))
print ' {} seconds'.format(time.time() - start_time)
print
print ' Years 100 - 900'
start_time = time.time()
event_data = events.get_event_data(['event_year', 'event_magnitude'], **kwargs1)
end_time = time.time() - start_time
print ' {} events'.format(len(event_data['event_year']))
print ' {} seconds'.format(time.time() - start_time)
print
print ' Years 100 - 900'
print ' Magnitudes >= 6.0'
start_time = time.time()
event_data = events.get_event_data(['event_year', 'event_magnitude'], **kwargs2)
end_time = time.time() - start_time
print ' {} events'.format(len(event_data['event_year']))
print ' {} seconds'.format(time.time() - start_time)
print
print ' Years 100 - 900'
print ' Magnitudes >= 6.0'
print ' Sections 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10'
start_time = time.time()
event_data = events.get_event_data(['event_year', 'event_magnitude'], **kwargs3)
end_time = time.time() - start_time
print ' {} events'.format(len(event_data['event_year']))
print ' {} seconds'.format(time.time() - start_time)
print
print
print 'Plotting event data'
print ' No filters'
print ' Average Slip vs Surface Rupture Length'
out_file = 'test_asrl.png'
start_time = time.time()
vcplots.average_slip_surface_rupture_length(sim_data_file, out_file)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Rupture Length'
out_file = 'test_mra.png'
start_time = time.time()
vcplots.magnitude_rupture_area(sim_data_file, out_file)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Average Slip'
out_file = 'test_mas.png'
start_time = time.time()
vcplots.magnitude_average_slip(sim_data_file, out_file)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Frequency vs Magnitude'
out_file = 'test_fm.png'
start_time = time.time()
vcplots.frequency_magnitude(sim_data_file, out_file)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Years 100 - 900'
print ' Average Slip vs Surface Rupture Length'
out_file = 'test_asrl-year.png'
start_time = time.time()
vcplots.average_slip_surface_rupture_length(sim_data_file, out_file, **kwargs1)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Rupture Length'
out_file = 'test_mra-year.png'
start_time = time.time()
vcplots.magnitude_rupture_area(sim_data_file, out_file, **kwargs1)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Average Slip'
out_file = 'test_mas-year.png'
start_time = time.time()
vcplots.magnitude_average_slip(sim_data_file, out_file, **kwargs1)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Frequency vs Magnitude'
out_file = 'test_fm-year.png'
start_time = time.time()
vcplots.frequency_magnitude(sim_data_file, out_file, **kwargs1)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Years 100 - 900'
print ' Magnitudes >= 6.0'
print ' Average Slip vs Surface Rupture Length'
out_file = 'test_asrl-year_mag.png'
start_time = time.time()
vcplots.average_slip_surface_rupture_length(sim_data_file, out_file, **kwargs2)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Rupture Length'
out_file = 'test_mra-year_mag.png'
start_time = time.time()
vcplots.magnitude_rupture_area(sim_data_file, out_file, **kwargs2)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Average Slip'
out_file = 'test_mas-year_mag.png'
start_time = time.time()
vcplots.magnitude_average_slip(sim_data_file, out_file, **kwargs2)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Frequency vs Magnitude'
out_file = 'test_fm-year_mag.png'
start_time = time.time()
vcplots.frequency_magnitude(sim_data_file, out_file, **kwargs2)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Years 100 - 900'
print ' Magnitudes >= 6.0'
print ' Sections 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10'
print ' Average Slip vs Surface Rupture Length'
out_file = 'test_asrl-year_mag_sec.png'
start_time = time.time()
vcplots.average_slip_surface_rupture_length(sim_data_file, out_file, **kwargs3)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Rupture Length'
out_file = 'test_mra-year_mag_sec.png'
start_time = time.time()
vcplots.magnitude_rupture_area(sim_data_file, out_file, **kwargs3)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Magnitude vs Average Slip'
out_file = 'test_mas-year_mag_sec.png'
start_time = time.time()
vcplots.magnitude_average_slip(sim_data_file, out_file, **kwargs3)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print
print ' Frequency vs Magnitude'
out_file = 'test_fm-year_mag_sec.png'
start_time = time.time()
vcplots.frequency_magnitude(sim_data_file, out_file, **kwargs3)
print ' plotted to {}'.format(out_file)
print ' {} seconds'.format(time.time() - start_time)
print