import numpy as np
import json as json

from o_plot import opl # a small local package dedicated to this project

import sys
print(sys.executable)

# loading the data
file_name = 'QAD_data_new.json'
f = open(file_name)
All_data = json.load(f)

# this for Jensen-Shannon metric 
s_metric = 'jensenshannon'
sm = np.array([96])
SAD=0
# ! will be unselected by running the next cell

# main option for metric: squared euclidean distance
# skip this cell if you don't want this option
s_metric = 'sqeuclidean'
sm = np.array([97])
SAD=2   

# this for measurement mitigation
mit = 'yes'
MIT=0
# ! will be unselected by running the next cell

# main option: no mitigation
# skip this cell if you don't want this option
mit = 'no'
MIT=-4

ADD=-3
opl.plot_curves(All_data, ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared euclidean distance - $\epsilon=0.001$ - no delay", 
             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=1
opl.plot_curves(All_data, ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared euclidean distance - $\epsilon=0.001$ - no delay", 
             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=45
opl.plot_curves(All_data, ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared euclidean distance - $\epsilon=0.001$ - with delay", 
             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=49
opl.plot_curves(All_data, ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared euclidean distance - $\epsilon=0.001$ - with delay", 
             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=-4
opl.plot_curves(All_data, ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared euclidean distance - $\epsilon=0.001$ - no delay", 
             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=0
opl.plot_curves(All_data, ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared euclidean distance - $\epsilon=0.001$ - no delay", 
             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=44
opl.plot_curves(All_data, ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared euclidean distance - $\epsilon=0.001$ - with delay", 
 
             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=48
opl.plot_curves(All_data,ADD+np.array([96-ADD,97-ADD,4,6,12,14,20,22,28,30,36,38,44,46]),
            "Jensen-Shannon vs squared eucliden distance - $\epsilon=0.001$ - with delay", 

             ["model","mitigation"], ["device","metric"],  right_xlimit = 90)

ADD=1+SAD
opl.plot_curves(All_data, np.append(sm,ADD+np.array([0,4,8,12,16,20,24,28,32,36,40,44])),
             "Effect of mitigation - $\epsilon=0.001$ - no delay", 
             ["model","metric"], ["device","mitigation"],  right_xlimit = 90)

ADD=49+SAD
opl.plot_curves(All_data, np.append(sm,ADD+np.array([0,4,8,12,16,20,24,28,32,36,40,44])),
             "Effect of mitigation - $\epsilon=0.001$ - with delay", 
             ["model","metric"], ["device","mitigation"],  right_xlimit = 90)

ADD=0+SAD
opl.plot_curves(All_data,np.append(sm,ADD+np.array([0,4,8,12,16,20,24,28,32,36,40,44])),        
         "Effect of mitigation - $\epsilon=0.001$ - no delay", 
         ["model","metric"], ["device","mitigation"],  right_xlimit = 90)

ADD=48+SAD
opl.plot_curves(All_data,np.append(sm,ADD+np.array([0,4,8,12,16,20,24,28,32,36,40,44])),        
         "Effect of mitigation - $\epsilon=0.001$ - with delay", 
         ["model","metric"], ["device","mitigation"],  right_xlimit =90)

ADD=-3+SAD
opl.plot_curves(All_data,np.append(sm,ADD+np.array([4,52,12,60,20,68,28,76,36,84,44,92])),
            "Effect of Delay - $\epsilon=0.001$",
            ["model","metric","mitigation"],
            ["device","model","id_gates"], right_xlimit = 90)

ADD=1+SAD
opl.plot_curves(All_data,np.append(sm,ADD+np.array([4,52,12,60,20,68,28,76,36,84,44,92])),
            "Effect of Delay - $\epsilon=0.001$",
            ["model","metric","mitigation"],
            ["device","model","id_gates"], right_xlimit = 90)

ADD=-4+SAD
opl.plot_curves(All_data,np.append(sm,ADD+np.array([4,52,12,60,20,68,28,76,36,84,44,92])),
                "Effect of Delay - $\epsilon=0.001$",
                ["model","metric","mitigation"],
                ["device","model","id_gates"], right_xlimit = 90)

ADD=0+SAD
opl.plot_curves(All_data,np.append(sm,ADD+np.array([4,52,12,60,20,68,28,76,36,84,44,92])),
                "Effect of Delay - $\epsilon=0.001$",
                ["model","metric","mitigation"],
                ["device","model","id_gates"], right_xlimit = 90)