# 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():


import scipy.linalg
import numpy as np
    import pylab
    import ClassTimeIt
    import ClassTimeIt
from killMS.Other import ModColor

    ls=np.log10(np.abs(s))
    pylab.subplot(2,3,3)
    pylab.plot(np.abs(s))
    pylab.title("[%f, %f]"%(ls.min(),ls.max()))

    I=np.dot(Ainv,A)

    pylab.subplot(2,3,4)
    pylab.imshow(I.real,interpolation="nearest",vmin=-0.01,vmax=0.01)
    pylab.colorbar()

    pylab.subplot(2,3,5)
    pylab.imshow(I.imag,interpolation="nearest")
    pylab.colorbar()

    pylab.draw()
    pylab.show(False)
    pylab.pause(0.1)        
    


def invSVD(A):


    try:
        u,s,v=np.linalg.svd(np.complex128(A))#+np.random.randn(*A.shape)*(1e-6*A.max()))
    except:
        Name="errSVDArray_%i"%int(np.random.rand(1)[0]*10000)
        print(ModColor.Str("Problem inverting Matrix, saving as %s"%Name))

# 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/Array/ModLinAlg.py
import scipy.linalg
import numpy as np
    import pylab
    import ClassTimeIt
    import ClassTimeIt
from killMS.Other import ModColor


    ls=np.log10(np.abs(s))
    pylab.subplot(2,3,3)
    pylab.plot(np.abs(s))
    pylab.title("[%f, %f]"%(ls.min(),ls.max()))

    I=np.dot(Ainv,A)

    pylab.subplot(2,3,4)
    pylab.imshow(I.real,interpolation="nearest",vmin=-0.01,vmax=0.01)
    pylab.colorbar()

    pylab.subplot(2,3,5)
    pylab.imshow(I.imag,interpolation="nearest")
    pylab.colorbar()

    pylab.draw()
    pylab.show(False)
    pylab.pause(0.1)        
    


def invSVD(A):


    try:
        u,s,v=np.linalg.svd(np.complex128(A))#+np.random.randn(*A.shape)*(1e-6*A.max()))
    except:
        Name="errSVDArray_%i"%int(np.random.rand(1)[0]*10000)
        print(ModColor.Str("Problem inverting Matrix, saving as %s"%Name))

        print(ModColor.Str("  will make it svd-able"))