def ajuste(year, month, day, doy, ti_MVA, tf_MVA): datos_tiempo = np.loadtxt("../outputs/t1t2t3t4.txt") idx_d = np.where(int(doy) == datos_tiempo[:, 1].astype(int))[0] idx_h = np.where(int(ti_MVA) == datos_tiempo[:, 2].astype(int))[0] idx = np.intersect1d(idx_d, idx_h)[0] t1 = datos_tiempo[idx, 2] t2 = datos_tiempo[idx, 3] t3 = datos_tiempo[idx, 4] t4 = datos_tiempo[idx, 5] mag, t, B, posicion = importar_mag(year, month, day, ti_MVA, tf_MVA) t_nave = find_nearest(t, (t2 + t3) / 2) # el tiempo en el medio de la hoja de corriente index = np.where(t == t_nave)[0][0] # x0 = 0.78 # e = 0.9 normal_ajuste, L0 = normal_fit(posicion, index) B3_fit = np.dot(B, normal_ajuste) print(f"La normal del fit es {normal_ajuste}") # print(f"B3 del fit es {B3_fit}") print("Ajuste terminado") return normal_ajuste, t1, t2, t3, t4
def ajuste(year, month, day, doy, ti_MVA, tf_MVA, nr): datos_tiempo = np.loadtxt("../outputs/t1t2t3t4.txt") idx_d = np.where(int(doy) == datos_tiempo[:, 1].astype(int))[0] idx_h = np.where(int(ti_MVA) == datos_tiempo[:, 2].astype(int))[0] idx = np.intersect1d(idx_d, idx_h)[0] t1 = datos_tiempo[idx, 2] t2 = datos_tiempo[idx, 3] t3 = datos_tiempo[idx, 4] t4 = datos_tiempo[idx, 5] tiempos = [t1, t2, t3, t4] mag, t, B, posicion = importar_mag(year, month, day, ti_MVA, tf_MVA) t_nave = find_nearest(t, (t2 + t3) / 2) # el tiempo en el medio de la hoja de corriente index = np.where(t == t_nave)[0][0] x0 = 0.78 e = 0.9 normal_ajuste, L0 = normal_fit(posicion, index) B3_fit = np.dot(B, normal_ajuste) print("Fin del ajuste. ") ( hoja_parametros, hoja_mva, hoja_boot, hoja_fit, fecha_sheet, hora_sheet, ) = acceso_spreadsheet() cell_times = hoja_parametros.range(f"F{nr}:I{nr}") for i, cell in enumerate(cell_times): cell.value = tiempos[i] hoja_parametros.update_cells(cell_times) hoja_fit.update_acell(f"D{nr}", f"{L0}") hoja_fit.update_acell(f"E{nr}", f"{e}") hoja_fit.update_acell(f"F{nr}", f"{x0}") cell_normal = hoja_fit.range(f"G{nr}:I{nr}") for i, cell in enumerate(cell_normal): cell.value = round(normal_ajuste[i], 3) hoja_fit.update_cells(cell_normal) hoja_fit.update_acell(f"K{nr}", f"{round(np.mean(B3_fit),2)}") print("Escribió la spreadsheet del ajuste.") return normal_ajuste, t1, t2, t3, t4
omega = angulo(B_upstream, B_downstream) J_s_MVA, J_v_MVA = corrientes(x3, B_upstream, B_downstream, x_23_MVA) J_s_fit, J_v_fit = corrientes(normal_ajuste, B_upstream, B_downstream, x_23_fit) J_s_boot, J_v_boot = corrientes(normal_boot, B_upstream, B_downstream, x_23_boot) fuerza_mva = np.cross(J_v_MVA * 1e-9, B[inicio_down, :] * 1e-9) # N/m^3 #en t4 fuerza_fit = np.cross(J_v_fit * 1e-9, B[inicio_down, :] * 1e-9) # N/m^3 #en t4 fuerza_boot = np.cross(J_v_boot * 1e-9, B[inicio_down, :] * 1e-9) # N/m^3 e_density = lpw[:, -1] t_lpw = lpw[:, 3] + lpw[:, 4] / 60 + lpw[:, 5] / 3600 ti_lpw = np.where(t_lpw == find_nearest(t_lpw, t2))[0][0] tf_lpw = np.where(t_lpw == find_nearest(t_lpw, t3))[0][0] n_e = np.nanmean( e_density[ti_lpw:tf_lpw]) # hace el mean ignorando los nans #cm⁻³ n_e = n_e * 1e6 # m⁻³ if np.isnan(n_e): n_e = 1e7 print("LPW no tiene datos de densidad, asumí n_e = 1E7") E_Hall = np.cross(J_v_MVA * 1e-9, B[inicio_down, :] * 1e-9) / (q_e * n_e ) # V/m E_Hall_fit = np.cross(J_v_fit * 1e-9, B[inicio_down, :] * 1e-9) / (q_e * n_e ) # V/m E_Hall_boot = np.cross(J_v_boot * 1e-9, B[inicio_down, :] * 1e-9) / (q_e * n_e ) # V/m
t_plot, B_para, B_perp_norm = Bpara_Bperp(B, t, ti, tf) ###############################################################################################SWEA file_size_swea = os.path.getsize( path + f'SWEA/mvn_swe_l2_svyspec_{year}{month}{day}_v04_r01.cdf') if file_size_swea > 10000000: swea = cdf.CDF( path + f'SWEA/mvn_swe_l2_svyspec_{year}{month}{day}_v04_r01.cdf') flux_all = swea.varget('diff_en_fluxes') energia = swea.varget('energy') t_unix = swea.varget('time_unix') tu = unix_to_decimal(t_unix) ti_swea = np.where(tu == find_nearest(tu, ti))[0][0] tf_swea = np.where(tu == find_nearest(tu, tf))[0][0] t_swea = tu[ti_swea:tf_swea] flux = flux_all[ti_swea:tf_swea] flux_plot = np.transpose(flux)[::-1] else: print('no hay datos de SWEA') ###############################################################################################SWIA file_size_swia = os.path.getsize( path + f'SWIA/mvn_swi_l2_onboardsvymom_{year}{month}{day}_v01_r01.cdf') if file_size_swia > 2300000: swia = cdf.CDF( path + f'SWIA/mvn_swi_l2_onboardsvymom_{year}{month}{day}_v01_r01.cdf')
for i in [1, 2, 3]: B[:, i - 1] = datos[:, i] MD = np.zeros((M, 5)) MD[:, 0] = t for i in range(1, 4): MD[:, i] = B[:, i - 1] MD[:, 4] = datos[:, -1] #la norma de B #si quiero elegir entre ciertas horas: t1 = find_nearest_inicial(t, ti) t2 = find_nearest_final(t, tf) inicio = np.where(t == t1)[0][0] fin = np.where(t == t2)[0][0] t_1 = np.where(t == find_nearest(t, 18.2167))[0][0] t_2 = np.where(t == find_nearest(t, 18.2204))[0][0] t_3 = np.where(t == find_nearest(t, 18.235))[0][0] t_4 = np.where(t == find_nearest(t, 18.2476))[0][0] ################# #ahora empieza el MVA con los datos que elegí MD_cut = MD[inicio:fin + 1, :] M_cut = np.size(MD_cut[:, 0]) B_cut = B[inicio:fin + 1, :] M_ij = Mij(B_cut) # np.savetxt('outs/matriz_%d'%dia[0], M_ij) #guarda la matriz de cada dia #ahora quiero los autovectores y autovalores [lamb, x] = np.linalg.eigh(M_ij) #uso eigh porque es simetrica
np.array([0.981, -0.032, 0.193]), ] dates = [ [2015, 10, 12], [2015, 10, 10], [2016, "04", "05"], [2016, "03", 31], [2016, "03", 16], [2017, 11, 24], ] times = [[18.75, 19.75], [12, 13], [5, 6], [12.5, 13.5], [17.75, 18.75], [11.75, 12.75]] tmean = [ "19:19:13", "12:40:47", "05:16:30", "13:04:38", "18:13:50", "12:15:27" ] for i in range(len(x3)): t, posicion_cut, year, month, day = datos_fijos(dates[i][0], dates[i][1], dates[i][2], times[i][0], times[i][1]) t_medio = UTC_to_hdec(tmean[i]) index = np.where(t == find_nearest(t, t_medio))[0][0] R = posicion_cut[index, :] # la posicion de la nave en RM asc, bsc, csc = parametros_elipse(R) # normal_MVA(R, x3, '2015-oct-12') normal_MVA(R, x3[i]) normal_vignes(R, asc, bsc, csc) plt.show()
escalas = datos[0, 2:] * 3600 cociente = np.transpose(datos[1:, 2:]) ti = tiempo_central[0] - 0.5 tf = tiempo_central[-1] + 0.5 n = int(ti * 32 * 3600) hh = mag[:, 3] mm = mag[:, 4] ss = mag[:, 5] t = hh + mm / 60 + ss / 3600 # hdec M = np.size(t) # el numero de datos inicio = np.where(t == find_nearest(t, ti))[0][0] fin = np.where(t == find_nearest(t, tf))[0][0] B_cut = Bnorm[inicio:fin] t_cut = t[inicio:fin] inicio_MVA = np.where(t == find_nearest(t, tiempo_central[0]))[0][0] fin_MVA = np.where(t == find_nearest(t, tiempo_central[-1]))[0][0] B_MVA = Bnorm[inicio_MVA:fin_MVA] t_MVA = t[inicio_MVA:fin_MVA] xfmt = md.DateFormatter("%H:%M:%S") plt.figure(1) imshow_UTC(year, month, day, tiempo_central, cociente, escalas, "inferno", 3) # plot_datetime(year, month, day,t_MVA, B_MVA, 'cyan', '-', 1, 0.5) #no sé por qué se superpone mal, tiene mal los tiempos.
from funciones_plot import plot_select from matplotlib.colors import LogNorm import datetime as dt import matplotlib.dates as md plt.ion() # np.set_printoptions(precision=4) path = '../../datos/SWEA/' #path a los datos cdf_file = cdf.CDF(path + 'mvn_swe_l2_svyspec_20160316_v04_r01.cdf') flux_all = cdf_file.varget('diff_en_fluxes') energia = cdf_file.varget('energy') t_unix = cdf_file.varget('time_unix') tu = unix_to_decimal(t_unix) ti = np.where(tu == find_nearest(tu, 17.85))[0][0] tf = np.where(tu == find_nearest(tu, 18.5))[0][0] t = tu[ti:tf] flux = flux_all[ti:tf] datenums = unix_to_timestamp(t_unix[ti:tf]) log_flux = np.flip(np.log(flux), axis=1) log_flux[log_flux < -1000] = None # np.min(log_flux[log_flux>-1000]) flux_plot = np.transpose(flux)[::-1] plt.figure() plt.subplots_adjust(bottom=0.2) plt.xticks(rotation=25) ax = plt.gca()
posicion[:, i - 11] = mag[:, i] #la matriz diaria: MD = np.zeros((M, 9)) MD[:, 0] = t for i in range(1, 4): MD[:, i] = B[:, i - 1] MD[:, 4] = np.linalg.norm(B, axis=1) #la norma de B for i in range(5, 8): MD[:, i] = posicion[:, i - 5] / 3390 #en radios marcianos MD[:, 8] = np.linalg.norm(posicion, axis=1) - 3390 #altitud en km inicio = np.where(t == find_nearest_inicial(t, t2))[0][0] fin = np.where(t == find_nearest_final(t, t3))[0][0] t_1 = np.where(t == find_nearest(t, t1))[0][0] t_2 = np.where(t == find_nearest(t, t2))[0][0] t_3 = np.where(t == find_nearest(t, t3))[0][0] t_4 = np.where(t == find_nearest(t, t4))[0][0] ################# #Filtramos los cantidad_datos b, a = signal.butter(3, 0.01, btype='lowpass') Bx_filtrado = signal.filtfilt(b, a, B[:, 0]) By_filtrado = signal.filtfilt(b, a, B[:, 1]) Bz_filtrado = signal.filtfilt(b, a, B[:, 2]) B_filtrado = np.linalg.norm(np.array([Bx_filtrado, By_filtrado, Bz_filtrado]), axis=0) #es el axis 0 porque no está traspuesta #ahora empieza el MVA con los datos que elegí MD_cut = MD[inicio:fin + 1, :]
mag_low = np.loadtxt(path + "mag_1s.sts", skiprows=160) tlow = mag_low[:, 6] # el dia decimal tlow = (tlow - int(doy)) * 24 # para que me de sobre la cantidad de horas Mlow = np.size(tlow) # el numero de datos # el campo Blow = np.zeros((Mlow, 3)) for i in range(7, 10): Blow[:, i - 7] = mag_low[:, i] ti = t1 - 0.15 tf = t4 + 0.15 inicio = np.where(t == find_nearest(t, ti))[0][0] fin = np.where(t == find_nearest(t, tf))[0][0] B_para, B_perp_norm, t_plot = Bpara_Bperp(Blow, tlow, ti, tf) # ##############################################################################################SWEA swea, t_swea, energias = importar_swea(year, month, day, ti, tf) energy = swea[:, 7] JE_total = swea[:, -1] inicio_swea = np.where(t_swea == find_nearest(t_swea, ti))[0][0] fin_swea = np.where(t_swea == find_nearest(t_swea, tf))[0][0] # ##############################################################################################SWIA swia, t_swia, density = importar_swia(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 tiempo_swea = np.array( [np.datetime64(datenum(year, month, day, x)) for x in t_swea]) tiempo_swia = np.array( [np.datetime64(datenum(year, month, day, x)) for x in t_swia]) tiempo_static = np.array( [np.datetime64(datenum(year, month, day, x)) for x in t_static]) tm1 = np.where(t == find_nearest(t, t1)) tm2 = np.where(t == find_nearest(t, t2)) tm3 = np.where(t == find_nearest(t, t3)) tm4 = np.where(t == find_nearest(t, t4)) # tm_up = np.where(t == find_nearest(t, t_up)) # tm_down = np.where(t == find_nearest(t, t_down)) # tmva = np.where(t == find_nearest(t, np.mean([t1, t2, t3, t4]))) # tbs = np.where(t == find_nearest(t, UTC_to_hdec("18:02:00"))) # tbs_swifa = np.where(t_swifa == find_nearest(t_swifa, UTC_to_hdec("18:02:00")))[0][0] # tmpr = np.where(t == find_nearest(t, UTC_to_hdec("18:19:00"))) tiempo_lim = [ tiempo_mag[tm1], tiempo_mag[tm2], tiempo_mag[tm3], tiempo_mag[tm4] ] B1, B2, B3 = proyecciones(B)
# Si quiero elegir manualmente la orbita: plt.plot(t, MD[:, 4]) plt.xlabel("t (hdec)") plt.ylabel("|B|") plt.title("Orbitas") plt.show() ti = float(input("Tiempo inicial = ")) tf = float(input("Tiempo final = ")) orbit_number = float(input("Número de órbita = ")) if tf < ti: print("El tiempo inicial no puede ser mayor al final") ti = float(input("Tiempo inicial = ")) tf = float(input("Tiempo final = ")) t1 = find_nearest(t, ti) t2 = find_nearest(t, tf) j_inicial = np.where(t == t1)[0][0] j_final = np.where(t == t2)[0][0] # el deltaB es una norma. Corresponde al t del medio del intervalo. # Lo hago en ventanas de 60s, moviendose de a 1s. B_para = np.zeros(j_final - j_inicial) B_perp = np.zeros((j_final - j_inicial, 3)) B_perp_norm = np.zeros(j_final - j_inicial) for j in range(j_inicial, j_final): Mi = j Mf = j + 25 M_delta = 25 B_delta = B[Mi:Mf] t_delta = t[Mi:Mf]
B_norm_medio = np.linalg.norm(B_medio_vectorial) # hodograma(B1, B2, B3, 'nT', 'MAVEN MAG MVA ') # el error phi, delta_B3 = error(lamb, B_cut, len(B_cut), x) ############### ####fit orbita = ( posicion[np.where(t == find_nearest_inicial(t, t1 - 1))[0][0]:np.where( t == find_nearest_final(t, t4 + 1))[0][0], :, ] / 3390 ) # radios marcianos t_nave = find_nearest(t, (t2 + t3) / 2) # el tiempo en el medio de la hoja de corriente index = np.where(t == t_nave)[0][0] x0 = 0.78 e = 0.9 normal_fit, X1, Y1, Z1, R, L0 = ajuste_conico(posicion, index, orbita, x3) B3_fit = np.dot(B_cut, normal_fit) ############# ##Bootstrap N_boot = 1000 normal_boot, phi_boot, delta_B3_boot, out, out_phi = bootstrap( N_boot, B_cut, len(B_cut)) muB, sigmaB, mu31, sigma31, mu32, sigma32 = plot_bootstrap(out, out_phi)
datos = np.loadtxt( '../../computacional/datos/importance_sampling_deltas_0_10.txt', skiprows=2) delta = datos[:, 0] paso_delta = np.abs(delta[0] - delta[1]) n_serie = len(datos[0, :]) - 1 # Aceptacion en funcion de deltas entre 0 y 10 aceptacion = np.zeros(len(delta)) for i in range(len(delta)): for j in range(n_serie): if datos[i, j] - datos[i, j + 1] != 0: aceptacion[i] = aceptacion[i] + 1 aceptacion = aceptacion * 100 / n_serie #asi ya esta en porcentaje idx = np.where(aceptacion == find_nearest(aceptacion, 50))[0][ 0] #donde la acpetacion es 50% plt.figure(1) plt.plot(delta, aceptacion) plt.plot(delta[idx], aceptacion[idx], 'ro', label='$\delta$ = {}'.format(delta[idx])) plt.xlabel('$\delta$') plt.ylabel('% aceptacion') plt.title('Aceptación para un paso entre deltas de {}'.format(paso_delta)) plt.ylim([0, 100]) plt.legend() plt.grid()
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 tiempo_swea = np.array( [np.datetime64(datenum(year, month, day, x)) for x in t_swea]) tiempo_swia = np.array( [np.datetime64(datenum(year, month, day, x)) for x in t_swia]) # tiempo_swica = np.array([np.datetime64(datenum(year, month, day, x)) for x in t_swica]) # tiempo_swifa = np.array([np.datetime64(datenum(year, month, day, x)) for x in t_swifa]) tiempo_static = np.array( [np.datetime64(datenum(year, month, day, x)) for x in t_static]) tiempo_low = np.array( [np.datetime64(datenum(year, month, day, x)) for x in t_plot]) tm1 = np.where(t == find_nearest(t, t1)) tm2 = np.where(t == find_nearest(t, t2)) tm3 = np.where(t == find_nearest(t, t3)) tm4 = np.where(t == find_nearest(t, t4)) tm_up = np.where(t == find_nearest(t, t_up)) tm_down = np.where(t == find_nearest(t, t_down)) tmva = np.where(t == find_nearest(t, np.mean([t1, t2, t3, t4]))) # tbs = np.where(t == find_nearest(t, UTC_to_hdec("18:02:00"))) # tbs_swifa = np.where(t_swifa == find_nearest(t_swifa, UTC_to_hdec("18:02:00")))[0][0] # tmpr = np.where(t == find_nearest(t, UTC_to_hdec("18:19:00"))) tiempo_lim = [ tiempo_mag[tm1], tiempo_mag[tm2], tiempo_mag[tm3], tiempo_mag[tm4] ] B1, B2, B3 = proyecciones(B)
def flujo_energia(t1, t2, cdf_file): # np.set_printoptions(precision=4) path = '../../datos/SWEA/' #path a los datos cdf_file = cdf.CDF(path + 'mvn_swe_l2_svyspec_20160402_v04_r01.cdf') flux = cdf_file.varget('diff_en_fluxes') energia = cdf_file.varget('energy') t_unix = cdf_file.varget('time_unix') tu = unix_to_decimal(t_unix) ti = np.where(tu == find_nearest(tu, t1))[0][0] tf = np.where(tu == find_nearest(tu, t2))[0][0] t = tu[ti:tf] flux = flux[ti:tf] #elijo la energia mas baja Ei = find_nearest(energia, 20) inicio = np.where(energia == Ei)[0][0] #empiezo un array al que le voy a meter las energias E = Ei i = inicio E = np.append(E, find_nearest(energia, E + 20)) i = np.append(i, np.where(energia == E[1])[0][0]) for j in range(len(energia)): if E[j + 1] > 100: break else: E = np.append(E, find_nearest(energia, E[j + 1] + 20)) i = np.append(i, np.where(energia == E[j + 2])[0][0]) E = np.append(E, find_nearest(energia, 220)) E = np.append(E, find_nearest(energia, 300)) i = np.append(i, np.where(energia == E[-2])[0][0]) i = np.append(i, np.where(energia == E[-1])[0][0]) flux_cut = np.zeros((len(flux), len(i))) for j in range(len(i)): flux_cut[:, j] = flux[:, int(i[j])] #borramos el punto donde el log(0) = inf for j in range(len(flux_cut[:, 0])): for i in range(len(flux_cut[0, :])): if np.log(flux_cut[j, i]) < 1: flux_cut[j, i] = None t1 = t_unix[np.where(tu == find_nearest(tu, 18.2193))[0][0]] t2 = t_unix[np.where(tu == find_nearest(tu, 18.2272))[0][0]] t3 = t_unix[np.where(tu == find_nearest(tu, 18.2331))[0][0]] t4 = t_unix[np.where(tu == find_nearest(tu, 18.2476))[0][0]] n = len(flux_cut) t_inicial = t_unix[ti] t_final = t_unix[tf] timestamps = np.linspace(t_inicial, t_final, n) dates = [dt.datetime.utcfromtimestamp(ts) for ts in timestamps] #me lo da en UTC datenums = md.date2num(dates) # flux = cdf_file.varget('diff_en_fluxes') # energia = cdf_file.varget('energy') # t_unix = cdf_file.varget('time_unix') # # tu = unix_to_decimal(t_unix) # ti = np.where(tu == find_nearest(tu, t1))[0][0] # tf = np.where(tu == find_nearest(tu, t2))[0][0] # t = tu[ti:tf] # flux = flux[ti:tf] # # # #elijo la energia mas baja # Ei = find_nearest(energia, 20) # inicio = np.where(energia == Ei)[0][0] # # #empiezo un array al que le voy a meter las energias # E = Ei # i = inicio # E = np.append(E, find_nearest(energia, E+20)) # i = np.append(i, np.where(energia == E[1])[0][0]) # # for j in range(len(energia)): # if E[j+1] > 100: # break # else: # E = np.append(E, find_nearest(energia, E[j+1]+20)) # i = np.append(i, np.where(energia == E[j+2])[0][0]) # # E = np.append(E, find_nearest(energia, 220)) # E = np.append(E,find_nearest(energia, 300)) # i = np.append(i, np.where(energia == E[-2])[0][0]) # i = np.append(i, np.where(energia == E[-1])[0][0]) # # flux_cut = np.zeros((len(flux), len(i))) # # for j in range(len(i)): # flux_cut[:, j] = flux[:, int(i[j])] # # #borramos el punto donde el log(0) = inf # for j in range(len(flux_cut[:,0])): # for i in range(len(flux_cut[0,:])): # if np.log(flux_cut[j,i]) < 1: # flux_cut[j, i] = None return (t, flux_cut, E)
Me va a dar las normales en un rango de 30s a 90s en diámetro, con 1s de diferencia. Empieza en 30s porque nos nos interesa ver la normal adentro de la hoja de corriente (es la que ya tenemos), pero sí ver cómo varía a medida que aumentamos la cantidad de puntos """ escalas = np.zeros(30) escalas[0] = 15 / 3600 for i in range(len(escalas) - 1): escalas[i + 1] = escalas[i] + 1 / 3600 # va de 15s a 45s program_starts = time.time() normales = np.zeros((len(tiempo_central), len(escalas), 3)) # un array en 3 dimensiones for i in range(len(tiempo_central)): for j in range(len(escalas)): inicio = np.where(t == find_nearest(t, tiempo_central[i] - escalas[j]))[0][0] fin = np.where(t == find_nearest(t, tiempo_central[i] + escalas[j]))[0][0] B_cut = B[inicio:fin + 1, :] M_ij = Mij(B_cut) [lamb, x] = np.linalg.eigh(M_ij) # uso eigh porque es simetrica idx = lamb.argsort()[::-1] lamb = lamb[idx] x = x[:, idx] # ojo que me da las columnas en vez de las filas como autovectores: el av x1 = x[:,0] x1 = x[:, 0] x2 = x[:, 1]
#si quiero elegir entre ciertas horas: # t1 = float(input("t1 = ")) # t2 = float(input("t2 = ")) # t3 = float(input("t3 = ")) # t4 = float(input("t4 = ")) t1 = 18.2167 t2 = 18.2204 t3 = 18.235 t4 = 18.2476 inicio = np.where(t == find_nearest_inicial(t, t2))[0][0] fin = np.where(t == find_nearest_final(t, t3))[0][0] t_1 = np.where(t == find_nearest(t, t1))[0][0] t_2 = np.where(t == find_nearest(t, t2))[0][0] t_3 = np.where(t == find_nearest(t, t3))[0][0] t_4 = np.where(t == find_nearest(t, t4))[0][0] ################# #ahora empieza el MVA con los datos que elegí MD_cut = MD[inicio:fin + 1, :] M_cut = np.size(MD_cut[:, 0]) B_cut = B[inicio:fin + 1, :] M_ij = Mij(B_cut) # np.savetxt('outs/matriz_%d'%dia[0], M_ij) #guarda la matriz de cada dia #ahora quiero los autovectores y autovalores
import numpy as np import pandas as pd import matplotlib.pyplot as plt from funciones import find_nearest import os path = os.getcwd() plt.ion() # sirve para graficar los resultados de means.txt de ising_means.c # for N in [8,16,64,128]: N = 64 datos = pd.read_csv(path + f"/means_N128.txt", sep="\t", skiprows=1, header=0) beta = 1 / datos['temp'] #metadata = pd.read_csv(path+"/means.txt",nrows=1,sep=" ",header=None) fin = np.where(beta == find_nearest(beta, 0.6))[0][0] plt.figure() plt.plot(beta[fin:], datos["Mag"][fin:], '.') plt.axvline(0.44, c='r') plt.xlabel(r'Temperatura inversa $\beta$') plt.title(f'Magnetización por sitio para L = {N}') plt.grid() plt.savefig(f'img/mag_L{N}.png') plt.figure() plt.plot(beta[fin:], datos["En"][fin:], '.') plt.xlabel(r'Temperatura inversa $\beta$') plt.title(f'Energía por sitio para L = {N}') plt.grid() plt.axvline(0.44, c='r') plt.savefig(f'img/en_L{N}.png') # plt.show()