Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
co2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tools
co2
Commits
48b8eb86
Commit
48b8eb86
authored
11 months ago
by
Berinda van Dijk
Browse files
Options
Downloads
Patches
Plain Diff
Noodzakelijke aanpassingen
parent
3362a985
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#13424
passed
11 months ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
generate.py
+19
-31
19 additions, 31 deletions
generate.py
with
19 additions
and
31 deletions
generate.py
+
19
−
31
View file @
48b8eb86
...
...
@@ -16,6 +16,7 @@ df = pd.concat(li, axis=0, ignore_index=True)
df
.
drop_duplicates
(
inplace
=
True
)
df
[
'
datetime
'
]
=
pd
.
to_datetime
(
df
[
'
datetime
'
])
df
=
df
.
sort_values
(
by
=
'
datetime
'
).
reset_index
(
drop
=
True
)
def
get_by_metadata
(
metadata_id
):
...
...
@@ -30,49 +31,36 @@ last_date = co2.index[-1]
def
extendIndex
(
item
):
#extend data
if
item
.
index
[
-
1
]
<
last_date
:
last_item
=
item
[
item
.
index
[
-
1
]]
item
.
at
[
last_date
]
=
last_item
item
.
at
[
last_date
]
=
item
[
item
.
index
[
-
1
]]
if
item
.
index
[
0
]
>
first_date
:
first_item
=
item
[
item
.
index
[
0
]]
item
.
at
[
first_date
]
=
first_item
item
.
at
[
first_date
]
=
item
[
item
.
index
[
0
]]
booleans
=
{
'
Raam open
'
:
420
,
'
Ventilator aan
'
:
2295
,
}
fig
=
make_subplots
(
rows
=
len
(
booleans
)
+
1
,
cols
=
1
,
shared_xaxes
=
True
)
co2_trace
=
go
.
Scatter
(
x
=
co2
.
index
,
y
=
co2
.
values
,
mode
=
'
lines
'
,
name
=
'
Co2
'
)
# Add traces to figure
#Co2 krijgt de helft van de ruimte, de rest is voor de booleans.
rijhoogtes
=
[
0.5
]
rijhoogtes
.
extend
([
0.5
/
len
(
booleans
)]
*
len
(
booleans
))
fig
=
make_subplots
(
rows
=
len
(
booleans
)
+
1
,
cols
=
1
,
shared_xaxes
=
True
,
row_heights
=
rijhoogtes
)
#Co2
co2_trace
=
go
.
Scatter
(
x
=
co2
.
index
,
y
=
co2
.
values
,
mode
=
'
lines
'
,
name
=
"
Co2
"
)
fig
.
add_trace
(
co2_trace
,
row
=
1
,
col
=
1
)
fig
.
update_yaxes
(
title_text
=
'
Co2
'
,
row
=
1
,
rangemode
=
'
tozero
'
,
fixedrange
=
True
)
#Boolean-variabelen
for
index
,
key
in
enumerate
(
booleans
):
item
=
get_by_metadata
(
booleans
[
key
]).
replace
({
"
off
"
:
False
,
'
on
'
:
True
})
extendIndex
(
item
)
trace
=
go
.
Scatter
(
x
=
item
.
index
,
y
=
item
.
values
.
astype
(
float
),
mode
=
'
lines
'
,
name
=
key
,
line_shape
=
'
hv
'
)
fig
.
add_trace
(
trace
,
row
=
index
+
2
,
col
=
1
)
fig
.
update_yaxes
(
row
=
index
+
2
,
title_text
=
key
,
fixedrange
=
True
,
tickvals
=
[
0
,
1
],
ticktext
=
[
"
nee
"
,
"
ja
"
],
showgrid
=
False
)
fig
.
update_xaxes
(
row
=
index
+
2
,
range
=
[
first_date
,
last_date
],
rangeslider
=
dict
(
visible
=
False
))
# Customize layout
fig
.
update_layout
(
xaxis
=
dict
(
tickmode
=
'
linear
'
,
tick0
=
co2
.
index
[
0
],
dtick
=
86400000
*
7
,
# milliseconds in a day * 7 (for weekly ticks)
tickformat
=
'
%a %d %d
'
,
tickangle
=-
45
),
yaxis
=
dict
(
title
=
'
Co2
'
),
autosize
=
True
,
margin
=
dict
(
l
=
50
,
r
=
50
,
t
=
50
,
b
=
50
),
)
for
index
,
key
in
enumerate
(
booleans
):
fig
.
update_yaxes
(
title_text
=
key
,
row
=
index
+
2
,
col
=
1
)
# Update shared axis settings
fig
.
update_layout
(
xaxis
=
dict
(
domain
=
[
0
,
1
],
rangeslider
=
dict
(
visible
=
False
)))
fig
.
update_xaxes
(
title_text
=
"
Date
"
,
row
=
len
(
booleans
)
+
1
,
col
=
1
)
fig
.
update_xaxes
(
range
=
[
co2
.
index
[
0
],
co2
.
index
[
-
1
]],
row
=
2
,
col
=
1
)
fig
.
update_layout
(
autosize
=
True
,
showlegend
=
False
,
margin
=
dict
(
l
=
50
,
r
=
50
,
t
=
50
,
b
=
50
),)
fig
.
write_html
(
"
output/all.html
"
,
include_plotlyjs
=
'
cdn
'
)
fig
.
write_html
(
"
output/all.html
"
,
include_plotlyjs
=
'
cdn
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment