Exemplo n.º 1
0
fila, hoja_parametros, hoja_MVA, hoja_Bootstrap, hoja_Ajuste = importar_fila(
    year, month, day, doy, ti)
normal = [
    float(hoja_MVA.cell(fila, 16).value),
    float(hoja_MVA.cell(fila, 17).value),
    float(hoja_MVA.cell(fila, 18).value),
]

t1 = float(hoja_parametros.cell(fila, 6).value)
t2 = float(hoja_parametros.cell(fila, 7).value)
t3 = float(hoja_parametros.cell(fila, 8).value)
t4 = float(hoja_parametros.cell(fila, 9).value)

mag, t_mag_entero, B_entero, posicion = importar_mag_1s(
    year, month, day, ti, tf)
swia, t_swia_entero, density, temperature, vel_mso_xyz = importar_swia(
    year, month, day, ti, tf)
"""
giroradio: rg = mp * v_perp / (q_e * B)  en la región upstream
where vperp is the component of the velocity perpendicular to the
direction of the magnetic field and B is the strength of the magnetic field
"""
# selecciono la región upstream:
inicio_mag = donde(t_mag_entero, t1 - 0.1)
fin_mag = donde(t_mag_entero, t1 - 0.05)
inicio_swia = donde(t_swia_entero, t1 - 0.1)
fin_swia = donde(t_swia_entero, t1 - 0.05)

t_mag = t_mag_entero[inicio_mag:fin_mag]
B = B_entero[inicio_mag:fin_mag] * 1e-9  # T

t_swia = t_swia_entero[inicio_swia:fin_swia]
Exemplo n.º 2
0
beta = P_plasma / P_B

density_mean = [np.mean(HpRho[i : i + 50]) for i in range(len(HpRho) - 50)]
ion_length = 2.28e07 / np.sqrt(density_mean) * 1e-5  # km
ion_length = np.append(ion_length, ion_length[-51:-1])
plt.plot(x, kT_H)
plt.plot(x, Pe / rho)
# plt.plot(x, kT_O)
# plt.plot(x, kT_O2)
# plt.plot(x, kT_CO2)
plt.show()


# Datos de MAVEN
mag, t, B_mag, posicion = importar_mag(2016, "03", 16, 17.7, 19)
swia, t_swia, proton_density = importar_swia(2016, "03", 16, 17.7, 19)

# Datos del análisis de MAVEN
R = [1.082, -0.064, 0.515]
normal = [0.920, -0.302, 0.251]
j_maven = 23.2  # mA/m

# hay 10 órbitas, cada una de 1620 puntos
"""Plotea nuestra MPB y la órbita de la simu que estamos usando"""
L = 0.96
x0 = 0.78
e = 0.9
theta = np.linspace(0, np.pi * 3 / 4, 100)
phi = np.linspace(0, 2 * np.pi, 100)
THETA, PHI = np.meshgrid(theta, phi)
Exemplo n.º 3
0
    Blow[:, i - 7] = mag_low[:, i]

B_para, B_perp_norm, t_plot = Bpara_Bperp(Blow, tlow, t[0], t[-1])

# ######### SWEA

swea, t_swea, energias = importar_swea(year, month, day, ti, tf)
energy = swea[:, 7]
JE_total = swea[:, -1]

inicio_swea = donde(t_swea, ti)  # debería ser 0
fin_swea = donde(t_swea, tf)

# ######################################################################## SWIA

swia, t_swia, density = importar_swia(year, month, day, ti, tf)

# t_swica, t_swifa, density_swica, density_swifa = importar_swicfa(
#     year, month, day, ti, tf
# )

# ########################## STATIC
static, t_static, mass, counts = importar_static(year, month, day, ti, tf)

# ############ tiempos UTC
year = int(year)
month = int(month)
day = int(day)

tiempo_mag = np.array([np.datetime64(datenum(year, month, day, x))
                       for x in t])  # datenum es una función mía
Exemplo n.º 4
0
    posicion = np.zeros((len(t), 3))
    for i in range(9, 12):
        posicion[:, i - 9] = mag[:, i]

    inicio = donde(t, ti)
    fin = donde(t, tf)

    t_cut = t[inicio:fin]
    B_cut = B[inicio:fin]
    posicion_cut = posicion[inicio:fin]
    return mag, t_cut, B_cut, posicion_cut


if ti_ms < tf_down:
    swia, t_swia, density, temperature, vel_mso = importar_swia(
        year, month, day, ti_ms, tf_down)
    mag, t_mag, B, posicion = importar_mag(year, month, day, ti_ms, tf_down)

else:
    swia, t_swia, density, temperature, vel_mso = importar_swia(
        year, month, day, ti_down, tf_ms)
    mag, t_mag, B, posicion = importar_mag(year, month, day, ti_down, tf_ms)

# quiero diezmar el tiempo y el campo para que sean los mismos que tiene swia
idx = diezmar(t_mag, t_swia)

tmag_diezmado = t_mag[idx]
B_cut = B[idx]
posicion_cut = posicion[idx]

inicio_up = donde(t_swia,
Exemplo n.º 5
0
CORREGIR PARA QUE USE CDFLIB
CORREGIR EL PLOT DE SWEA

Este script plotea mag, swea, swia y lpw en la región de interés y de nuevo en una región zoomeada
Es como la figura pricipal en mi tesis.

"""

# DATOS DE PDS

year, month, day, doy = fechas()
ti, tf = tiempos()

mag, t, B, posicion = importar_mag(year, month, day, ti, tf)
swea = importar_swea(year, month, day, ti, tf)
swia, t_swia, i_density, i_temp, vel_mso = importar_swia(
    year, month, day, ti, tf)
lpw, t_lpw, e_density = importar_lpw(year, month, day, ti, tf)

t1 = donde(t, ti)
t2 = donde(t, tf)

t_plot, B_para, B_perp_norm = Bpara_Bperp(B, t, ti, tf)

# ######### SWEA
# flux_all = swea.varget("diff_en_fluxes")
# energia = swea.varget("energy")
#
# t_unix_e = swea.varget("time_unix")
#
# t_swea = unix_to_decimal(t_unix_e)
# inicio_e = np.where(t_swea == find_nearest(t_swea, 17.85))[0][0]
Exemplo n.º 6
0
    """Calcula la matriz Kij para el vector m-ésimo de campo B."""
    P_ij = np.zeros((3, 3))
    for i in range(3):  # para las tres coordenadas
        for j in range(3):
            P_ij[i, j] = (
                delta_ij(i, j) - B[m, i] * B[m, j] / np.linalg.norm(B[m, :]) ** 2
            )

    K_ij = np.linalg.norm(B[m, :]) ** 2 * P_ij
    return K_ij


year, month, day, doy = 2016, "03", 16, "076"  # fechas()
ti, tf = 18.2258, 18.235  # tiempos()
mag, t, B, posicion = importar_mag(year, month, day, ti, tf)
swia, t_swia, density, v, v_norm = importar_swia(year, month, day, ti, tf)

# si hay buenos datos de v_electrones usamos ve en lugar de v


normal = [0.920, -0.302, 0.251]
# B y v no tienen la misma cantidad de puntos, tengo que diezmar (como siempre)

idx = diezmar(t, t_swia)
B_cut = B[idx]

K0 = np.mean(
    [Kij(B_cut, m) for m in range(len(B_cut))], axis=0
)  # tiene que ser una matriz
KK = np.mean([np.dot(Kij(B_cut, m), v[m, :]) for m in range(len(B_cut))], axis=0)
Exemplo n.º 7
0
angulo_mva = np.arccos(np.clip(np.dot(normal_fit, x3), -1.0, 1.0))


print(f"SZA = {SZAngle:.3g}º y altitud = {int(altitud)}km")
print(f"MVA entre los tiempos {ti_MVA} y {tf_MVA}")
print(f"Cociente de lambdas = {lamb[1]/lamb[2]:.4g}")
print(f"El ángulo entre las normales de MVA y del fit es {angulo_mva * 180/np.pi:.3g}º")

ti = t1 - 0.15
tf = t4 + 0.15

B_para, B_perp_norm, t_plot = Bpara_Bperp(B, t, t1, t4)

swea, t_swea, energia, flux_plot = importar_swea(year, month, day, t1 - 0.5, t4 + 0.5)
swia, t_swia, density, temp, vel = importar_swia(year, month, day, t1 - 0.5, t4 + 0.5)

plt.clf()  # clear figure
fig = plt.figure(
    1, constrained_layout=True
)  # Lo bueno de esta forma es que puedo hacer que solo algunos compartan eje
fig.subplots_adjust(
    top=0.93, bottom=0.07, left=0.05, right=0.95, hspace=0.005, wspace=0.15
)
fig.set_size_inches(15, 10)  # con este tamaño ocupa toda la pantalla de la laptop

ax1 = plt.subplot2grid((3, 2), (0, 0))
plt.plot(t_plot, B_para, linewidth=1, label=r"|$\Delta B \parallel$| / B")
plt.plot(t_plot, B_perp_norm, "-.", linewidth=1, label=r"|$\Delta B \perp$| / B")
plt.setp(ax1.get_xticklabels(), visible=False)
for xc in [t1, t2, t3, t4]: