irie 0.0.4__py3-none-any.whl → 0.0.6__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.

Files changed (62) hide show
  1. irie/apps/config.py +0 -1
  2. irie/apps/evaluation/identification.py +1 -1
  3. irie/apps/evaluation/models.py +3 -3
  4. irie/apps/evaluation/views.py +3 -3
  5. irie/apps/events/admin.py +2 -2
  6. irie/apps/events/migrations/0002_rename_event_eventrecord.py +19 -0
  7. irie/apps/events/migrations/0003_hazardevent.py +21 -0
  8. irie/apps/events/models.py +55 -5
  9. irie/apps/events/views.py +48 -3
  10. irie/apps/events/views_events.py +6 -10
  11. irie/apps/inventory/filters.py +37 -0
  12. irie/apps/inventory/models.py +7 -0
  13. irie/apps/inventory/urls.py +1 -0
  14. irie/apps/inventory/views.py +134 -227
  15. irie/apps/prediction/forms.py +4 -8
  16. irie/apps/prediction/metrics.py +0 -2
  17. irie/apps/prediction/migrations/0002_alter_predictormodel_protocol.py +18 -0
  18. irie/apps/prediction/models.py +4 -4
  19. irie/apps/prediction/predictor.py +18 -12
  20. irie/apps/prediction/runners/__init__.py +3 -398
  21. irie/apps/prediction/runners/hazus.py +579 -0
  22. irie/apps/prediction/runners/opensees/__init__.py +395 -0
  23. irie/apps/prediction/runners/{utilities.py → opensees/utilities.py} +7 -7
  24. irie/apps/prediction/runners/ssid.py +414 -0
  25. irie/apps/prediction/urls.py +1 -1
  26. irie/apps/prediction/views.py +45 -22
  27. irie/apps/site/view_sdof.py +2 -2
  28. irie/apps/templates/admin/base_site.html +3 -1
  29. irie/apps/templates/css/admin-extra.css +7 -0
  30. irie/apps/templates/includes/sidebar.html +17 -14
  31. irie/apps/templates/inventory/asset-event-summary.html +3 -2
  32. irie/apps/templates/inventory/asset-profile.html +126 -38
  33. irie/apps/templates/inventory/asset-table.html +191 -135
  34. irie/apps/templates/inventory/dashboard.html +105 -27
  35. irie/apps/templates/inventory/preamble.tex +131 -0
  36. irie/apps/templates/inventory/report.tex +59 -0
  37. irie/apps/templates/networks/corridor_table.html +2 -2
  38. irie/apps/templates/networks/networks.html +164 -0
  39. irie/apps/templates/networks/networks.js +2 -2
  40. irie/apps/templates/prediction/asset-predictors.html +6 -6
  41. irie/apps/templates/prediction/form-submission.html +3 -3
  42. irie/apps/templates/prediction/hazus/event.html +33 -0
  43. irie/apps/templates/prediction/hazus/history.html +1 -0
  44. irie/apps/templates/prediction/hazus/history.js +44 -0
  45. irie/apps/templates/prediction/{new-predictor.html → new-runner.html} +12 -8
  46. irie/apps/templates/site/index.html +29 -47
  47. irie/core/urls.py +7 -2
  48. irie/init/__main__.py +2 -0
  49. irie/init/bridges.py +5 -3
  50. irie/init/management/commands/init_assets.py +24 -45
  51. irie/init/management/commands/init_corridors.py +3 -6
  52. irie/init/management/commands/init_predictors.py +23 -8
  53. irie/post/__main__.py +88 -0
  54. {irie-0.0.4.dist-info → irie-0.0.6.dist-info}/METADATA +5 -3
  55. {irie-0.0.4.dist-info → irie-0.0.6.dist-info}/RECORD +62 -48
  56. /irie/apps/prediction/runners/{metrics.py → opensees/metrics.py} +0 -0
  57. /irie/apps/prediction/runners/{xmlutils.py → opensees/xmlutils.py} +0 -0
  58. /irie/apps/prediction/runners/{zipped.py → opensees/zipped.py} +0 -0
  59. /irie/init/data/{04.tar → nbi/04.tar} +0 -0
  60. {irie-0.0.4.dist-info → irie-0.0.6.dist-info}/WHEEL +0 -0
  61. {irie-0.0.4.dist-info → irie-0.0.6.dist-info}/entry_points.txt +0 -0
  62. {irie-0.0.4.dist-info → irie-0.0.6.dist-info}/top_level.txt +0 -0
@@ -23,12 +23,12 @@ Claudio Perez, Summer 2023
23
23
  {% block content %}
24
24
  <h1><code>{{ asset.calid }}</code> Predictors</h1>
25
25
  <div class="py-4 align-right">
26
- {% for predictor in predictor_types %}
27
- {% include 'prediction/new-predictor.html' with predictor=predictor %}
28
- {% endfor %}
29
-
30
26
  <a role="button" class="button btn btn-outline-white btn-gray-600 text-white"
31
- href="/inventory/{{ asset.calid }}" class="me-1">Back to Structure Profile</a>
27
+ href="/inventory/{{ asset.calid }}" class="me-1">Back to Structure</a>
28
+
29
+ {% for runner in runners %}
30
+ {% include 'prediction/new-runner.html' with runner=runner form=form %}
31
+ {% endfor %}
32
32
 
33
33
  {% if False %}
34
34
  <a role="button" class="button btn btn-outline-primary" disabled
@@ -102,7 +102,7 @@ Claudio Perez, Summer 2023
102
102
  let editor = new JSONEditor(editor_elem, config)
103
103
 
104
104
  editor.on('change', function () {
105
- element.querySelector('#input').value = JSON.stringify(editor.getValue())
105
+ element.querySelector('#editor-input').value = JSON.stringify(editor.getValue())
106
106
  })
107
107
  }
108
108
  </script>
@@ -12,8 +12,8 @@
12
12
  <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>
13
13
  </a>
14
14
  </li>
15
- <li class="breadcrumb-item"><a href="{% url 'dashboard' %}">BRACE2</a></li>
16
- <li class="breadcrumb-item">Assets</li>
15
+ <li class="breadcrumb-item"><a href="{% url 'dashboard' %}">BRACE<sup>2</sup></a></li>
16
+ <li class="breadcrumb-item">Inventory</li>
17
17
  <li class="breadcrumb-item active" aria-current="page">New Predictor</li>
18
18
  </ol>
19
19
  </nav>
@@ -54,7 +54,7 @@
54
54
  </p>
55
55
  <div class="form-group"></div>
56
56
  <form action="/docs/form-submission.html" method="get">
57
- <input id="input" type="hidden" name="json">
57
+ <input id="input" type="hidden" name="type" value="{{ runner. }}">
58
58
  <div id='editor-container'></div>
59
59
  <input id="submit" class="btn btn-primary" width="100" type="submit">
60
60
  </form>
@@ -0,0 +1,33 @@
1
+
2
+ <table class="table table-hover">
3
+ <thead>
4
+ <tr>
5
+ <th>Damage State</th>
6
+ <th>Probability</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ {% if hazus and hazus.probabilities %}
11
+ <tr>
12
+ <td>Slight</td>
13
+ <td>{{ hazus.probabilities.Slight|floatformat:2 }}</td>
14
+ </tr>
15
+ <tr>
16
+ <td>Moderate</td>
17
+ <td>{{ hazus.probabilities.Moderate|floatformat:2 }}</td>
18
+ </tr>
19
+ <tr>
20
+ <td>Extensive</td>
21
+ <td>{{ hazus.probabilities.Extensive|floatformat:2 }}</td>
22
+ </tr>
23
+ <tr>
24
+ <td>Complete</td>
25
+ <td>{{ hazus.probabilities.Complete|floatformat:2 }}</td>
26
+ </tr>
27
+ {% else %}
28
+ <tr>
29
+ <td colspan="2">No Hazus fragility data available.</td>
30
+ </tr>
31
+ {% endif %}
32
+ </tbody>
33
+ </table>
@@ -0,0 +1 @@
1
+ <div id="hazusPlot" data-hazus-x="{{ hazus.sa_range }}" data-hazus-curves="{{ hazus.curves }}"></div>
@@ -0,0 +1,44 @@
1
+ var layout = {
2
+ // title: {text: 'Hazus Fragility'},
3
+ uirevision:'true',
4
+ xaxis: {
5
+ title: {
6
+ text: 'Spectral Acceleration (g)',
7
+ font: {
8
+ //family: 'Courier New, monospace',
9
+ size: 18,
10
+ color: '#7f7f7f'
11
+ }
12
+ },
13
+ autorange: true
14
+ },
15
+ yaxis: {
16
+ title: {
17
+ text: 'Damage Probability',
18
+ font: {
19
+ //family: 'Courier New, monospace',
20
+ size: 18,
21
+ color: '#7f7f7f'
22
+ }
23
+ },
24
+ autorange: true
25
+ }
26
+ };
27
+
28
+ Plotly.react('hazusPlot', data, layout);
29
+
30
+ var elem = document.getElementById('hazusPlot');
31
+
32
+ let curves = JSON.parse(elem.dataset.hazusCurves);
33
+
34
+ var x = JSON.parse(elem.dataset.hazusX);
35
+
36
+ // add random data to three line traces
37
+ var data = [
38
+ {mode:'lines', line: {color: "#b55400"}, x: x, y: curves.Slight, name: "Slight"},
39
+ {mode: 'lines', line: {color: "#393e46"}, x: x, y: curves.Moderate, name: "Moderate"},
40
+ {mode: 'lines', line: {color: "#222831"}, x: x, y: curves.Extensive, name: "Extensive"},
41
+ {mode: 'lines', line: {color: "#222831"}, x: x, y: curves.Complete, name: "Complete"},
42
+ ]
43
+
44
+ Plotly.react('hazusPlot', data, layout);
@@ -3,18 +3,18 @@
3
3
  <button type="button"
4
4
  class="btn btn-outline-primary"
5
5
  data-bs-toggle="modal"
6
- data-bs-target="#{{predictor.name.lower}}Modal">
7
- <span class="me-1">New {{predictor.title}}</span>
6
+ data-bs-target="#{{runner.name.lower}}Modal">
7
+ <span class="me-1">New {{runner.title}}</span>
8
8
  </button>
9
9
 
10
10
  <!-- Modal -->
11
- <div class="modal fade" id="{{predictor.name.lower}}Modal" tabindex="-1"
12
- aria-labelledby="{{predictor.name.lower}}ModalLabel" aria-hidden="true">
11
+ <div class="modal fade" id="{{runner.name.lower}}Modal" tabindex="-1"
12
+ aria-labelledby="{{runner.name.lower}}ModalLabel" aria-hidden="true">
13
13
  <div class="modal-dialog modal-xl">
14
14
  <div class="modal-content">
15
15
  <div class="modal-header">
16
16
  <span class="me-3">
17
- <h3 class="modal-title" id="{{predictor.name.lower}}ModalLabel">New Predictor</h3> </span>
17
+ <h3 class="modal-title" id="{{runner.name.lower}}ModalLabel">New Predictor</h3> </span>
18
18
  <div class="d-flex justify-content-end align-items-center">
19
19
  <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
20
20
  </div>
@@ -42,10 +42,14 @@
42
42
  {% endcomment %}
43
43
 
44
44
  <div class="form-group"></div>
45
- <form id="{{predictor.name}}" action="./" method="post" >
45
+ <form id="{{runner.name}}" action="./" method="post" >
46
46
  {% csrf_token %}
47
- <input id="input" type="hidden" name="json">
48
- <div id="{{predictor.name}}-editor" data-schema="{{predictor.schema}}" ></div>
47
+ {# form.as_p #}
48
+ <input id="editor-input" type="hidden" name="json">
49
+ <div id="{{runner.name}}-editor"
50
+ data-schema="{{runner.schema}}"
51
+ data-protocol="{{ runner.protocol }}">
52
+ </div>
49
53
  <input id="submit" class="btn btn-primary" width="100" type="submit">
50
54
  </form>
51
55
  <br>
@@ -200,9 +200,8 @@ td.left-text{vertical-align:middle}
200
200
  <div class="row justify-content-between align-items-center mb-5 mb-lg-7">
201
201
  <div class="row justify-content-between align-items-center">
202
202
  <div class="col-lg-5 order-lg-2 mb-5 mb-lg-0">
203
- <h2 class="h1">Hazard Analysis</h2>
204
- <p class="mb-4 lead fw-bold">High Fidelity Modeling</p>
205
- <p class="mb-4">BRACE2 integrates state of the art modeling software</p>
203
+ <h2 class="h1">Health Diagnosis</h2>
204
+ <p class="mb-4">...</p>
206
205
  <a
207
206
  href="" target="_blank"
208
207
  class="btn btn-outline-gray-600 d-inline-flex align-items-center"><svg class="icon icon-xs me-2"
@@ -216,11 +215,8 @@ td.left-text{vertical-align:middle}
216
215
  alt="Front pages overview"></div>
217
216
  </div>
218
217
  <div class="col-lg-5 mb-5 mb-lg-0">
219
- <h2 class="h1 d-flex align-items-center">Events <span
220
- class="badge-md ms-3 mb-0 fs-6 badge rounded-pill text-dark bg-secondary">Pro</span></h2>
221
- <p class="mb-4 lead fw-bold">Advanced FullCalendar.js integration</p>
222
- <p class="mb-4">We created a fully editable calendar where you can add, edit and delete events for your
223
- admin dashboard.</p><a href="" target="_blank"
218
+ <h2 class="h1 d-flex align-items-center">Sensor Integration</h2>
219
+ <p class="mb-4">.</p><a href="" target="_blank"
224
220
  class="btn btn-secondary d-inline-flex align-items-center me-3"><svg class="icon icon-xs me-2"
225
221
  fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
226
222
  <path
@@ -229,55 +225,41 @@ td.left-text{vertical-align:middle}
229
225
  </svg> Demo
230
226
  </a>
231
227
  </div>
232
- <div class="col-lg-6"><img src="{{ ASSETS_ROOT}}/img/earthquake-hazard.png" alt="Kanban Preview"></div>
228
+ <div class="col-lg-6"><img src="{{ ASSETS_ROOT}}/img/earthquake-hazard.png" alt="Sensor Preview"></div>
233
229
  </div>
234
230
  <div class="row justify-content-between align-items-center mb-5 mb-lg-7">
231
+ <div class="row justify-content-between align-items-center">
232
+ <div class="col-lg-5 order-lg-2 mb-5 mb-lg-0">
233
+ <h2 class="h1">Digital Twins</h2>
234
+ <p class="mb-4">BRACE<sup>2</sup> integrates state of the art modeling software</p>
235
+ <a
236
+ href="" target="_blank"
237
+ class="btn btn-outline-gray-600 d-inline-flex align-items-center"><svg class="icon icon-xs me-2"
238
+ fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
239
+ <path
240
+ d="M9 4.804A7.968 7.968 0 005.5 4c-1.255 0-2.443.29-3.5.804v10A7.969 7.969 0 015.5 14c1.669 0 3.218.51 4.5 1.385A7.962 7.962 0 0114.5 14c1.255 0 2.443.29 3.5.804v-10A7.968 7.968 0 0014.5 4c-1.255 0-2.443.29-3.5.804V12a1 1 0 11-2 0V4.804z">
241
+ </path>
242
+ </svg> Getting started</a>
243
+ </div>
244
+ <div class="col-lg-6 order-lg-1"><img src="{{ ASSETS_ROOT }}/img/metric.png"
245
+ alt="Digital twins"></div>
246
+ </div>
235
247
  <div class="col-lg-5 order-lg-2 mb-5 mb-lg-0">
236
- <h2 class="h1 d-flex align-items-center">Corridors <span
237
- class="badge-md ms-3 mb-0 fs-6 badge rounded-pill text-dark bg-secondary">Pro</span></h2>
238
- <p class="mb-4 lead fw-bold">Markers and cards integration with Leaflet.js</p>
239
- <p class="mb-4">You can use this map to add markers with custom cards and show them on a map using our
240
- custom MapBox integration with Leaflet.js</p>
241
- <a href=""
242
- target="_blank"
243
- class="btn btn-secondary d-inline-flex align-items-center me-3"><svg
244
- class="icon icon-xs me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
245
- <path fill-rule="evenodd"
246
- d="M12 1.586l-4 4v12.828l4-4V1.586zM3.707 3.293A1 1 0 002 4v10a1 1 0 00.293.707L6 18.414V5.586L3.707 3.293zM17.707 5.293L14 1.586v12.828l2.293 2.293A1 1 0 0018 16V6a1 1 0 00-.293-.707z"
247
- clip-rule="evenodd"></path>
248
- </svg> Demo </a><a href="https://themesberg.com/docs/volt-bootstrap-5-dashboard/plugins/mapbox/"
248
+ <h2 class="h1 d-flex align-items-center"> Corridors<span
249
+ class="badge-md mb-0 fs-6 badge ms-3 rounded-pill text-dark bg-secondary">New</span></h2>
250
+ <p class="mb-4">Corridor-level health analysis and recovery planning</p>
251
+ <a href="https://dot.ca.gov/-/media/dot-media/programs/research-innovation-system-information/documents/research-notes/task3798-rns-05-24-a11y.pdf"
249
252
  target="_blank" class="btn btn-outline-gray-600 d-inline-flex align-items-center"><svg
250
253
  class="icon icon-xs me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
251
254
  <path fill-rule="evenodd"
252
255
  d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z"
253
256
  clip-rule="evenodd"></path>
254
- </svg> Guide</a>
257
+ </svg> Read More</a>
255
258
  </div>
256
259
  <div class="col-lg-6 order-lg-1"><img src="./assets/img/mockup-map-presentation.png"
257
- alt="MapBox Leaflet.js Custom Integration Mockup"></div>
258
- </div>
259
- <div class="row justify-content-between align-items-center mb-5 mb-lg-7">
260
- <div class="col-lg-5 mb-5 mb-lg-0">
261
- <h2 class="h1 d-flex align-items-center">Calendar <span
262
- class="badge-md ms-3 mb-0 fs-6 badge rounded-pill text-dark bg-secondary">Pro</span></h2>
263
- <p class="mb-4 lead fw-bold">Advanced FullCalendar.js integration</p>
264
- <p class="mb-4">We created a fully editable calendar where you can add, edit and delete events for your
265
- admin dashboard.</p><a href="https://demo.themesberg.com/volt-pro/pages/calendar.html" target="_blank"
266
- class="btn btn-secondary d-inline-flex align-items-center me-3"><svg class="icon icon-xs me-2"
267
- fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
268
- <path fill-rule="evenodd"
269
- d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
270
- clip-rule="evenodd"></path>
271
- </svg> Demo </a><a href="https://themesberg.com/docs/volt-bootstrap-5-dashboard/plugins/calendar/"
272
- target="_blank" class="btn btn-outline-gray-600 d-inline-flex align-items-center"><svg
273
- class="icon icon-xs me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
274
- <path fill-rule="evenodd"
275
- d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z"
276
- clip-rule="evenodd"></path>
277
- </svg> Guide</a>
278
- </div>
279
- <div class="col-lg-6"><img src="./assets/img/mockup-calendar-presentation.png" alt="Calendar Preview"></div>
260
+ alt="Corridors"></div>
280
261
  </div>
262
+
281
263
  </div>
282
264
  <figure class="position-absolute bottom-0 left-0 w-100 d-none d-md-block mb-n2">
283
265
  <svg class="home-pattern" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3000 185.4"><path d="M3000,0v185.4H0V0c496.4,115.6,996.4,173.4,1500,173.4S2503.6,115.6,3000,0z"></path></svg></figure>
@@ -286,7 +268,7 @@ td.left-text{vertical-align:middle}
286
268
  <div class="container align-items-center">
287
269
  <h1 class=tabs-title>Ecosystem</h1>
288
270
  <div class=uikit-tab-wrapper>
289
- <p>The BRACE<sup>2</sup> Ecosystem</p>
271
+ <p>The <em>BRACE</em><sup>2</sup> Ecosystem</p>
290
272
  <table>
291
273
  {% if False %}
292
274
  <tr class=highlight-th>
irie/core/urls.py CHANGED
@@ -7,7 +7,8 @@
7
7
  # Fall 2022
8
8
  #
9
9
  #----------------------------------------------------------------------------#
10
-
10
+ from django.conf import settings
11
+ from django.conf.urls.static import static
11
12
  from django.contrib import admin
12
13
  from django.urls import path, include
13
14
 
@@ -36,4 +37,8 @@ urlpatterns = [
36
37
 
37
38
  # Leave `site.urls` as last the last line
38
39
  path("", include("irie.apps.site.urls"))
39
- ]
40
+
41
+
42
+ # Ensure we can serve files stored with models (eg, bridge renderings)
43
+ ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
44
+
irie/init/__main__.py CHANGED
@@ -24,6 +24,8 @@ def init(settings):
24
24
 
25
25
  call_command("init_corridors")
26
26
 
27
+ call_command("init_predictors")
28
+
27
29
 
28
30
 
29
31
  if __name__ == "__main__":
irie/init/bridges.py CHANGED
@@ -2,6 +2,7 @@
2
2
  # - add descriptions
3
3
  import sys
4
4
  from math import pi
5
+ from pathlib import Path
5
6
 
6
7
  r = 12
7
8
  no=190
@@ -949,7 +950,7 @@ BRIDGES = {
949
950
  {
950
951
  "name": f"Linear",
951
952
  "metrics": [*LINEAR_METRICS],
952
- "protocol": "BRACE2_CLI_PREDICTOR_V1",
953
+ "protocol": "IRIE_PREDICTOR_V1",
953
954
  "entry_point": [PYTHON, "-mCE58658", f"Procedures/linear.tcl"],
954
955
  "platform": "OpenSees",
955
956
  "active": False,
@@ -958,11 +959,12 @@ BRIDGES = {
958
959
  {
959
960
  "name": f"OpenSees",
960
961
  "metrics": [*LINEAR_METRICS, *NONLINEAR_METRICS],
961
- "protocol": "BRACE2_CLI_PREDICTOR_V1",
962
+ "protocol": "IRIE_PREDICTOR_T4",
962
963
  "entry_point": [PYTHON, "-mCE58658", f"Procedures/nonlinear.tcl"],
963
964
  "platform": "OpenSees",
964
965
  "active": False,
965
- "config": CE58658
966
+ "config": CE58658,
967
+ "model_file": Path(__file__).parents[0]/"hayward.zip"
966
968
  },
967
969
  {
968
970
  "name": "SRIM_tran", "description": "Transverse configuration.", "protocol": "", "metrics": ["SPECTRAL_SHIFT_IDENTIFICATION"],"entry_point": [PYTHON, "-m", "mdof", "srim"],
@@ -6,10 +6,11 @@ import lzma
6
6
  import tarfile
7
7
  from pathlib import Path
8
8
  from django.core.management.base import BaseCommand
9
+ import json
9
10
  try:
10
- import orjson as json
11
+ import orjson
11
12
  except ImportError:
12
- import json
13
+ import json as orjson
13
14
 
14
15
  DATA = Path(irie.__file__).parents[0]/"init"/"data"
15
16
 
@@ -17,9 +18,8 @@ with open(DATA/"cgs_data.json") as f:
17
18
  CGS_DATA = json.loads(f.read())
18
19
 
19
20
 
20
-
21
21
  from collections import defaultdict
22
- from irie.apps.inventory.models import Asset, Corridor
22
+ from irie.apps.inventory.models import Asset
23
23
  from irie.init.calid import CALID, CESMD
24
24
  from irie.init.bridges import BRIDGES
25
25
 
@@ -49,8 +49,6 @@ SKIP_DESIGN = {
49
49
 
50
50
 
51
51
  def load_assets(NBI_DATA):
52
- # with open(NBI_FILE) as f:
53
- # NBI_DATA = json.loads(f.read())
54
52
 
55
53
  def find_bridge(bridges, calid):
56
54
  for bridge in bridges.values():
@@ -79,7 +77,7 @@ def load_assets(NBI_DATA):
79
77
  return not (
80
78
  (
81
79
  get_route(bridge) in routes
82
- and bridge["NBI_BRIDGE"]["Highway Agency District"] in DISTRICTS
80
+ # and bridge["NBI_BRIDGE"]["Highway Agency District"] in DISTRICTS
83
81
  # and bridge["NBI_POSTING_STATUS"]["Structure Operational Status Code"] == "A - Open"
84
82
  ) or (
85
83
  bridge["NBI_BRIDGE"]["Highway Agency District"] in DISTRICTS
@@ -101,15 +99,14 @@ def load_assets(NBI_DATA):
101
99
  # 1. Collect routes of interest
102
100
  ROUTES = set()
103
101
  for bridge in BRIDGES.values():
104
- nbi = get_nbi(bridge["calid"].split(" ")[0].replace("-", " "), missing_ok=True)
102
+ calid = bridge["calid"].split(" ")[0].replace("-", " ")
103
+ nbi = get_nbi(calid, missing_ok=True)
105
104
  if nbi is not None:
106
105
  ROUTES.add(get_route(nbi))
107
106
 
108
107
 
109
108
  count = 0
110
109
 
111
- # CORRIDORS = defaultdict(set)
112
-
113
110
  for item in NBI_DATA:
114
111
  calid = item.replace(" ", "-")
115
112
  nbi = get_nbi(item)
@@ -122,14 +119,6 @@ def load_assets(NBI_DATA):
122
119
  print("Failed to skip ", calid)
123
120
  continue
124
121
 
125
- count += 1
126
- # print(calid, f"({cesmd = })")
127
-
128
- cname = get_route(nbi)
129
-
130
- # CORRIDORS[cname].add(calid)
131
-
132
-
133
122
  if DRY:
134
123
  continue
135
124
 
@@ -144,7 +133,7 @@ def load_assets(NBI_DATA):
144
133
 
145
134
  # print(">> Saved ", calid, f"({cesmd = })")
146
135
 
147
- except:
136
+ except Asset.DoesNotExist:
148
137
  if nbi is None:
149
138
  print(">> Skipping ", calid)
150
139
  continue
@@ -156,38 +145,33 @@ def load_assets(NBI_DATA):
156
145
  cgs_data = CGS_DATA.get(cesmd, {}),
157
146
  nbi_data = nbi,
158
147
  is_complete=False)
159
- asset.save()
160
148
  print(asset)
161
149
 
162
- continue
163
-
164
-
165
- try:
166
- corridor = Corridor.objects.get(name=cname)
167
- corridor.save()
168
- print(">> Saved ", cname)
169
- continue
150
+ count += 1
170
151
 
171
- except:
172
- corridor = Corridor(name=cname)
173
- corridor.save()
174
- print(corridor)
152
+ if config:
153
+ asset.bridge_sensors = json.dumps(config["accelerometers"]["bridge_channels"])
154
+ asset.ground_sensors = json.dumps(config["accelerometers"]["ground_channels"])
175
155
 
176
- corridor.assets.add(asset)
156
+ asset.save()
177
157
 
178
- del nbi
158
+ continue
179
159
 
180
160
  print(f"Created {count} of {len(NBI_DATA)} assets")
181
161
 
182
- # print(f"Created {len(CORRIDORS)} corridors")
183
-
184
162
 
185
163
  class Command(BaseCommand):
186
164
  help = 'Description of what script_1 does'
187
165
 
188
166
  def handle(self, *args, **kwargs):
189
- # Open the tar file
190
- with tarfile.open(DATA/"04.tar", "r") as tar:
167
+
168
+ # Load assets outside of district 4
169
+ with open(DATA/"nbi_data-california.json") as f:
170
+ load_assets(json.load(f))
171
+
172
+
173
+ # Open the district tar file
174
+ with tarfile.open(DATA/"nbi"/"04.tar", "r") as tar:
191
175
  # Iterate through each file in the tar archive
192
176
  for member in tar.getmembers():
193
177
  # Process only .xz files
@@ -205,15 +189,10 @@ class Command(BaseCommand):
205
189
  with lzma.LZMAFile(xz_file) as decompressed_file:
206
190
  # Load the JSON content
207
191
  try:
208
- data = json.loads(decompressed_file.read())
192
+ data = orjson.loads(decompressed_file.read())
209
193
  load_assets(data)
210
194
 
211
- except json.JSONDecodeError as e:
195
+ except orjson.JSONDecodeError as e:
212
196
  print(f"Failed to parse JSON in {member.name}: {e}")
213
197
 
214
198
 
215
-
216
- # NBI_FILE = data/"nbi_data-california.json" # os.environ.get("IRIE_INIT_ASSETS") # "data/nbi/04.json" #"nbi_data-500.json" # "data/nbi_data-california.json" # "data/nbi-california-2024.json" #
217
-
218
-
219
-
@@ -10,21 +10,19 @@ which takes in corridor_line.geojson and soga_corridors.csv
10
10
  """
11
11
 
12
12
  import sys
13
- import csv
14
13
  import json
15
14
  from pathlib import Path
16
- from collections import defaultdict
17
15
 
18
16
  import irie
19
- from irie.apps.inventory.models import Asset, Corridor
17
+ from irie.apps.inventory.models import Asset, Corridor
20
18
 
21
19
  from django.core.management.base import BaseCommand
22
- data = Path(irie.__file__).parents[0]/"init"/"data"/"networks"
20
+ DATA = Path(irie.__file__).parents[0]/"init"/"data"/"networks"
23
21
 
24
22
  class Command(BaseCommand):
25
23
 
26
24
  def handle(self, *args, **kwargs):
27
- with open(data/"soga_corridors.json") as f:
25
+ with open(DATA/"soga_corridors.json") as f:
28
26
  corridors = json.load(f)
29
27
 
30
28
  for cdata in corridors:
@@ -39,7 +37,6 @@ class Command(BaseCommand):
39
37
  corridor.save()
40
38
 
41
39
  for calid in cdata["bridges"]:
42
- # corridor.assets.add(Asset.objects.get(calid=calid))
43
40
  try:
44
41
  corridor.assets.add(Asset.objects.get(calid=calid))
45
42
  print(f"Added {calid} to {corridor.name}")
@@ -1,22 +1,35 @@
1
1
  """
2
2
  Assets must already be created
3
3
  """
4
- import json
5
- from pathlib import Path
6
4
  from django.core.management.base import BaseCommand
5
+ from django.core.files.temp import NamedTemporaryFile
6
+ from django.core.files import File
7
7
 
8
8
  from irie.apps.inventory.models import Asset
9
9
  from irie.apps.prediction.models import PredictorModel
10
10
  from irie.init.bridges import BRIDGES
11
11
 
12
+
13
+ def _create_file(path):
14
+ temp_file = NamedTemporaryFile(delete=True)
15
+ with open(path, "rb") as f:
16
+ temp_file.write(f.read())
17
+ temp_file.flush()
18
+ return File(temp_file, name="model.zip")
19
+
20
+
12
21
  class Command(BaseCommand):
13
22
  def handle(self, *args, **kwargs):
14
23
  for bridge in BRIDGES.values():
15
24
  print(bridge["cesmd"])
25
+ try:
26
+ asset = Asset.objects.get(cesmd=bridge["cesmd"])
27
+ except Asset.DoesNotExist:
28
+ continue
29
+
16
30
  for conf in bridge.get("predictors", []):
17
31
  print(">> ", conf["name"])
18
32
  try:
19
- "a" + 1
20
33
  pred = PredictorModel.objects.get(cesmd=bridge["cesmd"])
21
34
  pred.config = conf["config"]
22
35
  pred.name = conf["name"]
@@ -31,19 +44,21 @@ class Command(BaseCommand):
31
44
  if str(type) == conf["protocol"]:
32
45
  protocol = type
33
46
 
34
- # if protocol is None:
35
- # raise ValueError(f"Unknown predictor protocol: {conf['protocol']}")
36
47
  config = conf.get("config", {})
37
48
 
38
- a = PredictorModel(asset = Asset.objects.get(cesmd=bridge["cesmd"]),
49
+ a = PredictorModel(asset = asset,
39
50
  name = conf["name"],
40
51
  entry_point = conf["entry_point"],
41
52
  config = config,
42
53
  description = conf.get("description", ""),
43
- active = True,
54
+ active = conf.get("active", True),
44
55
  metrics = list(conf.get("metrics", [])),
45
56
  protocol = protocol
46
- )
57
+ )
58
+
59
+ if "model_file" in conf:
60
+ a.config_file.save("model.zip", _create_file(conf["model_file"]))
61
+
47
62
  a.save()
48
63
  print(a)
49
64