Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
41cd4ebb
Commit
41cd4ebb
authored
Oct 20, 2020
by
Bogdan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5Layers demand plot visualisations
parent
0f0e6995
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
8 deletions
+143
-8
similarityMain.py
...oservice/app/processing/similarityFiles/similarityMain.py
+1
-1
visualisationPaper.py
...le-stage-discovery-microservice/app/visualisationPaper.py
+142
-7
No files found.
src/data-hub/role-stage-discovery-microservice/app/processing/similarityFiles/similarityMain.py
View file @
41cd4ebb
...
...
@@ -106,7 +106,7 @@ def main(use_case:str,layerNameList:List[str] ):
outputMongoConnClustDict
(
layerDict
,
runId
)
outputMongoSimilarity
(
similarityDict
,
runId
,
use_case
)
#Currently not used in the calculation of connections/similarity, developed for possible future uses
#connClustersFromMongo = getConnClusterDataFromMongo()
#similarityDictFromMongo = calculateSimilarity(connClustersFromMongo)
...
...
src/data-hub/role-stage-discovery-microservice/app/visualisationPaper.py
View file @
41cd4ebb
###add modules folder to interpreter path
import
sys
import
os
import
requests
import
numpy
as
np
import
matplotlib.pyplot
as
plt
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
######SECURITY#############
# import connecion
# from security import swagger_util
...
...
@@ -26,20 +31,150 @@ repo = Repository()
def
deleteWHOOLEData
():
print
(
"test"
)
repo
.
delete_all_similarity_data
()
def
processData
():
fetchy
.
fetch_nodes_from_semantic_linking
()
clustering
.
run_clustering_for_Paper_case
()
similCalc
.
run_similarity_calc_for_Paper_case
()
def
mainViz
():
# small set
# r = requests.get('https://drive.google.com/uc?export=download&id=1iaiFhwiadViXojYIvK1qkV2Mrf26IXme', timeout=15)
# print("Downloaded JSON")
# inputSimListOfDict = json.loads(r.content)
# big set
print
(
"Opening JSON"
)
with
open
(
'resultSimilarityDictN86400C3388.json'
)
as
json_file
:
inputSimListOfDict
=
json
.
load
(
json_file
)
print
(
"Opened JSON"
)
demandLayerListOfDict
=
[]
for
simDict
in
inputSimListOfDict
:
if
simDict
[
'cluster_layer'
]
==
'Demand_Layer'
:
demandLayerListOfDict
.
append
(
simDict
)
#procesing data
# {
# "cluster1_label": 3,
# "cluster2_label": 5,
# "cluster_layer": "Demand_Layer",
# "similarityValues": {
# "Solar_Production_Layer": 0.0,
# "Energy_Consumption_Layer": 0.0,
# "Heating_Consumption_Layer": 0.0,
# "Price_Layer": 46340.950540531645,
# "Position_Layer": 0.0
# },
# "runId": "5f886e7e35b70a1704c728e6",
# "use_case": "paper"
# },
print
(
"Starting DistribDicts"
)
distributionSolar
=
dict
()
distributionEnergy
=
dict
()
distributionHeating
=
dict
()
distributionPrice
=
dict
()
distributionPosition
=
dict
()
fetchy
.
fetch_nodes_from_semantic_linking
()
clustering
.
run_clustering_for_Paper_case
()
similCalc
.
run_similarity_calc_for_Paper_case
()
#TODO FIX
for
entry
in
demandLayerListOfDict
:
similVal
=
entry
[
'similarityValues'
]
if
checkKey
(
distributionSolar
,
similVal
[
'Solar_Production_Layer'
]):
distributionSolar
[
similVal
[
'Solar_Production_Layer'
]]
+=
1
else
:
if
(
similVal
[
'Solar_Production_Layer'
]
<
45000
):
distributionSolar
[
similVal
[
'Solar_Production_Layer'
]]
=
1
if
checkKey
(
distributionEnergy
,
similVal
[
'Energy_Consumption_Layer'
]):
distributionEnergy
[
similVal
[
'Energy_Consumption_Layer'
]]
+=
1
else
:
if
(
similVal
[
'Energy_Consumption_Layer'
]
<
45000
):
distributionEnergy
[
similVal
[
'Energy_Consumption_Layer'
]]
=
1
if
checkKey
(
distributionHeating
,
similVal
[
'Heating_Consumption_Layer'
]):
distributionHeating
[
similVal
[
'Heating_Consumption_Layer'
]]
+=
1
else
:
if
(
similVal
[
'Heating_Consumption_Layer'
]
<
45000
):
distributionHeating
[
similVal
[
'Heating_Consumption_Layer'
]]
=
1
if
checkKey
(
distributionPrice
,
similVal
[
'Price_Layer'
]):
distributionPrice
[
similVal
[
'Price_Layer'
]]
+=
1
else
:
if
(
similVal
[
'Price_Layer'
]
<
45000
):
distributionPrice
[
similVal
[
'Price_Layer'
]]
=
1
if
checkKey
(
distributionPosition
,
similVal
[
'Position_Layer'
]):
distributionPosition
[
similVal
[
'Position_Layer'
]]
+=
1
else
:
if
(
similVal
[
'Position_Layer'
]
<
45000
):
distributionPosition
[
similVal
[
'Position_Layer'
]]
=
1
print
(
"
\n
FinishedListDistrib
\n
"
)
#TRY TO PLOT
fig
,
axs
=
plt
.
subplots
(
1
,
5
,
sharex
=
True
)
fig
.
suptitle
(
'Choose A title??? '
)
fig
.
text
(
0.5
,
0.04
,
'Euclidean Distance'
,
ha
=
'center'
,
va
=
'center'
)
list1
=
sorted
(
distributionSolar
.
items
())
x2
,
y2
=
zip
(
*
list1
)
axs
[
0
]
.
bar
(
x2
,
y2
,
color
=
'purple'
,
label
=
"Solar"
,
width
=
0.2
)
axs
[
0
]
.
legend
()
axs
[
0
]
.
set_title
(
'Solar'
)
axs
[
0
]
.
set
(
ylabel
=
'Nr. of Similarity connections between two Clusters'
)
list1
=
sorted
(
distributionEnergy
.
items
())
x
,
y
=
zip
(
*
list1
)
axs
[
1
]
.
bar
(
x
,
y
,
color
=
'blue'
,
label
=
"Energy"
,
width
=
0.2
)
axs
[
1
]
.
legend
()
list1
=
sorted
(
distributionHeating
.
items
())
x3
,
y3
=
zip
(
*
list1
)
axs
[
2
]
.
bar
(
x3
,
y3
,
color
=
'red'
,
label
=
"Heating"
,
width
=
0.2
)
axs
[
2
]
.
legend
()
list1
=
sorted
(
distributionPrice
.
items
())
x4
,
y4
=
zip
(
*
list1
)
axs
[
3
]
.
bar
(
x4
,
y4
,
color
=
'green'
,
label
=
"Price"
,
width
=
0.2
)
axs
[
3
]
.
legend
()
list1
=
sorted
(
distributionPosition
.
items
())
x5
,
y5
=
zip
(
*
list1
)
axs
[
4
]
.
bar
(
x5
,
y5
,
color
=
'grey'
,
label
=
"Location"
,
width
=
0.2
)
axs
[
4
]
.
legend
()
plt
.
show
()
print
(
"FIN"
)
print
(
"
\n
"
)
#inputData.getClusterDataFromMongo("Paper",None,None)
#inputData.getSimilarityDataFromMongo(cluster_layer: str= None, batchSize: int=1000, run_id: str=None)
#similarityArrFromMongo = getSimilarityDataFromMongo("Paper")
deleteWHOOLEData
()
mainViz
()
\ No newline at end of file
def
checkKey
(
dict
,
key
):
if
key
in
dict
.
keys
():
#print("Present, ", end =" ")
#print(str(key)+ " : " + str(dict[key] ))
return
True
else
:
#print("Not present")
return
False
#deleteWHOOLEData()
#processData()
mainViz
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment