MAIN

 avatar
unknown
plain_text
2 years ago
4.3 kB
4
Indexable
from scipy.interpolate import interp2d

from fonctions_flou import *
from fonctions_autres import *
import numpy as np

import matplotlib.pyplot as plt

# FAIRE GAFFE, LES DONNES NETCDF SONT : [ORDONNEE;ABSCISSE]

# mettre les notations de Kauffman sur le rapport / dire que la T norm c'est min / Bibliographie,... TOUT METTRE
# dire ce qu'on aurait pu faire si on avait plus de temps

# longitude / latitude / time / d = divergence / r = humidity / t = temperature / u=uwind / v=vwind / vo=vortcity

# ________________________


# Les calculs se font en unités SI (mètres, secondes,...). Pour l'affichage, nous convertissons cependant l'abscisse
# et l'ordonnée en mètre
# plt.streamplot(met_to_deg(lon), met_to_deg(np.flip(lat)), np.flip(uwind[t,:,:], 0), np.flip(vwind[t,:,:], 0),
#               density=5,linewidth=0.3,color=np.flip(psi, axis=0))

# A t0 = t_TC0+40 pour Katrina ça marche pas avec CAF2, mais si avec CAF4
t0 = t_TC0 + 45  # Début de l'étude : Au moins 24h après T_TC0 pour garantir des résultats cohérents
t1 = t0 + 48
dt = 12
CAF2_output = np.array(0)
# Liste de points qui marchent bien :
# DENNIS T0 = T_TC0+45
for t in range(t0 + dt, t1, dt):
    print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$TEMPS RESTANT : ',t1-t,'EN HEURES$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
    # Espace de travail pour le cyclone
    rayon_espace = 500000  # En mètre
    range_lon = np.isclose(lon, x_TC[t0], atol=rayon_espace)
    range_lat = np.isclose(lat, y_TC[t0], atol=rayon_espace)
    range_grid = np.meshgrid(range_lon, range_lat)
    # Nous souhaitons les emplacements où les valeurs en lon ET en lat sont True
    study_grid = range_grid[0] * range_grid[1]

    print("______________________SF1________________________")
    SF1_temperature = np.where(study_grid, temperature[t0, :, :], float('nan'))

    SF1_temperature = np.nanmean(SF1_temperature)
    SF1_dwind = variation_vitesse_TC(t0, study_grid)
    SF1_lifetime = (t0 - t_TC0) / 24

    duree_de_vie = SF1_compute(SF1_temperature, SF1_dwind, SF1_lifetime, want_to_plot=False)

    print("Température °K:", np.round(SF1_temperature, 1), "Variation de la vitesse m/s:", np.round(SF1_dwind, 1),
          "Age du cyclone ,jours:", np.round(SF1_lifetime, 1))
    print("__________________SORTIE SF1 - Durée de Vie espérée en jours_____________________")
    print("Sortie :", np.round(duree_de_vie, 2))
    print('La durée de vie réelle restante est :', np.round((tmax - t0) / 24, 1), 'jours')

    CAF2_output = CAF2_output + estimation1(t0, t, dt, uwind, vwind, study_grid)

    print('___________________SF4 - Trajectoire Tendance____________________')

    SF4_regression = regression_trajectoire_TC(t0, want_to_plot=True)
    SF4_angle_TC = SF4_angle(t0, -12)  # Calcul l'angle entre un point à t0 et à t=t0-12

    # CHANGER "ANTECEDENTSSSS"

    print('Angle_TC, degrés: ', np.round(SF4_angle_TC, 1), "Angle_Regression, degrés :", np.round(SF4_regression, 1))
    print('_______________________SORTIE SF4 - Prediction _________________________')
    SF4_array_output, SF4_angle_output = SF4_conclusion(SF4_angle_TC, SF4_regression, t0)
    print('Sortie : SF4', SF4_angle_output)

    plt.figure(0)
    plt.plot(met_to_deg(x_TC[t0]), met_to_deg(y_TC[t0]), ms=10, marker='o', markeredgecolor='red')
    plt.plot(met_to_deg(x_TC[t]), met_to_deg(y_TC[t]), ms=10, marker='x', markeredgecolor='red')
    plt.figure(1)
    plt.plot(met_to_deg(x_TC[t0]), met_to_deg(y_TC[t0]), ms=10, marker='o', markeredgecolor='red')
    plt.plot(met_to_deg(x_TC[t]), met_to_deg(y_TC[t]), ms=10, marker='x', markeredgecolor='red')
    plt.figure(2)
    plt.plot(met_to_deg(x_TC[t0]), met_to_deg(y_TC[t0]), ms=10, marker='o', markeredgecolor='red')
    plt.plot(met_to_deg(x_TC[t]), met_to_deg(y_TC[t]), ms=10, marker='x', markeredgecolor='red')

plt.figure(0)
plot_array(CAF2_output, lon_fuzz_plot, lat_fuzz_plot)
plt.figure(1)
f = interp2d(lon, np.flip(lat),SF4_array_output, kind='cubic')
SF4_array_output= f(lon_fuzz_plot, np.flip(lat_fuzz_plot))
plot_array(SF4_array_output, lon_fuzz_plot, lat_fuzz_plot)
plt.figure(2)
plot_array(CAF2_output*SF4_array_output,lon_fuzz_plot,lat_fuzz_plot)
plt.show()
Editor is loading...