Skip to content

Commit cde6edc

Browse files
authored
Mergin Frontend with main (#7)
* Need to add Disclaimer and active tab color. * Also add comments to css * Added Disclaimer. Active tab and comments missing. * active tabs and length of page correction. * . * Adjusted the text on home * Removed unnecessary test script * Dynamic Figure width & result output
1 parent 989f294 commit cde6edc

30 files changed

+2348
-1229
lines changed

.vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "pwa-chrome",
9+
"request": "launch",
10+
"name": "Launch Chrome against localhost",
11+
"url": "http://localhost:8080",
12+
"webRoot": "${workspaceFolder}"
13+
}
14+
]
15+
}

db.sqlite3

176 KB
Binary file not shown.

lectureformat/lecture.py

+38-40
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import matplotlib.pyplot as plt
66
from scipy import stats
77
from scipy import interpolate
8-
import pandas as pd
98

109
from .models import *
1110

@@ -100,14 +99,24 @@ def __init__(self, num_stud, **kwargs):
10099
}
101100
self.debug_figures = {}
102101

102+
self.min_stud_online = None
103+
self.min_stud_offline = None
104+
self.min_stud_online_notransp = None
105+
self.min_stud_offline_notransp = None
106+
107+
self.res_cons = None
108+
self.res_cons_err = None
109+
self.res_cons_notransp = None
110+
self.res_cons_err_notransp = None
111+
103112
return
104113

105114
def get_hybrid_figure(self, grid, cons, cons_std, interp_grid):
106115
if "notransport" in self.options:
107116
notrans = 0
108117
notrans_std = 0
109118

110-
fig = plt.figure(figsize=[7.5, 4.8])
119+
fig = plt.figure(figsize=[6.4, 4.8])
111120
p = max(grid)
112121

113122
def online(x):
@@ -175,7 +184,7 @@ def onsite(x):
175184
)
176185

177186
# Put a legend to the right of the current axis
178-
plt.gca().legend(loc="center left", bbox_to_anchor=(1.05, 0.3))
187+
fig.legend(loc="upper center", ncol=2, bbox_to_anchor=(0.5, 0))
179188

180189
if "logplot" in self.options:
181190
plt.ylabel("log(Consumption per lecture) (kWh)")
@@ -196,52 +205,35 @@ def onsite(x):
196205

197206
plt.tight_layout()
198207

199-
# these are matplotlib.patch.Patch properties
200-
props = dict(boxstyle="round", alpha=0.5)
201-
208+
# Set values for result cards
209+
self.min_stud_online = grid[minind]
210+
self.min_stud_offline = max(grid) - grid[minind]
211+
self.res_cons = min_cons
212+
self.res_cons_err = min_std
202213
if "notransport" in self.options:
203214
min_ind_nt = np.where(notrans == min(notrans))
204215
min_cons_nt = notrans[min_ind_nt]
205216
min_std_nt = np.sqrt(notrans_std[min_ind_nt])
206-
textstr = "Optimal mode:\n- %d students online\n- %d students on-site\n- Total consumption: %.2f $\pm$ %.2f$\,$kWh\n\n" % (
207-
grid[minind],
208-
max(grid) - grid[minind],
209-
min_cons,
210-
min_std,
211-
) + "Without transportation:\n- %d students online\n- %d students on-site\n- Consumption: %.2f $\pm$ %.2f$\,$kWh" % (
212-
grid[min_ind_nt],
213-
max(grid) - grid[min_ind_nt],
214-
min_cons_nt,
215-
min_std_nt,
216-
)
217-
else:
218-
textstr = (
219-
"Optimal mode:\n- %d students online\n- %d students on-site\n- Total consumption: %.2f $\pm$ %.2f$\,$kWh"
220-
% (grid[minind], max(grid) - grid[minind], min_cons, min_std)
221-
)
222-
223-
# place a text box in upper left in axes coords
224-
txt = plt.gca().text(
225-
1.05,
226-
1.15,
227-
textstr,
228-
transform=plt.gca().transAxes,
229-
fontsize=14,
230-
verticalalignment="top",
231-
bbox=props,
232-
)
217+
self.min_stud_online_notransp = grid[min_ind_nt]
218+
self.min_stud_offline_notransp = max(grid) - grid[min_ind_nt]
219+
self.res_cons_notransp = min_cons_nt
220+
self.res_cons_err_notransp = min_std_nt
233221

234222
imgdata = io.StringIO()
235223
fig.savefig(
236224
imgdata,
237225
format="svg",
238226
bbox_inches="tight",
239-
bbox_extra_artists=(txt,),
240227
dpi=600,
241228
)
242229
imgdata.seek(0)
243230

244231
data = imgdata.getvalue()
232+
233+
# TODO Remove hardcoded string in favour for regex
234+
data = data.replace('width="452.799029pt"', 'width="100%"')
235+
data = data.replace('height="415.189062pt"', 'height="100%"')
236+
245237
return data
246238

247239
def get_random_living_consumption(
@@ -447,8 +439,6 @@ def get_consumption(
447439

448440
if mode == "online-streaming" or mode == "online-vod":
449441
# Calculation of the consumption for an online lecture
450-
# TODO Make sure that the calculation makes sense
451-
452442
# Streaming service
453443
if mode == "online-streaming":
454444
if self.streaming is None:
@@ -525,6 +515,12 @@ def get_consumption(
525515
consumption += c
526516
stat_uncertainty += s**2
527517

518+
self.res_cons = consumption
519+
self.res_cons_err = np.sqrt(stat_uncertainty)
520+
521+
self.res_cons_notransp = consumption - self.contribs["Transportation"][0]
522+
self.res_cons_err_notransp = np.sqrt(stat_uncertainty - self.contribs_std["Transportation"][0] ** 2)
523+
528524
return consumption, np.sqrt(stat_uncertainty)
529525

530526
if mode == "offline":
@@ -615,6 +611,12 @@ def get_consumption(
615611

616612
self.num_stud = num_stud_bak
617613

614+
self.res_cons = consumption
615+
self.res_cons_err = np.sqrt(stat_uncertainty)
616+
617+
self.res_cons_notransp = consumption - self.contribs["Transportation"][0]
618+
self.res_cons_err_notransp = np.sqrt(stat_uncertainty - self.contribs_std["Transportation"][0] ** 2)
619+
618620
return consumption, np.sqrt(stat_uncertainty)
619621

620622
if mode == "hybrid-streaming" or mode == "hybrid-vod":
@@ -709,10 +711,6 @@ def get_consumption(
709711
# Reset number of studenst
710712
self.num_stud = num_stud_bak
711713

712-
# Find optimal hybrid fraction
713-
cons = np.array(cons)
714-
cons_std = np.array(cons_std)
715-
716714
# Interpolate consumption values
717715
x = np.arange(self.num_stud + 1)
718716
func = interpolate.interp1d(grid, cons)

lectureformat/static/css/about.css

+135-12
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
background-attachment: fixed;
55
background-size: cover;
66

7-
height: 1000px;
8-
padding-top: 22rem;
7+
height: 1050px;
8+
padding-top: 8rem;
99

1010
text-align: center;
1111
}
@@ -26,20 +26,36 @@
2626
background-attachment: fixed;
2727
background-size: cover;
2828

29-
height: 1000px;
30-
padding-top: 2rem;
31-
32-
33-
29+
height: 1250px;
30+
padding-top: 0rem;
3431

3532
text-align: center;
3633
}
37-
.earth {
34+
.aboutimg {
35+
display: block;
3836
height: auto;
39-
width: 700px;
37+
width: 100%;
4038

41-
margin-top: -12rem;
39+
margin-top: -15rem;
40+
margin-left: auto;
41+
margin-right: auto;
42+
}
43+
.about3 .editimg {
44+
margin-top: -5rem;
45+
}
4246

47+
.about .col2 {
48+
margin-top: 10rem;
49+
}
50+
.about2 .col1 {
51+
margin-top: 25rem;
52+
}
53+
.about2 .col2 {
54+
margin-top: -62rem;
55+
margin-bottom: -10rem;
56+
}
57+
.about3 .col2 {
58+
margin-top: 30rem;
4359
}
4460
.about3 button {
4561
background: #18A0FB;
@@ -57,9 +73,116 @@
5773

5874
width: 173px;
5975
height: 34px;
76+
77+
z-index: 99;
6078
}
6179

6280
.about3 button:hover {
63-
transform: scale(1.1);
81+
transform: scale(.98);
6482
transition: all .2s ease-in-out;
65-
}
83+
}
84+
85+
@media (min-width: 768px) {
86+
.about3 .col1 {
87+
margin-bottom: -10rem;
88+
}
89+
90+
.aboutimg {
91+
height: auto;
92+
width: 80%;
93+
94+
margin-top: -15rem;
95+
margin-left: auto;
96+
margin-right: auto;
97+
98+
}
99+
.about2 .editimg {
100+
margin-top: -18rem;
101+
}
102+
.about3 .editimg {
103+
margin-top: 2rem;
104+
}
105+
}
106+
@media (min-width: 992px) {
107+
.aboutimg {
108+
height: auto;
109+
width: 70%;
110+
111+
margin-top: -20rem;
112+
margin-left: auto;
113+
margin-right: auto;
114+
115+
116+
}
117+
.about2 .editimg {
118+
margin-top: -25rem;
119+
}
120+
.about3 .editimg {
121+
margin-top: -7rem;
122+
}
123+
}
124+
@media (min-width: 1200px) {
125+
.about {
126+
background: transparent;
127+
background-repeat: no-repeat;
128+
background-attachment: fixed;
129+
background-size: cover;
130+
131+
height: 1050px;
132+
padding-top: 22rem;
133+
134+
text-align: center;
135+
}
136+
.about2 {
137+
background: #A9BA88;
138+
background-repeat: no-repeat;
139+
background-attachment: fixed;
140+
background-size: cover;
141+
142+
height: 1000px;
143+
padding-top: 15rem;
144+
145+
text-align: center;
146+
}
147+
.about3 {
148+
background: transparent;
149+
background-repeat: no-repeat;
150+
background-attachment: fixed;
151+
background-size: cover;
152+
153+
height: 1000px;
154+
padding-top: 2rem;
155+
156+
text-align: center;
157+
}
158+
159+
.aboutimg {
160+
height: auto;
161+
width: 110%;
162+
163+
margin-top: -5rem;
164+
margin-left: auto;
165+
margin-right: auto;
166+
167+
}
168+
.about2 .editimg {
169+
margin-top: -10rem;
170+
}
171+
.about3 .editimg {
172+
margin-top: 7rem;
173+
}
174+
.about .col2 {
175+
margin-top: 0rem;
176+
}
177+
.about2 .col1 {
178+
margin-top: 0rem;
179+
}
180+
.about2 .col2 {
181+
margin-top: 0rem;
182+
margin-bottom: 0rem;
183+
}
184+
.about3 .col2 {
185+
margin-top: 0rem;
186+
}
187+
188+
}

0 commit comments

Comments
 (0)