irie 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of irie might be problematic. Click here for more details.
- irie/apps/events/views.py +4 -5
- irie/apps/inventory/filters.py +1 -1
- irie/apps/inventory/models.py +5 -0
- irie/apps/inventory/urls.py +1 -1
- irie/apps/inventory/views.py +21 -12
- irie/apps/templates/inventory/asset-event-summary.html +26 -2
- irie/apps/templates/inventory/asset-profile.html +46 -0
- irie/apps/templates/inventory/asset-table.html +8 -30
- irie/apps/templates/prediction/hazus/history.js +4 -4
- irie/apps/templates/site/index.html +2 -0
- irie/core/settings.py +4 -7
- irie/usgs/__main__.py +145 -0
- {irie-0.0.7.dist-info → irie-0.0.8.dist-info}/METADATA +1 -1
- {irie-0.0.7.dist-info → irie-0.0.8.dist-info}/RECORD +17 -16
- {irie-0.0.7.dist-info → irie-0.0.8.dist-info}/WHEEL +0 -0
- {irie-0.0.7.dist-info → irie-0.0.8.dist-info}/entry_points.txt +0 -0
- {irie-0.0.7.dist-info → irie-0.0.8.dist-info}/top_level.txt +0 -0
irie/apps/events/views.py
CHANGED
|
@@ -6,7 +6,6 @@ from django.http import HttpResponse
|
|
|
6
6
|
from django.contrib.auth.decorators import login_required
|
|
7
7
|
|
|
8
8
|
from irie.apps.events.models import EventRecord
|
|
9
|
-
from irie.apps.site.view_utils import raise404
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
@login_required(login_url="/login/")
|
|
@@ -27,11 +26,11 @@ def event_table(request):
|
|
|
27
26
|
asset = request.GET.get("asset", None)
|
|
28
27
|
|
|
29
28
|
if asset is not None:
|
|
30
|
-
events = [i for i in
|
|
31
|
-
key=lambda x: x.motion_data["event_date"])
|
|
29
|
+
events = [i for i in sorted(EventRecord.objects.filter(asset=asset),
|
|
30
|
+
key=lambda x: x.motion_data["event_date"], reverse=True)]
|
|
32
31
|
else:
|
|
33
|
-
events = [i for i in
|
|
34
|
-
key=lambda x: x.motion_data["event_date"])
|
|
32
|
+
events = [i for i in sorted(EventRecord.objects.all(),
|
|
33
|
+
key=lambda x: x.motion_data["event_date"], reverse=True)]
|
|
35
34
|
|
|
36
35
|
# Paginator for 10 items per page
|
|
37
36
|
paginator = Paginator(events, 15)
|
irie/apps/inventory/filters.py
CHANGED
irie/apps/inventory/models.py
CHANGED
|
@@ -51,6 +51,11 @@ class Asset(models.Model):
|
|
|
51
51
|
for p in PredictorModel.objects.filter(asset=self)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
@property
|
|
55
|
+
def event_count(self):
|
|
56
|
+
from irie.apps.events.models import EventRecord
|
|
57
|
+
return len(EventRecord.objects.filter(cesmd=self.cesmd))
|
|
58
|
+
|
|
54
59
|
@property
|
|
55
60
|
def rendering(self):
|
|
56
61
|
from irie.apps.prediction.models import PredictorModel
|
irie/apps/inventory/urls.py
CHANGED
|
@@ -18,7 +18,7 @@ urlpatterns = [
|
|
|
18
18
|
path("dashboard/demo", views.dashboard),
|
|
19
19
|
|
|
20
20
|
path("asset-table.html", views.asset_table),
|
|
21
|
-
path("asset-table/",
|
|
21
|
+
path("asset-table/", views.asset_table, name="asset_table"),
|
|
22
22
|
re_path(
|
|
23
23
|
r"^evaluations/(?P<event>[0-9 A-Z-]*)/(?P<cesmd>[0-9 A-Z-]*)/.*", views.asset_event_summary, name="asset_event_summary"
|
|
24
24
|
),
|
irie/apps/inventory/views.py
CHANGED
|
@@ -28,7 +28,7 @@ from irie.apps.prediction.runners.ssid import make_mountains, ssid_stats, ssid_e
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@login_required(login_url="/login/")
|
|
31
|
-
def
|
|
31
|
+
def _fetch_rendering(request):
|
|
32
32
|
asset_id = request.GET.get('asset')
|
|
33
33
|
asset = Asset.objects.get(id=asset_id)
|
|
34
34
|
|
|
@@ -36,7 +36,6 @@ def fetch_rendering(request):
|
|
|
36
36
|
template = loader.get_template(f"bridges/InteractiveTwin-{asset.cesmd}.html")
|
|
37
37
|
return HttpResponse(template.render({}, request))
|
|
38
38
|
|
|
39
|
-
|
|
40
39
|
from irie.apps.prediction.models import PredictorModel
|
|
41
40
|
for p in PredictorModel.objects.filter(asset=asset):
|
|
42
41
|
if p.protocol == "IRIE_PREDICTOR_T4":
|
|
@@ -87,7 +86,8 @@ def asset_event_summary(request, cesmd, event):
|
|
|
87
86
|
}
|
|
88
87
|
context["asset"] = evaluation and evaluation.event.asset or None
|
|
89
88
|
context["nce_version"] = is_nce
|
|
90
|
-
context["
|
|
89
|
+
context["event"] = EventRecord.objects.get(pk=int(event))
|
|
90
|
+
context["event_data"] = context["event"].motion_data
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
resp = html_template.render(context, request)
|
|
@@ -113,8 +113,9 @@ def dashboard(request):
|
|
|
113
113
|
context["demo_version"] = True
|
|
114
114
|
|
|
115
115
|
context["recent_evaluations"] = [
|
|
116
|
-
(
|
|
117
|
-
for
|
|
116
|
+
(Evaluation.objects.get(event_id=event.id), event)
|
|
117
|
+
for event in sorted(EventRecord.objects.all(),
|
|
118
|
+
key=lambda x: x.motion_data["event_date"], reverse=True)[:6]
|
|
118
119
|
]
|
|
119
120
|
assets = list(set(
|
|
120
121
|
Asset.objects.get(cesmd=event[1].cesmd) for event in context["recent_evaluations"]
|
|
@@ -310,19 +311,27 @@ def asset_table(request):
|
|
|
310
311
|
except:
|
|
311
312
|
page = 1
|
|
312
313
|
|
|
314
|
+
# Copy the GET parameters and remove the 'page' parameter
|
|
315
|
+
page_query = request.GET.copy()
|
|
316
|
+
page_query.pop('page', None)
|
|
317
|
+
|
|
313
318
|
filter_set = AssetFilter(request.GET, queryset=Asset.objects.all())
|
|
314
|
-
|
|
319
|
+
order_query = page_query.copy()
|
|
320
|
+
if order := order_query.pop("order", None):
|
|
321
|
+
try:
|
|
322
|
+
assets = filter_set.qs.order_by(order[0])
|
|
323
|
+
except:
|
|
324
|
+
assets = sorted(filter_set.qs, key=lambda x: getattr(x, order[0]), reverse=True)
|
|
325
|
+
else:
|
|
326
|
+
assets = filter_set.qs
|
|
327
|
+
|
|
328
|
+
context["page_query"] = page_query.urlencode()
|
|
329
|
+
context["order_query"] = order_query.urlencode()
|
|
315
330
|
context["bridges"] = Paginator(assets, 10).get_page(page)
|
|
316
331
|
context["asset_map"] = AssetMap(assets=assets).get_html()
|
|
317
332
|
context["filter"] = filter_set
|
|
318
333
|
|
|
319
334
|
|
|
320
|
-
# Copy the GET parameters and remove the 'page' parameter
|
|
321
|
-
query_params = request.GET.copy()
|
|
322
|
-
query_params.pop('page', None) # Remove 'page' parameter if it exists
|
|
323
|
-
context["query_string"] = query_params.urlencode()
|
|
324
|
-
|
|
325
|
-
|
|
326
335
|
html_template = loader.get_template("inventory/asset-table.html")
|
|
327
336
|
try:
|
|
328
337
|
return HttpResponse(html_template.render(context, request))
|
|
@@ -15,8 +15,32 @@
|
|
|
15
15
|
{% endblock stylesheets %}
|
|
16
16
|
|
|
17
17
|
{% block content %}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center py-4">
|
|
19
|
+
<div class="d-block mb-4 mb-md-0">
|
|
20
|
+
<nav aria-label="breadcrumb" class="d-none d-md-inline-block">
|
|
21
|
+
<ol class="breadcrumb breadcrumb-dark breadcrumb-transparent">
|
|
22
|
+
<li class="breadcrumb-item">
|
|
23
|
+
<a href="/">
|
|
24
|
+
<svg class="icon icon-xxs" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path></svg>
|
|
25
|
+
</a>
|
|
26
|
+
</li>
|
|
27
|
+
<li class="breadcrumb-item"><a href="{% url 'dashboard' %}">BRACE<sup>2</sup></a></li>
|
|
28
|
+
<li class="breadcrumb-item" aria-current="page">Evaluations</li>
|
|
29
|
+
<li class="breadcrumb-item" aria-current="page">{{ event.id }}</li>
|
|
30
|
+
<li class="breadcrumb-item active"><code>{{ asset.calid }}</code></li>
|
|
31
|
+
</ol>
|
|
32
|
+
</nav>
|
|
33
|
+
<h2 class="fs-2 lh-2 me-3">{{ asset.name }}</h2>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="btn-toolbar mb-2 mb-md-0">
|
|
36
|
+
<a role="button"
|
|
37
|
+
href="/inventory/{{ asset.calid }}"
|
|
38
|
+
class="btn btn-sm btn-gray-800 d-inline-flex align-items-center">
|
|
39
|
+
Asset Profile
|
|
40
|
+
</a>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
20
44
|
<div class="py-4 align-right">
|
|
21
45
|
<a role="button" class="button btn btn-outline-primary"
|
|
22
46
|
href="/inventory/{{ asset.calid }}" class="me-1">Structure Profile</a>
|
|
@@ -146,7 +146,15 @@
|
|
|
146
146
|
<div class="col-10 mb-4">
|
|
147
147
|
<div class="card h-100 bg-white-100 border-0 shadow">
|
|
148
148
|
<div class="card-header d-sm-flex flex-row align-items-center flex-0">
|
|
149
|
+
{% comment %}
|
|
150
|
+
<button
|
|
151
|
+
class="btn btn-primary position-absolute top-0 end-0 m-2"
|
|
152
|
+
onclick="openFullViewer('{{ asset.rendering }}')">
|
|
153
|
+
Full Screen
|
|
154
|
+
</button>
|
|
155
|
+
{% endcomment %}
|
|
149
156
|
</div>
|
|
157
|
+
|
|
150
158
|
<div class="card-body align-items-center">
|
|
151
159
|
<model-viewer
|
|
152
160
|
id="viewer"
|
|
@@ -297,4 +305,42 @@
|
|
|
297
305
|
myWindow.print();
|
|
298
306
|
}
|
|
299
307
|
</script>
|
|
308
|
+
<script>
|
|
309
|
+
function openFullViewer(src) {
|
|
310
|
+
// Construct the HTML for the full-screen viewer
|
|
311
|
+
const fullViewerHTML = `
|
|
312
|
+
<!DOCTYPE html>
|
|
313
|
+
<html lang="en">
|
|
314
|
+
<head>
|
|
315
|
+
<meta charset="UTF-8">
|
|
316
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
317
|
+
<title>Full Viewer</title>
|
|
318
|
+
<style>
|
|
319
|
+
body { margin: 0; padding: 0; overflow: hidden; }
|
|
320
|
+
model-viewer { width: 100vw; height: 100vh; }
|
|
321
|
+
</style>
|
|
322
|
+
</head>
|
|
323
|
+
<body>
|
|
324
|
+
<model-viewer
|
|
325
|
+
src="${src}"
|
|
326
|
+
alt="3D Model"
|
|
327
|
+
auto-rotate
|
|
328
|
+
camera-controls
|
|
329
|
+
style="width: 100%; height: 100%;">
|
|
330
|
+
</model-viewer>
|
|
331
|
+
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"><\/script>
|
|
332
|
+
</body>
|
|
333
|
+
</html>
|
|
334
|
+
`;
|
|
335
|
+
|
|
336
|
+
// Open a new tab
|
|
337
|
+
const newTab = window.open();
|
|
338
|
+
|
|
339
|
+
// Write the HTML into the new tab
|
|
340
|
+
newTab.document.open();
|
|
341
|
+
newTab.document.write(fullViewerHTML);
|
|
342
|
+
newTab.document.close();
|
|
343
|
+
}
|
|
344
|
+
</script>
|
|
345
|
+
|
|
300
346
|
{% endblock javascripts %}
|
|
@@ -162,8 +162,9 @@ table a[href^="https://"]::after
|
|
|
162
162
|
title="Structure Number is an alphanumeric sequence assigned by each State to uniquely identify the structure within each State.">
|
|
163
163
|
CALID
|
|
164
164
|
</span></th>
|
|
165
|
-
<th>CESMD</th>
|
|
166
|
-
<th>Name</th>
|
|
165
|
+
<th><a href="?page=1&order=cesmd&{{ order_query }}">CESMD</a></th>
|
|
166
|
+
<th><a href="?page=1&order=name&{{ order_query }}">Name</a></th>
|
|
167
|
+
<th><a href="?page=1&order=event_count&{{ order_query }}">Events</a></th>
|
|
167
168
|
</tr>
|
|
168
169
|
</thead>
|
|
169
170
|
<tbody>
|
|
@@ -181,6 +182,8 @@ table a[href^="https://"]::after
|
|
|
181
182
|
<td> <a href="{% url 'asset_profile' calid=v.calid %}" >{{ v.calid }}</a></td>
|
|
182
183
|
{% endif %}
|
|
183
184
|
|
|
185
|
+
<td>{{ v.event_count }}</td>
|
|
186
|
+
|
|
184
187
|
</tr>
|
|
185
188
|
{% endfor %}
|
|
186
189
|
</tbody>
|
|
@@ -192,7 +195,7 @@ table a[href^="https://"]::after
|
|
|
192
195
|
<ul class="pagination mb-0">
|
|
193
196
|
<li class="page-item {% if not bridges.has_previous %}disabled{% endif %}">
|
|
194
197
|
{% if bridges.has_previous %}
|
|
195
|
-
<a class="page-link" href="?page={{ bridges.previous_page_number }}&{{
|
|
198
|
+
<a class="page-link" href="?page={{ bridges.previous_page_number }}&{{ page_query }}">Previous</a>
|
|
196
199
|
{% else %}
|
|
197
200
|
<a class="page-link disabled" href="#">Previous</a>
|
|
198
201
|
{% endif %}
|
|
@@ -200,42 +203,17 @@ table a[href^="https://"]::after
|
|
|
200
203
|
{% for page in bridges.paginator.page_range %}
|
|
201
204
|
{% if page <= bridges.number|add:3 and page >= bridges.number|add:-3 %}
|
|
202
205
|
<li class="page-item {% if page == bridges.number %}active{% endif %}">
|
|
203
|
-
<a class="page-link" href="?page={{ page }}&{{
|
|
206
|
+
<a class="page-link" href="?page={{ page }}&{{ page_query }}">{{ page }}</a>
|
|
204
207
|
</li>
|
|
205
208
|
{% endif %}
|
|
206
209
|
{% endfor %}
|
|
207
210
|
<li class="page-item {% if not bridges.has_next %}disabled{% endif %}">
|
|
208
211
|
{% if bridges.has_next %}
|
|
209
|
-
<a class="page-link" href="?page={{ bridges.next_page_number }}&{{
|
|
212
|
+
<a class="page-link" href="?page={{ bridges.next_page_number }}&{{ page_query }}">Next</a>
|
|
210
213
|
{% else %}
|
|
211
214
|
<a class="page-link disabled" href="#">Next</a>
|
|
212
215
|
{% endif %}
|
|
213
216
|
</li>
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
{% if False %}
|
|
217
|
-
<li class="page-item {% if not bridges.has_previous %}disabled{% endif %}">
|
|
218
|
-
{% if bridges.has_previous %}
|
|
219
|
-
<a class="page-link" href="?page={{ bridges.previous_page_number }}/">Previous</a>
|
|
220
|
-
{% else %}
|
|
221
|
-
<a class="page-link disabled" href="#">Previous</a>
|
|
222
|
-
{% endif %}
|
|
223
|
-
</li>
|
|
224
|
-
{% for page in bridges.paginator.page_range %}
|
|
225
|
-
{% if page <= bridges.number|add:3 and page >= bridges.number|add:-3 %}
|
|
226
|
-
<li class="page-item {% if page == bridges.number %}active{% endif %}">
|
|
227
|
-
<a class="page-link" href="?page={{ page }}">{{ page }}</a>
|
|
228
|
-
</li>
|
|
229
|
-
{% endif %}
|
|
230
|
-
{% endfor %}
|
|
231
|
-
<li class="page-item {% if not bridges.has_next %}disabled{% endif %}">
|
|
232
|
-
{% if bridges.has_next %}
|
|
233
|
-
<a class="page-link" href="?page={{ bridges.next_page_number }}/">Next</a>
|
|
234
|
-
{% else %}
|
|
235
|
-
<a class="page-link disabled" href="#">Next</a>
|
|
236
|
-
{% endif %}
|
|
237
|
-
</li>
|
|
238
|
-
{% endif %}
|
|
239
217
|
</ul>
|
|
240
218
|
</nav>
|
|
241
219
|
<div class="fw-normal small mt-4 mt-lg-0">Showing <b>{{ bridges|length }}</b> out of <b>{{ bridges.paginator.count }}</b> entries</div>
|
|
@@ -35,10 +35,10 @@ var x = JSON.parse(elem.dataset.hazusX);
|
|
|
35
35
|
|
|
36
36
|
// add random data to three line traces
|
|
37
37
|
var data = [
|
|
38
|
-
{mode:'lines', line: {color: "
|
|
39
|
-
{mode: 'lines', line: {color: "
|
|
40
|
-
{mode: 'lines', line: {color: "
|
|
41
|
-
{mode: 'lines', line: {color: "
|
|
38
|
+
{mode:'lines', line: {color: "turquoise"}, x: x, y: curves.Slight, name: "Slight"},
|
|
39
|
+
{mode: 'lines', line: {color: "green"}, x: x, y: curves.Moderate, name: "Moderate"},
|
|
40
|
+
{mode: 'lines', line: {color: "orange"}, x: x, y: curves.Extensive, name: "Extensive"},
|
|
41
|
+
{mode: 'lines', line: {color: "red"}, x: x, y: curves.Complete, name: "Complete"},
|
|
42
42
|
]
|
|
43
43
|
|
|
44
44
|
Plotly.react('hazusPlot', data, layout);
|
|
@@ -244,6 +244,7 @@ td.left-text{vertical-align:middle}
|
|
|
244
244
|
<div class="col-lg-6 order-lg-1"><img src="{{ ASSETS_ROOT }}/img/metric.png"
|
|
245
245
|
alt="Digital twins"></div>
|
|
246
246
|
</div>
|
|
247
|
+
{% comment %}
|
|
247
248
|
<div class="col-lg-5 order-lg-2 mb-5 mb-lg-0">
|
|
248
249
|
<h2 class="h1 d-flex align-items-center"> Corridors<span
|
|
249
250
|
class="badge-md mb-0 fs-6 badge ms-3 rounded-pill text-dark bg-secondary">New</span></h2>
|
|
@@ -258,6 +259,7 @@ td.left-text{vertical-align:middle}
|
|
|
258
259
|
</div>
|
|
259
260
|
<div class="col-lg-6 order-lg-1"><img src="./assets/img/mockup-map-presentation.png"
|
|
260
261
|
alt="Corridors"></div>
|
|
262
|
+
{% endcomment %}
|
|
261
263
|
</div>
|
|
262
264
|
|
|
263
265
|
</div>
|
irie/core/settings.py
CHANGED
|
@@ -11,9 +11,6 @@ env = environ.Env(DEBUG=(bool, False))
|
|
|
11
11
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
|
12
12
|
CORE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
13
13
|
|
|
14
|
-
# Take environment variables from .env file
|
|
15
|
-
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))
|
|
16
|
-
|
|
17
14
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
18
15
|
SECRET_KEY = env("SECRET_KEY", default="S#perS3crEt_007")
|
|
19
16
|
|
|
@@ -198,11 +195,11 @@ STATIC_ROOT = os.path.join(CORE_DIR, "staticfiles")
|
|
|
198
195
|
STATIC_URL = "/static/"
|
|
199
196
|
|
|
200
197
|
# Extra places for collectstatic to find static files.
|
|
201
|
-
STATICFILES_DIRS = (
|
|
198
|
+
STATICFILES_DIRS = (
|
|
199
|
+
os.path.join(CORE_DIR, "apps/static"),
|
|
200
|
+
)
|
|
202
201
|
|
|
203
|
-
|
|
204
|
-
MEDIA_ROOT = os.path.join(BASE_DIR, "uploads/")
|
|
205
|
-
MEDIA_URL = "/uploads/"
|
|
202
|
+
# cmp
|
|
206
203
|
FILE_UPLOAD_HANDLERS = (
|
|
207
204
|
# "django.core.files.uploadhandler.MemoryFileUploadHandler",
|
|
208
205
|
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
|
irie/usgs/__main__.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from xml.etree import ElementTree
|
|
3
|
+
import numpy as np
|
|
4
|
+
from scipy.interpolate import griddata
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
def log(message):
|
|
8
|
+
"""Utility to log diagnostics to stderr."""
|
|
9
|
+
print(message, file=sys.stderr)
|
|
10
|
+
|
|
11
|
+
# Function to fetch events from USGS within a time window
|
|
12
|
+
def fetch_events(start_time, end_time, min_magnitude=0, max_magnitude=10):
|
|
13
|
+
"""
|
|
14
|
+
Fetch earthquake events from the USGS Earthquake API.
|
|
15
|
+
|
|
16
|
+
API Documentation:
|
|
17
|
+
https://earthquake.usgs.gov/fdsnws/event/1/
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
start_time (str): Start time in ISO format (e.g., "2024-01-01").
|
|
21
|
+
end_time (str): End time in ISO format (e.g., "2024-12-01").
|
|
22
|
+
min_magnitude (float): Minimum earthquake magnitude.
|
|
23
|
+
max_magnitude (float): Maximum earthquake magnitude.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
list: List of earthquake events as GeoJSON features.
|
|
27
|
+
"""
|
|
28
|
+
url = "https://earthquake.usgs.gov/fdsnws/event/1/query"
|
|
29
|
+
params = {
|
|
30
|
+
"format": "geojson",
|
|
31
|
+
"starttime": start_time,
|
|
32
|
+
"endtime": end_time,
|
|
33
|
+
"minmagnitude": min_magnitude,
|
|
34
|
+
"maxmagnitude": max_magnitude,
|
|
35
|
+
}
|
|
36
|
+
log(f"Querying events from {url} with parameters: {params}")
|
|
37
|
+
response = requests.get(url, params=params)
|
|
38
|
+
response.raise_for_status()
|
|
39
|
+
return response.json()["features"]
|
|
40
|
+
|
|
41
|
+
# Function to fetch ShakeMap XML grid for a specific event
|
|
42
|
+
def fetch_shakemap_grid(event_id):
|
|
43
|
+
"""
|
|
44
|
+
Fetch the ShakeMap XML grid for a specific event.
|
|
45
|
+
|
|
46
|
+
API Documentation:
|
|
47
|
+
https://earthquake.usgs.gov/earthquakes/eventpage/[event_id]/shakemap/grid.xml
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
event_id (str): The ID of the earthquake event.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
str: XML content of the ShakeMap grid, or None if unavailable.
|
|
54
|
+
"""
|
|
55
|
+
xml_url = f"https://earthquake.usgs.gov/earthquakes/eventpage/{event_id}/shakemap/grid.xml"
|
|
56
|
+
log(f"Fetching ShakeMap grid from {xml_url}")
|
|
57
|
+
response = requests.get(xml_url)
|
|
58
|
+
if response.status_code == 200:
|
|
59
|
+
return response.content
|
|
60
|
+
else:
|
|
61
|
+
log(f"No XML grid data available for event {event_id}")
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
# Function to extract PGA from XML grid
|
|
65
|
+
def get_pga_from_grid(xml_data, latitude, longitude):
|
|
66
|
+
"""
|
|
67
|
+
Extract PGA from ShakeMap XML grid at a specific latitude and longitude.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
xml_data (str): XML content of the ShakeMap grid.
|
|
71
|
+
latitude (float): Latitude of the desired location.
|
|
72
|
+
longitude (float): Longitude of the desired location.
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
float: Interpolated PGA value at the given location, or None if unavailable.
|
|
76
|
+
"""
|
|
77
|
+
root = ElementTree.fromstring(xml_data)
|
|
78
|
+
log("Parsing ShakeMap XML grid.")
|
|
79
|
+
|
|
80
|
+
# Parse the grid metadata
|
|
81
|
+
nx = int(root.find(".//grid[@name='longitude']").attrib["nrows"])
|
|
82
|
+
ny = int(root.find(".//grid[@name='latitude']").attrib["nrows"])
|
|
83
|
+
lon_min = float(root.find(".//grid[@name='longitude']").attrib["min"])
|
|
84
|
+
lon_max = float(root.find(".//grid[@name='longitude']").attrib["max"])
|
|
85
|
+
lat_min = float(root.find(".//grid[@name='latitude']").attrib["min"])
|
|
86
|
+
lat_max = float(root.find(".//grid[@name='latitude']").attrib["max"])
|
|
87
|
+
|
|
88
|
+
# Parse the grid data
|
|
89
|
+
grid_values = root.find(".//grid_data").text.strip().split()
|
|
90
|
+
grid_values = np.array(grid_values, dtype=float).reshape((ny, nx))
|
|
91
|
+
|
|
92
|
+
# Generate grid points
|
|
93
|
+
lons = np.linspace(lon_min, lon_max, nx)
|
|
94
|
+
lats = np.linspace(lat_min, lat_max, ny)
|
|
95
|
+
lon_grid, lat_grid = np.meshgrid(lons, lats)
|
|
96
|
+
|
|
97
|
+
# Interpolate PGA at the desired location
|
|
98
|
+
pga = griddata(
|
|
99
|
+
points=(lon_grid.flatten(), lat_grid.flatten()),
|
|
100
|
+
values=grid_values.flatten(),
|
|
101
|
+
xi=(longitude, latitude),
|
|
102
|
+
method="linear",
|
|
103
|
+
)
|
|
104
|
+
if pga is not None:
|
|
105
|
+
log(f"Interpolated PGA at ({latitude}, {longitude}): {pga:.4f} g")
|
|
106
|
+
else:
|
|
107
|
+
log(f"Failed to interpolate PGA at ({latitude}, {longitude}).")
|
|
108
|
+
return pga
|
|
109
|
+
|
|
110
|
+
# Main script
|
|
111
|
+
def main():
|
|
112
|
+
"""
|
|
113
|
+
Main script to fetch earthquake events, download ShakeMap grids, and compute PGA.
|
|
114
|
+
"""
|
|
115
|
+
# Parameters
|
|
116
|
+
start_time = "2024-01-01"
|
|
117
|
+
end_time = "2024-12-01"
|
|
118
|
+
latitude = 37.7749 # Example location: San Francisco
|
|
119
|
+
longitude = -122.4194
|
|
120
|
+
|
|
121
|
+
log(f"Starting process for time window: {start_time} to {end_time}")
|
|
122
|
+
events = fetch_events(start_time, end_time)
|
|
123
|
+
if not events:
|
|
124
|
+
log("No events found in the specified time window.")
|
|
125
|
+
return
|
|
126
|
+
|
|
127
|
+
log(f"Found {len(events)} events.")
|
|
128
|
+
for event in events:
|
|
129
|
+
event_id = event["id"]
|
|
130
|
+
event_title = event["properties"]["title"]
|
|
131
|
+
log(f"Processing event: {event_title} (ID: {event_id})")
|
|
132
|
+
|
|
133
|
+
xml_data = fetch_shakemap_grid(event_id)
|
|
134
|
+
if xml_data:
|
|
135
|
+
pga = get_pga_from_grid(xml_data, latitude, longitude)
|
|
136
|
+
if pga is not None:
|
|
137
|
+
print(f"Event: {event_title}, PGA at ({latitude}, {longitude}): {pga:.4f} g")
|
|
138
|
+
else:
|
|
139
|
+
print(f"Event: {event_title}, PGA data not available.")
|
|
140
|
+
else:
|
|
141
|
+
print(f"Event: {event_title}, ShakeMap grid data not found.")
|
|
142
|
+
|
|
143
|
+
if __name__ == "__main__":
|
|
144
|
+
main()
|
|
145
|
+
|
|
@@ -36,7 +36,7 @@ irie/apps/events/models.py,sha256=GIAus3bXLfrMKD6qBGvp6-Qiq6uZZxcMd7GGF17W3gk,39
|
|
|
36
36
|
irie/apps/events/tests.py,sha256=PSZUTXteVS5Fim2upOndb1HW5Pu7DoC1r25-7_1i-so,33
|
|
37
37
|
irie/apps/events/tests_events.py,sha256=iVNwnlZgqug1MtEIGS_E82wcQ7522m-0q47kreN_D90,8363
|
|
38
38
|
irie/apps/events/urls.py,sha256=UrVmK0NpKvmDNH9Iad4CTbN9KdXaW4W3ZNWxPpiSgUY,1052
|
|
39
|
-
irie/apps/events/views.py,sha256=
|
|
39
|
+
irie/apps/events/views.py,sha256=lr3BFL_yEkppjuVigGucCwL0we0SrAqsNSyu0RBbCcU,3034
|
|
40
40
|
irie/apps/events/views_events.py,sha256=BYt0th365bW6qJwFvOd55W1d9Yq08vJefL6OwBdHz5k,7082
|
|
41
41
|
irie/apps/events/migrations/0001_initial.py,sha256=sSCS0Kbyb73m_x3kw5Q4tRrTJcCqh3gRTLmkrcf6_ps,1065
|
|
42
42
|
irie/apps/events/migrations/0002_rename_event_eventrecord.py,sha256=TNRUB9-EZmdURlkyAtz7KBdtuoSXwbwCQDRP4CKmdBw,431
|
|
@@ -48,13 +48,13 @@ irie/apps/inventory/admin.py,sha256=bwSoY9qzF8VYbVilaKqz8w90QGpDifNo55BVC4JQm8Q,
|
|
|
48
48
|
irie/apps/inventory/apps.py,sha256=bZ6qYIwPMG4_4IeLfg9N4WuZAEgEVj84oOswV-7_MAI,424
|
|
49
49
|
irie/apps/inventory/calid.py,sha256=3L8MbPIGOE3kzDnqeyY055pRBiF2O2l0cmpuDbTsdTg,3014
|
|
50
50
|
irie/apps/inventory/fields.py,sha256=J3nTImPsuCeiOWBizSL4tnuKs36sPfXALNTKEZY-wVg,79
|
|
51
|
-
irie/apps/inventory/filters.py,sha256=
|
|
51
|
+
irie/apps/inventory/filters.py,sha256=9P4KoDe4mhbjWish8NE7q19C53AgKm6rKo19GK-O1Hk,1092
|
|
52
52
|
irie/apps/inventory/forms.py,sha256=8KaegZRIJlCEpHbdNLWEETfa4x3oGYSE_YTfwUEgyYs,400
|
|
53
|
-
irie/apps/inventory/models.py,sha256=
|
|
53
|
+
irie/apps/inventory/models.py,sha256=IOZpd5Awev333IYgnzc6yP8JLN1afw5X3GwbCrciTLA,3065
|
|
54
54
|
irie/apps/inventory/tables.py,sha256=vZdPOcbN1ibuWXqLwbBUoQw9iavwa1GJ5fd83k8bu7Y,27874
|
|
55
55
|
irie/apps/inventory/traffic.py,sha256=B3PHqn2Pm4AEdUZ_tuA16fuFruo2rm5waMBwLQyF-9g,4490337
|
|
56
|
-
irie/apps/inventory/urls.py,sha256=
|
|
57
|
-
irie/apps/inventory/views.py,sha256=
|
|
56
|
+
irie/apps/inventory/urls.py,sha256=mpmHjvDSHhC5xrEosbTH_h2bGWNJfslGcrt2mnUO40E,1019
|
|
57
|
+
irie/apps/inventory/views.py,sha256=9frBu7X-BRXqKwa0OqOcrVzpA0kbX7A1GbZgO2dN5tc,14426
|
|
58
58
|
irie/apps/inventory/archive/arcGIS.py,sha256=vcfsy1be4edOXD1Z3rkUnq9QmCTol7dypdF816Q3B_w,34893
|
|
59
59
|
irie/apps/inventory/migrations/0001_initial.py,sha256=PwTHv4Q3gqWFha--8Zp9kUOh-cYalB14jXj7RVJUVnw,1786
|
|
60
60
|
irie/apps/inventory/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -178,9 +178,9 @@ irie/apps/templates/includes/paginate.js,sha256=dAaL4uFQzEIbm61c_USEHlQLFkKc2ndJ
|
|
|
178
178
|
irie/apps/templates/includes/scripts.html,sha256=3O-gBodubd9leK7ncujL40gl2Upf9wlP0VRE5DFTvzk,1194
|
|
179
179
|
irie/apps/templates/includes/settings-box.html,sha256=wexsLS4SMRyKci-r4L_LQ6QM27h4U291091NcGiTT3o,2486
|
|
180
180
|
irie/apps/templates/includes/sidebar.html,sha256=kVrReAUqKm3rRvfyCYOV4JsWfUslarMvdUr0jogKxJA,10975
|
|
181
|
-
irie/apps/templates/inventory/asset-event-summary.html,sha256=
|
|
182
|
-
irie/apps/templates/inventory/asset-profile.html,sha256=
|
|
183
|
-
irie/apps/templates/inventory/asset-table.html,sha256=
|
|
181
|
+
irie/apps/templates/inventory/asset-event-summary.html,sha256=WhANtDgvg_2myyVyhuCXIh-liHQF9tjzVQKMLgzWndE,50711
|
|
182
|
+
irie/apps/templates/inventory/asset-profile.html,sha256=bZKPKNgcAypSKktGWym9kOm3sPPELK--QOqIViTe8TM,11223
|
|
183
|
+
irie/apps/templates/inventory/asset-table.html,sha256=TP6V-IkPHzqsBBWBt8o3-GoCvk1CJUqJCjw5BYMzC0A,10483
|
|
184
184
|
irie/apps/templates/inventory/bridge-dashboard.html,sha256=67zrDlih3LOi9xFVwPVZZkgRT3DO-lE_qRL7q8Uz9GY,45472
|
|
185
185
|
irie/apps/templates/inventory/bridge.html,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
186
186
|
irie/apps/templates/inventory/dashboard.html,sha256=Uu74fiPu5V0ZCZ9__lndt06ogQavUPq0YX9s8Ve9_aU,7599
|
|
@@ -200,11 +200,11 @@ irie/apps/templates/prediction/predictor-profile.html,sha256=fcK_VmrzVYPPFUncW39
|
|
|
200
200
|
irie/apps/templates/prediction/predictor-upload.html,sha256=KSM7jiyi6xBkmYvhzyyU5arYj_ROVmkDZiwVAz8Y8LQ,1014
|
|
201
201
|
irie/apps/templates/prediction/hazus/event.html,sha256=vcmQKfb-Gww5sd-kn6b2QL3llRrfQFv8mafVNNxTHrY,841
|
|
202
202
|
irie/apps/templates/prediction/hazus/history.html,sha256=r78lK4hAMk8becMHrDQVyAvuZkUTF0mdmOV5X7aGDjk,101
|
|
203
|
-
irie/apps/templates/prediction/hazus/history.js,sha256=
|
|
203
|
+
irie/apps/templates/prediction/hazus/history.js,sha256=blHRXzlEfMBCezPE-2dZCpt2rVgTiGHkYlY1t-clOE8,1101
|
|
204
204
|
irie/apps/templates/site/about.html,sha256=5hS5taj3XF-F8z-uIn53ZFXVHVS4apLRMg39OyvMvRs,610
|
|
205
205
|
irie/apps/templates/site/asset_map.html,sha256=rnTjeYMc8NESIo6Uuq8fgZ_xcKNuKdt4zcqoUTDI8Xg,387
|
|
206
206
|
irie/apps/templates/site/components-forms.html,sha256=FKOiR-3e9iw-xOHeaP2RB3O2gP10R-Mt8wdXfb1rDBQ,13865
|
|
207
|
-
irie/apps/templates/site/index.html,sha256=
|
|
207
|
+
irie/apps/templates/site/index.html,sha256=E1v79lxEs7KkvecTKQS3lYDUh0VKPw3KifXGiC1z7HM,16833
|
|
208
208
|
irie/apps/templates/site/json-form.html,sha256=ZrRWy5xnGBOqG51b6mdVGI0Io5X1z47DTFB9wW6ZQYA,1785
|
|
209
209
|
irie/apps/templates/site/page-403.html,sha256=caU6t3fsCJiAIuZvRQekK2UemdZSNxc3l80ceSz0mp0,1289
|
|
210
210
|
irie/apps/templates/site/page-404-sidebar.html,sha256=krMA-iYHaJNfXSwY7H_epZycWLiIb_bBbuWTmqC4ca4,1581
|
|
@@ -221,7 +221,7 @@ irie/apps/templates/site/transactions.html,sha256=-heynHR8PTt_C4P3IWmYG_VE1aGH68
|
|
|
221
221
|
irie/apps/templates/site/unused-dashboard-cards.html,sha256=DDNWrnIf4o0wj06WYH8YitTfemzARRcVafZ2iNFdJZM,14715
|
|
222
222
|
irie/core/__init__.py,sha256=wkkNngGxgYcCM745-rlvP6ynrI0b0QN3aWmLWDsR8zU,230
|
|
223
223
|
irie/core/asgi.py,sha256=3lVQKFRA4bznM2mWu5Cv24a5H9pfb6YU07q-I_TN0DM,395
|
|
224
|
-
irie/core/settings.py,sha256=
|
|
224
|
+
irie/core/settings.py,sha256=1gybngenzE840FTVMkDjSA1o4cTRDWAprlkycpwPbhU,6286
|
|
225
225
|
irie/core/urls.py,sha256=24aomuoyDKxqYnw8axnYO1pXF_J2_5KNKliypxwWp3I,1277
|
|
226
226
|
irie/core/wsgi.py,sha256=8dxK789vOoRWm0IatEhNqMgZhov9TlspjM6hOUbjg24,395
|
|
227
227
|
irie/init/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -240,8 +240,9 @@ irie/init/management/commands/init_assets.py,sha256=3-8WMzKwzyaSO-cigPKYBV61XzQf
|
|
|
240
240
|
irie/init/management/commands/init_corridors.py,sha256=EzLk0HUiFxlco-2u0rypewOc9mAo_raqXC2_UCG8a_w,1241
|
|
241
241
|
irie/init/management/commands/init_predictors.py,sha256=jdD7rd8l2qxuUuR5GOYuHXp-ZQkAK477TefksBMdlOw,2362
|
|
242
242
|
irie/post/__main__.py,sha256=ACDm47LwhNoqMhuGnbYXDV-_lflnD8f1qOCdv2VTulU,2284
|
|
243
|
-
irie
|
|
244
|
-
irie-0.0.
|
|
245
|
-
irie-0.0.
|
|
246
|
-
irie-0.0.
|
|
247
|
-
irie-0.0.
|
|
243
|
+
irie/usgs/__main__.py,sha256=HiSvPn5IW5IqRiCk1qRRq5dCy3-7iISw7v1P_w2rLrk,5049
|
|
244
|
+
irie-0.0.8.dist-info/METADATA,sha256=hB6U_cJY2gHR2As3dn7V8jkAV7Cr22LnxtM7QTS5B68,2506
|
|
245
|
+
irie-0.0.8.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
246
|
+
irie-0.0.8.dist-info/entry_points.txt,sha256=A_3h9wPBGfxGQ78_MGa-nO6Z0foxOYeAnIE47jxEztg,44
|
|
247
|
+
irie-0.0.8.dist-info/top_level.txt,sha256=zVCxi5E2nkISZPzKq8VEhWe_dGuPcefLYV1tYqQdwlY,5
|
|
248
|
+
irie-0.0.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|