-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaracteristicas.py
More file actions
187 lines (131 loc) · 5.87 KB
/
caracteristicas.py
File metadata and controls
187 lines (131 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import matplotlib.pyplot as plt
import pandas as pd
from Ler_dados_raytracing_plots import maximum_flux, ler_dados_rt, forward_backward, raytrancing_parametros, read_parameters, pegue_os_parametros
from utils import config_labels, save
def trocando_eixo(ax):
def rate(xx):
if xx >= 24:
return str(int(xx - 24)) + ":00"
else:
return str(int(xx)) + ":00"
ax.set(xticks = ax.get_xticks(),
xlabel = "Horas (UT)",
xlim = ax.get_xlim())
ax.xaxis.set_major_formatter(lambda x, pos: rate(x))
def plot(ax,
df,
hora_inicial,
date_sel,
phase = "descendente",
xcol = "altitude_(metros)",
ycol = "latitude",
alt_emission = 97, color = "blue",
linestyle = "-",
name = "Vento HWM14"):
fo, ba = forward_backward(df,
hora_inicial,
phase = phase)
args = dict(color = color, lw = 2, linestyle = linestyle)
if xcol == "time":
ax.plot(fo[ycol], **args, label = name)
ax.plot(ba[ycol], **args)
ax.plot(hora_inicial, alt_emission, "^",
markersize = 15,
color = "purple")
max_flux_time, max_flux_alt, flux_max, flux10_alt, flux10_time, flux10Menor = maximum_flux(df, phase)
args_sq = dict(marker = "s", color = color, markersize =10)
ax.plot(hora_inicial + max_flux_time, max_flux_alt, **args_sq)
ax.plot(hora_inicial + flux10_time, flux10_alt, fillstyle = "none", **args_sq)
trocando_eixo(ax)
ax.legend()
else:
ax.plot(fo[xcol], fo[ycol], **args, label = name)
ax.plot(ba[xcol], ba[ycol], **args)
ax.legend()
return ax
def plot_caracteristicas(axs,
df,
hora_inicial,
date_sel,
altitude,
phase = "descendente",
color = "blue",
linestyle = "-",
name = "Vento HWM14"):
combinations = [("altitude_(metros)", "time"),
("altitude_(metros)", "longitude"),
("latitude", "altitude_(metros)")]
labels = [("Altitude (km)", "Horas (UT)", "both"),
("Altitude (km)", "Longitude (°)", "x"),
("Latitude (°)", "Altitude (km)", "y")]
letters = ["(a)", "(b)", "(c)"]
for num, ax in enumerate(axs.flat):
ycol, xcol = combinations[num]
ylabel, xlabel, grid = labels[num]
ax.text(0., 1.1,
letters[num],
transform = ax.transAxes)
ax.set(ylabel = ylabel,
xlabel = xlabel)
args = dict(color = 'gray',
linestyle = '--',
linewidth = 0.5)
ax.grid(axis=grid, **args)
ax = plot(ax,
df,
hora_inicial,
date_sel,
xcol = xcol,
ycol = ycol,
phase = phase,
alt_emission = altitude,
color = color,
linestyle = linestyle,
name = name)
def plot_lat_lon_tempo(parameters, dados, num, phase):
hora_inicial, altitude, date_sel = tuple(parameters[num])
colors = ["blue", "red"]
styles = ["-", "--"]
names = ["Vento HWM14", "sem vento"]
parametros = read_parameters(phase, date_sel)
emission, lambdaH, lambdaV, periodo, vel_fase, propagacao = pegue_os_parametros(parametros)
infos = f"$\lambda_H = ${lambdaH} km, $\\tau = $ {periodo} min, $c_H = $ {vel_fase} m/s, $\phi = $ {propagacao}°"
com_vento, sem_vento = dados[num]
fig, axs = plt.subplots(figsize = (12, 10),
nrows = 3)
axs[0].text(0.2, 1.1, infos, transform = axs[0].transAxes)
# altitude = 87
axs[0].axhline(altitude, color = "k", lw = 1,
label = f"Alt. de emissão {altitude} km")
plt.subplots_adjust(hspace = 0.4)
for i, df in enumerate(dados[num]):
plot_caracteristicas(axs,
df,
hora_inicial,
date_sel,
altitude,
phase = phase,
color = colors[i],
linestyle = styles[i],
name = names[i])
path_to_save = f"C:\\Users\\Ander\\OneDrive\\Documentos\\ANDERSON\\a_Programas_raytracing\\{phase}"
path = "C:\\Users\\Ander\\OneDrive\\Documentos\\ANDERSON\\a_Programas_raytracing\\figures\\"
FigureName = f"{phase}_{date_sel.strftime('%Y_%m_%d')}.pdf"
print(FigureName)
#save(fig, path_to_save, FigureName)
fig.savefig(path + FigureName, dpi = 500)
def all_plots(phase = "descendente"):
parameters, dados = raytrancing_parametros(phase, start = None, end = None)
for num in range(len(dados)):
try:
plot_lat_lon_tempo(parameters, dados, num, phase)
except:
continue
def run():
for na in ["descendente", "ascendente"]:
all_plots(phase = na)
phase = "descendente"
parameters, dados = raytrancing_parametros(phase, start = None, end = None)
num = 0
plot_lat_lon_tempo(parameters, dados, num, phase)
all_plots(phase = "ascendente")