import numpy as np
import matplotlib.pyplot as plt
import json


rutaPLA = 'Comparar_Resultados/PLAcond.mdb'
rutaMetal = 'Comparar_Resultados/M800-50A.mdb'

with open("h_values/h_values.json", "r") as f : hPLA = np.array(json.load(f))

muVacio = 4 * np.pi * 1e-7
bPLA = muVacio * hPLA 

bPLAcond = []
hPLAcond = []

with open(rutaPLA, 'r') as f:
    for linea in f.readlines():
        if linea.startswith("BValue["): bPLAcond.append(float(linea.split("=")[1]))
        if linea.startswith("HValue["): hPLAcond.append(float(linea.split("=")[1]))

bM800 = []
hM800 = []

with open(rutaMetal, 'r') as f:
    for linea in f.readlines():
        if linea.startswith("BValue["): bM800.append(float(linea.split("=")[1]))
        if linea.startswith("HValue["): hM800.append(float(linea.split("=")[1]))

plt.figure()
plt.plot(hPLA, bPLA, label = 'PLA')
plt.plot(hPLAcond, bPLAcond, label = 'PLACond')
plt.plot(hM800, bM800, label = 'M800-50A')
plt.title('Comparacion entre Curvas para Motor CAD')
plt.legend()
plt.show()