Commit e5246f65 authored by Romain Creuzenet's avatar Romain Creuzenet

Cluster finish'

parent 2c17dd6c
......@@ -2,8 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="dec891dc-2fad-4291-af33-64d4fd64029d" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/parameters.py" beforeDir="false" afterPath="$PROJECT_DIR$/parameters.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -16,7 +16,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/create_table.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<state relative-caret-position="279">
<caret line="51" column="17" selection-start-line="51" selection-start-column="17" selection-end-line="51" selection-end-column="17" />
</state>
</provider>
......@@ -25,12 +25,10 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="659">
<caret line="297" column="51" selection-start-line="297" selection-start-column="51" selection-end-line="297" selection-end-column="51" />
<state relative-caret-position="439">
<caret line="296" column="14" selection-start-line="296" selection-start-column="14" selection-end-line="296" selection-end-column="14" />
<folding>
<element signature="e#45#96#0" expanded="true" />
<element signature="e#3287#4955#0" />
<element signature="e#4984#7500#0" />
<element signature="e#45#107#0" expanded="true" />
</folding>
</state>
</provider>
......@@ -48,8 +46,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/parameters.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
<caret line="15" column="1" lean-forward="true" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
<state relative-caret-position="-443">
<caret line="15" column="1" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
</state>
</provider>
</entry>
......@@ -101,7 +99,17 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="ProjectPane" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="nf26_projet" type="b2602c69:ProjectViewProjectNode" />
<item name="nf26_projet" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
......@@ -139,7 +147,7 @@
<frame x="67" y="25" width="1853" height="1055" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.16229509" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.16229509" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
......@@ -213,9 +221,16 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/env_nf26/lib/python3.6/site-packages/cassandra/cluster.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="291">
<caret line="140" column="8" selection-start-line="140" selection-start-column="8" selection-end-line="140" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/create_table.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<state relative-caret-position="279">
<caret line="51" column="17" selection-start-line="51" selection-start-column="17" selection-end-line="51" selection-end-column="17" />
</state>
</provider>
......@@ -227,28 +242,19 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/env_nf26/lib/python3.6/site-packages/cassandra/cluster.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="291">
<caret line="140" column="8" selection-start-line="140" selection-start-column="8" selection-end-line="140" selection-end-column="8" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/parameters.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
<caret line="15" column="1" lean-forward="true" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
<state relative-caret-position="-443">
<caret line="15" column="1" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="659">
<caret line="297" column="51" selection-start-line="297" selection-start-column="51" selection-end-line="297" selection-end-column="51" />
<state relative-caret-position="439">
<caret line="296" column="14" selection-start-line="296" selection-start-column="14" selection-end-line="296" selection-end-column="14" />
<folding>
<element signature="e#45#96#0" expanded="true" />
<element signature="e#3287#4955#0" />
<element signature="e#4984#7500#0" />
<element signature="e#45#107#0" expanded="true" />
</folding>
</state>
</provider>
......
......@@ -16,7 +16,7 @@ import numpy as np
# Graph map
from mpl_toolkits.basemap import Basemap
from pandas.plotting import register_matplotlib_converters
from datetime import datetime
from datetime import datetime, timedelta
register_matplotlib_converters()
warnings.filterwarnings("ignore")
......@@ -258,25 +258,31 @@ class Manager:
print("Entrez le nombre de cluster voulus")
nb_cluster = ask_int()
# Calc of mean
query = "SELECT station, lon, lat, {attr} FROM {table} WHERE time >= {begin} AND time <= {end} " \
"ALLOW FILTERING".format(
attr=", ".join(ATTRIBUTS.keys()),
table=self.table,
begin=date_begin,
end=date_end
)
stations = {} # station: {'nb': 3, 'attr1': 5, 'attr2': 7, ..., 'lon': 3.27, 'lat': 12}
for row in execute_query(query):
if None in [row.station, row.lon, row.lat] + [getattr(row, attr) for attr in ATTRIBUTS.keys()]:
continue
if row.station in stations:
datetime_begin = datetime(*list(date_begin)) # Convert datetime
datetime_end = datetime(*list(date_end)) # Convert datetime
while datetime_begin <= datetime_end:
print("Données récupérée pour {}".format(datetime_begin.strftime("%Y-%m-%d %H:%M")), end="\r")
# Calc of mean
query = "SELECT station, lon, lat, {attr} FROM {table} WHERE time = {date}".format(
attr=", ".join(ATTRIBUTS.keys()),
table=self.table,
date=(datetime_begin.year, datetime_begin.month, datetime_begin.day, datetime_begin.hour,
datetime_begin.minute)
)
for row in execute_query(query):
if None in [row.station, row.lon, row.lat] + [getattr(row, attr) for attr in ATTRIBUTS.keys()]:
continue
if row.station not in stations:
stations[row.station] = {'nb': 0, 'lon': row.lon, 'lat': row.lat,
**{key: 0 for key in ATTRIBUTS.keys()}}
for attr in ATTRIBUTS.keys():
stations[row.station][attr] += getattr(row, attr)
stations[row.station]['nb'] += 1
else:
stations[row.station] = {'nb': 1, 'lon': row.lon, 'lat': row.lat,
**{key: 0 for key in ATTRIBUTS.keys()}}
datetime_begin += timedelta(minutes=1)
for value in stations.values():
for attr in ATTRIBUTS.keys():
value[attr] = value[attr] / value['nb']
......@@ -288,6 +294,8 @@ class Manager:
for _ in range(nb_cluster)
]
print()
print("Clusterisation...")
while old_centroids != new_centroids:
old_centroids = new_centroids
data = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment