Commit 26305be1 authored by sim-baz's avatar sim-baz
Browse files

Details

parent 86c8b86e
...@@ -123,18 +123,24 @@ def plotHistory(station, indicator, dateMin, dateMax): ...@@ -123,18 +123,24 @@ def plotHistory(station, indicator, dateMin, dateMax):
# Plot, with both measures and season mean # Plot, with both measures and season mean
fig, ax1 = plt.subplots() fig, ax1 = plt.subplots()
# Measures on axis 1 # Measures on axis 1
ax1.plot_date(table_mean.keys(), table_mean.values(), '-', xdate = True) ax1.plot_date(table_mean.keys(), table_mean.values(), '-', xdate = True, label = 'Evolution')
ax1.xaxis.set_ticks(graduation) ax1.xaxis.set_ticks(graduation)
ax2 = ax1.twiny() ax2 = ax1.twiny()
# Seasonal mean # Seasonal mean
ax2.plot([elt[0] for elt in liste], [elt[1] for elt in liste], '-', color = "r") ax2.plot([elt[0] for elt in liste], [elt[1] for elt in liste], '-', color = "r", label = 'Saison')
# Do not show graduation on the top of the plot # Do not show graduation on the top of the plot
ax2.xaxis.set_ticks([]) ax2.xaxis.set_ticks([])
# Set title and labels # Set title and labels
plt.title(f"Evolution de {indicator} pour la station {station}") plt.title(f"Evolution de {indicator} pour la station {station}")
plt.xlabel('Date') ax1.set_xlabel('Date')
plt.ylabel(indicator) ax1.set_ylabel(indicator)
# Legend
h1, l1 = ax1.get_legend_handles_labels()
h2, l2 = ax2.get_legend_handles_labels()
plt.legend(h1+h2, l1+l2, loc='lower right')
plt.tick_params( plt.tick_params(
axis='x', axis='x',
which='both', which='both',
......
...@@ -135,9 +135,9 @@ def kmeans(startPeriod, endPeriod, indicators_list): ...@@ -135,9 +135,9 @@ def kmeans(startPeriod, endPeriod, indicators_list):
station_with_center = applyKmeans(table_deciles, nb_indicators, indicators_list_numeric, startPeriod, endPeriod) station_with_center = applyKmeans(table_deciles, nb_indicators, indicators_list_numeric, startPeriod, endPeriod)
if station_with_center != None: if station_with_center != None:
file_name = f"{startPeriod} to {endPeriod}.html" file_name = f"map_kmeans_{startPeriod}_to_{endPeriod}.html"
# Create map # Create map
m = folium.Map(location=[64.2815, 27.6753]) m = folium.Map(location=[64.2815, 27.6753], zoom_start = 5)
# Add Marker for each station # Add Marker for each station
for key, value in station_with_center.items(): for key, value in station_with_center.items():
folium.Marker([coord[key][0], coord[key][1]], popup=f"<b>{key}</b>", icon=folium.Icon(color=colours[value])).add_to(m) folium.Marker([coord[key][0], coord[key][1]], popup=f"<b>{key}</b>", icon=folium.Icon(color=colours[value])).add_to(m)
......
...@@ -368,18 +368,18 @@ if __name__ == '__main__': ...@@ -368,18 +368,18 @@ if __name__ == '__main__':
dict = loadata(FILE_NAME) dict = loadata(FILE_NAME)
# # -------------------------------------------------------- # --------------------------------------------------------
# # A faire seulement 1 fois pour charger les données # A faire seulement 1 fois pour charger les données
# session.execute(dropTableQuery(table_name_space)) session.execute(dropTableQuery(table_name_space))
# print(f"Table {table_name_space} dropped") print(f"Table {table_name_space} dropped")
# session.execute(createTableQuery(table_name_space)) session.execute(createTableQuery(table_name_space))
# print(f"Table {table_name_space} created") print(f"Table {table_name_space} created")
# print(f"Starting inserting datas into table {table_name_space}") print(f"Starting inserting datas into table {table_name_space}")
# for d in dict: for d in dict:
# session.execute(insertQueryData(d, table_name_space)) session.execute(insertQueryData(d, table_name_space))
# print(f"Datas inserted into {table_name_space}") print(f"Datas inserted into {table_name_space}")
# # -------------------------------------------------------- # --------------------------------------------------------
# -------------------------------------------------------- # --------------------------------------------------------
# A faire seulement 1 fois pour charger les données # A faire seulement 1 fois pour charger les données
......
...@@ -52,9 +52,9 @@ def mapIndicator(date, indicators): ...@@ -52,9 +52,9 @@ def mapIndicator(date, indicators):
print(f"Aucune donnée pour pour le jour : {year}-{month}-{day}") print(f"Aucune donnée pour pour le jour : {year}-{month}-{day}")
return return
else: else:
file_name = f"{year}-{month}-{day}.html" file_name = f"map_for_{year}-{month}-{day}.html"
# Create map # Create map
m = folium.Map(location=[64.2815, 27.6753]) m = folium.Map(location=[64.2815, 27.6753], zoom_start = 5)
# Add Marker for each station # Add Marker for each station
for d in data: for d in data:
text = '' text = ''
......
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