Skip to content

Commit

Permalink
QoL update
Browse files Browse the repository at this point in the history
  • Loading branch information
leoid3 committed Oct 24, 2024
1 parent 7807879 commit 10f5845
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
Binary file modified code/classes/__pycache__/gui.cpython-311.pyc
Binary file not shown.
24 changes: 19 additions & 5 deletions code/classes/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from satellite_tle import fetch_tle_from_celestrak
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.patches import Patch
from tkcalendar import DateEntry
import numpy as np
from datetime import timedelta, datetime
Expand All @@ -22,7 +23,6 @@
from functions.country import get_country_name, get_poly_coordinate
from functions.coordinates_converter import latlong_to_cartesian
from functions.save_result import save_gs_visibility, save_poi_visibility, general_result
from functions.find_tm import centroid
from functions.itur_model import get_attenuation

#############################################################################################
Expand Down Expand Up @@ -1422,12 +1422,22 @@ def poi_visibility(self, miss, chosen_sat):
elevation_fin = zenith_angle.loc[date_fin.strftime("%Y-%m-%d %H:%M:%S")].elevation
mean_elevation = (elevation_ini+elevation_fin)/2
visibility.append((chosen_sat.get_name(), poi.get_name(), date_ini, date_fin, delta.seconds, mean_elevation))

sza_condition = []
for i in range(len(visibility)):
if visibility[i][5] >= miss.get_minsza():
sza_condition.append(True)
else:
sza_condition.append(False)
sza_color = ['green' if condition else 'red' for condition in sza_condition]
#Plot les durées de visibilité
ax_2D_3 = fig2d.add_subplot(313)
ax_2D_3.bar([date.strftime('%Y-%m-%d %H:%M:%S') for date in date_ini_list], timedelta_list, width=0.35, color=list_colors, align='center')
ax_2D_3.bar([date.strftime('%Y-%m-%d %H:%M:%S') for date in date_ini_list], timedelta_list, width=0.35, color=sza_color, align='center')
ax_2D_3.set_ylabel('Times (s)')
ax_2D_3.legend()
legend_patches = [
Patch(color='green', label=f'Date meeting SZA >= {miss.get_minsza()}'),
Patch(color='red', label=f'Date not meeting SZA >= {miss.get_minsza()}')
]
ax_2D_3.legend(handles=legend_patches)
plt.title(f"Visibilities duration at {poi.get_name()} with a swath of {chosen_sat.get_swath()} km")
plt.grid(True)
plt.xticks(rotation=45)
Expand Down Expand Up @@ -1477,16 +1487,19 @@ def visibility_grid(self, poi, chosen_sat, miss):
green = Line2D([0], [0], marker='o', color='w', markerfacecolor='green', markersize=10, label='Observation possible')
orange = Line2D([0], [0], marker='o', color='w', markerfacecolor='orange', markersize=10, label='Area visible but minimum sza not reached')
red =Line2D([0], [0], marker='o', color='w', markerfacecolor='red', markersize=10, label='Observation impossible')
prct = 0
for i in range(len(square_visible)):
if square_visible[i][0]:
if square_visible[i][1]:
gpd.GeoSeries(square_visible[i][2]).plot(ax=ax, color="green")
prct += 1
else:
gpd.GeoSeries(square_visible[i][2]).plot(ax=ax, color="orange")
else:
gpd.GeoSeries(square_visible[i][2]).plot(ax=ax, color="red")
ax.legend(handles=[green, orange, red])
plt.title(f"Visibility map of {poi.get_name()}")
prct = (prct*100)/len(square_visible)
plt.title(f"{prct:.2f}% of {poi.get_name()} covered during the simulation ")
fig.savefig(result_folder / miss.get_name() / f"Result {poi.get_name()} visibility ({chosen_sat.get_name()}) figure.png")

def save_result(self):
Expand Down Expand Up @@ -1562,6 +1575,7 @@ def save_result(self):
gs_visibility.append((sat[j].get_name(), len(interval)))
gs_opportunities.append((gs[i].get_name(), gs_visibility))
general_result(mission, gs_opportunities, poi_opportunities)
showinfo("Message", "Mission report created successfully")

#############################################################################################
# Additional windows
Expand Down
Binary file modified code/functions/__pycache__/save_result.cpython-311.pyc
Binary file not shown.
14 changes: 9 additions & 5 deletions code/functions/save_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ def plot_result_gs(opportunities):

def plot_result_poi(opportunities):
temp = opportunities
visi_list = []
color = []

if temp[1][0][0]:
visi_list = []
color = []
fig, ax = plt.subplots(figsize=(15, 15))
if temp[1][1][4]:
grid_poi = temp[1][1][3]
Expand Down Expand Up @@ -176,21 +177,24 @@ def plot_result_poi(opportunities):
pass
if i==0:
color.append(color_temp)
prct = 0
for i in range(len(color)):
for j in range(len(color[i])):
if color[i][j][0]==2:
gpd.GeoSeries(color[i][j][1]).plot(ax=ax, color="green")
prct += 1
elif color[i][j][0]==1:
gpd.GeoSeries(color[i][j][1]).plot(ax=ax, color="orange")
else:
gpd.GeoSeries(color[i][j][1]).plot(ax=ax, color="red")
green = Line2D([0], [0], marker='o', color='w', markerfacecolor='green', markersize=10, label='Observation possible')
orange = Line2D([0], [0], marker='o', color='w', markerfacecolor='orange', markersize=10, label='Area visible but minimum sza not reached')
red =Line2D([0], [0], marker='o', color='w', markerfacecolor='red', markersize=10, label='Observation impossible')
prct = (prct*100)/len(color[0])
ax.legend(handles=[green, orange, red])
ax.set_title(f"Visibility map of {title}")
fig.savefig(result_folder / mission.get_name() / f"Visibility at {title}.png", bbox_inches='tight')
img = Image(result_folder / mission.get_name() / f"Visibility at {title}.png", width=400, height=300)
ax.set_title(f"{prct:.2f}% of {title} covered during the simulation ")
fig.savefig(result_folder / mission.get_name() / f"Coverage map of {title}.png", bbox_inches='tight')
img = Image(result_folder / mission.get_name() / f"coverage map of {title}.png", width=400, height=300)
return img
else:
fig2d = plt.figure(figsize=(10, 6))
Expand Down

0 comments on commit 10f5845

Please sign in to comment.