irie 0.0.0__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 (145) hide show
  1. irie/__main__.py +24 -0
  2. irie/apps/__init__.py +5 -0
  3. irie/apps/authentication/__init__.py +1 -0
  4. irie/apps/authentication/admin.py +1 -0
  5. irie/apps/authentication/config.py +6 -0
  6. irie/apps/authentication/forms.py +41 -0
  7. irie/apps/authentication/migrations/__init__.py +1 -0
  8. irie/apps/authentication/models.py +1 -0
  9. irie/apps/authentication/tests.py +1 -0
  10. irie/apps/authentication/urls.py +9 -0
  11. irie/apps/authentication/views.py +53 -0
  12. irie/apps/config.py +8 -0
  13. irie/apps/context_processors.py +5 -0
  14. irie/apps/documents/__init__.py +0 -0
  15. irie/apps/documents/apps.py +7 -0
  16. irie/apps/documents/documents.py +61 -0
  17. irie/apps/documents/migrations/__init__.py +0 -0
  18. irie/apps/documents/tests.py +3 -0
  19. irie/apps/documents/urls.py +12 -0
  20. irie/apps/documents/views.py +27 -0
  21. irie/apps/evaluation/__init__.py +0 -0
  22. irie/apps/evaluation/admin.py +43 -0
  23. irie/apps/evaluation/apps.py +18 -0
  24. irie/apps/evaluation/daemon.py +107 -0
  25. irie/apps/evaluation/identification.py +196 -0
  26. irie/apps/evaluation/migrations/0001_initial.py +25 -0
  27. irie/apps/evaluation/migrations/0002_remove_evaluation_cesmd.py +17 -0
  28. irie/apps/evaluation/migrations/0003_evaluation_asset.py +20 -0
  29. irie/apps/evaluation/migrations/__init__.py +0 -0
  30. irie/apps/evaluation/models.py +72 -0
  31. irie/apps/evaluation/urls.py +16 -0
  32. irie/apps/evaluation/views.py +68 -0
  33. irie/apps/events/__init__.py +0 -0
  34. irie/apps/events/admin.py +9 -0
  35. irie/apps/events/apps.py +12 -0
  36. irie/apps/events/migrations/0001_initial.py +27 -0
  37. irie/apps/events/migrations/0002_alter_event_id.py +18 -0
  38. irie/apps/events/migrations/0003_event_cesmd.py +19 -0
  39. irie/apps/events/migrations/0004_event_record_identifier.py +19 -0
  40. irie/apps/events/migrations/0005_event_asset.py +21 -0
  41. irie/apps/events/migrations/0006_alter_event_event_file.py +18 -0
  42. irie/apps/events/migrations/__init__.py +0 -0
  43. irie/apps/events/models.py +70 -0
  44. irie/apps/events/tests.py +1 -0
  45. irie/apps/events/tests_events.py +240 -0
  46. irie/apps/events/urls.py +29 -0
  47. irie/apps/events/views.py +55 -0
  48. irie/apps/events/views_events.py +215 -0
  49. irie/apps/inventory/CESMD.py +81 -0
  50. irie/apps/inventory/__init__.py +5 -0
  51. irie/apps/inventory/admin.py +10 -0
  52. irie/apps/inventory/apps.py +12 -0
  53. irie/apps/inventory/archive/arcGIS.py +1175 -0
  54. irie/apps/inventory/calid.py +65 -0
  55. irie/apps/inventory/fields.py +5 -0
  56. irie/apps/inventory/forms.py +12 -0
  57. irie/apps/inventory/migrations/0001_initial.py +31 -0
  58. irie/apps/inventory/migrations/0002_assetevaluationmodel_cesmd.py +19 -0
  59. irie/apps/inventory/migrations/0003_auto_20230520_2030.py +23 -0
  60. irie/apps/inventory/migrations/0004_asset.py +27 -0
  61. irie/apps/inventory/migrations/0005_auto_20230731_1802.py +23 -0
  62. irie/apps/inventory/migrations/0006_auto_20230731_1816.py +28 -0
  63. irie/apps/inventory/migrations/0007_auto_20230731_1827.py +24 -0
  64. irie/apps/inventory/migrations/0008_asset_is_complete.py +19 -0
  65. irie/apps/inventory/migrations/0009_auto_20230731_1842.py +29 -0
  66. irie/apps/inventory/migrations/0010_auto_20230801_0025.py +23 -0
  67. irie/apps/inventory/migrations/0011_alter_asset_cgs_data.py +18 -0
  68. irie/apps/inventory/migrations/0012_corridor.py +22 -0
  69. irie/apps/inventory/migrations/0013_alter_asset_cesmd.py +18 -0
  70. irie/apps/inventory/migrations/0014_alter_asset_cesmd.py +18 -0
  71. irie/apps/inventory/migrations/__init__.py +0 -0
  72. irie/apps/inventory/models.py +70 -0
  73. irie/apps/inventory/tables.py +584 -0
  74. irie/apps/inventory/traffic.py +175052 -0
  75. irie/apps/inventory/urls.py +25 -0
  76. irie/apps/inventory/views.py +515 -0
  77. irie/apps/management/__init__.py +0 -0
  78. irie/apps/management/commands/__init__.py +0 -0
  79. irie/apps/networks/__init__.py +0 -0
  80. irie/apps/networks/apps.py +5 -0
  81. irie/apps/networks/forms.py +64 -0
  82. irie/apps/networks/migrations/0001_initial.py +26 -0
  83. irie/apps/networks/migrations/__init__.py +0 -0
  84. irie/apps/networks/models.py +14 -0
  85. irie/apps/networks/networks.py +782 -0
  86. irie/apps/networks/tests.py +1 -0
  87. irie/apps/networks/urls.py +18 -0
  88. irie/apps/networks/views.py +89 -0
  89. irie/apps/prediction/__init__.py +0 -0
  90. irie/apps/prediction/admin.py +9 -0
  91. irie/apps/prediction/apps.py +12 -0
  92. irie/apps/prediction/forms.py +20 -0
  93. irie/apps/prediction/metrics.py +61 -0
  94. irie/apps/prediction/migrations/0001_initial.py +32 -0
  95. irie/apps/prediction/migrations/0002_auto_20230731_1801.py +27 -0
  96. irie/apps/prediction/migrations/0003_rename_assetevaluationmodel_evaluation.py +18 -0
  97. irie/apps/prediction/migrations/0004_delete_evaluation.py +16 -0
  98. irie/apps/prediction/migrations/0005_predictormodel_protocol.py +18 -0
  99. irie/apps/prediction/migrations/0006_alter_predictormodel_protocol.py +18 -0
  100. irie/apps/prediction/migrations/0007_predictormodel_active.py +19 -0
  101. irie/apps/prediction/migrations/0008_predictormodel_description.py +18 -0
  102. irie/apps/prediction/migrations/0009_predictormodel_entry_point.py +19 -0
  103. irie/apps/prediction/migrations/0010_alter_predictormodel_entry_point.py +18 -0
  104. irie/apps/prediction/migrations/0011_remove_predictormodel_entry_point.py +17 -0
  105. irie/apps/prediction/migrations/0012_predictormodel_entry_point.py +18 -0
  106. irie/apps/prediction/migrations/0013_predictormodel_metrics.py +18 -0
  107. irie/apps/prediction/migrations/0014_auto_20240930_0004.py +28 -0
  108. irie/apps/prediction/migrations/0015_alter_predictormodel_render_file.py +18 -0
  109. irie/apps/prediction/migrations/__init__.py +0 -0
  110. irie/apps/prediction/models.py +37 -0
  111. irie/apps/prediction/predictor.py +286 -0
  112. irie/apps/prediction/runners/__init__.py +450 -0
  113. irie/apps/prediction/runners/metrics.py +168 -0
  114. irie/apps/prediction/runners/opensees/__init__.py +0 -0
  115. irie/apps/prediction/runners/opensees/schemas/__init__.py +39 -0
  116. irie/apps/prediction/runners/utilities.py +277 -0
  117. irie/apps/prediction/runners/xmlutils.py +232 -0
  118. irie/apps/prediction/runners/zipped.py +27 -0
  119. irie/apps/prediction/templatetags/__init__.py +0 -0
  120. irie/apps/prediction/templatetags/predictor.py +20 -0
  121. irie/apps/prediction/urls.py +19 -0
  122. irie/apps/prediction/views.py +184 -0
  123. irie/apps/prediction/views_api.py +216 -0
  124. irie/apps/site/__init__.py +0 -0
  125. irie/apps/site/admin.py +1 -0
  126. irie/apps/site/config.py +6 -0
  127. irie/apps/site/migrations/__init__.py +1 -0
  128. irie/apps/site/models.py +2 -0
  129. irie/apps/site/templatetags/__init__.py +0 -0
  130. irie/apps/site/templatetags/indexing.py +7 -0
  131. irie/apps/site/tests.py +1 -0
  132. irie/apps/site/urls.py +8 -0
  133. irie/apps/site/view_sdof.py +40 -0
  134. irie/apps/site/view_utils.py +13 -0
  135. irie/apps/site/views.py +88 -0
  136. irie/core/__init__.py +5 -0
  137. irie/core/asgi.py +12 -0
  138. irie/core/settings.py +223 -0
  139. irie/core/urls.py +39 -0
  140. irie/core/wsgi.py +12 -0
  141. irie-0.0.0.dist-info/METADATA +48 -0
  142. irie-0.0.0.dist-info/RECORD +145 -0
  143. irie-0.0.0.dist-info/WHEEL +5 -0
  144. irie-0.0.0.dist-info/entry_points.txt +2 -0
  145. irie-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,286 @@
1
+ #===----------------------------------------------------------------------===#
2
+ #
3
+ # STAIRLab -- STructural Artificial Intelligence Laboratory
4
+ #
5
+ #===----------------------------------------------------------------------===#
6
+ #
7
+ # This module implements the predictor abstraction.
8
+ #
9
+ # Author: Claudio Perez
10
+ #
11
+ #----------------------------------------------------------------------------#
12
+ from __future__ import annotations
13
+ import sys
14
+ import json
15
+ import subprocess
16
+ from pathlib import Path
17
+ from typing import Dict
18
+
19
+ from .runners import Runner, RunID, Event, MetricType, classproperty, OpenSeesRunner
20
+
21
+
22
+
23
+ class PredictorType1(Runner):
24
+ @property
25
+ def platform(self):
26
+ return self.conf.get("platform", "")
27
+
28
+ @classmethod
29
+ def create(cls, asset, request):
30
+ from .models import PredictorModel
31
+ predictor = PredictorModel()
32
+ data = json.loads(request.data.get("json"))
33
+ predictor.entry_point = [
34
+ sys.executable, "-m", "opensees"
35
+ ]
36
+ data["metrics"] = []
37
+
38
+ predictor.name = data.pop("name")
39
+ predictor.config = data
40
+ predictor.asset = asset
41
+ predictor.protocol = "BRACE2_CLI_PREDICTOR_T1"
42
+ predictor.active = False
43
+ return predictor
44
+
45
+
46
+ @classproperty
47
+ def schema(cls):
48
+ from .runners.opensees import schemas
49
+ return {
50
+ "title": "Structural Model",
51
+ "options": {"disable_collaps": True},
52
+ "schema": "http://json-schema.org/draft-04/schema#",
53
+ "type": "object",
54
+ "properties": {
55
+ "platform": {
56
+ "type": "string",
57
+ "title": "Platform",
58
+ "enum": ["OpenSees","CSiBridge"]
59
+ },
60
+ "model": schemas.load("hwd_conf.schema.json"),
61
+ "analysis": schemas.load("hwd_analysis.schema.json"),
62
+ }
63
+ }
64
+
65
+ def newPrediction(self, event: Event) -> RunID:
66
+ self.event = event
67
+ event_file = Path(event.event_file.path).resolve()
68
+ command = [*self.entry_point, "new", event_file]
69
+ run_id = subprocess.check_output(command).decode().strip()
70
+ return RunID(int(run_id))
71
+
72
+ def runPrediction(self, run_id: RunID):
73
+ command = [*self.entry_point, "run", str(run_id)]
74
+
75
+ if "scale" in self.event.upload_data:
76
+ command.extend(["--scale", str(float(self.event.upload_data["scale"]))])
77
+ print(":: Running ", command, file=sys.stderr)
78
+ subprocess.check_output(command)
79
+
80
+ print(f":: Model {self.name} returned", file=sys.stderr)
81
+ return
82
+
83
+ def getMetricData(self, run, metric):
84
+ try:
85
+ return json.loads(subprocess.check_output([*self.entry_point, "get", str(run), metric]).decode())
86
+ except json.decoder.JSONDecodeError:
87
+ return {}
88
+
89
+
90
+ class PredictorType2(Runner):
91
+ platform = "mdof"
92
+
93
+ schema = {
94
+ "title": "System ID",
95
+ "name": "P2",
96
+ "type": "object",
97
+ "required": [
98
+ "name",
99
+ "decimation",
100
+ "method",
101
+ "channels"
102
+ ],
103
+ "properties": {
104
+ "name": {
105
+ "type": "string",
106
+ "title": "Name",
107
+ "description": "Predictor name",
108
+ "minLength": 2,
109
+ # "default": "S1"
110
+ },
111
+ "method": {
112
+ "type": "string",
113
+ "title": "Method",
114
+ "enum": ["Fourier Spectrum","Response Spectrum","SRIM","OKID"]
115
+ },
116
+ "decimation": {
117
+ "type": "integer",
118
+ "title": "Decimation",
119
+ "default": 1,
120
+ "minimum": 1,
121
+ "maximum": 8
122
+ },
123
+ "order": {
124
+ "type": "integer",
125
+ "title": "Model Order",
126
+ "default": 8,
127
+ "minimum": 2,
128
+ "maximum": 64,
129
+ "options": {"dependencies": {"method": ["SRIM","OKID"]}}
130
+ },
131
+ "horizon": {
132
+ "type": "integer",
133
+ "title": "Prediction Horizon",
134
+ "default": 100,
135
+ "minimum": 50,
136
+ "maximum": 500,
137
+ "options": {"dependencies": {"method": ["SRIM"]}}
138
+ },
139
+ "period_band": {
140
+ "type": "string",
141
+ "title": "Period Band",
142
+ "default": "[0.1,2.3]",
143
+ "options": {"dependencies": {"method": ["Fourier Spectrum"]}},
144
+ "description": "[0.1,2.3] if interested in periods between 0.1 seconds and 2.3 seconds"
145
+ },
146
+ "damping": {
147
+ "type": "float",
148
+ "title": "Damping",
149
+ "default": 0.02,
150
+ "options": {"dependencies": {"method": ["Response Spectrum"]}},
151
+ "description": "assumed damping ratio"
152
+ },
153
+ "channels": {
154
+ "type": "array",
155
+ "format": "table",
156
+ "title": "Channels",
157
+ "uniqueItems": True,
158
+ "items": {
159
+ "title": "Acceleration",
160
+ "type": "object",
161
+ "properties": {
162
+ "type": {
163
+ "type": "string",
164
+ "enum": ["output","input"],
165
+ "default": "output"
166
+ },
167
+ "id": {"type": "integer", "description": "Number identifying signal channel"}
168
+ }
169
+ },
170
+ "default": [{"type": "output", "id": 1}]
171
+ }
172
+ }
173
+ }
174
+
175
+ @classmethod
176
+ def create(cls, asset, request):
177
+ from .models import PredictorModel
178
+ predictor = PredictorModel()
179
+ data = json.loads(request.data.get("json"))
180
+ method = {
181
+ "Fourier Spectrum": "fourier",
182
+ "Response Spectrum": "response",
183
+ "FDD": "fdd",
184
+ "OKID": "okid-era",
185
+ "SRIM": "srim"
186
+ }[data.pop("method")]
187
+ predictor.entry_point = [
188
+ sys.executable, "-m", "mdof", method
189
+ ]
190
+ data["outputs"] = [i["id"] for i in data["channels"] if i["type"] == "output"]
191
+ data["inputs"] = [i["id"] for i in data["channels"] if i["type"] == "input"]
192
+ data["threads"] = 4
193
+ data["metrics"] = ["SPECTRAL_SHIFT_IDENTIFICATION"]
194
+ del data["channels"]
195
+
196
+ predictor.name = data.pop("name")
197
+ predictor.config = data
198
+ predictor.asset = asset
199
+ predictor.protocol = "BRACE2_CLI_PREDICTOR_T2"
200
+ predictor.active = True
201
+ return predictor
202
+
203
+
204
+ def newPrediction(self, event):
205
+ self.event = event
206
+ return RunID(1)
207
+
208
+ def runPrediction(self, run_id: RunID) -> bool:
209
+ event_file = Path(self.event.event_file.path).resolve()
210
+ # if "config" in self.conf:
211
+ command = [*self.entry_point,
212
+ "--config", json.dumps(self.conf),
213
+ event_file]
214
+ if False:
215
+ command = [*self.entry_point,
216
+ event_file,
217
+ *map(str, self.conf.get("argv", []))]
218
+
219
+ self.metric_details = subprocess.check_output(command).decode()
220
+ print(self.metric_details)
221
+ return True
222
+
223
+ def getMetricData(self, run, metric):
224
+ if not hasattr(self, "metric_details"):
225
+ raise Exception(f"Error {self.name}({id(self)}), {run}")
226
+ return json.loads(self.metric_details)
227
+
228
+
229
+ class PredictorType4(Runner):
230
+ platform = "csi"
231
+
232
+ schema = {
233
+ "title": "CSI Predictor",
234
+ "properties": {}
235
+ }
236
+
237
+ @classmethod
238
+ def create(cls, asset, request, config):
239
+ from .models import PredictorModel
240
+ predictor = PredictorModel()
241
+
242
+ predictor.entry_point = [
243
+ sys.executable, "-m", "opensees"
244
+ ]
245
+
246
+ predictor.name = config.pop("name")
247
+ predictor.config = config
248
+ predictor.asset = asset
249
+ predictor.protocol = "BRACE2_CLI_PREDICTOR_T4"
250
+ predictor.active = True
251
+ return predictor
252
+
253
+
254
+ def newPrediction(self, event):
255
+ self.event = event
256
+ return RunID(1)
257
+
258
+ def runPrediction(self, run_id: RunID) -> bool:
259
+ event_file = Path(self.event.event_file.path).resolve()
260
+ # if "config" in self.conf:
261
+ command = [*self.entry_point,
262
+ "--config", json.dumps(self.conf),
263
+ event_file]
264
+ if False:
265
+ command = [*self.entry_point,
266
+ event_file,
267
+ *map(str, self.conf.get("argv", []))]
268
+
269
+ self.metric_details = subprocess.check_output(command).decode()
270
+ print(self.metric_details)
271
+ return True
272
+
273
+ def getMetricData(self, run, metric):
274
+ if not hasattr(self, "metric_details"):
275
+ raise Exception(f"Error {self.name}({id(self)}), {run}")
276
+ return json.loads(self.metric_details)
277
+
278
+
279
+ PREDICTOR_TYPES : Dict[str, Runner] = {
280
+ "BRACE2_CLI_PREDICTOR_V1" : PredictorType1,
281
+ "BRACE2_CLI_PREDICTOR_T2" : PredictorType2,
282
+ "" : PredictorType2,
283
+ # "BRACE2_CLI_PREDICTOR_T3" : PredictorType3,
284
+ "BRACE2_CLI_PREDICTOR_T4" : OpenSeesRunner,
285
+ }
286
+