irie 0.0.15__py3-none-any.whl → 0.0.17__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_events.py +4 -6
- irie/apps/inventory/filters.py +37 -5
- irie/apps/inventory/models.py +14 -1
- irie/apps/inventory/sitemaps.py +19 -0
- irie/apps/inventory/views.py +2 -7
- irie/apps/prediction/forms.py +4 -1
- irie/apps/prediction/predictor.py +5 -274
- irie/apps/prediction/runners/__init__.py +17 -15
- irie/apps/prediction/runners/hazus.py +271 -182
- irie/apps/prediction/runners/opensees/__init__.py +88 -11
- irie/apps/prediction/runners/ssid.py +168 -9
- irie/apps/prediction/urls.py +3 -4
- irie/apps/prediction/views.py +8 -85
- irie/apps/sitemaps.py +14 -0
- irie/apps/templates/includes/asset-event-table.html +3 -3
- irie/apps/templates/includes/scripts.html +3 -8
- irie/apps/templates/includes/sidebar.html +1 -1
- irie/apps/templates/inventory/asset-event-summary.html +8 -8
- irie/apps/templates/inventory/asset-profile.html +10 -22
- irie/apps/templates/inventory/asset-table.html +38 -15
- irie/apps/templates/prediction/asset-predictors.html +38 -5
- irie/apps/templates/prediction/hazus/history.html +1 -1
- irie/apps/templates/prediction/new-runner.html +1 -1
- irie/apps/templates/prediction/predictor-profile.html +11 -0
- irie/apps/templates/site/index.html +6 -21
- irie/init/__main__.py +8 -5
- irie/init/data/cgs-stations.json +2967 -0
- irie/init/getCGSData.py +9 -4
- irie/init/management/commands/init_assets.py +1 -1
- irie/init/management/commands/init_cesmd.py +25 -0
- irie/rest/__main__.py +2 -3
- {irie-0.0.15.dist-info → irie-0.0.17.dist-info}/METADATA +1 -1
- {irie-0.0.15.dist-info → irie-0.0.17.dist-info}/RECORD +36 -32
- {irie-0.0.15.dist-info → irie-0.0.17.dist-info}/WHEEL +0 -0
- {irie-0.0.15.dist-info → irie-0.0.17.dist-info}/entry_points.txt +0 -0
- {irie-0.0.15.dist-info → irie-0.0.17.dist-info}/top_level.txt +0 -0
|
@@ -11,7 +11,7 @@ import zipfile
|
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
import contextlib
|
|
13
13
|
|
|
14
|
-
from irie.apps.prediction.runners import (Runner,
|
|
14
|
+
from irie.apps.prediction.runners import (Runner, RunID, classproperty)
|
|
15
15
|
|
|
16
16
|
from .utilities import read_model
|
|
17
17
|
from .metrics import (
|
|
@@ -29,7 +29,6 @@ OPENSEES = [
|
|
|
29
29
|
@contextlib.contextmanager
|
|
30
30
|
def new_cd(x):
|
|
31
31
|
d = os.getcwd()
|
|
32
|
-
|
|
33
32
|
# This could raise an exception, but it's probably
|
|
34
33
|
# best to let it propagate and let the caller
|
|
35
34
|
# deal with it, since they requested x
|
|
@@ -52,19 +51,28 @@ class OpenSeesRunner(Runner):
|
|
|
52
51
|
|
|
53
52
|
|
|
54
53
|
@classmethod
|
|
55
|
-
def create(cls, asset, request
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
def create(cls, asset, request):
|
|
55
|
+
from irie.apps.prediction.models import PredictorModel
|
|
56
|
+
predictor = PredictorModel()
|
|
57
|
+
data = json.loads(request.body)
|
|
58
|
+
# TODO
|
|
59
|
+
data.pop("file")
|
|
60
|
+
uploaded_file = request.FILES.get('config_file', None)
|
|
61
|
+
print(uploaded_file)
|
|
62
|
+
if uploaded_file:
|
|
63
|
+
|
|
64
|
+
with open(uploaded_file.name, 'wb+') as destination:
|
|
65
|
+
for chunk in uploaded_file.chunks():
|
|
66
|
+
destination.write(chunk)
|
|
67
|
+
|
|
68
|
+
# predictor.config_file = uploaded_file # data.pop("file")
|
|
69
|
+
predictor.name = data.pop("name")
|
|
70
|
+
predictor.config = data
|
|
71
|
+
predictor.asset = asset
|
|
62
72
|
predictor.protocol = "IRIE_PREDICTOR_T4"
|
|
63
73
|
predictor.active = True
|
|
64
|
-
# predictor.metrics = self.getMetricList()
|
|
65
74
|
return predictor
|
|
66
75
|
|
|
67
|
-
|
|
68
76
|
@classproperty
|
|
69
77
|
def schema(cls):
|
|
70
78
|
from . import schemas
|
|
@@ -491,3 +499,72 @@ class OpenSeesRunner(Runner):
|
|
|
491
499
|
return {}
|
|
492
500
|
return {}
|
|
493
501
|
|
|
502
|
+
|
|
503
|
+
import subprocess
|
|
504
|
+
class Event: pass
|
|
505
|
+
|
|
506
|
+
class PredictorType1(Runner):
|
|
507
|
+
@property
|
|
508
|
+
def platform(self):
|
|
509
|
+
return self.conf.get("platform", "")
|
|
510
|
+
|
|
511
|
+
@classmethod
|
|
512
|
+
def create(cls, asset, request):
|
|
513
|
+
from irie.apps.prediction.models import PredictorModel
|
|
514
|
+
predictor = PredictorModel()
|
|
515
|
+
data = json.loads(request.data.get("json"))
|
|
516
|
+
predictor.entry_point = [
|
|
517
|
+
sys.executable, "-m", "opensees"
|
|
518
|
+
]
|
|
519
|
+
data["metrics"] = []
|
|
520
|
+
|
|
521
|
+
predictor.name = data.pop("name")
|
|
522
|
+
predictor.config = data
|
|
523
|
+
predictor.asset = asset
|
|
524
|
+
predictor.protocol = "IRIE_PREDICTOR_T1"
|
|
525
|
+
predictor.active = False
|
|
526
|
+
return predictor
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
@classproperty
|
|
530
|
+
def schema(cls):
|
|
531
|
+
from irie.apps.prediction.runners.opensees import schemas
|
|
532
|
+
return {
|
|
533
|
+
"title": "Structural Model",
|
|
534
|
+
"options": {"disable_collaps": True},
|
|
535
|
+
"schema": "http://json-schema.org/draft-04/schema#",
|
|
536
|
+
"type": "object",
|
|
537
|
+
"properties": {
|
|
538
|
+
"platform": {
|
|
539
|
+
"type": "string",
|
|
540
|
+
"title": "Platform",
|
|
541
|
+
"enum": ["OpenSees","CSiBridge"]
|
|
542
|
+
},
|
|
543
|
+
"model": schemas.load("hwd_conf.schema.json"),
|
|
544
|
+
"analysis": schemas.load("hwd_analysis.schema.json"),
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
def newPrediction(self, event: Event) -> RunID:
|
|
549
|
+
self.event = event
|
|
550
|
+
event_file = Path(event.event_file.path).resolve()
|
|
551
|
+
command = [*self.entry_point, "new", event_file]
|
|
552
|
+
run_id = subprocess.check_output(command).decode().strip()
|
|
553
|
+
return RunID(int(run_id))
|
|
554
|
+
|
|
555
|
+
def runPrediction(self, run_id: RunID):
|
|
556
|
+
command = [*self.entry_point, "run", str(run_id)]
|
|
557
|
+
|
|
558
|
+
if "scale" in self.event.upload_data:
|
|
559
|
+
command.extend(["--scale", str(float(self.event.upload_data["scale"]))])
|
|
560
|
+
print(":: Running ", command, file=sys.stderr)
|
|
561
|
+
subprocess.check_output(command)
|
|
562
|
+
|
|
563
|
+
print(f":: Model {self.name} returned", file=sys.stderr)
|
|
564
|
+
return
|
|
565
|
+
|
|
566
|
+
def getMetricData(self, run, metric):
|
|
567
|
+
try:
|
|
568
|
+
return json.loads(subprocess.check_output([*self.entry_point, "get", str(run), metric]).decode())
|
|
569
|
+
except json.decoder.JSONDecodeError:
|
|
570
|
+
return {}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
from irie.apps.events.models import EventRecord
|
|
2
|
+
from irie.apps.prediction.runners import Runner, RunID
|
|
3
|
+
from irie.apps.prediction.models import PredictorModel
|
|
4
|
+
|
|
1
5
|
from pathlib import Path
|
|
2
6
|
import json
|
|
3
7
|
import io
|
|
@@ -12,6 +16,7 @@ from mdof import transform
|
|
|
12
16
|
from scipy.signal import find_peaks
|
|
13
17
|
from mdof.utilities import Config, extract_channels
|
|
14
18
|
from matplotlib import colormaps
|
|
19
|
+
import subprocess
|
|
15
20
|
# try:
|
|
16
21
|
# import scienceplots
|
|
17
22
|
# plt.style.use(["science"])
|
|
@@ -22,7 +27,155 @@ N_PEAKS = 5 # number of "significant" peaks per record
|
|
|
22
27
|
MISSING_CHANNEL_LIMIT = 3 # number of missing output channels allowed before skipping event
|
|
23
28
|
MAX_ACCEL = 3.0
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
|
|
31
|
+
class SystemIdRunner(Runner):
|
|
32
|
+
platform = "mdof"
|
|
33
|
+
|
|
34
|
+
schema = {
|
|
35
|
+
"title": "System ID",
|
|
36
|
+
"name": "P2",
|
|
37
|
+
"type": "object",
|
|
38
|
+
"required": [
|
|
39
|
+
"name",
|
|
40
|
+
"decimation",
|
|
41
|
+
"method",
|
|
42
|
+
"channels"
|
|
43
|
+
],
|
|
44
|
+
"properties": {
|
|
45
|
+
"name": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"title": "Name",
|
|
48
|
+
"description": "Predictor name",
|
|
49
|
+
"minLength": 2,
|
|
50
|
+
# "default": "S1"
|
|
51
|
+
},
|
|
52
|
+
"method": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"title": "Method",
|
|
55
|
+
"enum": ["Fourier Spectrum","Response Spectrum","SRIM","OKID"]
|
|
56
|
+
},
|
|
57
|
+
"decimation": {
|
|
58
|
+
"type": "integer",
|
|
59
|
+
"title": "Decimation",
|
|
60
|
+
"default": 1,
|
|
61
|
+
"minimum": 1,
|
|
62
|
+
"maximum": 8
|
|
63
|
+
},
|
|
64
|
+
"order": {
|
|
65
|
+
"type": "integer",
|
|
66
|
+
"title": "Model Order",
|
|
67
|
+
"default": 8,
|
|
68
|
+
"minimum": 2,
|
|
69
|
+
"maximum": 64,
|
|
70
|
+
"options": {"dependencies": {"method": ["SRIM","OKID"]}}
|
|
71
|
+
},
|
|
72
|
+
"horizon": {
|
|
73
|
+
"type": "integer",
|
|
74
|
+
"title": "Prediction Horizon",
|
|
75
|
+
"default": 100,
|
|
76
|
+
"minimum": 50,
|
|
77
|
+
"maximum": 500,
|
|
78
|
+
"options": {"dependencies": {"method": ["SRIM"]}}
|
|
79
|
+
},
|
|
80
|
+
"period_band": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"title": "Period Band",
|
|
83
|
+
"default": "[0.1,2.3]",
|
|
84
|
+
"options": {"dependencies": {"method": ["Fourier Spectrum"]}},
|
|
85
|
+
"description": "[0.1,2.3] if interested in periods between 0.1 seconds and 2.3 seconds"
|
|
86
|
+
},
|
|
87
|
+
"damping": {
|
|
88
|
+
"type": "float",
|
|
89
|
+
"title": "Damping",
|
|
90
|
+
"default": 0.02,
|
|
91
|
+
"options": {"dependencies": {"method": ["Response Spectrum"]}},
|
|
92
|
+
"description": "assumed damping ratio"
|
|
93
|
+
},
|
|
94
|
+
"channels": {
|
|
95
|
+
"type": "array",
|
|
96
|
+
"format": "table",
|
|
97
|
+
"title": "Channels",
|
|
98
|
+
"uniqueItems": True,
|
|
99
|
+
"items": {
|
|
100
|
+
"title": "Acceleration",
|
|
101
|
+
"type": "object",
|
|
102
|
+
"properties": {
|
|
103
|
+
"type": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"enum": ["output","input"],
|
|
106
|
+
"default": "output"
|
|
107
|
+
},
|
|
108
|
+
"id": {"type": "integer", "description": "Number identifying signal channel"}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"default": [{"type": "output", "id": 1}]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
def render(self):
|
|
117
|
+
try:
|
|
118
|
+
return make_mountains(self.asset, self.conf)
|
|
119
|
+
except:
|
|
120
|
+
return None
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
def create(cls, asset, request):
|
|
124
|
+
predictor = PredictorModel()
|
|
125
|
+
data = json.loads(request.body)
|
|
126
|
+
method = {
|
|
127
|
+
"Fourier Spectrum": "fourier",
|
|
128
|
+
"Response Spectrum": "response",
|
|
129
|
+
"FDD": "fdd",
|
|
130
|
+
"OKID": "okid-era",
|
|
131
|
+
"SRIM": "srim"
|
|
132
|
+
}[data.pop("method")]
|
|
133
|
+
|
|
134
|
+
predictor.entry_point = [
|
|
135
|
+
sys.executable, "-m", "mdof", method
|
|
136
|
+
]
|
|
137
|
+
data["outputs"] = [i["id"] for i in data["channels"] if i["type"] == "output"]
|
|
138
|
+
data["inputs"] = [i["id"] for i in data["channels"] if i["type"] == "input"]
|
|
139
|
+
data["threads"] = 4
|
|
140
|
+
data["metrics"] = ["SPECTRAL_SHIFT_IDENTIFICATION"]
|
|
141
|
+
del data["channels"]
|
|
142
|
+
|
|
143
|
+
predictor.name = data.pop("name")
|
|
144
|
+
predictor.config = data
|
|
145
|
+
predictor.asset = asset
|
|
146
|
+
predictor.protocol = "IRIE_PREDICTOR_T2"
|
|
147
|
+
predictor.active = True
|
|
148
|
+
return predictor
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def newPrediction(self, event):
|
|
152
|
+
self.event = event
|
|
153
|
+
return RunID(1)
|
|
154
|
+
|
|
155
|
+
def runPrediction(self, run_id: RunID) -> bool:
|
|
156
|
+
event_file = Path(self.event.event_file.path).resolve()
|
|
157
|
+
command = [*self.entry_point,
|
|
158
|
+
"--config",
|
|
159
|
+
json.dumps(self.conf),
|
|
160
|
+
event_file]
|
|
161
|
+
|
|
162
|
+
if False:
|
|
163
|
+
command = [*self.entry_point,
|
|
164
|
+
event_file,
|
|
165
|
+
*map(str, self.conf.get("argv", []))]
|
|
166
|
+
try:
|
|
167
|
+
self.metric_data = json.loads(
|
|
168
|
+
subprocess.check_output(command).decode()
|
|
169
|
+
)
|
|
170
|
+
return True
|
|
171
|
+
except Exception as e:
|
|
172
|
+
self.metric_data = {"error": str(e)}
|
|
173
|
+
return False
|
|
174
|
+
|
|
175
|
+
def getMetricData(self, run, metric):
|
|
176
|
+
if not hasattr(self, "metric_data"):
|
|
177
|
+
raise Exception(f"Error {self.name}({id(self)}), {run}")
|
|
178
|
+
return self.metric_data
|
|
26
179
|
|
|
27
180
|
|
|
28
181
|
|
|
@@ -186,12 +339,14 @@ def _load_events(asset, output_channels):
|
|
|
186
339
|
return {k:v for k,v in events}
|
|
187
340
|
|
|
188
341
|
|
|
189
|
-
def
|
|
342
|
+
def _get_spectra(event, conf, cmap):
|
|
190
343
|
"""
|
|
191
344
|
Get coordinates (periods, amplitudes) of spectra for an event, and return them along
|
|
192
345
|
with the maximum period of the N_PEAKS tallest peaks, as well as plotting options
|
|
193
346
|
such as color and alpha.
|
|
194
347
|
"""
|
|
348
|
+
period_band = conf.period_band
|
|
349
|
+
|
|
195
350
|
n_outputs = event['outputs'].shape[0]
|
|
196
351
|
frequencies,_,S = transform.fdd(outputs=event['outputs'], step=event['dt']) # Full frequency spectrum
|
|
197
352
|
periods = 1/frequencies
|
|
@@ -309,14 +464,18 @@ def _plot_mountains(spectra, accellim=None):
|
|
|
309
464
|
return fig
|
|
310
465
|
|
|
311
466
|
|
|
312
|
-
def make_mountains(asset, output_channels=None):
|
|
467
|
+
def make_mountains(asset, conf=None, output_channels=None):
|
|
313
468
|
|
|
314
469
|
cmap = colormaps['plasma']
|
|
315
|
-
conf
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
470
|
+
if conf is None:
|
|
471
|
+
conf = Config()
|
|
472
|
+
conf.period_band = (0.1,3)
|
|
473
|
+
conf.damping = 0.02
|
|
474
|
+
conf.ss_decimation = 8
|
|
475
|
+
conf.order = 40
|
|
476
|
+
conf.method = "fdd"
|
|
477
|
+
else:
|
|
478
|
+
conf = Config(**conf)
|
|
320
479
|
|
|
321
480
|
if output_channels is None:
|
|
322
481
|
if not asset.bridge_sensors:
|
|
@@ -333,7 +492,7 @@ def make_mountains(asset, output_channels=None):
|
|
|
333
492
|
print(f"Missing {n_expected_outputs-n_parsed_channels} output channels; skipping event") # Missing too many channels
|
|
334
493
|
continue
|
|
335
494
|
|
|
336
|
-
spectra[filename] =
|
|
495
|
+
spectra[filename] = _get_spectra(event, conf, cmap) # {'spec_coords':spec_coords, 'max_peak_period':max_peak_period, 'plot_conf':plot_conf}
|
|
337
496
|
|
|
338
497
|
|
|
339
498
|
# if station == 'CE89494':
|
irie/apps/prediction/urls.py
CHANGED
|
@@ -12,8 +12,7 @@ from .views import new_prediction, asset_predictors, predictor_profile, predicto
|
|
|
12
12
|
|
|
13
13
|
urlpatterns = [
|
|
14
14
|
re_path("^inventory/[0-9 A-Z-]*/predictors/new", new_prediction),
|
|
15
|
-
re_path("^inventory/[0-9 A-Z-]
|
|
16
|
-
re_path("^inventory/(?P<calid>[0-9 A-Z-]*)/predictors/create
|
|
17
|
-
re_path("^inventory/[0-9 A-Z-]*/predictors/", asset_predictors, name="asset_predictors")
|
|
18
|
-
re_path("^inventory/[0-9 A-Z-]*/predictors/", asset_predictors),
|
|
15
|
+
re_path("^inventory/(?P<calid>[0-9 A-Z-]*)/predictors/(?P<preid>[0-9 A-Z-]{1,})", predictor_profile),
|
|
16
|
+
re_path("^inventory/(?P<calid>[0-9 A-Z-]*)/predictors/create", predictor_upload),
|
|
17
|
+
re_path("^inventory/[0-9 A-Z-]*/predictors/", asset_predictors, name="asset_predictors")
|
|
19
18
|
]
|
irie/apps/prediction/views.py
CHANGED
|
@@ -19,9 +19,6 @@ from django.core.exceptions import ObjectDoesNotExist
|
|
|
19
19
|
|
|
20
20
|
from django.shortcuts import render
|
|
21
21
|
|
|
22
|
-
from rest_framework.decorators import api_view, permission_classes
|
|
23
|
-
from rest_framework.permissions import IsAuthenticated
|
|
24
|
-
|
|
25
22
|
from irie.apps.site.view_utils import raise404
|
|
26
23
|
from irie.apps.inventory.models import Asset
|
|
27
24
|
from irie.apps.prediction.predictor import PREDICTOR_TYPES, OpenSeesRunner
|
|
@@ -38,41 +35,7 @@ def new_prediction(request):
|
|
|
38
35
|
return HttpResponse(html_template.render(context, request))
|
|
39
36
|
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
@api_view(["GET", "POST", "PUT"])
|
|
43
|
-
@permission_classes([IsAuthenticated])
|
|
44
|
-
def predictor_api(request):
|
|
45
|
-
|
|
46
|
-
context = {"segment": "assets"}
|
|
47
|
-
|
|
48
|
-
context["predictor_types"] = list(reversed([
|
|
49
|
-
{"schema": json.dumps(cls.schema),
|
|
50
|
-
"name": cls.__name__,
|
|
51
|
-
"title": cls.schema["title"]}
|
|
52
|
-
for cls in set(PREDICTOR_TYPES.values())
|
|
53
|
-
]))
|
|
54
|
-
|
|
55
|
-
calid = request.path.split("/")[-3]
|
|
56
|
-
|
|
57
|
-
try:
|
|
58
|
-
context["asset"] = Asset.objects.get(calid=calid)
|
|
59
|
-
|
|
60
|
-
except:
|
|
61
|
-
return HttpResponse(
|
|
62
|
-
loader.get_template("site/page-404-sidebar.html").render(context, request)
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
if request.method == "POST":
|
|
66
|
-
print(request.POST)
|
|
67
|
-
PREDICTOR_TYPES["IRIE_PREDICTOR_T2"].create(context["asset"],request).save()
|
|
68
|
-
|
|
69
|
-
html_template = loader.get_template("prediction/asset-predictors.html")
|
|
70
|
-
return HttpResponse(html_template.render(context, request))
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@api_view(["GET", "POST", "PUT"])
|
|
74
|
-
# @login_required(login_url="/login/")
|
|
75
|
-
@permission_classes([IsAuthenticated])
|
|
38
|
+
@login_required(login_url="/login/")
|
|
76
39
|
def asset_predictors(request):
|
|
77
40
|
|
|
78
41
|
calid = request.path.split("/")[-3]
|
|
@@ -97,45 +60,17 @@ def asset_predictors(request):
|
|
|
97
60
|
loader.get_template("site/page-404-sidebar.html").render(context, request)
|
|
98
61
|
)
|
|
99
62
|
|
|
100
|
-
if request.method == "POST":
|
|
101
|
-
form = PredictorForm(request.POST, request.FILES)
|
|
102
|
-
if form.is_valid():
|
|
103
|
-
# Process the form data and uploaded file
|
|
104
|
-
# asset = form.cleaned_data['asset']
|
|
105
|
-
asset = Asset.objects.get(calid=calid)
|
|
106
|
-
uploaded_file = request.FILES['config_file']
|
|
107
|
-
|
|
108
|
-
if uploaded_file:
|
|
109
|
-
with open(uploaded_file.name, 'wb+') as destination:
|
|
110
|
-
for chunk in uploaded_file.chunks():
|
|
111
|
-
destination.write(chunk)
|
|
112
|
-
|
|
113
|
-
# Save the predictor
|
|
114
|
-
if request.POST.get("runner", None) == "IRIE_PREDICTOR_T2":
|
|
115
|
-
PREDICTOR_TYPES["IRIE_PREDICTOR_T2"].create(context["asset"],request).save()
|
|
116
|
-
else:
|
|
117
|
-
OpenSeesRunner.create(asset,None,form).save()
|
|
118
|
-
else:
|
|
119
|
-
context["form"] = PredictorForm()
|
|
120
|
-
|
|
121
63
|
html_template = loader.get_template("prediction/asset-predictors.html")
|
|
122
64
|
return HttpResponse(html_template.render(context, request))
|
|
123
65
|
|
|
124
66
|
|
|
125
67
|
@login_required(login_url="/login/")
|
|
126
|
-
def predictor_profile(request):
|
|
68
|
+
def predictor_profile(request, calid, preid):
|
|
127
69
|
|
|
128
70
|
context = {}
|
|
129
71
|
html_template = loader.get_template("prediction/predictor-profile.html")
|
|
130
72
|
context["segment"] = "inventory"
|
|
131
73
|
|
|
132
|
-
url_segs = request.path.split("/")
|
|
133
|
-
if len(url_segs) < 5:
|
|
134
|
-
return raise404(request, context)
|
|
135
|
-
else:
|
|
136
|
-
calid = url_segs[2]
|
|
137
|
-
preid = url_segs[4]
|
|
138
|
-
|
|
139
74
|
try:
|
|
140
75
|
asset = Asset.objects.get(calid=calid)
|
|
141
76
|
except Asset.DoesNotExist:
|
|
@@ -149,7 +84,6 @@ def predictor_profile(request):
|
|
|
149
84
|
context["asset"] = asset
|
|
150
85
|
context["predictor"] = PREDICTOR_TYPES[predictor.protocol](predictor)
|
|
151
86
|
|
|
152
|
-
|
|
153
87
|
try:
|
|
154
88
|
return HttpResponse(html_template.render(context, request))
|
|
155
89
|
|
|
@@ -167,29 +101,19 @@ def predictor_profile(request):
|
|
|
167
101
|
@login_required(login_url="/login/")
|
|
168
102
|
def predictor_upload(request, calid):
|
|
169
103
|
|
|
170
|
-
context = {}
|
|
171
104
|
html_template = loader.get_template("prediction/predictor-upload.html")
|
|
172
|
-
context["segment"] = "assets"
|
|
173
105
|
|
|
174
106
|
if request.method == 'POST':
|
|
175
107
|
form = PredictorForm(request.POST, request.FILES) # include request.FILES
|
|
176
|
-
if form.is_valid():
|
|
177
|
-
|
|
178
|
-
# asset = form.cleaned_data['asset']
|
|
179
|
-
asset = Asset.objects.get(calid=calid)
|
|
180
|
-
uploaded_file = request.FILES['config_file']
|
|
181
|
-
|
|
182
|
-
with open(uploaded_file.name, 'wb+') as destination:
|
|
183
|
-
for chunk in uploaded_file.chunks():
|
|
184
|
-
destination.write(chunk)
|
|
108
|
+
# if form.is_valid():
|
|
109
|
+
asset = Asset.objects.get(calid=calid)
|
|
185
110
|
|
|
186
|
-
|
|
187
|
-
|
|
111
|
+
# Save the predictor
|
|
112
|
+
predictor = PREDICTOR_TYPES[request.POST.get("runner")].create(asset, request)
|
|
113
|
+
predictor.save()
|
|
188
114
|
|
|
189
|
-
|
|
115
|
+
return HttpResponse(json.dumps({"data": {"id": predictor.id}}))
|
|
190
116
|
|
|
191
|
-
return render(request, 'prediction/predictor-upload.html',
|
|
192
|
-
context)
|
|
193
117
|
else:
|
|
194
118
|
form = PredictorForm()
|
|
195
119
|
|
|
@@ -197,7 +121,6 @@ def predictor_upload(request, calid):
|
|
|
197
121
|
try:
|
|
198
122
|
return render(request, 'prediction/predictor-upload.html', {"form": form})
|
|
199
123
|
|
|
200
|
-
|
|
201
124
|
except Exception as e:
|
|
202
125
|
if "DEBUG" in os.environ and os.environ["DEBUG"]:
|
|
203
126
|
raise e
|
irie/apps/sitemaps.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from django.contrib.sitemaps import Sitemap
|
|
2
|
+
from django.urls import reverse
|
|
3
|
+
|
|
4
|
+
class IrieSitemap(Sitemap):
|
|
5
|
+
priority = 0.9
|
|
6
|
+
changefreq = 'weekly'
|
|
7
|
+
|
|
8
|
+
def items(self):
|
|
9
|
+
# Return the names of your static views
|
|
10
|
+
return ['home', 'about', 'dashboard', 'asset_table']
|
|
11
|
+
|
|
12
|
+
def location(self, item):
|
|
13
|
+
return reverse(item)
|
|
14
|
+
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<div class="card shadow table-wrapper table-responsive">
|
|
1
|
+
<div class="card border-0 shadow table-wrapper table-responsive">
|
|
2
2
|
<div class="card-header">
|
|
3
3
|
<div class="row align-items-center">
|
|
4
4
|
<div class="col">
|
|
5
|
-
<h2 class="fs-5 fw-bold
|
|
5
|
+
<h2 class="fs-5 fw-bold">Events</h2>
|
|
6
6
|
</div>
|
|
7
7
|
<div class="col text-end">
|
|
8
8
|
<div class="align-right">
|
|
9
9
|
<div class="dropdown">
|
|
10
|
-
<button class="btn btn-
|
|
10
|
+
<button class="btn btn-outline-dark d d-inline-flex align-items-center me-2 dropdown-toggle"
|
|
11
11
|
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
12
12
|
<svg class="icon icon-xs me-2" 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="M12 6v6m0 0v6m0-6h6m-6 0H6"></path></svg>
|
|
13
13
|
{% for method in evaluations.0.evaluation %}
|
|
@@ -3,23 +3,18 @@
|
|
|
3
3
|
<script src="{{ ASSETS_ROOT }}/vendor/@popperjs/core/dist/umd/popper.min.js"></script>
|
|
4
4
|
<script src="{{ ASSETS_ROOT }}/vendor/bootstrap/dist/js/bootstrap.min.js"></script>
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
{% comment %}
|
|
7
7
|
<script src="{{ ASSETS_ROOT }}/vendor/onscreen/dist/on-screen.umd.min.js"></script>
|
|
8
8
|
<script src="{{ ASSETS_ROOT }}/vendor/nouislider/distribute/nouislider.min.js"></script>
|
|
9
9
|
<script src="{{ ASSETS_ROOT }}/vendor/vanillajs-datepicker/dist/js/datepicker.min.js"></script>
|
|
10
10
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js"></script>
|
|
11
|
-
|
|
11
|
+
<script src="{{ ASSETS_ROOT }}/vendor/vanillajs-datepicker/dist/js/datepicker.min.js"></script>
|
|
12
|
+
{% endcomment %}
|
|
12
13
|
|
|
13
14
|
<script src="{{ ASSETS_ROOT }}/vendor/smooth-scroll/dist/smooth-scroll.polyfills.min.js"></script>
|
|
14
15
|
|
|
15
16
|
<script src="{{ ASSETS_ROOT }}/vendor/sweetalert2/dist/sweetalert2.all.min.js"></script>
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
<!--
|
|
19
|
-
<script src="{{ ASSETS_ROOT }}/vendor/vanillajs-datepicker/dist/js/datepicker.min.js"></script>
|
|
20
|
-
-->
|
|
21
|
-
|
|
22
|
-
<!-- Notyf -->
|
|
23
18
|
<script src="{{ ASSETS_ROOT }}/vendor/notyf/notyf.min.js"></script>
|
|
24
19
|
|
|
25
20
|
<!-- Simplebar -->
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
<span class="sidebar-icon">
|
|
142
142
|
<svg class="icon icon-xs me-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z" clip-rule="evenodd"></path></svg>
|
|
143
143
|
</span>
|
|
144
|
-
<span class="sidebar-text">
|
|
144
|
+
<span class="sidebar-text">IRiE</span>
|
|
145
145
|
</a>
|
|
146
146
|
</li>
|
|
147
147
|
<li class="nav-item {% if 'settings' in segment %} active {% endif %}">
|
|
@@ -35,25 +35,25 @@
|
|
|
35
35
|
<div class="btn-toolbar mb-2 mb-md-0">
|
|
36
36
|
<a role="button"
|
|
37
37
|
href="/inventory/{{ asset.calid }}"
|
|
38
|
-
class="btn btn-sm btn-
|
|
38
|
+
class="btn btn-sm btn-outline-primary d-inline-flex align-items-center">
|
|
39
39
|
Asset Profile
|
|
40
40
|
</a>
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
43
43
|
|
|
44
44
|
<div class="py-4 align-right">
|
|
45
|
+
{% comment %}
|
|
45
46
|
<a role="button" class="button btn btn-outline-primary"
|
|
46
47
|
href="/inventory/{{ asset.calid }}" class="me-1">Structure Profile</a>
|
|
47
48
|
|
|
48
49
|
{% include 'includes/modal-report.html' with event_summaries=event_summaries %}
|
|
49
|
-
{% comment %}
|
|
50
50
|
{% endcomment %}
|
|
51
51
|
</div>
|
|
52
52
|
|
|
53
53
|
{# BRIDGE RENDER #}
|
|
54
54
|
<div class="row">
|
|
55
55
|
<div class="col-12 mb-4">
|
|
56
|
-
<div class="card h-100 bg-white-100 border-0 shadow">
|
|
56
|
+
<div class="card h-100 bg-white-100 border-0 shadow rounded-sm">
|
|
57
57
|
<div class="card-body p-2">
|
|
58
58
|
<div class="tab-content" id="pills-tabContent">
|
|
59
59
|
<div class="tab-pane fade show active"
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
<div class="row">
|
|
100
100
|
<div class="col-12 col-sm-6 col-xl-4 mb-4">
|
|
101
101
|
{# if false #}
|
|
102
|
-
<div class="card h-100 border-0 shadow">
|
|
102
|
+
<div class="card h-100 border-0 shadow rounded-sm">
|
|
103
103
|
<div class="card-body">
|
|
104
104
|
<div class="col-xs-12">
|
|
105
105
|
<div class="progress mb-3">
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
{# endif #}
|
|
183
183
|
<!-- </div> -->
|
|
184
184
|
<div class="col-12 col-sm-6 col-xl-4 mb-4">
|
|
185
|
-
<div class="card h-100 border-0 shadow">
|
|
185
|
+
<div class="card h-100 border-0 shadow rounded-sm">
|
|
186
186
|
<div class="card-body">
|
|
187
187
|
<div class="col-xs-12">
|
|
188
188
|
<div class="progress mb-3">
|
|
@@ -616,18 +616,18 @@
|
|
|
616
616
|
</div> -->
|
|
617
617
|
{% endif %}
|
|
618
618
|
</div>
|
|
619
|
-
{% comment %}
|
|
620
619
|
<div class="d-block ms-auto">
|
|
621
620
|
<div class="d-flex align-items-center text-end mb-2">
|
|
622
621
|
<span class="dot rounded-circle bg-gray-800 me-2"></span>
|
|
623
|
-
<span class="fw-normal small">
|
|
622
|
+
<span class="fw-normal small">mdof</span>
|
|
624
623
|
</div>
|
|
624
|
+
{% comment %}
|
|
625
625
|
<div class="d-flex align-items-center text-end">
|
|
626
626
|
<span class="dot rounded-circle bg-secondary me-2"></span>
|
|
627
627
|
<span class="fw-normal small">Damping [%]</span>
|
|
628
628
|
</div>
|
|
629
|
+
{% endcomment %}
|
|
629
630
|
</div>
|
|
630
|
-
{% endcomment %}
|
|
631
631
|
</div>
|
|
632
632
|
<div class="card-body p-2">
|
|
633
633
|
<div class="col-xs-12">
|