# Path: killMS/Other/ModColor.py
# HEADER = '\033[95m'
# OKBLUE = '\033[94m'
# OKGREEN = '\033[92m'
# WARNING = '\033[93m'
# FAIL = '\033[91m'
# ENDC = '\033[0m'
#     HEADER = ''
#     OKBLUE = ''
#     OKGREEN = ''
#     WARNING = ''
#     FAIL = ''
#     ENDC = ''
# def Str(strin0,col="red",Bold=True):
# def Sep(strin=None,D=1):
# def Title(strin,Big=False):
# def disable():
# 
# Path: killMS/Other/reformat.py
# def reformat(ssin,slash=True,LastSlash=True):
#     ss=ssin.split("/")
#     ss=filter (lambda a: a != "", ss)
#     ss="/".join(ss)+"/"
#     if ssin[0]=="/": ss="/"+ss
#     if not(slash):
#         ss=ss[1:-1]
#     if not(LastSlash):
#         if ss[-1]=="/": ss=ss[0:-1]
#     return ss


import numpy as np
import os
from DDFacet.Other import logger
from killMS.Other import ModColor
from killMS.Other import reformat
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
log=logger.getLogger("ClassSolPredictMachine")

def D(a0,a1,b0=None,b1=None):
    if b0 is not None:
        d=np.sqrt((a0.reshape((-1,1))-a1.reshape((1,-1)))**2+(b0.reshape((-1,1))-b1.reshape((1,-1)))**2)
    else:
        d=np.sqrt((a0.reshape((-1,1))-a1.reshape((1,-1)))**2)
    return d

        
class ClassSolPredictMachine():
    def __init__(self,GD):
        self.GD=GD
        # FileName=self.GD["KAFCA"]["EvolutionSolFile"]
        # if not ".npz" in FileName:
        #     FileName="%s/killMS.%s.sols.npz"%(self.GD["VisData"]["MSName"],FileName)


        SolsDir=GD["Solutions"]["SolsDir"]
        SolsName=self.GD["KAFCA"]["EvolutionSolFile"]
        MSName=os.path.abspath(self.GD["VisData"]["MSName"])
        if SolsDir is None:
            FileName="%skillMS.%s.sols.npz"%(reformat.reformat(options.MSName),SolsName)
        else:
            _MSName=reformat.reformat(MSName).split("/")[-2]

# Path: killMS/Other/ModColor.py
# HEADER = '\033[95m'
# OKBLUE = '\033[94m'
# OKGREEN = '\033[92m'
# WARNING = '\033[93m'
# FAIL = '\033[91m'
# ENDC = '\033[0m'
#     HEADER = ''
#     OKBLUE = ''
#     OKGREEN = ''
#     WARNING = ''
#     FAIL = ''
#     ENDC = ''
# def Str(strin0,col="red",Bold=True):
# def Sep(strin=None,D=1):
# def Title(strin,Big=False):
# def disable():
# 
# Path: killMS/Other/reformat.py
# def reformat(ssin,slash=True,LastSlash=True):
#     ss=ssin.split("/")
#     ss=filter (lambda a: a != "", ss)
#     ss="/".join(ss)+"/"
#     if ssin[0]=="/": ss="/"+ss
#     if not(slash):
#         ss=ss[1:-1]
#     if not(LastSlash):
#         if ss[-1]=="/": ss=ss[0:-1]
#     return ss


# Path: killMS/Wirtinger/ClassSolPredictMachine.py
import numpy as np
import os
from DDFacet.Other import logger
from killMS.Other import ModColor
from killMS.Other import reformat

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
log=logger.getLogger("ClassSolPredictMachine")

def D(a0,a1,b0=None,b1=None):
    if b0 is not None:
        d=np.sqrt((a0.reshape((-1,1))-a1.reshape((1,-1)))**2+(b0.reshape((-1,1))-b1.reshape((1,-1)))**2)
    else:
        d=np.sqrt((a0.reshape((-1,1))-a1.reshape((1,-1)))**2)
    return d

        
class ClassSolPredictMachine():
    def __init__(self,GD):
        self.GD=GD
        # FileName=self.GD["KAFCA"]["EvolutionSolFile"]
        # if not ".npz" in FileName:
        #     FileName="%s/killMS.%s.sols.npz"%(self.GD["VisData"]["MSName"],FileName)


        SolsDir=GD["Solutions"]["SolsDir"]
        SolsName=self.GD["KAFCA"]["EvolutionSolFile"]
        MSName=os.path.abspath(self.GD["VisData"]["MSName"])
        if SolsDir is None:
            FileName="%skillMS.%s.sols.npz"%(reformat.reformat(options.MSName),SolsName)
        else:
            _MSName=reformat.reformat(MSName).split("/")[-2]

            DirName=os.path.abspath("%s%s"%(reformat.reformat(SolsDir),_MSName))