# Path: killMS/Other/ClassTimeIt.py
# class ClassTimeIt():
#     def __init__(self,name="",f=1.):
#         self.t0=timemod.time()
#         self.IsEnable=True
#         if name=="":
#             self.name=name
#         else:
#             self.name=name+": "
#         self.IsEnableIncr=False
#         self.Counter=""
#         self.f=f
# 
#     def reinit(self):
#         self.t0=timemod.time()
# 
#     def timeit(self,stri=" Time",hms=False):
#         if self.IsEnable==False: return
#         t1=timemod.time()
#         dt=self.f*(t1-self.t0)
#         if not(hms):
#             Sout= "  * %s%s %s : %7.5fs"%(self.name,stri,str(self.Counter),dt)
#             if self.IsEnableIncr: self.Counter+=1
#         else:
#             ss=(dt)/60.
#             m=int(ss)
#             s=(ss-m)*60.
#             Sout= "  * %s computation time: %i min. %4.1f sec."%(stri,m,s)
#         self.t0=t1
#         if DoLog:
#             log.print( Sout)
#         else:
#             print(Sout)
# 
#         return dt
# 
#     def timeitHMS(self,stri=" Time"):
#         t1=timemod.time()
#         self.t0=t1
# 
#     def disable(self):
#         self.IsEnable=False
# 
#     def enableIncr(self,incr=1):
#         self.IsEnableIncr=True
#         self.Counter=0
# 
#     def AddDt(self,Var):
#         t1=timemod.time()
#         dt=t1-self.t0
#         Var=Var+dt
#         self.t0=t1
#         return Var


import numpy as np
import scipy.ndimage
from killMS.Other import ClassTimeIt
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

class ClassAverageMachine():
    def __init__(self,
                 GD,
                 PM_Compress,
                 SM_Compress,
                 PolMode="Scalar",
                 DicoMergeStations=None):
        self.GD=GD
        self.PM_Compress=PM_Compress
        self.SM_Compress=SM_Compress
        self.PolMode=PolMode
        self.DicoMergeStations=DicoMergeStations
        if self.GD["Solvers"]["NChanSols"]!=1:
            raise ValueError("Only deal with NChanSol=1")
        if self.GD["Solvers"]["PolMode"]!="Scalar":
            raise ValueError("Only deal with PolMode=Scalar")
        self.NJacobBlocks_X,self.NJacobBlocks_Y=1,1
        
    def AverageKernelMatrix(self,DicoData,K):

# Path: killMS/Other/ClassTimeIt.py
# class ClassTimeIt():
#     def __init__(self,name="",f=1.):
#         self.t0=timemod.time()
#         self.IsEnable=True
#         if name=="":
#             self.name=name
#         else:
#             self.name=name+": "
#         self.IsEnableIncr=False
#         self.Counter=""
#         self.f=f
# 
#     def reinit(self):
#         self.t0=timemod.time()
# 
#     def timeit(self,stri=" Time",hms=False):
#         if self.IsEnable==False: return
#         t1=timemod.time()
#         dt=self.f*(t1-self.t0)
#         if not(hms):
#             Sout= "  * %s%s %s : %7.5fs"%(self.name,stri,str(self.Counter),dt)
#             if self.IsEnableIncr: self.Counter+=1
#         else:
#             ss=(dt)/60.
#             m=int(ss)
#             s=(ss-m)*60.
#             Sout= "  * %s computation time: %i min. %4.1f sec."%(stri,m,s)
#         self.t0=t1
#         if DoLog:
#             log.print( Sout)
#         else:
#             print(Sout)
# 
#         return dt
# 
#     def timeitHMS(self,stri=" Time"):
#         t1=timemod.time()
#         self.t0=t1
# 
#     def disable(self):
#         self.IsEnable=False
# 
#     def enableIncr(self,incr=1):
#         self.IsEnableIncr=True
#         self.Counter=0
# 
#     def AddDt(self,Var):
#         t1=timemod.time()
#         dt=t1-self.t0
#         Var=Var+dt
#         self.t0=t1
#         return Var


# Path: killMS/Wirtinger/ClassAverageMachine.py
import numpy as np
import scipy.ndimage
from killMS.Other import ClassTimeIt

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

class ClassAverageMachine():
    def __init__(self,
                 GD,
                 PM_Compress,
                 SM_Compress,
                 PolMode="Scalar",
                 DicoMergeStations=None):
        self.GD=GD
        self.PM_Compress=PM_Compress
        self.SM_Compress=SM_Compress
        self.PolMode=PolMode
        self.DicoMergeStations=DicoMergeStations
        if self.GD["Solvers"]["NChanSols"]!=1:
            raise ValueError("Only deal with NChanSol=1")
        if self.GD["Solvers"]["PolMode"]!="Scalar":
            raise ValueError("Only deal with PolMode=Scalar")
        self.NJacobBlocks_X,self.NJacobBlocks_Y=1,1
        
    def AverageKernelMatrix(self,DicoData,K):

        T=ClassTimeIt.ClassTimeIt("AverageKernelMatrix")