Index: src/conf.py
===================================================================
--- src/conf.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/conf.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,4 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 import sys
 import os
@@ -6,4 +8,5 @@
 
 # ipython
+
 import sip
 sip.setapi('QString', 2)
@@ -11,8 +14,10 @@
 
 # pyqt4
+
 from PyQt4 import QtCore, QtGui
 from PyQt4 import Qt
 
 # matplot
+
 import matplotlib
 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
@@ -27,25 +32,30 @@
 # import vtk
 
-#sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+# sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
 
 # TextEdit Height
-CSNStextMaximumHeight=26
-CSNStextMinimumHeight=10
+
+CSNStextMaximumHeight = 26
+CSNStextMinimumHeight = 10
 
 # Table Height
-CSNStableMinimumHeight=100
+
+CSNStableMinimumHeight = 100
 
 # unit mm
-CSNSMRslit1Height=20
-CSNSMRslit2Height=12.7
-CSNSMRsampleHeight=10
 
-CSNSMRsamplePosition=0
-CSNSMRslit1Position=-2315
-CSNSMRslit2Position=-635
-CSNSMRslit3Position=650
+CSNSMRslit1Height = 20
+CSNSMRslit2Height = 12.7
+CSNSMRsampleHeight = 10
+
+CSNSMRsamplePosition = 0
+CSNSMRslit1Position = -2315
+CSNSMRslit2Position = -635
+CSNSMRslit3Position = 650
 
 # sizePolicy
-CSNSsizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
+
+CSNSsizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
+                                   QtGui.QSizePolicy.Expanding)
 CSNSsizePolicy.setHorizontalStretch(1)
 CSNSsizePolicy.setVerticalStretch(1)
Index: src/dat/3d.py
===================================================================
--- src/dat/3d.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/dat/3d.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,8 +1,12 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 import math
 from math import atan
-from numpy import*
+from numpy import *
 from scipy import pi
 import numpy as np
-#import pylab
+
+# import pylab
+
 import time
 from scipy.interpolate import InterpolatedUnivariateSpline
@@ -10,78 +14,83 @@
 import random
 
+
 def gauss(parameters, values):
-	a, x0, w, y0 = parameters
-	x = values
-	return(a * exp(-(x-x0)**2/2/w**2) + y0)
+    (a, x0, w, y0) = parameters
+    x = values
+    return a * exp(-(x - x0) ** 2 / 2 / w ** 2) + y0
 
-nx=100
-ny=80
 
-dat1=np.zeros((nx,ny))
-dat2=np.zeros((nx,ny))
-dat3=np.zeros((nx,ny))
+nx = 100
+ny = 80
 
-peak=1000
-background=peak*0.05
-iwidth=10
-jwidth=2
-center1=26
-center2=64
+dat1 = np.zeros((nx, ny))
+dat2 = np.zeros((nx, ny))
+dat3 = np.zeros((nx, ny))
+
+peak = 1000
+background = peak * 0.05
+iwidth = 10
+jwidth = 2
+center1 = 26
+center2 = 64
 
 for i in range(nx):
-	for j in range(ny):
-		dat1[i][j]=random.uniform(0,background)
-		dat2[i][j]=dat1[i][j]
+    for j in range(ny):
+        dat1[i][j] = random.uniform(0, background)
+        dat2[i][j] = dat1[i][j]
 
-_r0=sqrt((0-nx/2)**2/iwidth**2+(0-ny/2)**2/jwidth**2)
-for i in range(nx):
-	for j in range(ny):
-		_r1=sqrt((i-nx/2)**2/iwidth**2+(j-center1)**2/jwidth**2)
-		_r2=sqrt((i-nx/2)**2/iwidth**2+(j-center2)**2/jwidth**2)
-		if _r1<=sqrt(2) or _r2<=sqrt(2):
-		    dat1[i][j]+=peak*(1-0.2/iwidth*abs(i-nx/2))
-		else:
-		    dat1[i][j]+=peak*(1/_r1+1/_r2)*0.2*random.uniform(0,1)
-
-_nx=random.randint(5,nx-5)
-_ny=random.randint(5,ny-5)
+_r0 = sqrt((0 - nx / 2) ** 2 / iwidth ** 2 + (0 - ny / 2) ** 2 / jwidth
+           ** 2)
 for i in range(nx):
     for j in range(ny):
-        if(i-_nx)**2/10**2+(j-_ny)**2/5**2<1:
-            dat2[i][j]+=5*background*random.uniform(0.1,1)
-        elif (j>17 and j<21):
-            dat2[i][j]=-background
+        _r1 = sqrt((i - nx / 2) ** 2 / iwidth ** 2 + (j - center1) ** 2
+                   / jwidth ** 2)
+        _r2 = sqrt((i - nx / 2) ** 2 / iwidth ** 2 + (j - center2) ** 2
+                   / jwidth ** 2)
+        if _r1 <= sqrt(2) or _r2 <= sqrt(2):
+            dat1[i][j] += peak * (1 - 0.2 / iwidth * abs(i - nx / 2))
+        else:
+            dat1[i][j] += peak * (1 / _r1 + 1 / _r2) * 0.2 \
+                * random.uniform(0, 1)
 
-f1=open('3d0.dat',"w")
+_nx = random.randint(5, nx - 5)
+_ny = random.randint(5, ny - 5)
 for i in range(nx):
-	for j in range(ny):
-		f1.write('%8.f\t' % (dat1[i][j]))
-	f1.write('%s' % ('\n'))
+    for j in range(ny):
+        if (i - _nx) ** 2 / 10 ** 2 + (j - _ny) ** 2 / 5 ** 2 < 1:
+            dat2[i][j] += 5 * background * random.uniform(0.1, 1)
+        elif j > 17 and j < 21:
+            dat2[i][j] = -background
+
+f1 = open('3d0.dat', 'w')
+for i in range(nx):
+    for j in range(ny):
+        f1.write('%8.f\t' % dat1[i][j])
+    f1.write('%s' % '\n')
 f1.close()
 
-f1=open('3d1.dat',"w")
+f1 = open('3d1.dat', 'w')
 for i in range(nx):
-	for j in range(ny):
-		f1.write('%8.f\t%8.f\t%8.f\n' % (i,j,dat1[i][j]))
+    for j in range(ny):
+        f1.write('%8.f\t%8.f\t%8.f\n' % (i, j, dat1[i][j]))
 
 f1.close()
 
-f1=open('detector.dat',"w")
+f1 = open('detector.dat', 'w')
 for i in range(nx):
     for j in range(ny):
-        f1.write('%8.f\t%8.f\t%8.f\n' % (i,j,dat2[i][j]))
+        f1.write('%8.f\t%8.f\t%8.f\n' % (i, j, dat2[i][j]))
 
 f1.close()
 
-
-f1=open('2d-x.dat',"w")
+f1 = open('2d-x.dat', 'w')
 for i in range(nx):
-	f1.write('%f\t%8.f\n' % (i, dat1[i][int(center1)]))
+    f1.write('%f\t%8.f\n' % (i, dat1[i][int(center1)]))
 
 f1.close()
 
-f1=open('2d-y.dat',"w")
+f1 = open('2d-y.dat', 'w')
 for j in range(ny):
-	f1.write('%f\t%8.f\n' % (j, dat1[int(nx/2)][j]))
+    f1.write('%f\t%8.f\n' % (j, dat1[int(nx / 2)][j]))
 
 f1.close()
Index: src/dat/ReadData.py
===================================================================
--- src/dat/ReadData.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/dat/ReadData.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,46 +1,51 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+
 def Read2DData(fname):
-    data=[]
+    data = []
 
-    fopen=open(fname, "r")
-    lines=fopen.readlines()
+    fopen = open(fname, 'r')
+    lines = fopen.readlines()
 
-    check=lines[-1].split()
-    n=len(check)
+    check = lines[-1].split()
+    n = len(check)
     for i in range(n):
-    	data.append([])
+        data.append([])
 
     for line in lines:
-    	tmp=line.split()
-    	for i in range(n):
-    		data[i].append(float(tmp[i]))
+        tmp = line.split()
+        for i in range(n):
+            data[i].append(float(tmp[i]))
 
-    return n, data
+    return (n, data)
+
 
 def Read3DData(fname):
-    data=[]
+    data = []
 
-    fopen=open(fname, "r")
-    lines=fopen.readlines()
+    fopen = open(fname, 'r')
+    lines = fopen.readlines()
 
-    ngroup=-1
-    nfirst=-1
+    ngroup = -1
+    nfirst = -1
     for line in lines:
-        ngroup+=1
-        tmp=line.split()
-        if ngroup==0:
-            nfirst=tmp[0]
-        elif nfirst==tmp[0]:
+        ngroup += 1
+        tmp = line.split()
+        if ngroup == 0:
+            nfirst = tmp[0]
+        elif nfirst == tmp[0]:
             break
 
-    nline=-1
-    nnew=0
+    nline = -1
+    nnew = 0
     X.append([])
     Y.append([])
     Z.append([])
     for line in lines:
-        nline+=1
-        if nline==ngroup:
-            nline=-1
-            nnew+=1
+        nline += 1
+        if nline == ngroup:
+            nline = -1
+            nnew += 1
             X.append([])
             Y.append([])
@@ -51,3 +56,5 @@
             Z[nnew].append(float(tmp[0]))
 
-    return X, Y, Z
+    return (X, Y, Z)
+
+
Index: src/main.py
===================================================================
--- src/main.py	(revision 2b41ffeb36a5e52980441e46fafca007f1479f36)
+++ src/main.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,7 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# configure
+
 '''
 Created on 2015.9.25
@@ -4,8 +9,8 @@
 '''
 
-# configure
 from conf import *
 
 # user defined
+
 from viewer.runList import *
 from viewer.runData import *
@@ -13,7 +18,9 @@
 from viewer.subTab import *
 
+
 class myMenuBar(QtGui.QMenuBar):
+
     def __init__(self, parent=None):
-        super(myMenuBar,self).__init__(parent)
+        super(myMenuBar, self).__init__(parent)
         self.CreateMenuBar()
         self.open_action.triggered.connect(self.file_open)
@@ -21,40 +28,51 @@
     def CreateMenuBar(self):
 
-        self.file_menu = self.addMenu("File(&F)")
-        self.edit_menu = self.addMenu("Edit(&E)")
-        self.help_menu = self.addMenu("Help(&H)")
+        self.file_menu = self.addMenu('File(&F)')
+        self.edit_menu = self.addMenu('Edit(&E)')
+        self.help_menu = self.addMenu('Help(&H)')
 
-        self.open_action = self.file_menu.addAction("Open")
-        self.save_action = self.file_menu.addAction("Save")
-        self.exit_action = self.file_menu.addAction("Exit")
+        self.open_action = self.file_menu.addAction('Open')
+        self.save_action = self.file_menu.addAction('Save')
+        self.exit_action = self.file_menu.addAction('Exit')
         icon = QtGui.QIcon()
-        icon.addPixmap(QtGui.QPixmap("icon/open.jpg"),QtGui.QIcon.Normal,QtGui.QIcon.Off)
+        icon.addPixmap(QtGui.QPixmap('icon/open.jpg'),
+                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
         self.open_action.setIcon(icon)
-        self.open_action.setShortcut(QtCore.QCoreApplication.translate("MainWindow","Ctrl+O"))
+        self.open_action.setShortcut(QtCore.QCoreApplication.translate('MainWindow'
+                , 'Ctrl+O'))
         icon2 = QtGui.QIcon()
-        icon2.addPixmap(QtGui.QPixmap("icon/save.jpg"),QtGui.QIcon.Normal,QtGui.QIcon.Off)
+        icon2.addPixmap(QtGui.QPixmap('icon/save.jpg'),
+                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
         self.save_action.setIcon(icon2)
-        self.save_action.setShortcut(QtCore.QCoreApplication.translate("MainWindow","Ctrl+S"))
+        self.save_action.setShortcut(QtCore.QCoreApplication.translate('MainWindow'
+                , 'Ctrl+S'))
         icon3 = QtGui.QIcon()
-        icon3.addPixmap(QtGui.QPixmap("icon/exit.jpg"),QtGui.QIcon.Normal,QtGui.QIcon.Off)
+        icon3.addPixmap(QtGui.QPixmap('icon/exit.jpg'),
+                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
         self.exit_action.setIcon(icon3)
-        self.exit_action.setShortcut(QtCore.QCoreApplication.translate("MainWindow","Ctrl+P"))
+        self.exit_action.setShortcut(QtCore.QCoreApplication.translate('MainWindow'
+                , 'Ctrl+P'))
 
-        self.cut_action = self.edit_menu.addAction("Cut")
-        self.copy_action = self.edit_menu.addAction("Copy")
-        self.past_action = self.edit_menu.addAction("Paste")
+        self.cut_action = self.edit_menu.addAction('Cut')
+        self.copy_action = self.edit_menu.addAction('Copy')
+        self.past_action = self.edit_menu.addAction('Paste')
 
     def file_open(self):
-        fileName = QtGui.QFileDialog.getOpenFileName(self,("title"),("./"),(""))#,None)
-        print('fileName:',fileName)
-        #print(selectedFilter)
+        fileName = QtGui.QFileDialog.getOpenFileName(self, 'title', './'
+                , '')  # ,None)
+        print ('fileName:', fileName)
+
+
+        # print(selectedFilter)
 
 class myStatusBar(QtGui.QStatusBar):
+
     def __init__(self, parent=None):
-        super(myStatusBar,self).__init__(parent)
+        super(myStatusBar, self).__init__(parent)
         self.CreateStatusBar()
 
     def CreateStatusBar(self):
         pass
+
 
 class mywindow(QtGui.QMainWindow):
@@ -64,5 +82,5 @@
         self.setupUi(self)
 
-    def setupUi(self,MainWindow):
+    def setupUi(self, MainWindow):
 
         self.myMenuBar = myMenuBar(self)
@@ -72,8 +90,8 @@
         self.setStatusBar(self.myStatusBar)
 
-        self.mainSplitter = QtGui.QSplitter(QtCore.Qt.Horizontal,self)
+        self.mainSplitter = QtGui.QSplitter(QtCore.Qt.Horizontal, self)
 
-        self.leftSplitter = QtGui.QSplitter(QtCore.Qt.Vertical,self)
-        self.rightSplitter = QtGui.QSplitter(QtCore.Qt.Vertical,self)
+        self.leftSplitter = QtGui.QSplitter(QtCore.Qt.Vertical, self)
+        self.rightSplitter = QtGui.QSplitter(QtCore.Qt.Vertical, self)
 
         self.upLeftListWidget = CSNSRunList(self.leftSplitter)
@@ -83,6 +101,6 @@
         self.downRightTab = CSNSSubTab(self.rightSplitter)
 
-        self.leftSplitter.setSizes([600,200])
-        self.rightSplitter.setSizes([700,100])
+        self.leftSplitter.setSizes([600, 200])
+        self.rightSplitter.setSizes([700, 100])
 
         self.leftSplitter.addWidget(self.upLeftListWidget)
@@ -96,21 +114,25 @@
 
     def btnExit(self):
-        if self.pushButton.text()=="Let it go":
-               print(self.pushButton.text())
-               self.pushButton.setText("I'm still here!")
+        if self.pushButton.text() == 'Let it go':
+            print self.pushButton.text()
+            self.pushButton.setText("I'm still here!")
         else:
-               print(self.pushButton.text())
-               self.pushButton.setText("Let it go")
+            print self.pushButton.text()
+            self.pushButton.setText('Let it go')
+
 
 def main():
     myapp = QtGui.QApplication(sys.argv)
     mytop = mywindow()
-    mytop.setWindowTitle("GPPD")
-    mytop.resize(1200,800)
+    mytop.setWindowTitle('GPPD')
+    mytop.resize(1200, 800)
     mytop.show()
     sys.exit(myapp.exec_())
 
+
 if __name__ == '__main__':
-    #if __package__ is None:
-    	#sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
+
+    # if __package__ is None:
+        # sys.path.append( path.dirname( path.dirname( path.abspath(__file__) ) ) )
+
     main()
Index: src/model/__init__.py
===================================================================
--- src/model/__init__.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/__init__.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,15 +1,18 @@
-__all__=['model']
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+__all__ = ['model']
 
 import os
 from glob import glob
 
-_modules=list(map(os.path.basename, glob(os.path.join(os.path.dirname(__file__), '*.py'))))
+_modules = list(map(os.path.basename,
+                glob(os.path.join(os.path.dirname(__file__), '*.py'))))
 _modules.remove('__init__.py')
-_modules=[mod[:-3] for mod in _modules]
+_modules = [mod[:-3] for mod in _modules]
 
-model={}
+model = {}
 
 for mod in _modules:
-  _module=__import__('model.'+mod, fromlist=[mod])
-  if 'suite' in _module.__dict__:
-    model[mod]=_module.suite
+    _module = __import__('model.' + mod, fromlist=[mod])
+    if 'suite' in _module.__dict__:
+        model[mod] = _module.suite
Index: src/model/chopperModel.py
===================================================================
--- src/model/chopperModel.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/chopperModel.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,42 +1,50 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 import numpy as np
 
-class TimeFrameCalculation():
+
+class TimeFrameCalculation:
+
     def __init__(self, lambdaMin=0.1, lambdaMax=6.0):
-        #super(TimeFrameCalculation, self).__init__(lambdaMin, lambdaMax)
-        self.lambdaMin=lambdaMin
-        self.lambdaMax=lambdaMax
+
+        # super(TimeFrameCalculation, self).__init__(lambdaMin, lambdaMax)
+
+        self.lambdaMin = lambdaMin
+        self.lambdaMax = lambdaMax
 
     def getTimeFrame(self):
-        _npulse=5
-        pulseList=[]
+        _npulse = 5
+        pulseList = []
         for i in range(_npulse):
-            pulseList.append(i*40)
+            pulseList.append(i * 40)
 
-        _nchopper=5
-        chopperList=[0,6.395,8.359,9.923,12]
+        _nchopper = 5
+        chopperList = [0, 6.395, 8.359, 9.923, 12]
 
-        timeList=[]
+        timeList = []
         for i in range(_nchopper):
             timeList.append([])
             timeList[i].append(0)
             for j in range(_npulse):
-                _t0=j*40
-                _t1=chopperList[i]*self.lambdaMin/3.9562
-                _t2=chopperList[i]*self.lambdaMax/3.9562
-                timeList[i].append(_t0+_t1)
-                timeList[i].append(_t0+_t2)
-            timeList[i].append((_npulse+1)*40)
+                _t0 = j * 40
+                _t1 = chopperList[i] * self.lambdaMin / 3.9562
+                _t2 = chopperList[i] * self.lambdaMax / 3.9562
+                timeList[i].append(_t0 + _t1)
+                timeList[i].append(_t0 + _t2)
+            timeList[i].append((_npulse + 1) * 40)
 
-        lineList=[]
+        lineList = []
 
-        xList=[]
-        yList=[0,chopperList[-1]]
-        
-        _LDC1=chopperList[1]
-        _LSAM=chopperList[-1]
-        for i in range(1,len(timeList[1])-1):
-            _tmp=_LSAM/(_LDC1/timeList[1][i])
-            for j in range(len(pulseList)):                
-                xList.append([pulseList[j],pulseList[j]+_tmp])
+        xList = []
+        yList = [0, chopperList[-1]]
 
-        return pulseList, chopperList, timeList, xList, yList
+        _LDC1 = chopperList[1]
+        _LSAM = chopperList[-1]
+        for i in range(1, len(timeList[1]) - 1):
+            _tmp = _LSAM / (_LDC1 / timeList[1][i])
+            for j in range(len(pulseList)):
+                xList.append([pulseList[j], pulseList[j] + _tmp])
+
+        return (pulseList, chopperList, timeList, xList, yList)
+
+
Index: src/model/getROI.py
===================================================================
--- src/model/getROI.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/getROI.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,10 +1,15 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 from model.peakFinder import *
 
-def getROI( dataX, dataY):
-    peakfinder=PeakFinder(dataX,dataY)
-    _ridge_length=max(dataY)
-    peaks=peakfinder.get_peaks(snr=5, min_width=4, max_width=20, ridge_length=_ridge_length)
+
+def getROI(dataX, dataY):
+    peakfinder = PeakFinder(dataX, dataY)
+    _ridge_length = max(dataY)
+    peaks = peakfinder.get_peaks(snr=5, min_width=4, max_width=20,
+                                 ridge_length=_ridge_length)
     print peaks
 
     return peaks
 
+
Index: src/model/peakFinder.py
===================================================================
--- src/model/peakFinder.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/peakFinder.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,3 +1,5 @@
-#-*- coding: utf8 -*-
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
 '''
 Peak finder algorithm based on the continuous wavelet transform (CWT) method
@@ -10,11 +12,17 @@
 import numpy
 try:
-  from scipy.stats.mstats import mquantiles
+    from scipy.stats.mstats import mquantiles
 except (ImportError, RuntimeError):
+
+
   # use the slightly slower quantiles function that does not rely on scipy
-  def mquantiles(data, prob, *ignore): return quantile(data, prob)
+
+    def mquantiles(data, prob, *ignore):
+        return quantile(data, prob)
+
 
 class PeakFinder(object):
-  '''
+
+    '''
   Peak finder which can be reevaluated with different thresholds 
   without recalculation all steps.
@@ -28,30 +36,33 @@
   '''
 
-  def __init__(self, xdata, ydata, resolution=5):
-    xdata=numpy.array(xdata)
-    ydata=numpy.array(ydata)
-    idx=numpy.argsort(xdata)
-    self.xdata=xdata[idx]
-    self.ydata=ydata[idx]
-    self.resolution=resolution
-    self.positions=[]
-
-    self._CWT()
-    self._find_ridges()
-    self._SNR()
-
-  def _CWT(self):
-    '''
+    def __init__(
+        self,
+        xdata,
+        ydata,
+        resolution=5,
+        ):
+        xdata = numpy.array(xdata)
+        ydata = numpy.array(ydata)
+        idx = numpy.argsort(xdata)
+        self.xdata = xdata[idx]
+        self.ydata = ydata[idx]
+        self.resolution = resolution
+        self.positions = []
+
+        self._CWT()
+        self._find_ridges()
+        self._SNR()
+
+    def _CWT(self):
+        '''
     Create the continous wavelet transform for the dataset.
     '''
-    self.CWT=MexicanHat(self.ydata,
-                        largestscale=1,
-                        notes=self.resolution,
-                        order=1,
-                        scaling='log',
-                        )
-
-  def _find_ridges(self, maxgap=4):
-    '''
+
+        self.CWT = MexicanHat(self.ydata, largestscale=1,
+                              notes=self.resolution, order=1,
+                              scaling='log')
+
+    def _find_ridges(self, maxgap=4):
+        '''
     Ridges are lines connecting local maxima at different
     scales of the CWT. Starting from the highest scale
@@ -60,106 +71,130 @@
     weaker or noise, as they start at higher scales.
     '''
-    cwt=self.CWT.getdata()
-    scales=self.CWT.getscales()
+
+        cwt = self.CWT.getdata()
+        scales = self.CWT.getscales()
+
     # initialize ridges starting at smoothest scaling
-    ridges=[]
-    gaps=[]
-    cwt_len=len(cwt)
-    for j, cwti in enumerate(reversed(cwt)):
-      local_maxi=self._find_local_max(cwti)
-      local_max_positions=numpy.where(local_maxi)[0]
-      if len(local_max_positions)==0:
+
+        ridges = []
+        gaps = []
+        cwt_len = len(cwt)
+        for (j, cwti) in enumerate(reversed(cwt)):
+            local_maxi = self._find_local_max(cwti)
+            local_max_positions = numpy.where(local_maxi)[0]
+            if len(local_max_positions) == 0:
+
         # if there is no local maximum, continue with next step
-        continue
-      for i, ridge in enumerate(ridges):
-        if gaps[i]<=maxgap:
-          ridge_pos=ridge[-1][1]
-          min_dist=numpy.abs(local_max_positions-ridge_pos).min()
-          if min_dist<=scales[cwt_len-j]:
-            idx=numpy.where(numpy.abs(local_max_positions-ridge_pos)==min_dist)[0][0]
-            ridge.append([cwt_len-j-1, int(local_max_positions[idx])])
-            gaps[i]=0
-            local_max_positions[idx]=-1000
-          else:
-            gaps[i]+=1
-      for ridge_pos in local_max_positions[local_max_positions>=0]: #@NoEffect
-        gaps.append(0)
-        ridges.append([[cwt_len-j-1, ridge_pos]])
+
+                continue
+            for (i, ridge) in enumerate(ridges):
+                if gaps[i] <= maxgap:
+                    ridge_pos = ridge[-1][1]
+                    min_dist = numpy.abs(local_max_positions
+                            - ridge_pos).min()
+                    if min_dist <= scales[cwt_len - j]:
+                        idx = numpy.where(numpy.abs(local_max_positions
+                                - ridge_pos) == min_dist)[0][0]
+                        ridge.append([cwt_len - j - 1,
+                                int(local_max_positions[idx])])
+                        gaps[i] = 0
+                        local_max_positions[idx] = -1000
+                    else:
+                        gaps[i] += 1
+            for ridge_pos in local_max_positions[local_max_positions
+                    >= 0]:  # @NoEffect
+                gaps.append(0)
+                ridges.append([[cwt_len - j - 1, ridge_pos]])
+
     # collect some information on the ridge lines
-    evaluated_ridges=[]
-    ridge_info=[]
-    ridge_intensities=[]
-    for ridge in ridges:
-      ridge=numpy.array(ridge)
+
+        evaluated_ridges = []
+        ridge_info = []
+        ridge_intensities = []
+        for ridge in ridges:
+            ridge = numpy.array(ridge)
+
       # len of ridge line and position of last point
-      info=[ridge.shape[0], ridge[-1][1]]
-      ridge_intensity=[]
-      for rs, rx in ridge:
-        ridge_intensity.append(cwt[rs, rx])
-      ridge_intensity=numpy.array(ridge_intensity)
-      max_idx=numpy.argmax(ridge_intensity)
+
+            info = [ridge.shape[0], ridge[-1][1]]
+            ridge_intensity = []
+            for (rs, rx) in ridge:
+                ridge_intensity.append(cwt[rs, rx])
+            ridge_intensity = numpy.array(ridge_intensity)
+            max_idx = numpy.argmax(ridge_intensity)
+
       # scale of maximum coefficient on the ridge line
-      #info.append(ridge[max_idx][0])
-      info.append(scales[ridge[max_idx][0]])
-      info.append(ridge_intensity[max_idx])
+      # info.append(ridge[max_idx][0])
+
+            info.append(scales[ridge[max_idx][0]])
+            info.append(ridge_intensity[max_idx])
+
       # peak center estimate from ridge maximum
-      info.append(ridge[max_idx][1])
-      ridge_info.append(info)
-      ridge_intensities.append(ridge_intensity)
-      evaluated_ridges.append(numpy.vstack([ridge[:, 0], ridge[:, 1], ridge_intensity]))
-    self.ridges=evaluated_ridges
-    self.ridge_info=ridge_info
-    self.ridge_intensities=ridge_intensities
-
-  def _SNR(self, minimum_noise_level=0.001):
-    '''
+
+            info.append(ridge[max_idx][1])
+            ridge_info.append(info)
+            ridge_intensities.append(ridge_intensity)
+            evaluated_ridges.append(numpy.vstack([ridge[:, 0], ridge[:,
+                                    1], ridge_intensity]))
+        self.ridges = evaluated_ridges
+        self.ridge_info = ridge_info
+        self.ridge_intensities = ridge_intensities
+
+    def _SNR(self, minimum_noise_level=0.001):
+        '''
     Calculate signal to noise ratio. Signal is the highest
     CWT intensity of all scales, noise is the 95% quantile
     of the lowest scale WT, which is dominated by noise.
     '''
-    ridge_info=self.ridge_info
-    cwt=self.CWT.getdata()
-    noise_cwt=cwt[0]
+
+        ridge_info = self.ridge_info
+        cwt = self.CWT.getdata()
+        noise_cwt = cwt[0]
+
     # minimum noise is the noise value for the whole dataset times minimum_noise_level
-    minimum_noise=float(minimum_noise_level*mquantiles(
-                        noise_cwt,
-                        0.95,
-                        3./8., 3./8.))
-    for info in ridge_info:
-      scale=max(3, info[2]) # get a minimal width of 30 items for noise calculation
-      signal=info[3]
-      base_left=max(0, int(info[1]-scale*5))
-      base_right=int(info[1]+scale*5)
-      noise=mquantiles(noise_cwt[base_left:base_right+1],
-                       0.95,
-                       3./8., 3./8.)
-      noise=numpy.nan_to_num(noise)
-      noise=float(max([minimum_noise, noise]))
-      info.append(signal/noise)
-
-  def _find_local_max(self, data, steps=3):
-    '''
+
+        minimum_noise = float(minimum_noise_level
+                              * mquantiles(noise_cwt, 0.95, 3. / 8., 3.
+                              / 8.))
+        for info in ridge_info:
+            scale = max(3, info[2])  # get a minimal width of 30 items for noise calculation
+            signal = info[3]
+            base_left = max(0, int(info[1] - scale * 5))
+            base_right = int(info[1] + scale * 5)
+            noise = mquantiles(noise_cwt[base_left:base_right + 1],
+                               0.95, 3. / 8., 3. / 8.)
+            noise = numpy.nan_to_num(noise)
+            noise = float(max([minimum_noise, noise]))
+            info.append(signal / noise)
+
+    def _find_local_max(self, data, steps=3):
+        '''
     Find the positions of local maxima in a set of data.
     A window of size steps is used to check if the central
     point is the largest in the window region.
     '''
-    if steps%2==0:
-      steps+=1
-    windows=[]
-    for i in range(steps):
-      windows.append(data[i:(-(steps-i-1) or None)])
-    windows=numpy.vstack(windows)
-    lmax=windows[(steps+1)//2-1]==windows.max(axis=0)
-    return numpy.hstack([numpy.zeros(steps//2),
-                         lmax,
-                         numpy.zeros(steps//2)])
-
-  def get_peaks(self, snr=2.5,
-                min_width=None, max_width=None,
-                ridge_length=15, analyze=False,
-                double_peak_detection=False,
-                double_peak_reduced_ridge_length=3,
-                estimate_center=False):
-    '''
+
+        if steps % 2 == 0:
+            steps += 1
+        windows = []
+        for i in range(steps):
+            windows.append(data[i:-(steps - i - 1) or None])
+        windows = numpy.vstack(windows)
+        lmax = windows[(steps + 1) // 2 - 1] == windows.max(axis=0)
+        return numpy.hstack([numpy.zeros(steps // 2), lmax,
+                            numpy.zeros(steps // 2)])
+
+    def get_peaks(
+        self,
+        snr=2.5,
+        min_width=None,
+        max_width=None,
+        ridge_length=15,
+        analyze=False,
+        double_peak_detection=False,
+        double_peak_reduced_ridge_length=3,
+        estimate_center=False,
+        ):
+        '''
     Return a list of peaks fulfilling the defined conditions.
     
@@ -174,169 +209,235 @@
     :return: List of found peaks as (x0, width, I0, ridge length, SNR)
     '''
-    xdata=self.xdata
-    if min_width is None:
-      min_width=1.5*abs(xdata[1]-xdata[0])
-    if max_width is None:
-      max_width=0.3*(xdata.max()-xdata.min())
-    ridge_info=self.ridge_info
-
-    if analyze:
-      self.length_filtered=filter(lambda item: item[0]<ridge_length,
-                     ridge_info)
-      self.snr_filtered=filter(lambda item: item[5]<snr, ridge_info)
+
+        xdata = self.xdata
+        if min_width is None:
+            min_width = 1.5 * abs(xdata[1] - xdata[0])
+        if max_width is None:
+            max_width = 0.3 * (xdata.max() - xdata.min())
+        ridge_info = self.ridge_info
+
+        if analyze:
+            self.length_filtered = filter(lambda item: item[0] \
+                    < ridge_length, ridge_info)
+            self.snr_filtered = filter(lambda item: item[5] < snr,
+                    ridge_info)
+
     # filter for signal to noise ratio
-    ridge_info=filter(lambda item: item[5]>=snr, ridge_info)
-    if double_peak_detection:
+
+        ridge_info = filter(lambda item: item[5] >= snr, ridge_info)
+        if double_peak_detection:
+
       # store peaks filtered by ridge length
-      ridge_filtered=filter(lambda item: (item[0]<ridge_length)&
-                            (item[0]>=double_peak_reduced_ridge_length),
+
+            ridge_filtered = filter(lambda item: (item[0]
+                                    < ridge_length) & (item[0]
+                                    >= double_peak_reduced_ridge_length),
+                                    ridge_info)
+
+    # filter for minimum ridge line length
+
+        ridge_info = filter(lambda item: item[0] >= ridge_length,
                             ridge_info)
-    # filter for minimum ridge line length
-    ridge_info=filter(lambda item: item[0]>=ridge_length,
-                     ridge_info)
+
     # calculate peak info from ridge info
     # peak info items are [center_position, width, intensity]
-    peak_info=[]
-    for item in ridge_info:
-      info=[]
+
+        peak_info = []
+        for item in ridge_info:
+            info = []
+
       # x corresponding to index
-      if estimate_center:
-        info.append(xdata[item[4]])
-      else:
-        info.append(xdata[item[1]])
+
+            if estimate_center:
+                info.append(xdata[item[4]])
+            else:
+                info.append(xdata[item[1]])
+
       # width corresponding to index width
-      i_low=int(item[1]-item[2]/2.)
-      i_high=int(item[1]+item[2]/2.)
-      if i_low<0:
-        i_low=0
-      elif i_low==item[1]:
-        i_low-=1
-      if i_high>=len(xdata):
-        i_high=len(xdata)-1
-      elif i_high==item[1]:
-        i_high+=1
-      w_low=xdata[i_low]
-      w_high=xdata[i_high]
-      w=w_high-w_low
-      info.append(float(abs(w)/numpy.sqrt(2.))) # estimated peak FWHM
+
+            i_low = int(item[1] - item[2] / 2.)
+            i_high = int(item[1] + item[2] / 2.)
+            if i_low < 0:
+                i_low = 0
+            elif i_low == item[1]:
+                i_low -= 1
+            if i_high >= len(xdata):
+                i_high = len(xdata) - 1
+            elif i_high == item[1]:
+                i_high += 1
+            w_low = xdata[i_low]
+            w_high = xdata[i_high]
+            w = w_high - w_low
+            info.append(float(abs(w) / numpy.sqrt(2.)))  # estimated peak FWHM
+
       # intensity from ridge value (empirical from application to Gauss peak)
-      info.append(item[3]*3.)
+
+            info.append(item[3] * 3.)
+
       # ridge length
-      info.append(item[0])
+
+            info.append(item[0])
+
       # SNR
-      info.append(item[5])
-      peak_info.append(info)
+
+            info.append(item[5])
+            peak_info.append(info)
+
     # filter for peak width
-    peak_info=filter(lambda item: (item[1]>=min_width)&(item[1]<=max_width),
-                     peak_info)
-    if double_peak_detection:
+
+        peak_info = filter(lambda item: (item[1] >= min_width) \
+                           & (item[1] <= max_width), peak_info)
+        if double_peak_detection:
+
       # detect double-peaks by reducing the ridge-length filtering in adjacency of
       # strong peaks
 
       # collect peak information of all ridge filtered peaks
-      double_peak_info=[]
-      for item in ridge_filtered:
-        info=[]
+
+            double_peak_info = []
+            for item in ridge_filtered:
+                info = []
+
         # x corresponding to index
-        if estimate_center:
-          info.append(xdata[item[4]])
-        else:
-          info.append(xdata[item[1]])
+
+                if estimate_center:
+                    info.append(xdata[item[4]])
+                else:
+                    info.append(xdata[item[1]])
+
         # width corresponding to index width
-        i_low=int(round(item[1]-item[2]/2.))
-        i_high=int(round(item[1]+item[2]/2.))
-        if i_low<0:
-          i_low=0
-        elif i_low==item[1]:
-          i_low-=1
-        if i_high>=len(xdata):
-          i_high=len(xdata)-1
-        elif i_high==item[1]:
-          i_high+=1
-        w_low=xdata[i_low]
-        w_high=xdata[i_high]
-        w=w_high-w_low
-        info.append(float(abs(w))/1.6) # estimated peak width
+
+                i_low = int(round(item[1] - item[2] / 2.))
+                i_high = int(round(item[1] + item[2] / 2.))
+                if i_low < 0:
+                    i_low = 0
+                elif i_low == item[1]:
+                    i_low -= 1
+                if i_high >= len(xdata):
+                    i_high = len(xdata) - 1
+                elif i_high == item[1]:
+                    i_high += 1
+                w_low = xdata[i_low]
+                w_high = xdata[i_high]
+                w = w_high - w_low
+                info.append(float(abs(w)) / 1.6)  # estimated peak width
+
         # intensity
-        info.append(item[3]*3.)
+
+                info.append(item[3] * 3.)
+
         # ridge length
-        info.append(item[0])
+
+                info.append(item[0])
+
         # SNR
-        info.append(item[5])
-        if (w>=min_width)&(w<=max_width):
-          double_peak_info.append(info)
-      adjecent_peaks=[]
-      for peaki in peak_info:
+
+                info.append(item[5])
+                if (w >= min_width) & (w <= max_width):
+                    double_peak_info.append(info)
+            adjecent_peaks = []
+            for peaki in peak_info:
+
         # all peaks in SNR/2-sigmas range are used
         # this way peaks close to stronger peaks are found
-        adjecent_peaks+=[item for item in double_peak_info if
-                        (item[0]>=(peaki[0]-peaki[3]/2.*peaki[1]))
-                        and (item[0]<=(peaki[0]+peaki[3]/2.*peaki[1]))
-                        and not item in adjecent_peaks
-                        ]
-      peak_info+=adjecent_peaks
-    if analyze:
-      width_filtered=zip(ridge_info, peak_info)
-      self.width_filtered=filter(lambda item: \
-              (item[1][1]<min_width)|(item[1][1]>max_width), width_filtered)
-    peak_info.sort()
-    return peak_info
-
-  def visualize(self, snr=2.5,
-                min_width=None, max_width=None,
-                ridge_length=15, double_peak_detection=False,
-                double_peak_reduced_ridge_length=3,
-                estimate_center=False):
-    '''
+
+                adjecent_peaks += [item for item in double_peak_info
+                                   if item[0] >= peaki[0] - peaki[3]
+                                   / 2. * peaki[1] and item[0]
+                                   <= peaki[0] + peaki[3] / 2.
+                                   * peaki[1] and not item
+                                   in adjecent_peaks]
+            peak_info += adjecent_peaks
+        if analyze:
+            width_filtered = zip(ridge_info, peak_info)
+            self.width_filtered = filter(lambda item: (item[1][1]
+                    < min_width) | (item[1][1] > max_width),
+                    width_filtered)
+        peak_info.sort()
+        return peak_info
+
+    def visualize(
+        self,
+        snr=2.5,
+        min_width=None,
+        max_width=None,
+        ridge_length=15,
+        double_peak_detection=False,
+        double_peak_reduced_ridge_length=3,
+        estimate_center=False,
+        ):
+        '''
       Use matplotlib to visualize the peak finding routine.
     '''
-    from pylab import figure, plot, semilogy, errorbar, pcolormesh, show, draw, \
-                      legend, title, xlabel, ylabel, ylim
-    fig=figure(101)
-    fig.clear()
-    peaks=self.get_peaks(snr, min_width, max_width, ridge_length, True,
-                         double_peak_detection, double_peak_reduced_ridge_length,
-                         estimate_center)
-    mcount=self.ydata[self.ydata>0].min()
-    semilogy(self.xdata, numpy.maximum(self.ydata, 0.1*mcount), 'r-', label='Data')
-    if len(peaks)>0:
-      errorbar([p[0] for p in peaks], [p[2] for p in peaks],
-             xerr=[p[1]/2. for p in peaks], fmt='go',
-             elinewidth=2, barsabove=True, capsize=6,
-             label='Detected Peaks', markersize=10)
-    legend()
-    xlabel('x')
-    ylabel('I')
-    ylim((0.5*mcount, None))
-    draw()
-    fig=figure(102)
-    fig.clear()
-    pcolormesh(self.CWT.getdata())
-    peak_pos=[p[0] for p in peaks]
-    snr_filtered=self.snr_filtered
-    length_filtered=self.length_filtered
-    #width_filtered=[item[0] for item in self.width_filtered]
-    if estimate_center:
-      xidx=4
-    else:
-      xidx=1
-    for ridge, ridge_info in reversed(zip(self.ridges, self.ridge_info)):
-      if self.xdata[ridge_info[xidx]] in peak_pos:
-        plot(ridge[1], ridge[0], 'r-', linewidth=3)
-      elif ridge_info in length_filtered:
-        plot(ridge[1], ridge[0], 'g-', linewidth=2)
-      elif ridge_info in snr_filtered:
-        plot(ridge[1], ridge[0], 'b-', linewidth=2)
-      else:
-        plot(ridge[1], ridge[0], "y-")
-    title('Detected Peaks (Red) and Filtered by Ridge Length (Green), SNR (Blue), Width (Yellow)')
-    xlabel('x')
-    ylabel('CWT scale index')
-    draw()
-    show()
+
+        from pylab import figure, plot, semilogy, errorbar, pcolormesh, \
+            show, draw, legend, title, xlabel, ylabel, ylim
+        fig = figure(101)
+        fig.clear()
+        peaks = self.get_peaks(
+            snr,
+            min_width,
+            max_width,
+            ridge_length,
+            True,
+            double_peak_detection,
+            double_peak_reduced_ridge_length,
+            estimate_center,
+            )
+        mcount = self.ydata[self.ydata > 0].min()
+        semilogy(self.xdata, numpy.maximum(self.ydata, 0.1 * mcount),
+                 'r-', label='Data')
+        if len(peaks) > 0:
+            errorbar(
+                [p[0] for p in peaks],
+                [p[2] for p in peaks],
+                xerr=[p[1] / 2. for p in peaks],
+                fmt='go',
+                elinewidth=2,
+                barsabove=True,
+                capsize=6,
+                label='Detected Peaks',
+                markersize=10,
+                )
+        legend()
+        xlabel('x')
+        ylabel('I')
+        ylim((.5 * mcount, None))
+        draw()
+        fig = figure(102)
+        fig.clear()
+        pcolormesh(self.CWT.getdata())
+        peak_pos = [p[0] for p in peaks]
+        snr_filtered = self.snr_filtered
+        length_filtered = self.length_filtered
+
+    # width_filtered=[item[0] for item in self.width_filtered]
+
+        if estimate_center:
+            xidx = 4
+        else:
+            xidx = 1
+        for (ridge, ridge_info) in reversed(zip(self.ridges,
+                self.ridge_info)):
+            if self.xdata[ridge_info[xidx]] in peak_pos:
+                plot(ridge[1], ridge[0], 'r-', linewidth=3)
+            elif ridge_info in length_filtered:
+                plot(ridge[1], ridge[0], 'g-', linewidth=2)
+            elif ridge_info in snr_filtered:
+                plot(ridge[1], ridge[0], 'b-', linewidth=2)
+            else:
+                plot(ridge[1], ridge[0], 'y-')
+        title('Detected Peaks (Red) and Filtered by Ridge Length (Green), SNR (Blue), Width (Yellow)'
+              )
+        xlabel('x')
+        ylabel('CWT scale index')
+        draw()
+        show()
 
 
 ############## Code below here is adapted from an python CWT example ###########
+
 class Cwt:
+
     """
     Base class for continuous wavelet transforms
@@ -349,11 +450,20 @@
     """
 
-    fourierwl=1.00
+    fourierwl = 1.00
 
     def _log2(self, x):
+
         # utility function to return (integer) log2
+
         return int(numpy.log2(float(x)))
 
-    def __init__(self, data, largestscale=1, notes=0, order=2, scaling='log'):
+    def __init__(
+        self,
+        data,
+        largestscale=1,
+        notes=0,
+        order=2,
+        scaling='log',
+        ):
         """
         Continuous wavelet transform of data
@@ -368,51 +478,70 @@
         :param scaling: Linear or log
         """
-        ndata=len(data)
-        self.order=order
-        self.scale=largestscale
+
+        ndata = len(data)
+        self.order = order
+        self.scale = largestscale
         self._setscales(ndata, largestscale, notes, scaling)
-        self.cwt=numpy.zeros((self.nscale, ndata), numpy.float64)
-        omega=numpy.array(range(0, ndata+1))*(2.0*numpy.pi/ndata)
+        self.cwt = numpy.zeros((self.nscale, ndata), numpy.float64)
+        omega = numpy.array(range(0, ndata + 1)) * (2. * numpy.pi
+                / ndata)
+
         # create a grid twice the size of the original grid to remove boundary
         # effects in the convolution
-        scaled_data=numpy.zeros(ndata*2)
-        scaled_data[ndata//2:ndata//2+ndata]=data
-        scaled_data[ndata//2+ndata:]=data[-10:].mean()
-        scaled_data[:ndata//2]=data[:10].mean()
-        datahat=numpy.fft.rfft(scaled_data)
-        self.fftdata=datahat
-        #self.psihat0=self.wf(omega*self.scales[3*self.nscale/4])
+
+        scaled_data = numpy.zeros(ndata * 2)
+        scaled_data[ndata // 2:ndata // 2 + ndata] = data
+        scaled_data[ndata // 2 + ndata:] = data[-10:].mean()
+        scaled_data[:ndata // 2] = data[:10].mean()
+        datahat = numpy.fft.rfft(scaled_data)
+        self.fftdata = datahat
+
+        # self.psihat0=self.wf(omega*self.scales[3*self.nscale/4])
         # loop over scales and compute wvelet coeffiecients at each scale
         # using the fft to do the convolution
+
         for scaleindex in range(self.nscale):
-            currentscale=self.scales[scaleindex]
-            self.currentscale=currentscale  # for internal use
-            s_omega=omega*currentscale
-            psihat=self.wf(s_omega)
+            currentscale = self.scales[scaleindex]
+            self.currentscale = currentscale  # for internal use
+            s_omega = omega * currentscale
+            psihat = self.wf(s_omega)
+
             # TODO: need to check the math behind it, seems to work better without factor
-            #psihat*=numpy.sqrt(2.0*numpy.pi*currentscale)
-            convhat=psihat*datahat
-            W=numpy.fft.irfft(convhat)
-            self.cwt[scaleindex, :]=W[ndata//2:ndata//2+ndata]
+            # psihat*=numpy.sqrt(2.0*numpy.pi*currentscale)
+
+            convhat = psihat * datahat
+            W = numpy.fft.irfft(convhat)
+            self.cwt[scaleindex, :] = W[ndata // 2:ndata // 2 + ndata]
         return
 
-    def _setscales(self, ndata, largestscale, notes, scaling):
+    def _setscales(
+        self,
+        ndata,
+        largestscale,
+        notes,
+        scaling,
+        ):
         """
         if notes non-zero, returns a log scale based on notes per ocave
         else a linear scale
         """
-        if scaling=="log":
-            if notes<=0: notes=1
+
+        if scaling == 'log':
+            if notes <= 0:
+                notes = 1
+
             # adjust nscale so smallest scale is 1
-            noctave=self._log2(2.*ndata/largestscale)
-            self.nscale=notes*noctave
-            self.scales=numpy.zeros(self.nscale, float)
+
+            noctave = self._log2(2. * ndata / largestscale)
+            self.nscale = notes * noctave
+            self.scales = numpy.zeros(self.nscale, float)
             for j in range(self.nscale):
-                self.scales[j]=2.0**(float(j)/notes)
-        elif scaling=="linear":
-            nmax=ndata/largestscale/2
-            self.scales=numpy.arange(float(2), float(nmax))
-            self.nscale=len(self.scales)
-        else: raise ValueError, "scaling must be linear or log"
+                self.scales[j] = 2. ** (float(j) / notes)
+        elif scaling == 'linear':
+            nmax = ndata / largestscale / 2
+            self.scales = numpy.arange(float(2), float(nmax))
+            self.nscale = len(self.scales)
+        else:
+            raise ValueError, 'scaling must be linear or log'
         return
 
@@ -421,37 +550,54 @@
         returns wavelet coefficient array
         """
+
         return self.cwt
+
     def getcoefficients(self):
         return self.cwt
+
     def getpower(self):
         """
         returns square of wavelet coefficient array
         """
-        return (self.cwt*numpy.conjugate(self.cwt)).real
+
+        return (self.cwt * numpy.conjugate(self.cwt)).real
+
     def getscales(self):
         """
         returns array containing scales used in transform
         """
+
         return self.scales
+
     def getnscale(self):
         """
         return number of scales
         """
+
         return self.nscale
 
+
 class MexicanHat(Cwt):
+
     """
     2nd Derivative Gaussian (mexican hat) wavelet
     """
-    fourierwl=2.0*numpy.pi/numpy.sqrt(2.5)
+
+    fourierwl = 2. * numpy.pi / numpy.sqrt(2.5)
+
     def wf(self, s_omega):
-        ss_omega_scaled=(s_omega/2./numpy.pi*numpy.sqrt(2))**2
+        ss_omega_scaled = (s_omega / 2. / numpy.pi * numpy.sqrt(2)) ** 2
+
         # should this number be 1/sqrt(3/4) (no pi)?
-        #s_omega = s_omega/self.fourierwl
-        #print max(s_omega)
+        # s_omega = s_omega/self.fourierwl
+        # print max(s_omega)
 #        a=(s_omega*)**2
 #        b=s_omega**2/2.
-        return ss_omega_scaled*numpy.exp(-0.5*ss_omega_scaled)/1.1529702
-        #return s_omega**2*numpy.exp(-s_omega**2/2.0)/1.1529702
+
+        return ss_omega_scaled * numpy.exp(-.5 * ss_omega_scaled) \
+            / 1.1529702
+
+
+        # return s_omega**2*numpy.exp(-s_omega**2/2.0)/1.1529702
 
 def quantile(a, prob):
@@ -467,29 +613,36 @@
     See also: scipy.stats.mstats.mquantiles
     """
-    a=numpy.asanyarray(a)
-    a=a[numpy.logical_not(numpy.isnan(a))].ravel()
-    n=a.size
-
-    if prob>=1-.5/n:
+
+    a = numpy.asanyarray(a)
+    a = a[numpy.logical_not(numpy.isnan(a))].ravel()
+    n = a.size
+
+    if prob >= 1 - .5 / n:
         return a.max()
-    elif prob<=.5/n:
+    elif prob <= .5 / n:
         return a.min()
 
     # find the two bounds we're interpreting between:
     # that is, find i such that (i+.5) / n <= prob <= (i+1.5)/n
-    t=n*prob-.5
-    i=int(t)
+
+    t = n * prob - .5
+    i = int(t)
 
     # partial sort so that the ith element is at position i, with bigger ones
     # to the right and smaller to the left
+
     a.sort()
 
-    if i==t: # did we luck out and get an integer index?
+    if i == t:  # did we luck out and get an integer index?
         return a[i]
     else:
+
         # we'll linearly interpolate between this and the next index
-        smaller=a[i]
-        larger=a[i+1:].min()
+
+        smaller = a[i]
+        larger = a[i + 1:].min()
         if numpy.isinf(smaller):
-            return smaller # avoid inf - inf
-        return smaller+(larger-smaller)*(t-i)
+            return smaller  # avoid inf - inf
+        return smaller + (larger - smaller) * (t - i)
+
+
Index: src/model/readData.py
===================================================================
--- src/model/readData.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/readData.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,21 +1,25 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 import numpy as np
 
+
 def CSNSRead2DData(fname):
-    data=[]
+    data = []
 
-    fopen=open(fname, "r")
-    lines=fopen.readlines()
+    fopen = open(fname, 'r')
+    lines = fopen.readlines()
 
-    check=lines[-1].split()
-    n=len(check)
+    check = lines[-1].split()
+    n = len(check)
     for i in range(n):
-    	data.append([])
+        data.append([])
 
     for line in lines:
-    	tmp=line.split()
-    	for i in range(n):
-    		data[i].append(float(tmp[i]))
+        tmp = line.split()
+        for i in range(n):
+            data[i].append(float(tmp[i]))
 
-    return n, data
+    return (n, data)
+
 
 def CSNSRead4DData(fname):
@@ -32,27 +36,28 @@
 
     '''
-    n=50
-    
-    R=np.zeros(n)   
-    X=np.zeros(n)   
-    Y=np.zeros(n)   
-    Z=np.zeros(n)   
-    C=np.zeros(n)   
- 
+
+    n = 50
+
+    R = np.zeros(n)
+    X = np.zeros(n)
+    Y = np.zeros(n)
+    Z = np.zeros(n)
+    C = np.zeros(n)
+
     for i in range(n):
-        X[i]=i*0.01+0.01
-        Y[i]=i*0.01+0.01
-        Z[i]=i*0.01+0.01
-    X,Y=np.meshgrid(X,Y)
-    Z,tmp=np.meshgrid(Z,R)
-    C,tmp=np.meshgrid(C,R)
+        X[i] = i * 0.01 + 0.01
+        Y[i] = i * 0.01 + 0.01
+        Z[i] = i * 0.01 + 0.01
+    (X, Y) = np.meshgrid(X, Y)
+    (Z, tmp) = np.meshgrid(Z, R)
+    (C, tmp) = np.meshgrid(C, R)
 
     for i in range(C.shape[0]):
         for j in range(C.shape[1]):
-            C[i][j]=Y[i][n/2]
+            C[i][j] = Y[i][n / 2]
 
-    C/=float(C.max())
- 
-    return X, Y, Z, C
+    C /= float(C.max())
+
+    return (X, Y, Z, C)
 
 
@@ -71,23 +76,23 @@
     '''
 
-    X=[]
-    Y=[]
-    Z=[]
+    X = []
+    Y = []
+    Z = []
 
-    fopen=open(fname, "r")
-    lines=fopen.readlines()
+    fopen = open(fname, 'r')
+    lines = fopen.readlines()
 
-    ngroup=-1
-    nfirst=-1
+    ngroup = -1
+    nfirst = -1
     for line in lines:
-        tmp=line.split()
-        first=tmp[1]
+        tmp = line.split()
+        first = tmp[1]
         break
 
-    ngroup=-1
+    ngroup = -1
     for line in lines:
-        tmp=line.split()
-        if tmp[1]==first:
-            ngroup+=1
+        tmp = line.split()
+        if tmp[1] == first:
+            ngroup += 1
             X.append([])
             Y.append([])
@@ -98,3 +103,5 @@
         Z[ngroup].append(float(tmp[2]))
 
-    return X, Y, Z
+    return (X, Y, Z)
+
+
Index: src/model/readFile.py
===================================================================
--- src/model/readFile.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/readFile.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,12 +1,16 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 import numpy as np
+
 
 def CSNSReadText(fname):
 
-    fopen=open(fname, "r")
-    lines=fopen.readlines()
+    fopen = open(fname, 'r')
+    lines = fopen.readlines()
 
-    text=""
+    text = ''
     for line in lines:
-        text+=line
+        text += line
     return text
 
+
Index: src/model/readImage.py
===================================================================
--- src/model/readImage.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/readImage.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,26 +1,31 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 import numpy as np
 import scipy
 import Image
-from  PIL import ImageOps
+from PIL import ImageOps
+
 
 def CSNSReadImage2Table(fname):
-    img = Image.open(fname).convert("L")
+    img = Image.open(fname).convert('L')
     box = (630, 400, 2630, 2000)
-    #box = (int(left), int(top),int(right),int(bottom))
+
+    # box = (int(left), int(top),int(right),int(bottom))
+
     region = img.crop(box)
-    nx=100
-    ny=100
-    size=(nx,ny)
-    img_resized=region.resize(size, Image.ANTIALIAS)
+    nx = 100
+    ny = 100
+    size = (nx, ny)
+    img_resized = region.resize(size, Image.ANTIALIAS)
 
     arr = np.asarray(img_resized)
 
-    X=[]
-    Y=[]
-    Z=[]
+    X = []
+    Y = []
+    Z = []
 
-    ngroup=-1
+    ngroup = -1
     for i in range(nx):
-        ngroup+=1
+        ngroup += 1
         X.append([])
         Y.append([])
@@ -31,63 +36,72 @@
             Z[ngroup].append(arr[i][j])
 
-    return X, Y, Z
+    return (X, Y, Z)
+
 
 def CSNSReadImage2Matrix(fname, xpixel, ypixel):
-    img = Image.open(fname).convert("L")
+    img = Image.open(fname).convert('L')
 
-    img=ImageOps.invert(img)
+    img = ImageOps.invert(img)
 
     box = (630, 400, 2630, 2000)
-    #box = (int(left), int(top),int(right),int(bottom))
+
+    # box = (int(left), int(top),int(right),int(bottom))
+
     region = img.crop(box)
-    nx=100
-    ny=100
-    size=(ny-1,nx-1)
-    img_resized=region.resize(size, Image.ANTIALIAS)
+    nx = 100
+    ny = 100
+    size = (ny - 1, nx - 1)
+    img_resized = region.resize(size, Image.ANTIALIAS)
 
     Z = np.asarray(img_resized)
 
-    X=np.zeros((nx,ny))
-    Y=np.zeros((nx,ny))
+    X = np.zeros((nx, ny))
+    Y = np.zeros((nx, ny))
 
     for i in range(nx):
         for j in range(ny):
-            X[i][j]=(i+1)*xpixel
-            Y[i][j]=(j+1)*ypixel
+            X[i][j] = (i + 1) * xpixel
+            Y[i][j] = (j + 1) * ypixel
 
-    return X, Y, Z
+    return (X, Y, Z)
+
 
 def CSNSReadImageSurface(fname):
-    img = Image.open(fname).convert("L")
+    img = Image.open(fname).convert('L')
 
-    img=ImageOps.invert(img)
+    img = ImageOps.invert(img)
 
     box = (630, 400, 2630, 2000)
-    #box = (int(left), int(top),int(right),int(bottom))
+
+    # box = (int(left), int(top),int(right),int(bottom))
+
     region = img.crop(box)
-    n=50
-    size=(n,n)
-    img_resized=region.resize(size, Image.ANTIALIAS)
+    n = 50
+    size = (n, n)
+    img_resized = region.resize(size, Image.ANTIALIAS)
 
     img = np.asarray(img_resized)
 
-    R=np.zeros(n)
-    a=np.zeros(n)
-    b=np.zeros(n)
-    c=np.zeros(n)
+    R = np.zeros(n)
+    a = np.zeros(n)
+    b = np.zeros(n)
+    c = np.zeros(n)
 
     for i in range(n):
-        a[i]=i*0.01+0.01
-        b[i]=i*0.01+0.01
-        b[i]=i*0.01+0.01
+        a[i] = i * 0.01 + 0.01
+        b[i] = i * 0.01 + 0.01
+        b[i] = i * 0.01 + 0.01
 
-    X,Y=np.meshgrid(a,b)
-    Z,tmp=np.meshgrid(c,R)
+    (X, Y) = np.meshgrid(a, b)
+    (Z, tmp) = np.meshgrid(c, R)
 
     for i in range(n):
-    	for j in range(n):
-			Z[i][j]=scipy.sqrt(abs(0.4**2-X[i][j]**2-Y[i][j]**2))
+        for j in range(n):
+            Z[i][j] = scipy.sqrt(abs(0.4 ** 2 - X[i][j] ** 2 - Y[i][j]
+                                 ** 2))
 
-    C=img/float(img.max())
+    C = img / float(img.max())
 
-    return X, Y, Z, C
+    return (X, Y, Z, C)
+
+
Index: src/model/sampleModel.py
===================================================================
--- src/model/sampleModel.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/sampleModel.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,6 +1,42 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+
 def sampleModel():
-	sampleList=[1, 2, 3, 4, 5, 6, 7, 8, 9]
-	peakList=[500, 700, 800, 950, 1000, 800, 500, 400,350]
-	areaList=[1000, 1300, 1500, 1600, 1800, 2000, 1500, 800, 700]
+    sampleList = [
+        1,
+        2,
+        3,
+        4,
+        5,
+        6,
+        7,
+        8,
+        9,
+        ]
+    peakList = [
+        500,
+        700,
+        800,
+        950,
+        1000,
+        800,
+        500,
+        400,
+        350,
+        ]
+    areaList = [
+        1000,
+        1300,
+        1500,
+        1600,
+        1800,
+        2000,
+        1500,
+        800,
+        700,
+        ]
 
-	return sampleList, peakList, areaList
+    return (sampleList, peakList, areaList)
+
+
Index: src/model/slitModel.py
===================================================================
--- src/model/slitModel.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/model/slitModel.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,22 +1,31 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 from conf import *
 
 from peakFinder import *
 
-def getXYdata(x0, y0, dataX, dataY, dataZ):
-    ylist=dataY[0][:]
-    ny=len(ylist)
 
-    xlist=[]
+def getXYdata(
+    x0,
+    y0,
+    dataX,
+    dataY,
+    dataZ,
+    ):
+    ylist = (dataY[0])[:]
+    ny = len(ylist)
+
+    xlist = []
     for i in range(ny):
         xlist.append(dataX[i][0])
 
-    nx=len(xlist)
+    nx = len(xlist)
 
-    xid=min(xlist, key=lambda x:abs(x-x0))
-    yid=min(ylist, key=lambda x:abs(x-y0))
-    xid=xlist.index(xid)
-    yid=ylist.index(yid)
+    xid = min(xlist, key=lambda x: abs(x - x0))
+    yid = min(ylist, key=lambda x: abs(x - y0))
+    xid = xlist.index(xid)
+    yid = ylist.index(yid)
 
-    dataYZ=[]
+    dataYZ = []
     dataYZ.append([])
     dataYZ.append([])
@@ -25,5 +34,5 @@
         dataYZ[1].append(dataZ[xid][i])
 
-    dataXZ=[]
+    dataXZ = []
     dataXZ.append([])
     dataXZ.append([])
@@ -32,19 +41,26 @@
         dataXZ[1].append(dataZ[i][yid])
 
-    return dataYZ, dataXZ
+    return (dataYZ, dataXZ)
 
-class SlitCalculation():
+
+class SlitCalculation:
+
     def __init__(self, incidentAngle=0.1, reflectedAngle=0.1):
-        self.incidentAngle=incidentAngle
-        self.reflectedAngle=reflectedAngle
+        self.incidentAngle = incidentAngle
+        self.reflectedAngle = reflectedAngle
 
     def getSlitHeight(self):
-        self.slitList=[CSNSMRslit1Position,CSNSMRslit2Position, CSNSMRsamplePosition, CSNSMRslit3Position]
+        self.slitList = [CSNSMRslit1Position, CSNSMRslit2Position,
+                         CSNSMRsamplePosition, CSNSMRslit3Position]
 
-        _a=(CSNSMRslit1Height+CSNSMRsampleHeight)/2.0/(-CSNSMRslit1Position)
-        _b=CSNSMRsampleHeight/2.0
-        _s3=(_a*CSNSMRslit3Position+_b)*2
+        _a = (CSNSMRslit1Height + CSNSMRsampleHeight) / 2.0 \
+            / -CSNSMRslit1Position
+        _b = CSNSMRsampleHeight / 2.0
+        _s3 = (_a * CSNSMRslit3Position + _b) * 2
 
-        self.heightList=[CSNSMRslit1Height, CSNSMRslit2Height, CSNSMRsampleHeight, _s3]
+        self.heightList = [CSNSMRslit1Height, CSNSMRslit2Height,
+                           CSNSMRsampleHeight, _s3]
 
-        return self.slitList, self.heightList
+        return (self.slitList, self.heightList)
+
+
Index: src/presenter/__init__.py
===================================================================
--- src/presenter/__init__.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/presenter/__init__.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,15 +1,18 @@
-__all__=['presenter']
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+__all__ = ['presenter']
 
 import os
 from glob import glob
 
-_modules=list(map(os.path.basename, glob(os.path.join(os.path.dirname(__file__), '*.py'))))
+_modules = list(map(os.path.basename,
+                glob(os.path.join(os.path.dirname(__file__), '*.py'))))
 _modules.remove('__init__.py')
-_modules=[mod[:-3] for mod in _modules]
+_modules = [mod[:-3] for mod in _modules]
 
-presenter={}
+presenter = {}
 
 for mod in _modules:
-  _module=__import__('presenter.'+mod, fromlist=[mod])
-  if 'suite' in _module.__dict__:
-    presenter[mod]=_module.suite
+    _module = __import__('presenter.' + mod, fromlist=[mod])
+    if 'suite' in _module.__dict__:
+        presenter[mod] = _module.suite
Index: src/presenter/slitSignal.py
===================================================================
--- src/presenter/slitSignal.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/presenter/slitSignal.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,11 +1,17 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 # configure
+
 from conf import *
 
 from model.readData import *
 
+
 def slitImageEvents(canvas):
     canvas.mpl_connect('button_press_event', changeRegion)
     canvas.mpl_connect('motion_notify_event', changeRegion)
-    #self.canvas = canvas
+
+
+    # self.canvas = canvas
 
 def changeRegion(event):
@@ -13,21 +19,24 @@
 
     if event.button == 1:
-        '''
-        dataX, dataY, dataZ = CSNSRead3DData("./dat/3d1.dat")
-        event.inaxes.clear()
-        cset = event.inaxes.contourf(dataY, dataX, dataZ, zdir='z', offset=0, cmap=cm.coolwarm)
-        '''
         print event.xdata
-        #_canvas.x1.set_xdata([event.xdata,event.ydata])
+
+        # _canvas.x1.set_xdata([event.xdata,event.ydata])
+
         event.inaxes.x1.clear()
-        event.inaxes.x1.set_xdata([event.xdata,event.ydata])
-        #event.inaxes.axhline(event.ydata,color='green')
+        event.inaxes.x1.set_xdata([event.xdata, event.ydata])
+
+        # event.inaxes.axhline(event.ydata,color='green')
+
         event.inaxes.draw_artist(event.inaxes)
         _canvas.blit(event.inaxes.bbox)
         _canvas.flush_events()
         _canvas.draw()
+    elif event.button == 3:
+
         # _canvas.lines[1].set_xdate([event.xdata+5,event.ydate])
-    elif event.button == 3:
+
         pass
+
+
        # _canvas.lines[2].set_ydate([event.xdata,event.ydate-5])
        # _canvas.lines[3].set_ydate([event.xdata,event.ydate+5])
Index: src/viewer/__init__.py
===================================================================
--- src/viewer/__init__.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/viewer/__init__.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,15 +1,18 @@
-__all__=['viewer']
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+__all__ = ['viewer']
 
 import os
 from glob import glob
 
-_modules=list(map(os.path.basename, glob(os.path.join(os.path.dirname(__file__), '*.py'))))
+_modules = list(map(os.path.basename,
+                glob(os.path.join(os.path.dirname(__file__), '*.py'))))
 _modules.remove('__init__.py')
-_modules=[mod[:-3] for mod in _modules]
+_modules = [mod[:-3] for mod in _modules]
 
-viewer={}
+viewer = {}
 
 for mod in _modules:
-  _module=__import__('viewer.'+mod, fromlist=[mod])
-  if 'suite' in _module.__dict__:
-    viewer[mod]=_module.suite
+    _module = __import__('viewer.' + mod, fromlist=[mod])
+    if 'suite' in _module.__dict__:
+        viewer[mod] = _module.suite
Index: src/viewer/analysis.py
===================================================================
--- src/viewer/analysis.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/viewer/analysis.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,4 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 '''
 Created on 2015.6.4
@@ -6,4 +8,5 @@
 
 '''
+
 from conf import *
 from canvas import *
@@ -13,4 +16,5 @@
 from histogram import *
 
+
 class CSNSAnalysisPage(QtGui.QTabWidget):
 
@@ -19,16 +23,18 @@
         self.setupUi(self)
 
-    def setupUi(self,QTabWidget):
-    	self.setTabPosition(QTabWidget.West)
+    def setupUi(self, QTabWidget):
+        self.setTabPosition(QTabWidget.West)
 
         self.HistogramTab = CSNSHistogramPage()
         self.HotimageTab = CSNSHotimagePage()
-        #self.mainFrame = QtGui.QFrame(self.XYTab)
-        #self.mainFrame.setFrameShape(QtGui.QFrame.StyledPanel)
-        #self.scrollArea = QtGui.QScrollArea()
-        #self.scrollArea.setWidgetResizable(True)
-        #self.scrollArea.setWidget(self.mainFrame)
 
-    	self.addTab(self.HistogramTab, "Histogram")
-        self.addTab(self.HotimageTab, "Hotimage") 
+        # self.mainFrame = QtGui.QFrame(self.XYTab)
+        # self.mainFrame.setFrameShape(QtGui.QFrame.StyledPanel)
+        # self.scrollArea = QtGui.QScrollArea()
+        # self.scrollArea.setWidgetResizable(True)
+        # self.scrollArea.setWidget(self.mainFrame)
 
+        self.addTab(self.HistogramTab, 'Histogram')
+        self.addTab(self.HotimageTab, 'Hotimage')
+
+
Index: src/viewer/calibration.py
===================================================================
--- src/viewer/calibration.py	(revision 2b41ffeb36a5e52980441e46fafca007f1479f36)
+++ src/viewer/calibration.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,4 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 '''
 Created on 2015.10.26
@@ -6,8 +8,10 @@
 
 '''
+
 from conf import *
 from canvas import *
 from model.readData import *
 from model.readImage import *
+
 
 class CSNSCalibrationPage(QtGui.QTabWidget):
@@ -17,89 +21,142 @@
         self.setupUi(self)
 
-    def setupUi(self,QTabWidget):
-    	self.setTabPosition(QTabWidget.West)
+    def setupUi(self, QTabWidget):
+        self.setTabPosition(QTabWidget.West)
 
-        #main  grid
+        # main  grid
+
         self.mainGridWidget = QtGui.QWidget(self)
         self.mainGrid = QtGui.QGridLayout(self.mainGridWidget)
 
-        #Background
-        _xsize=5
-        _ysize=0.8
+        # Background
+
+        _xsize = 5
+        _ysize = 0.8
 
         # Background
-        self.BackgroundLabel = QtGui.QLabel("Background")
-        self.CountBackgroundLabel = QtGui.QLabel("Count")
-        self.LoadBackgroundLabel = QtGui.QLabel("Load")
-        self.TOFBackgroundLabel = QtGui.QLabel("TOF")
+
+        self.BackgroundLabel = QtGui.QLabel('Background')
+        self.CountBackgroundLabel = QtGui.QLabel('Count')
+        self.LoadBackgroundLabel = QtGui.QLabel('Load')
+        self.TOFBackgroundLabel = QtGui.QLabel('TOF')
 
         self.BackgroundImageCanvas = CSNSCanvas(self, _xsize, _ysize)
-        
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]       
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[0], 1, 1)
-        self.BackgroundImage = self.BackgroundImageCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[0], 1, 1)
+        self.BackgroundImage = \
+            self.BackgroundImageCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.BackgroundImageCanvas.ax.add_patch(self.rect)
         self.BackgroundImageCanvas.draw()
 
         # Noise
-        self.NoiseLabel = QtGui.QLabel("Noise")
-        self.CountNoiseLabel = QtGui.QLabel("Count")
-        self.LoadNoiseLabel = QtGui.QLabel("Load")
-        self.TOFNoiseLabel = QtGui.QLabel("TOF")
+
+        self.NoiseLabel = QtGui.QLabel('Noise')
+        self.CountNoiseLabel = QtGui.QLabel('Count')
+        self.LoadNoiseLabel = QtGui.QLabel('Load')
+        self.TOFNoiseLabel = QtGui.QLabel('TOF')
         self.NoiseCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        nx, dataX = CSNSRead2DData("./dat/monitor.dat")
-        self.NoiseCanvas.ax.plot(dataX[0],dataX[1],color='red')
-        self.NoiseCanvas.ax.tick_params(axis='both', which='major', labelsize=5)
+        (nx, dataX) = CSNSRead2DData('./dat/monitor.dat')
+        self.NoiseCanvas.ax.plot(dataX[0], dataX[1], color='red')
+        self.NoiseCanvas.ax.tick_params(axis='both', which='major',
+                labelsize=5)
         self.NoiseCanvas.draw()
-        
+
         # Holder
-        self.HolderLabel = QtGui.QLabel("Holder")
-        self.CountHolderLabel = QtGui.QLabel("Count")
-        self.LoadHolderLabel = QtGui.QLabel("Load")
-        self.TOFHolderLabel = QtGui.QLabel("TOF")
+
+        self.HolderLabel = QtGui.QLabel('Holder')
+        self.CountHolderLabel = QtGui.QLabel('Count')
+        self.LoadHolderLabel = QtGui.QLabel('Load')
+        self.TOFHolderLabel = QtGui.QLabel('TOF')
         self.HolderCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxtX, self.dataxtY, self.dataxtZ = CSNSReadImage2Matrix(self.filexy[0], 1, 0.4)
-        self.HolderImage = self.HolderCanvas.ax.pcolormesh(self.dataxtY, self.dataxtX, self.dataxtZ, cmap=cm.hot)
+        (self.dataxtX, self.dataxtY, self.dataxtZ) = \
+            CSNSReadImage2Matrix(self.filexy[0], 1, 0.4)
+        self.HolderImage = \
+            self.HolderCanvas.ax.pcolormesh(self.dataxtY, self.dataxtX,
+                self.dataxtZ, cmap=cm.hot)
         self.HolderCanvas.draw()
 
         # Efficience
-        self.EfficienceLabel = QtGui.QLabel("Efficience")
-        self.CountEfficienceLabel = QtGui.QLabel("Count")
-        self.LoadEfficienceLabel = QtGui.QLabel("Load")
-        self.TOFEfficienceLabel = QtGui.QLabel("TOF")
+
+        self.EfficienceLabel = QtGui.QLabel('Efficience')
+        self.CountEfficienceLabel = QtGui.QLabel('Count')
+        self.LoadEfficienceLabel = QtGui.QLabel('Load')
+        self.TOFEfficienceLabel = QtGui.QLabel('TOF')
         self.EfficienceCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataXTx=[]
-        for i in range(1,self.dataxtY.shape[0]):
+        self.dataXTx = []
+        for i in range(1, self.dataxtY.shape[0]):
             self.dataXTx.append(self.dataxtY[0][i])
-        self.dataXTy=[]
-        for i in range(1,self.dataxtX.shape[0]):
+        self.dataXTy = []
+        for i in range(1, self.dataxtX.shape[0]):
             self.dataXTy.append(self.dataxtX[i][0])
 
-        self.EfficienceFigure=self.EfficienceCanvas.ax.plot(self.dataXTx,self.dataxtZ[40][:],color='red')
+        self.EfficienceFigure = \
+            self.EfficienceCanvas.ax.plot(self.dataXTx,
+                (self.dataxtZ[40])[:], color='red')
         self.EfficienceCanvas.draw()
 
-        self.mainGrid.addWidget(self.BackgroundLabel,        0,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountBackgroundLabel,   0,0,1,1)
-        self.mainGrid.addWidget(self.LoadBackgroundLabel,    0,2,1,1)
-        self.mainGrid.addWidget(self.BackgroundImageCanvas,  1,1,1,1)
-        self.mainGrid.addWidget(self.TOFBackgroundLabel,     1,2,1,1)
-        self.mainGrid.addWidget(self.NoiseLabel,             2,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountNoiseLabel,        2,0,1,1)
-        self.mainGrid.addWidget(self.LoadNoiseLabel,         2,2,1,1)
-        self.mainGrid.addWidget(self.NoiseCanvas,            3,1,1,1)
-        self.mainGrid.addWidget(self.TOFNoiseLabel,          3,2,1,1)
-        self.mainGrid.addWidget(self.HolderLabel,            4,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountHolderLabel,       4,0,1,1)
-        self.mainGrid.addWidget(self.LoadHolderLabel,        4,2,1,1)
-        self.mainGrid.addWidget(self.HolderCanvas,           5,1,1,1)
-        self.mainGrid.addWidget(self.TOFHolderLabel,         5,2,1,1)
-        self.mainGrid.addWidget(self.EfficienceLabel,        6,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountEfficienceLabel,   6,0,1,1)
-        self.mainGrid.addWidget(self.LoadEfficienceLabel,    6,2,1,1)
-        self.mainGrid.addWidget(self.EfficienceCanvas,       7,1,1,1)
-        self.mainGrid.addWidget(self.TOFEfficienceLabel,     7,2,1,1)
+        self.mainGrid.addWidget(
+            self.BackgroundLabel,
+            0,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountBackgroundLabel, 0, 0, 1, 1)
+        self.mainGrid.addWidget(self.LoadBackgroundLabel, 0, 2, 1, 1)
+        self.mainGrid.addWidget(self.BackgroundImageCanvas, 1, 1, 1, 1)
+        self.mainGrid.addWidget(self.TOFBackgroundLabel, 1, 2, 1, 1)
+        self.mainGrid.addWidget(
+            self.NoiseLabel,
+            2,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountNoiseLabel, 2, 0, 1, 1)
+        self.mainGrid.addWidget(self.LoadNoiseLabel, 2, 2, 1, 1)
+        self.mainGrid.addWidget(self.NoiseCanvas, 3, 1, 1, 1)
+        self.mainGrid.addWidget(self.TOFNoiseLabel, 3, 2, 1, 1)
+        self.mainGrid.addWidget(
+            self.HolderLabel,
+            4,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountHolderLabel, 4, 0, 1, 1)
+        self.mainGrid.addWidget(self.LoadHolderLabel, 4, 2, 1, 1)
+        self.mainGrid.addWidget(self.HolderCanvas, 5, 1, 1, 1)
+        self.mainGrid.addWidget(self.TOFHolderLabel, 5, 2, 1, 1)
+        self.mainGrid.addWidget(
+            self.EfficienceLabel,
+            6,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountEfficienceLabel, 6, 0, 1, 1)
+        self.mainGrid.addWidget(self.LoadEfficienceLabel, 6, 2, 1, 1)
+        self.mainGrid.addWidget(self.EfficienceCanvas, 7, 1, 1, 1)
+        self.mainGrid.addWidget(self.TOFEfficienceLabel, 7, 2, 1, 1)
+
+
Index: src/viewer/calibration1.py
===================================================================
--- src/viewer/calibration1.py	(revision 2b41ffeb36a5e52980441e46fafca007f1479f36)
+++ src/viewer/calibration1.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,4 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 '''
 Created on 2015.6.4
@@ -6,8 +8,10 @@
 
 '''
+
 from conf import *
 from canvas import *
 from model.readData import *
 from model.readImage import *
+
 
 class CSNSCalibrationPage(QtGui.QTabWidget):
@@ -17,54 +21,85 @@
         self.setupUi(self)
 
-    def setupUi(self,QTabWidget):
-    	self.setTabPosition(QTabWidget.West)
+    def setupUi(self, QTabWidget):
+        self.setTabPosition(QTabWidget.West)
 
-        #main  grid
+        # main  grid
+
         self.mainGridWidget = QtGui.QWidget(self)
         self.mainGrid = QtGui.QGridLayout(self.mainGridWidget)
- 
+
         # Left Label
-        self.LeftLabel = QtGui.QLabel("Left")
+
+        self.LeftLabel = QtGui.QLabel('Left')
+
         # Right Label
-        self.RightLabel = QtGui.QLabel("Right")
-         
+
+        self.RightLabel = QtGui.QLabel('Right')
+
         # Bckward 2D/3D
+
         self.BackwardComboBox = QtGui.QComboBox()
-        self.BackwardComboBox.addItem("2D")
-        self.BackwardComboBox.addItem("3D")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.BackwardComboBox.currentIndex()
+        self.BackwardComboBox.addItem('2D')
+        self.BackwardComboBox.addItem('3D')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.BackwardComboBox.currentIndex()
 
-        _xsize=3
-        _ysize=1
+        _xsize = 3
+        _ysize = 1
 
         # Backward
-        self.BackwardLabel = QtGui.QLabel("Backward")
+
+        self.BackwardLabel = QtGui.QLabel('Backward')
 
         self.BackwardImageCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
-        self.BackwardImage = self.BackwardImageCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.BackwardImage = \
+            self.BackwardImageCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.BackwardImageCanvas.ax.add_patch(self.rect)
         self.BackwardImageCanvas.draw()
 
-        #Background
-        self.BackgroundLabel = QtGui.QLabel("Backward")
+        # Background
+
+        self.BackgroundLabel = QtGui.QLabel('Backward')
 
         self.BackgroundCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)  
-        self.BackgroundImage = self.BackwardImageCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2) 
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.BackgroundImage = \
+            self.BackwardImageCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.BackgroundCanvas.ax.add_patch(self.rect)
         self.BackgroundCanvas.draw()
 
-        self.mainGrid.addWidget(self.LeftLabel,  0,0,1,1)
-        self.mainGrid.addWidget(self.RightLabel, 0,1,1,1)
-        self.mainGrid.addWidget(self.BackwardLabel, 1,0,1,1)
-        self.mainGrid.addWidget(self.BackgroundLabel,    1,1,1,1)
-        self.mainGrid.addWidget(self.BackwardImageCanvas,    2,0,1,1)
-        self.mainGrid.addWidget(self.BackgroundCanvas,    2,1,1,1)
-        self.mainGrid.addWidget(self.BackwardComboBox,    2,2,1,1)
+        self.mainGrid.addWidget(self.LeftLabel, 0, 0, 1, 1)
+        self.mainGrid.addWidget(self.RightLabel, 0, 1, 1, 1)
+        self.mainGrid.addWidget(self.BackwardLabel, 1, 0, 1, 1)
+        self.mainGrid.addWidget(self.BackgroundLabel, 1, 1, 1, 1)
+        self.mainGrid.addWidget(self.BackwardImageCanvas, 2, 0, 1, 1)
+        self.mainGrid.addWidget(self.BackgroundCanvas, 2, 1, 1, 1)
+        self.mainGrid.addWidget(self.BackwardComboBox, 2, 2, 1, 1)
+
+
Index: src/viewer/canvas.py
===================================================================
--- src/viewer/canvas.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/viewer/canvas.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,24 +1,47 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 # for pyqt4
+
 from PyQt4 import QtCore, QtGui
 from PyQt4 import Qt
 
 # for 2d plot
+
 import matplotlib
 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
 from matplotlib.figure import Figure
 
+
 class CSNSCanvas(FigureCanvas):
-    def __init__(self, parent=None, width=3, height=2, dpi=150):
-        self.fig=Figure(figsize=(width, height), dpi=dpi, facecolor="white", edgecolor=None, linewidth=1.0, frameon=False, tight_layout=False)
-        self.ax=self.fig.add_subplot(111)
+
+    def __init__(
+        self,
+        parent=None,
+        width=3,
+        height=2,
+        dpi=150,
+        ):
+        self.fig = Figure(
+            figsize=(width, height),
+            dpi=dpi,
+            facecolor='white',
+            edgecolor=None,
+            linewidth=1.0,
+            frameon=False,
+            tight_layout=False,
+            )
+        self.ax = self.fig.add_subplot(111)
         self.ax.tick_params(axis='both', which='major', labelsize=5)
-        self.xtitle=""
-        self.ytitle=""
-        self.PlotTitle=""
-        self.grid_status=True
-        self.xaxis_style='linear'
-        self.yaxis_style='linear'
+        self.xtitle = ''
+        self.ytitle = ''
+        self.PlotTitle = ''
+        self.grid_status = True
+        self.xaxis_style = 'linear'
+        self.yaxis_style = 'linear'
         self.ax.hold(True)
         FigureCanvas.__init__(self, self.fig)
-        FigureCanvas.setSizePolicy(self,QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
+        FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,
+                                   QtGui.QSizePolicy.Expanding)
         FigureCanvas.updateGeometry(self)
+
+
Index: src/viewer/chopper.py
===================================================================
--- src/viewer/chopper.py	(revision 2b41ffeb36a5e52980441e46fafca007f1479f36)
+++ src/viewer/chopper.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,7 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# configure
+
 '''
 Created on 2015.9.25
@@ -6,8 +11,8 @@
 '''
 
-#configure
 from conf import *
 
-#user defined
+# user defined
+
 from model.readData import *
 from model.chopperModel import *
@@ -16,4 +21,5 @@
 import random
 
+
 class CSNSChopperPage(QtGui.QWidget):
 
@@ -22,8 +28,9 @@
         self.setupUi(self)
 
-    def setupUi(self,QWidget):
+    def setupUi(self, QWidget):
         self.horizontalLayout = QtGui.QHBoxLayout(self)
 
         # chopper tab control
+
         self.first = QtGui.QFrame(self)
         self.first.setFrameShape(QtGui.QFrame.StyledPanel)
@@ -33,85 +40,183 @@
 
         # left grid
+
         self.mainGrid = QtGui.QGridLayout(self.first)
 
         # left grid label
-        self.timeframeLabel = QtGui.QLabel("Time Frame")
+
+        self.timeframeLabel = QtGui.QLabel('Time Frame')
 
         # canvas for time frame
-        self.timeframeFigure = Figure((8,4), dpi=150, facecolor="white", edgecolor=None, linewidth=1.0, frameon=False, tight_layout=True)
+
+        self.timeframeFigure = Figure(
+            (8, 4),
+            dpi=150,
+            facecolor='white',
+            edgecolor=None,
+            linewidth=1.0,
+            frameon=False,
+            tight_layout=True,
+            )
         self.timeframeCanvas = FigureCanvas(self.timeframeFigure)
         self.timeframeCanvas.setParent(self.first)
         self.timeframeAxes = self.timeframeFigure.add_subplot(111)
-        #self.timeframeFigure.subplots_adjust(left=0.05,bottom=0.10,right=0.95,top=0.95)
-        self.timeframeAxes.tick_params(axis='both', which='major', labelsize=5)
-        self.timeframeAxes.set_xlabel('Time of Flight (ms)',fontsize=9,x=1,y=1)
+
+        # self.timeframeFigure.subplots_adjust(left=0.05,bottom=0.10,right=0.95,top=0.95)
+
+        self.timeframeAxes.tick_params(axis='both', which='major',
+                labelsize=5)
+        self.timeframeAxes.set_xlabel('Time of Flight (ms)',
+                fontsize=9, x=1, y=1)
         self.timeframeAxes.get_yaxis().set_visible(False)
-        self.timeframeAxes.set_ylabel("Distance (m)",fontsize=5)
+        self.timeframeAxes.set_ylabel('Distance (m)', fontsize=5)
         self.timeframeCanvas.draw()
 
         # canvas bottom
-        self.wavelengthLabel = QtGui.QLabel("Wavelenght: ")
-        self.toLabel =  QtGui.QLabel(" - ")
-
-        self.waveminTextEdit=QtGui.QTextEdit("0.1")
+
+        self.wavelengthLabel = QtGui.QLabel('Wavelenght: ')
+        self.toLabel = QtGui.QLabel(' - ')
+
+        self.waveminTextEdit = QtGui.QTextEdit('0.1')
         self.waveminTextEdit.setReadOnly(True)
         self.waveminTextEdit.setMaximumHeight(CSNStextMaximumHeight)
-        self.wavemaxTextEdit=QtGui.QTextEdit("4.0")
+        self.wavemaxTextEdit = QtGui.QTextEdit('4.0')
         self.wavemaxTextEdit.setReadOnly(True)
         self.wavemaxTextEdit.setMaximumHeight(CSNStextMaximumHeight)
 
         # canvas for monitor 1
-        self.monitor1Figure = Figure((4,4), dpi=150, facecolor="white", edgecolor=None, linewidth=1.0, frameon=False, tight_layout=False)
+
+        self.monitor1Figure = Figure(
+            (4, 4),
+            dpi=150,
+            facecolor='white',
+            edgecolor=None,
+            linewidth=1.0,
+            frameon=False,
+            tight_layout=False,
+            )
         self.monitor1Canvas = FigureCanvas(self.monitor1Figure)
         self.monitor1Canvas.setParent(self.first)
         self.monitor1Axes = self.monitor1Figure.add_subplot(111)
-        self.monitor1Axes.tick_params(axis='both', which='major', labelsize=5)
-	self.monitor1Axes.set_xlim(0,20)
-
-        self.monitor1Axes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%3.1E'))
-        nmoderator, dataModerator=CSNSRead2DData("./dat/DPHM.dat")
-        wavemin=1.0
-        wavemax=5.0
-        imin=min(dataModerator[0], key=lambda x:abs(x-wavemin))
-        imax=min(dataModerator[0], key=lambda x:abs(x-wavemax))
-        imin=dataModerator[0].index(imin)
-        imax=dataModerator[0].index(imax)
-        self.monitor1Axes.plot(dataModerator[0],np.array(dataModerator[1])/1E5,color='red')
-        self.monitor1Axes.vlines(dataModerator[0][imin:imax],0,np.array(dataModerator[1][imin:imax])/1E5,color='yellow')
-        self.monitor1Figure.subplots_adjust(left=0.2,bottom=0.20,right=0.95,top=0.95)
-        self.monitor1Axes.set_xlabel("(m)",fontsize=5)
-        self.monitor1Axes.set_ylabel("(m)",fontsize=5)
+        self.monitor1Axes.tick_params(axis='both', which='major',
+                labelsize=5)
+        self.monitor1Axes.set_xlim(0, 20)
+
+        self.monitor1Axes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%3.1E'
+                ))
+        (nmoderator, dataModerator) = CSNSRead2DData('./dat/DPHM.dat')
+        wavemin = 1.0
+        wavemax = 5.0
+        imin = min(dataModerator[0], key=lambda x: abs(x - wavemin))
+        imax = min(dataModerator[0], key=lambda x: abs(x - wavemax))
+        imin = dataModerator[0].index(imin)
+        imax = dataModerator[0].index(imax)
+        self.monitor1Axes.plot(dataModerator[0],
+                               np.array(dataModerator[1]) / 1E5,
+                               color='red')
+        self.monitor1Axes.vlines((dataModerator[0])[imin:imax], 0,
+                                 np.array((dataModerator[1])[imin:imax])
+                                 / 1E5, color='yellow')
+        self.monitor1Figure.subplots_adjust(left=0.20, bottom=0.20,
+                right=0.95, top=0.95)
+        self.monitor1Axes.set_xlabel('(m)', fontsize=5)
+        self.monitor1Axes.set_ylabel('(m)', fontsize=5)
         self.monitor1Canvas.draw()
-        
+
         # canvas for monitor 2
-        self.monitor2Canvas= CSNSCanvas(self,4,4)
+
+        self.monitor2Canvas = CSNSCanvas(self, 4, 4)
+
         # read monitor data
-        #self.monitor2Axes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%3.1E'))
-        nmonitor, dataMonitor=CSNSRead2DData("./dat/monitor.dat")
-        self.monitor2Canvas.ax.plot(dataMonitor[0],dataMonitor[1],color='green', zorder=1)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        # self.monitor2Axes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%3.1E'))
+
+        (nmonitor, dataMonitor) = CSNSRead2DData('./dat/monitor.dat')
+        self.monitor2Canvas.ax.plot(dataMonitor[0], dataMonitor[1],
+                                    color='green', zorder=1)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.monitor2Canvas.ax.add_patch(self.rect)
-        self.monitor2Canvas.fig.subplots_adjust(left=0.2,bottom=0.20,right=0.95,top=0.95)
-        self.monitor2Canvas.ax.set_xlabel("(m)",fontsize=5)
-        self.monitor2Canvas.ax.set_ylabel("(m)",fontsize=5)
+        self.monitor2Canvas.fig.subplots_adjust(left=0.20, bottom=0.20,
+                right=0.95, top=0.95)
+        self.monitor2Canvas.ax.set_xlabel('(m)', fontsize=5)
+        self.monitor2Canvas.ax.set_ylabel('(m)', fontsize=5)
         self.monitor2Canvas.draw()
         self.zoomEvents()
 
-        self.parameterWidget= QtGui.QWidget(self.first)
+        self.parameterWidget = QtGui.QWidget(self.first)
         self.parameterGrid = QtGui.QGridLayout(self.parameterWidget)
-        self.parameterGrid.addWidget(self.wavelengthLabel,0,0,1,1,QtCore.Qt.AlignLeft)
-        self.parameterGrid.addWidget(self.waveminTextEdit,0,1,1,1,QtCore.Qt.AlignLeft)
-        self.parameterGrid.addWidget(self.toLabel,0,2,1,1,QtCore.Qt.AlignLeft)
-        self.parameterGrid.addWidget(self.wavemaxTextEdit,0,3,1,1,QtCore.Qt.AlignLeft)
-
-        self.mainGrid.addWidget(self.timeframeLabel,0,0,1,1)#,QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.timeframeCanvas,1,0,1,2,QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.monitor1Canvas,2,0,1,1,QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.monitor2Canvas,2,1,1,1,QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.parameterWidget,3,0,1,2,QtCore.Qt.AlignCenter)
-
-        '''
-        Window for right panel
-        '''
+        self.parameterGrid.addWidget(
+            self.wavelengthLabel,
+            0,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        self.parameterGrid.addWidget(
+            self.waveminTextEdit,
+            0,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        self.parameterGrid.addWidget(
+            self.toLabel,
+            0,
+            2,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        self.parameterGrid.addWidget(
+            self.wavemaxTextEdit,
+            0,
+            3,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+
+        self.mainGrid.addWidget(self.timeframeLabel, 0, 0, 1, 1)  # ,QtCore.Qt.AlignCenter)
+        self.mainGrid.addWidget(
+            self.timeframeCanvas,
+            1,
+            0,
+            1,
+            2,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(
+            self.monitor1Canvas,
+            2,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(
+            self.monitor2Canvas,
+            2,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(
+            self.parameterWidget,
+            3,
+            0,
+            1,
+            2,
+            QtCore.Qt.AlignCenter,
+            )
+
         self.second = QtGui.QFrame(self)
         self.second.setFrameShape(QtGui.QFrame.StyledPanel)
@@ -123,18 +228,21 @@
 
         # for DC1
-        self.dc1Label = QtGui.QLabel("<font color=red>DC1</font>", self.second)
-
-        self.dc1FrequencyLabel = QtGui.QLabel("Frequency", self.second)
+
+        self.dc1Label = QtGui.QLabel('<font color=red>DC1</font>',
+                self.second)
+
+        self.dc1FrequencyLabel = QtGui.QLabel('Frequency', self.second)
 
         self.dc1FrequencyComboBox = QtGui.QComboBox(self.second)
-        self.dc1FrequencyComboBox.addItem("25")
-        self.dc1FrequencyComboBox.addItem("25/2")
-        self.dc1FrequencyComboBox.addItem("25/3")
-        self.dc1FrequencyComboBox.addItem("25/4")
-        self.dc1FrequencyComboBox.addItem("25/5")
-        self.dc1FrequencyComboBox.addItem("0")
-        self.dc1FrequencyComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
-
-        self.dc1PhaseLabel = QtGui.QLabel("Phase", self.second)
+        self.dc1FrequencyComboBox.addItem('25')
+        self.dc1FrequencyComboBox.addItem('25/2')
+        self.dc1FrequencyComboBox.addItem('25/3')
+        self.dc1FrequencyComboBox.addItem('25/4')
+        self.dc1FrequencyComboBox.addItem('25/5')
+        self.dc1FrequencyComboBox.addItem('0')
+        self.dc1FrequencyComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding,
+                QtGui.QSizePolicy.Fixed)
+
+        self.dc1PhaseLabel = QtGui.QLabel('Phase', self.second)
 
         self.dc1PhaseSpinBox = QtGui.QSpinBox(self.second)
@@ -143,17 +251,19 @@
 
         # for DC2
-        self.dc2Label = QtGui.QLabel("<font color=red>DC2</font>", self.second)
-
-        self.dc2FrequencyLabel = QtGui.QLabel("Frequency", self.second)
+
+        self.dc2Label = QtGui.QLabel('<font color=red>DC2</font>',
+                self.second)
+
+        self.dc2FrequencyLabel = QtGui.QLabel('Frequency', self.second)
 
         self.dc2FrequencyComboBox = QtGui.QComboBox(self.second)
-        self.dc2FrequencyComboBox.addItem("25")
-        self.dc2FrequencyComboBox.addItem("25/2")
-        self.dc2FrequencyComboBox.addItem("25/3")
-        self.dc2FrequencyComboBox.addItem("25/4")
-        self.dc2FrequencyComboBox.addItem("25/5")
-        self.dc2FrequencyComboBox.addItem("0")
-
-        self.dc2PhaseLabel = QtGui.QLabel("Phase", self.second)
+        self.dc2FrequencyComboBox.addItem('25')
+        self.dc2FrequencyComboBox.addItem('25/2')
+        self.dc2FrequencyComboBox.addItem('25/3')
+        self.dc2FrequencyComboBox.addItem('25/4')
+        self.dc2FrequencyComboBox.addItem('25/5')
+        self.dc2FrequencyComboBox.addItem('0')
+
+        self.dc2PhaseLabel = QtGui.QLabel('Phase', self.second)
 
         self.dc2PhaseSpinBox = QtGui.QSpinBox(self.second)
@@ -162,17 +272,19 @@
 
         # for DC3
-        self.dc3Label = QtGui.QLabel("<font color=red>DC3</font>", self.second)
-
-        self.dc3FrequencyLabel = QtGui.QLabel("Frequency", self.second)
+
+        self.dc3Label = QtGui.QLabel('<font color=red>DC3</font>',
+                self.second)
+
+        self.dc3FrequencyLabel = QtGui.QLabel('Frequency', self.second)
 
         self.dc3FrequencyComboBox = QtGui.QComboBox(self.second)
-        self.dc3FrequencyComboBox.addItem("0")
-        self.dc3FrequencyComboBox.addItem("25")
-        self.dc3FrequencyComboBox.addItem("25/2")
-        self.dc3FrequencyComboBox.addItem("25/3")
-        self.dc3FrequencyComboBox.addItem("25/4")
-        self.dc3FrequencyComboBox.addItem("25/5")
-
-        self.dc3PhaseLabel = QtGui.QLabel("Phase", self.second)
+        self.dc3FrequencyComboBox.addItem('0')
+        self.dc3FrequencyComboBox.addItem('25')
+        self.dc3FrequencyComboBox.addItem('25/2')
+        self.dc3FrequencyComboBox.addItem('25/3')
+        self.dc3FrequencyComboBox.addItem('25/4')
+        self.dc3FrequencyComboBox.addItem('25/5')
+
+        self.dc3PhaseLabel = QtGui.QLabel('Phase', self.second)
 
         self.dc3PhaseSpinBox = QtGui.QSpinBox(self.second)
@@ -181,50 +293,127 @@
 
         # for button
-        self.cancelButton = QtGui.QPushButton("Reset",self.second)
-        self.okButton = QtGui.QPushButton("OK",self.second)
-
-        '''
-        # add QVBox
-        '''
-        nrow=-1
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc1Label, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc1FrequencyLabel, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc1FrequencyComboBox, nrow, 0, 1, 2)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc1PhaseLabel, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
+
+        self.cancelButton = QtGui.QPushButton('Reset', self.second)
+        self.okButton = QtGui.QPushButton('OK', self.second)
+
+        nrow = -1
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc1Label,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc1FrequencyLabel,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
+        self.rightGrid.addWidget(self.dc1FrequencyComboBox, nrow, 0, 1,
+                                 2)
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc1PhaseLabel,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
         self.rightGrid.addWidget(self.dc1PhaseSpinBox, nrow, 0, 1, 2)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc2Label, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc2FrequencyLabel, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc2FrequencyComboBox, nrow, 0, 1, 2)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc2PhaseLabel, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc2Label,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc2FrequencyLabel,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
+        self.rightGrid.addWidget(self.dc2FrequencyComboBox, nrow, 0, 1,
+                                 2)
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc2PhaseLabel,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
         self.rightGrid.addWidget(self.dc2PhaseSpinBox, nrow, 0, 1, 2)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc3Label, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc3FrequencyLabel, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc3FrequencyComboBox, nrow, 0, 1, 2)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.dc3PhaseLabel, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc3Label,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc3FrequencyLabel,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
+        self.rightGrid.addWidget(self.dc3FrequencyComboBox, nrow, 0, 1,
+                                 2)
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.dc3PhaseLabel,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
         self.rightGrid.addWidget(self.dc3PhaseSpinBox, nrow, 0, 1, 2)
-        nrow=nrow+1
-        self.rightGrid.addWidget(self.cancelButton, nrow,0, 1, 1, QtCore.Qt.AlignLeft)
-        self.rightGrid.addWidget(self.okButton, nrow,1, 1, 1, QtCore.Qt.AlignLeft)
-        nrow=nrow+1
-        self.rightGrid.addItem(QtGui.QSpacerItem(-1, -1, QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Expanding), nrow, 0)
-
-        '''
-        # add QSplitter
-        '''
+        nrow = nrow + 1
+        self.rightGrid.addWidget(
+            self.cancelButton,
+            nrow,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        self.rightGrid.addWidget(
+            self.okButton,
+            nrow,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignLeft,
+            )
+        nrow = nrow + 1
+        self.rightGrid.addItem(QtGui.QSpacerItem(-1, -1,
+                               QtGui.QSizePolicy.Ignored,
+                               QtGui.QSizePolicy.Expanding), nrow, 0)
+
         self.splitter = QtGui.QSplitter(QtCore.Qt.Horizontal)
         self.splitter.addWidget(self.scrollAreaLeft)
@@ -233,46 +422,60 @@
         self.horizontalLayout.addWidget(self.splitter)
 
-    def updateTimeFrame(self, pulseList, chopperList, timeList, xList, yList):
+    def updateTimeFrame(
+        self,
+        pulseList,
+        chopperList,
+        timeList,
+        xList,
+        yList,
+        ):
         self.timeframeAxes.clear()
-        self.timeframeAxes.YTick=chopperList
-
-        _x=pulseList[0]-(pulseList[1]-pulseList[0])/6.0
-        self.timeframeAxes.text(_x, chopperList[1], 'DC1',   fontsize=5)
-        self.timeframeAxes.text(_x, chopperList[2], 'DC2',   fontsize=5)
-        self.timeframeAxes.text(_x, chopperList[3], 'DC3',   fontsize=5)
-        self.timeframeAxes.text(_x, chopperList[4], 'Sample',fontsize=5)
-
-        for i in range(1,len(timeList)):
-            for j in range(0,len(timeList[i]),2):
-                self.timeframeAxes.plot( (timeList[i][j], timeList[i][j+1]), (chopperList[i],chopperList[i]), color='black')
-
-        for i in range(0,len(xList)):
-            _R=random.uniform(0,1)
-            _G=random.uniform(0,1)
-            _B=random.uniform(0,1)
-            self.timeframeAxes.plot( xList[i], yList, color=[_R, _G, _B])
-
-        self.timeframeAxes.set_xlim((pulseList[0],pulseList[-1]))
+        self.timeframeAxes.YTick = chopperList
+
+        _x = pulseList[0] - (pulseList[1] - pulseList[0]) / 6.0
+        self.timeframeAxes.text(_x, chopperList[1], 'DC1', fontsize=5)
+        self.timeframeAxes.text(_x, chopperList[2], 'DC2', fontsize=5)
+        self.timeframeAxes.text(_x, chopperList[3], 'DC3', fontsize=5)
+        self.timeframeAxes.text(_x, chopperList[4], 'Sample',
+                                fontsize=5)
+
+        for i in range(1, len(timeList)):
+            for j in range(0, len(timeList[i]), 2):
+                self.timeframeAxes.plot((timeList[i][j], timeList[i][j
+                        + 1]), (chopperList[i], chopperList[i]),
+                        color='black')
+
+        for i in range(0, len(xList)):
+            _R = random.uniform(0, 1)
+            _G = random.uniform(0, 1)
+            _B = random.uniform(0, 1)
+            self.timeframeAxes.plot(xList[i], yList, color=[_R, _G, _B])
+
+        self.timeframeAxes.set_xlim((pulseList[0], pulseList[-1]))
 
         self.timeframeCanvas.draw()
 
     def zoomEvents(self):
-        self.monitor2Canvas.mpl_connect('button_press_event',   self.zoomFigurePress)
-        self.monitor2Canvas.mpl_connect('button_release_event', self.zoomFigureRelease)
-        self.monitor2Canvas.mpl_connect('motion_notify_event',  self.zoomFigureMove)
-
-    def zoomFigurePress(self,event):
-        if event.button==1:
-            self.zoomClick=True
+        self.monitor2Canvas.mpl_connect('button_press_event',
+                self.zoomFigurePress)
+        self.monitor2Canvas.mpl_connect('button_release_event',
+                self.zoomFigureRelease)
+        self.monitor2Canvas.mpl_connect('motion_notify_event',
+                self.zoomFigureMove)
+
+    def zoomFigurePress(self, event):
+        if event.button == 1:
+            self.zoomClick = True
             self.x0 = event.xdata
             self.y0 = event.ydata
-        elif event.button==3:
+        elif event.button == 3:
             self.monitor2Canvas.ax.autoscale(enable=True)
             self.monitor2Canvas.draw()
-        else:    
+        else:
             return
 
     def zoomFigureMove(self, event):
-        if event.button==1 and self.zoomClick==True and self.x0 and self.y0 and event.xdata and event.ydata:
+        if event.button == 1 and self.zoomClick == True and self.x0 \
+            and self.y0 and event.xdata and event.ydata:
 
             self.rect.set_width(event.xdata - self.x0)
@@ -284,7 +487,8 @@
 
     def zoomFigureRelease(self, event):
-        self.zoomClick=False
-
-        if event.button==1 and self.x0 and self.y0 and event.xdata and event.ydata:
+        self.zoomClick = False
+
+        if event.button == 1 and self.x0 and self.y0 and event.xdata \
+            and event.ydata:
             self.x1 = event.xdata
             self.y1 = event.ydata
@@ -293,11 +497,13 @@
             self.rect.set_height(0)
 
-            _min=min(self.x0,self.x1)
-            _max=max(self.x0,self.x1)
+            _min = min(self.x0, self.x1)
+            _max = max(self.x0, self.x1)
             self.monitor2Canvas.ax.set_xlim(_min, _max)
-            _min=min(self.y0,self.y1)
-            _max=max(self.y0,self.y1)
+            _min = min(self.y0, self.y1)
+            _max = max(self.y0, self.y1)
             self.monitor2Canvas.ax.set_ylim(_min, _max)
             self.monitor2Canvas.draw()
         else:
             return
+
+
Index: src/viewer/guishell.py
===================================================================
--- src/viewer/guishell.py	(revision f491a953c1e81994ded21373b67caa98f38cc5b9)
+++ src/viewer/guishell.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,22 +1,38 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 # Set the QT API to PyQt4
+
 import os
 os.environ['QT_API'] = 'pyqt'
 import sip
-#sip.setapi("QString", 2)
-#sip.setapi("QVariant", 2)
-#from PyQt4.QtGui  import *
+
+# sip.setapi("QString", 2)
+# sip.setapi("QVariant", 2)
+# from PyQt4.QtGui  import *
+
 from PyQt4 import QtCore, QtGui
 from PyQt4.QtGui import QWidget
+
 # Import the console machinery from ipython
+
 from qtconsole.rich_jupyter_widget import RichJupyterWidget
 from qtconsole.inprocess import QtInProcessKernelManager
 from IPython.lib import guisupport
 
+
 class QIPythonWidget(RichJupyterWidget):
+
     """ Convenience class for a live IPython console widget. We can replace the standard banner using the customBanner argument"""
-    def __init__(self,customBanner=None,*args,**kwargs):
-        if customBanner!=None: self.banner=customBanner
-        super(QIPythonWidget, self).__init__(*args,**kwargs)
-        
+
+    def __init__(
+        self,
+        customBanner=None,
+        *args,
+        **kwargs
+        ):
+        if customBanner != None:
+            self.banner = customBanner
+        super(QIPythonWidget, self).__init__(*args, **kwargs)
+
         kernel_manager = QtInProcessKernelManager()
         self.kernel_manager = kernel_manager
@@ -37,29 +53,42 @@
             kernel_client.stop_channels()
             kernel_manager.shutdown_kernel()
-            guisupport.get_app_qt4().exit()            
+            guisupport.get_app_qt4().exit()
 
         self.exit_requested.connect(stop)
 
-    def pushVariables(self,variableDict):
+    def pushVariables(self, variableDict):
         """ Given a dictionary containing name / value pairs, push those variables to the IPython console widget """
+
         self.kernel_manager.kernel.shell.push(variableDict)
+
     def clearTerminal(self):
         """ Clears the terminal """
-        self._control.clear()    
-    def printText(self,text):
+
+        self._control.clear()
+
+    def printText(self, text):
         """ Prints some plain text to the console """
-        self._append_plain_text(text)        
-    def executeCommand(self,command):
+
+        self._append_plain_text(text)
+
+    def executeCommand(self, command):
         """ Execute a command in the frame of the console widget """
-        self._execute(command,False)
+
+        self._execute(command, False)
 
 
 class ConsoleWidget(QWidget):
+
     """ Main GUI Widget including a button and IPython Console widget inside vertical layout """
+
     def __init__(self, parent=None):
         super(ConsoleWidget, self).__init__(parent)
         layout = QtGui.QVBoxLayout(self)
-        guiconsole = QIPythonWidget(customBanner="Welcome to CSNS GPPD console (Lili YAN)!\n")
+        guiconsole = \
+            QIPythonWidget(customBanner='Welcome to CSNS GPPD console (Lili YAN)!\n'
+                           )
         guiconsole.set_default_style(colors='linux')
-        layout.addWidget(guiconsole)        
+        layout.addWidget(guiconsole)
+
+
         # This allows the variable foo and method print_process_id to be accessed from the ipython console
Index: src/viewer/histogram.py
===================================================================
--- src/viewer/histogram.py	(revision 2b41ffeb36a5e52980441e46fafca007f1479f36)
+++ src/viewer/histogram.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,4 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 '''
 Created on 2015.10.10
@@ -6,8 +8,10 @@
 
 '''
+
 from conf import *
 from canvas import *
 from model.readData import *
 from model.readImage import *
+
 
 class CSNSHistogramPage(QtGui.QTabWidget):
@@ -17,119 +21,177 @@
         self.setupUi(self)
 
-    def setupUi(self,QTabWidget):
-    	self.setTabPosition(QTabWidget.West)
+    def setupUi(self, QTabWidget):
+        self.setTabPosition(QTabWidget.West)
 
-        #main  grid
+        # main  grid
+
         self.mainGridWidget = QtGui.QWidget(self)
         self.mainGrid = QtGui.QGridLayout(self.mainGridWidget)
 
-        #Backward TOF/d
+        # Backward TOF/d
+
         self.BackwardComboBox = QtGui.QComboBox()
-        self.BackwardComboBox.addItem("TOF")
-        self.BackwardComboBox.addItem("d")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.BackwardComboBox.currentIndex()
-        
-        _xsize=5
-        _ysize=0.8
+        self.BackwardComboBox.addItem('TOF')
+        self.BackwardComboBox.addItem('d')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.BackwardComboBox.currentIndex()
+
+        _xsize = 5
+        _ysize = 0.8
 
         # Backward
-        self.BackwardLabel = QtGui.QLabel("Backward")
-        self.CountBackwardLabel = QtGui.QLabel("Count")
+
+        self.BackwardLabel = QtGui.QLabel('Backward')
+        self.CountBackwardLabel = QtGui.QLabel('Count')
 
         self.BackwardImageCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
-        self.BackwardImage = self.BackwardImageCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.BackwardImage = \
+            self.BackwardImageCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.BackwardImageCanvas.ax.add_patch(self.rect)
-        self.BackwardImageCanvas.fig.subplots_adjust(left=0.12,bottom=0.15,right=0.95,top=0.95)
-        self.BackwardImageCanvas.ax.set_xlabel("Vertical",fontsize=5)
-        self.BackwardImageCanvas.ax.set_ylabel("Horizental",fontsize=5)
+        self.BackwardImageCanvas.fig.subplots_adjust(left=0.12,
+                bottom=0.15, right=0.95, top=0.95)
+        self.BackwardImageCanvas.ax.set_xlabel('Vertical', fontsize=5)
+        self.BackwardImageCanvas.ax.set_ylabel('Horizental', fontsize=5)
         self.BackwardImageCanvas.draw()
 
         # 90-Bank TOF/d
+
         self.BankComboBox = QtGui.QComboBox()
-        self.BankComboBox.addItem("TOF")
-        self.BankComboBox.addItem("d")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.BankComboBox.currentIndex()
+        self.BankComboBox.addItem('TOF')
+        self.BankComboBox.addItem('d')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.BankComboBox.currentIndex()
 
         # 90-Bank
-        self.BankLabel = QtGui.QLabel("90 Bank")
-        self.CountBankLabel = QtGui.QLabel("Count")
+
+        self.BankLabel = QtGui.QLabel('90 Bank')
+        self.CountBankLabel = QtGui.QLabel('Count')
         self.BankCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        nx, dataX = CSNSRead2DData("./dat/monitor.dat")
-        self.BankCanvas.ax.plot(dataX[0],dataX[1],color='red')
-        self.BankCanvas.ax.tick_params(axis='both', which='major', labelsize=5)
-        self.BankCanvas.fig.subplots_adjust(left=0.12,bottom=0.15,right=0.95,top=0.95)
-        self.BankCanvas.ax.set_xlabel("Vertical",fontsize=5)
-        self.BankCanvas.ax.set_ylabel("Horizental",fontsize=5)
+        (nx, dataX) = CSNSRead2DData('./dat/monitor.dat')
+        self.BankCanvas.ax.plot(dataX[0], dataX[1], color='red')
+        self.BankCanvas.ax.tick_params(axis='both', which='major',
+                labelsize=5)
+        self.BankCanvas.fig.subplots_adjust(left=0.12, bottom=0.15,
+                right=0.95, top=0.95)
+        self.BankCanvas.ax.set_xlabel('Vertical', fontsize=5)
+        self.BankCanvas.ax.set_ylabel('Horizental', fontsize=5)
         self.BankCanvas.draw()
-        
+
         # Small-angle bank TOF/d
+
         self.SmallComboBox = QtGui.QComboBox()
-        self.SmallComboBox.addItem("TOF")
-        self.SmallComboBox.addItem("d")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.SmallComboBox.currentIndex()
-        
+        self.SmallComboBox.addItem('TOF')
+        self.SmallComboBox.addItem('d')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.SmallComboBox.currentIndex()
+
         # Small-angle bank
-        self.SmallLabel = QtGui.QLabel("Small-angle bank")
-        self.CountSmallLabel = QtGui.QLabel("Count")
+
+        self.SmallLabel = QtGui.QLabel('Small-angle bank')
+        self.CountSmallLabel = QtGui.QLabel('Count')
         self.SmallCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxtX, self.dataxtY, self.dataxtZ = CSNSReadImage2Matrix(self.filext[_index], 1, 0.4)
-        self.SmallImage = self.SmallCanvas.ax.pcolormesh(self.dataxtY, self.dataxtX, self.dataxtZ, cmap=cm.hot)
-        self.SmallCanvas.fig.subplots_adjust(left=0.12,bottom=0.15,right=0.95,top=0.95)
-        self.SmallCanvas.ax.set_xlabel("Vertical",fontsize=5)
-        self.SmallCanvas.ax.set_ylabel("Horizental",fontsize=5)        
+        (self.dataxtX, self.dataxtY, self.dataxtZ) = \
+            CSNSReadImage2Matrix(self.filext[_index], 1, 0.4)
+        self.SmallImage = self.SmallCanvas.ax.pcolormesh(self.dataxtY,
+                self.dataxtX, self.dataxtZ, cmap=cm.hot)
+        self.SmallCanvas.fig.subplots_adjust(left=0.12, bottom=0.15,
+                right=0.95, top=0.95)
+        self.SmallCanvas.ax.set_xlabel('Vertical', fontsize=5)
+        self.SmallCanvas.ax.set_ylabel('Horizental', fontsize=5)
         self.SmallCanvas.draw()
 
         # Monitor TOF/d
+
         self.MonitorComboBox = QtGui.QComboBox()
-        self.MonitorComboBox.addItem("TOF")
-        self.MonitorComboBox.addItem("d")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.MonitorComboBox.currentIndex()
-        
+        self.MonitorComboBox.addItem('TOF')
+        self.MonitorComboBox.addItem('d')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.MonitorComboBox.currentIndex()
+
         # Monitor
-        self.MonitorLabel = QtGui.QLabel("Monitor")
-        self.CountMonitorLabel = QtGui.QLabel("Count")
+
+        self.MonitorLabel = QtGui.QLabel('Monitor')
+        self.CountMonitorLabel = QtGui.QLabel('Count')
         self.MonitorCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataXTx=[]
-        for i in range(1,self.dataxtY.shape[0]):
+        self.dataXTx = []
+        for i in range(1, self.dataxtY.shape[0]):
             self.dataXTx.append(self.dataxtY[0][i])
-        self.dataXTy=[]
-        for i in range(1,self.dataxtX.shape[0]):
+        self.dataXTy = []
+        for i in range(1, self.dataxtX.shape[0]):
             self.dataXTy.append(self.dataxtX[i][0])
 
-        self.MonitorFigure=self.MonitorCanvas.ax.plot(self.dataXTx,self.dataxtZ[40][:],color='red')
-        self.MonitorCanvas.fig.subplots_adjust(left=0.12,bottom=0.15,right=0.95,top=0.95)
-        self.MonitorCanvas.ax.set_xlabel("Vertical",fontsize=5)
-        self.MonitorCanvas.ax.set_ylabel("Horizental",fontsize=5)
+        self.MonitorFigure = self.MonitorCanvas.ax.plot(self.dataXTx,
+                (self.dataxtZ[40])[:], color='red')
+        self.MonitorCanvas.fig.subplots_adjust(left=0.12, bottom=0.15,
+                right=0.95, top=0.95)
+        self.MonitorCanvas.ax.set_xlabel('Vertical', fontsize=5)
+        self.MonitorCanvas.ax.set_ylabel('Horizental', fontsize=5)
         self.MonitorCanvas.draw()
 
-        self.mainGrid.addWidget(self.BackwardLabel,        0 ,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountBackwardLabel,   0 ,0,1,1)
-        self.mainGrid.addWidget(self.BackwardImageCanvas,  1,1,1,1)
-        self.mainGrid.addWidget(self.BackwardComboBox,     1,2,1,1)
-        self.mainGrid.addWidget(self.BackwardImageCanvas,  1,1,1,1)
-        self.mainGrid.addWidget(self.BankLabel,            2,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountBankLabel,       2 ,0,1,1)
-        self.mainGrid.addWidget(self.BankCanvas,           3,1,1,1)
-        self.mainGrid.addWidget(self.BankComboBox,         3,2,1,1)
-        self.mainGrid.addWidget(self.SmallLabel,           4,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountSmallLabel,      4 ,0,1,1)
-        self.mainGrid.addWidget(self.SmallCanvas,          5,1,1,1)
-        self.mainGrid.addWidget(self.SmallComboBox,        5,2,1,1)
-        self.mainGrid.addWidget(self.MonitorLabel,         6,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.CountMonitorLabel,    6 ,0,1,1)
-        self.mainGrid.addWidget(self.MonitorCanvas,        7,1,1,1)
-        self.mainGrid.addWidget(self.MonitorComboBox,      7,2,1,1)
+        self.mainGrid.addWidget(
+            self.BackwardLabel,
+            0,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountBackwardLabel, 0, 0, 1, 1)
+        self.mainGrid.addWidget(self.BackwardImageCanvas, 1, 1, 1, 1)
+        self.mainGrid.addWidget(self.BackwardComboBox, 1, 2, 1, 1)
+        self.mainGrid.addWidget(self.BackwardImageCanvas, 1, 1, 1, 1)
+        self.mainGrid.addWidget(
+            self.BankLabel,
+            2,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountBankLabel, 2, 0, 1, 1)
+        self.mainGrid.addWidget(self.BankCanvas, 3, 1, 1, 1)
+        self.mainGrid.addWidget(self.BankComboBox, 3, 2, 1, 1)
+        self.mainGrid.addWidget(
+            self.SmallLabel,
+            4,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountSmallLabel, 4, 0, 1, 1)
+        self.mainGrid.addWidget(self.SmallCanvas, 5, 1, 1, 1)
+        self.mainGrid.addWidget(self.SmallComboBox, 5, 2, 1, 1)
+        self.mainGrid.addWidget(
+            self.MonitorLabel,
+            6,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(self.CountMonitorLabel, 6, 0, 1, 1)
+        self.mainGrid.addWidget(self.MonitorCanvas, 7, 1, 1, 1)
+        self.mainGrid.addWidget(self.MonitorComboBox, 7, 2, 1, 1)
+
+
Index: src/viewer/hotimage.py
===================================================================
--- src/viewer/hotimage.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/viewer/hotimage.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,4 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 '''
 Created on 2015.10.10
@@ -6,4 +8,5 @@
 
 '''
+
 from conf import *
 from canvas import *
@@ -11,4 +14,5 @@
 from model.readImage import *
 
+
 class CSNSHotimagePage(QtGui.QTabWidget):
 
@@ -17,125 +21,202 @@
         self.setupUi(self)
 
-    def setupUi(self,QTabWidget):
-    	self.setTabPosition(QTabWidget.West)
-
-        #main  grid
+    def setupUi(self, QTabWidget):
+        self.setTabPosition(QTabWidget.West)
+
+        # main  grid
+
         self.mainGridWidget = QtGui.QWidget(self)
         self.mainGrid = QtGui.QGridLayout(self.mainGridWidget)
- 
+
         # Left Label
-        self.LeftLabel = QtGui.QLabel("Left")
+
+        self.LeftLabel = QtGui.QLabel('Left')
+
         # Right Label
-        self.RightLabel = QtGui.QLabel("Right")
-         
+
+        self.RightLabel = QtGui.QLabel('Right')
+
         # Bckward 2D/3D
+
         self.BackwardComboBox = QtGui.QComboBox()
-        self.BackwardComboBox.addItem("2D")
-        self.BackwardComboBox.addItem("3D")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.BackwardComboBox.currentIndex()
-
-        _xsize=3
-        _ysize=1
+        self.BackwardComboBox.addItem('2D')
+        self.BackwardComboBox.addItem('3D')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.BackwardComboBox.currentIndex()
+
+        _xsize = 3
+        _ysize = 1
 
         # Backward
-        self.BackwardLabel = QtGui.QLabel("Backward")
+
+        self.BackwardLabel = QtGui.QLabel('Backward')
 
         self.BackwardCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
-        self.BackwardImage = self.BackwardCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.BackwardImage = \
+            self.BackwardCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.BackwardCanvas.ax.add_patch(self.rect)
         self.BackwardCanvas.draw()
 
         # Background
-        self.BackgroundLabel = QtGui.QLabel("Backward")
+
+        self.BackgroundLabel = QtGui.QLabel('Backward')
 
         self.BackgroundCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)  
-        self.BackgroundImage = self.BackwardCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2) 
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.BackgroundImage = \
+            self.BackwardCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.BackgroundCanvas.ax.add_patch(self.rect)
         self.BackgroundCanvas.draw()
 
         # 90-bank
-        self.BankLabel = QtGui.QLabel("90-Bank")
+
+        self.BankLabel = QtGui.QLabel('90-Bank')
 
         self.BankCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
-        self.BankImage = self.BankCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.BankImage = self.BankCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.BankCanvas.ax.add_patch(self.rect)
         self.BankCanvas.draw()
 
         # noise
-        self.NoiseLabel = QtGui.QLabel("Noise")
+
+        self.NoiseLabel = QtGui.QLabel('Noise')
 
         self.NoiseCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
-        self.NoiseImage = self.NoiseCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.NoiseImage = self.NoiseCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.NoiseCanvas.ax.add_patch(self.rect)
         self.NoiseCanvas.draw()
 
         # ComboBox 2D/3D
+
         self.BankComboBox = QtGui.QComboBox()
-        self.BankComboBox.addItem("2D")
-        self.BankComboBox.addItem("3D")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.BankComboBox.currentIndex()
+        self.BankComboBox.addItem('2D')
+        self.BankComboBox.addItem('3D')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.BankComboBox.currentIndex()
 
         # Small-angle Bank
-        self.SmallLabel = QtGui.QLabel("90-Bank")
+
+        self.SmallLabel = QtGui.QLabel('90-Bank')
 
         self.SmallCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
-        self.SmallImage = self.SmallCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.SmallImage = self.SmallCanvas.ax.pcolormesh(self.dataxyY,
+                self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.SmallCanvas.ax.add_patch(self.rect)
         self.SmallCanvas.draw()
 
         # Holder
-        self.HolderLabel = QtGui.QLabel("Noise")
+
+        self.HolderLabel = QtGui.QLabel('Noise')
 
         self.HolderCanvas = CSNSCanvas(self, _xsize, _ysize)
 
-        self.dataxyX, self.dataxyY, self.dataxyZ = CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
-        self.HolderImage = self.HolderCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX, self.dataxyZ, cmap=cm.coolwarm)
-        self.rect = Rectangle((0,0), 0, 0, facecolor='None', edgecolor='black', alpha=0.8,zorder=2)
+        (self.dataxyX, self.dataxyY, self.dataxyZ) = \
+            CSNSReadImage2Matrix(self.filexy[_index], 1, 1)
+        self.HolderImage = \
+            self.HolderCanvas.ax.pcolormesh(self.dataxyY, self.dataxyX,
+                self.dataxyZ, cmap=cm.coolwarm)
+        self.rect = Rectangle(
+            (0, 0),
+            0,
+            0,
+            facecolor='None',
+            edgecolor='black',
+            alpha=0.8,
+            zorder=2,
+            )
         self.HolderCanvas.ax.add_patch(self.rect)
         self.HolderCanvas.draw()
-        
+
         # ComboBox 2D/3D
+
         self.SmallComboBox = QtGui.QComboBox()
-        self.SmallComboBox.addItem("2D")
-        self.SmallComboBox.addItem("3D")
-        self.filexy=["img/XY ++.png", "img/XY +-.png"]
-        self.filext=["img/XT ++.png", "img/XT +-.png"]
-        _index=self.SmallComboBox.currentIndex()
-
-
-        self.mainGrid.addWidget(self.LeftLabel,  0,0,1,1)
-        self.mainGrid.addWidget(self.RightLabel, 0,1,1,1)
-        self.mainGrid.addWidget(self.BackwardLabel, 1,0,1,1)
-        self.mainGrid.addWidget(self.BackgroundLabel,    1,1,1,1)
-        self.mainGrid.addWidget(self.BackwardCanvas,    2,0,1,1)
-        self.mainGrid.addWidget(self.BackgroundCanvas,    2,1,1,1)
-        self.mainGrid.addWidget(self.BackwardComboBox,    2,2,1,1)
-        self.mainGrid.addWidget(self.BankLabel, 3,0,1,1)
-        self.mainGrid.addWidget(self.NoiseLabel, 3,1,1,1)
-        self.mainGrid.addWidget(self.BankCanvas, 4,0,1,1)
-        self.mainGrid.addWidget(self.NoiseCanvas, 4,1,1,1)
-        self.mainGrid.addWidget(self.BankComboBox,    4,2,1,1)
-        self.mainGrid.addWidget(self.SmallLabel, 5,0,1,1)
-        self.mainGrid.addWidget(self.HolderLabel, 5,1,1,1)
-        self.mainGrid.addWidget(self.SmallCanvas, 6,0,1,1)
-        self.mainGrid.addWidget(self.HolderCanvas, 6,1,1,1)
-        self.mainGrid.addWidget(self.SmallComboBox,    6,2,1,1)
+        self.SmallComboBox.addItem('2D')
+        self.SmallComboBox.addItem('3D')
+        self.filexy = ['img/XY ++.png', 'img/XY +-.png']
+        self.filext = ['img/XT ++.png', 'img/XT +-.png']
+        _index = self.SmallComboBox.currentIndex()
+
+        self.mainGrid.addWidget(self.LeftLabel, 0, 0, 1, 1)
+        self.mainGrid.addWidget(self.RightLabel, 0, 1, 1, 1)
+        self.mainGrid.addWidget(self.BackwardLabel, 1, 0, 1, 1)
+        self.mainGrid.addWidget(self.BackgroundLabel, 1, 1, 1, 1)
+        self.mainGrid.addWidget(self.BackwardCanvas, 2, 0, 1, 1)
+        self.mainGrid.addWidget(self.BackgroundCanvas, 2, 1, 1, 1)
+        self.mainGrid.addWidget(self.BackwardComboBox, 2, 2, 1, 1)
+        self.mainGrid.addWidget(self.BankLabel, 3, 0, 1, 1)
+        self.mainGrid.addWidget(self.NoiseLabel, 3, 1, 1, 1)
+        self.mainGrid.addWidget(self.BankCanvas, 4, 0, 1, 1)
+        self.mainGrid.addWidget(self.NoiseCanvas, 4, 1, 1, 1)
+        self.mainGrid.addWidget(self.BankComboBox, 4, 2, 1, 1)
+        self.mainGrid.addWidget(self.SmallLabel, 5, 0, 1, 1)
+        self.mainGrid.addWidget(self.HolderLabel, 5, 1, 1, 1)
+        self.mainGrid.addWidget(self.SmallCanvas, 6, 0, 1, 1)
+        self.mainGrid.addWidget(self.HolderCanvas, 6, 1, 1, 1)
+        self.mainGrid.addWidget(self.SmallComboBox, 6, 2, 1, 1)
+
+
Index: src/viewer/mainTab.py
===================================================================
--- src/viewer/mainTab.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/viewer/mainTab.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,6 +1,9 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 from PyQt4 import QtCore, QtGui
 from PyQt4 import Qt
 
 # for user defined
+
 from chopper import *
 from sample import *
@@ -10,12 +13,14 @@
 from model.chopperModel import *
 
+
 class CSNSMainTab(QtGui.QTabWidget):
+
     def __init__(self, parent=None):
         super(CSNSMainTab, self).__init__(parent)
         self.setupUi(self)
 
-    def setupUi(self,QTabWidget):
+    def setupUi(self, QTabWidget):
 
-        #self.main_tab = QtGui.QTabWidget(self.main_vertical)
+        # self.main_tab = QtGui.QTabWidget(self.main_vertical)
 
         self.chopperPage = CSNSChopperPage()
@@ -26,11 +31,14 @@
 
         self.tfvalue = TimeFrameCalculation(0.5, 6.0)
-        pulseList, chopperList, timeList, xList, yList=self.tfvalue.getTimeFrame()
-        self.chopperPage.updateTimeFrame(pulseList, chopperList, timeList, xList, yList)
+        (pulseList, chopperList, timeList, xList, yList) = \
+            self.tfvalue.getTimeFrame()
+        self.chopperPage.updateTimeFrame(pulseList, chopperList,
+                timeList, xList, yList)
 
-        self.addTab(self.chopperPage, "Chopper")
-        self.addTab(self.samplePage, "Sample")
-        self.addTab(self.analysisPage, "Analysis")
-        self.addTab(self.calibrationPage, "Calibration")
-        self.addTab(self.reductionPage, "Reduction")
+        self.addTab(self.chopperPage, 'Chopper')
+        self.addTab(self.samplePage, 'Sample')
+        self.addTab(self.analysisPage, 'Analysis')
+        self.addTab(self.calibrationPage, 'Calibration')
+        self.addTab(self.reductionPage, 'Reduction')
 
+
Index: src/viewer/reduction.py
===================================================================
--- src/viewer/reduction.py	(revision 2701891655f0e8a08577f9810aecfe572d1d3892)
+++ src/viewer/reduction.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,6 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# configure
+
 '''
 Created on 2015.6.2
@@ -5,5 +9,5 @@
 reduction
 '''
-# configure
+
 from conf import *
 
@@ -12,7 +16,9 @@
 
 # user defined
+
 from model.readData import *
 from model.readFile import *
 from model.readImage import *
+
 
 class CSNSReductionPage(QtGui.QWidget):
@@ -22,10 +28,12 @@
         self.setupUi(self)
 
-    def setupUi(self,QWidget):
-        #for main  grid
+    def setupUi(self, QWidget):
+
+        # for main  grid
+
         self.mainGrid = QtGui.QGridLayout(self)
 
         self.flowText = QtGui.QTextEdit(self)
-        self.flowText.setText(CSNSReadText("dat/flowchart.dot"))
+        self.flowText.setText(CSNSReadText('dat/flowchart.dot'))
 
         self.flowEdit = QtGui.QTextEdit(self)
@@ -35,10 +43,13 @@
         self.flowAxes = fig.add_subplot(111)
 
-        self.flowFigure = nx.read_dot("dat/flowchart.dot")
-        nx.draw_networkx(self.flowFigure,ax=self.flowAxes, node_color='b')
-        
+        self.flowFigure = nx.read_dot('dat/flowchart.dot')
+        nx.draw_networkx(self.flowFigure, ax=self.flowAxes,
+                         node_color='b')
+
         self.flowCanvas.draw()
 
-        self.mainGrid.addWidget(self.flowText,     0,0,1,1)
-        self.mainGrid.addWidget(self.flowCanvas,   0,2,1,1)
-        self.mainGrid.addWidget(self.flowEdit,     0,3,1,1)
+        self.mainGrid.addWidget(self.flowText, 0, 0, 1, 1)
+        self.mainGrid.addWidget(self.flowCanvas, 0, 2, 1, 1)
+        self.mainGrid.addWidget(self.flowEdit, 0, 3, 1, 1)
+
+
Index: src/viewer/runData.py
===================================================================
--- src/viewer/runData.py	(revision 9c2015434bf7d916d73bb607d21cbed47c284c37)
+++ src/viewer/runData.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,6 +1,10 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 # configure
+
 from conf import *
 
 from model.readData import *
+
 
 class CSNSRunData(QtGui.QWidget):
@@ -10,33 +14,82 @@
         self.setupUi(self)
 
-    def setupUi(self,QWidget):
+    def setupUi(self, QWidget):
         self.mainGrid = QtGui.QGridLayout(self)
         self.mainGrid.setMargin(0)
 
         with plt.xkcd():
-            self.runFigure = Figure((1,1), dpi=150, facecolor="white", edgecolor=None, frameon=False, tight_layout=False)
+            self.runFigure = Figure(
+                (1, 1),
+                dpi=150,
+                facecolor='white',
+                edgecolor=None,
+                frameon=False,
+                tight_layout=False,
+                )
             self.runCanvas = FigureCanvas(self.runFigure)
             self.runCanvas.setParent(self)
 
             self.runAxes = self.runFigure.add_subplot(111)
-            self.runFigure.subplots_adjust(left=0.05, bottom=0.05, right=0.95, top=0.95)
-            self.runAxes.tick_params(axis='both', which='major', labelsize=6)
+            self.runFigure.subplots_adjust(left=0.05, bottom=0.05,
+                    right=0.95, top=0.95)
+            self.runAxes.tick_params(axis='both', which='major',
+                    labelsize=6)
             self.runAxes.get_xaxis().set_visible(False)
             self.runAxes.get_yaxis().set_visible(False)
-            _ntmp, runData = CSNSRead2DData("./dat/refl.dat")
-            self.runAxes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%3.1E'))
-            self.runAxes.plot(runData[0],runData[1])
+            (_ntmp, runData) = CSNSRead2DData('./dat/refl.dat')
+            self.runAxes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%3.1E'
+                    ))
+            self.runAxes.plot(runData[0], runData[1])
             self.runCanvas.draw()
 
-        self.chargeLabel = QtGui.QLabel("Proton Charge: ")
-        self.chargeText = QtGui.QLabel("1.3E6 ")
+        self.chargeLabel = QtGui.QLabel('Proton Charge: ')
+        self.chargeText = QtGui.QLabel('1.3E6 ')
 
-        self.countsLabel = QtGui.QLabel("Neutron Counts: ")
-        self.countsText = QtGui.QLabel("5.2E10 ")
+        self.countsLabel = QtGui.QLabel('Neutron Counts: ')
+        self.countsText = QtGui.QLabel('5.2E10 ')
 
-        self.mainGrid.addWidget(self.chargeLabel,0,0,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.chargeText, 0,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.countsLabel,1,0,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.countsText, 1,1,1,1, QtCore.Qt.AlignCenter)
-        self.mainGrid.addWidget(self.runCanvas,  2,0,1,2, QtCore.Qt.AlignCenter)
-        self.mainGrid.addItem(QtGui.QSpacerItem(-1, -1, QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Expanding), 2, 0)
+        self.mainGrid.addWidget(
+            self.chargeLabel,
+            0,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(
+            self.chargeText,
+            0,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(
+            self.countsLabel,
+            1,
+            0,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(
+            self.countsText,
+            1,
+            1,
+            1,
+            1,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addWidget(
+            self.runCanvas,
+            2,
+            0,
+            1,
+            2,
+            QtCore.Qt.AlignCenter,
+            )
+        self.mainGrid.addItem(QtGui.QSpacerItem(-1, -1,
+                              QtGui.QSizePolicy.Ignored,
+                              QtGui.QSizePolicy.Expanding), 2, 0)
+
+
Index: src/viewer/runList.py
===================================================================
--- src/viewer/runList.py	(revision d68a4a738afaddd578514b3a8910e72403d0eecd)
+++ src/viewer/runList.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,5 +1,8 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 from PyQt4 import QtCore, QtGui
 from PyQt4 import Qt
 import json
+
 
 class CSNSRunList(QtGui.QWidget):
@@ -13,31 +16,43 @@
         self.mainGrid.setMargin(0)
 
-        #self.runListWidget = QtGui.QListWidget(self)
-        #_runlist=["BL04_MR_0000016","BL04_MR_0000017","BL04_MR_0000018","BL04_MR_0000019"]
-        #self.runListWidget.addItems(_runlist)
-        #self.runListWidget.setMinimumSize(QtCore.QSize(0, 400))
+        # self.runListWidget = QtGui.QListWidget(self)
+        # _runlist=["BL04_MR_0000016","BL04_MR_0000017","BL04_MR_0000018","BL04_MR_0000019"]
+        # self.runListWidget.addItems(_runlist)
+        # self.runListWidget.setMinimumSize(QtCore.QSize(0, 400))
 
-        #self.loadButton  = QtGui.QPushButton("+",self) 
-        #self.clearButton = QtGui.QPushButton("-",self)
-        
-        #load json file
-        summary  = open('./dat/summary.json').read()
+        # self.loadButton  = QtGui.QPushButton("+",self)
+        # self.clearButton = QtGui.QPushButton("-",self)
+
+        # load json file
+
+        summary = open('./dat/summary.json').read()
         expData = json.loads(summary)
-        
-        #Analysis json file,dict format
+
+        # Analysis json file,dict format
+
         self.treeWidget = QtGui.QTreeWidget(self)
-        self.treeWidget.setHeaderLabels(['Summary'])        
+        self.treeWidget.setHeaderLabels(['Summary'])
         for item in range(len(expData)):
-            root= QtGui.QTreeWidgetItem(self.treeWidget)
-            root.setText(0,expData.keys()[item])
-            if type(expData[expData.keys()[item]]) == dict:#dict in dict format
-                for key in range(len(expData[expData.keys()[item]].keys())):
+            root = QtGui.QTreeWidgetItem(self.treeWidget)
+            root.setText(0, expData.keys()[item])
+            if type(expData[expData.keys()[item]]) == dict:  # dict in dict format
+                for key in \
+                    range(len(expData[expData.keys()[item]].keys())):
                     dict0 = QtGui.QTreeWidgetItem(root)
-                    dict0.setText(0,expData[expData.keys()[item]].keys()[key])
+                    dict0.setText(0,
+                                  expData[expData.keys()[item]].keys()[key])
                     key0 = QtGui.QTreeWidgetItem(dict0)
-                    key0.setText(0,expData[expData.keys()[item]][expData[expData.keys()[item]].keys()[key]])
-            else:#list in dict format
-                for listlength in range(len(expData[expData.keys()[item]])):
+                    key0.setText(0,
+                                 expData[expData.keys()[item]][expData[expData.keys()[item]].keys()[key]])
+            else:
+
+                 # list in dict format
+
+                for listlength in \
+                    range(len(expData[expData.keys()[item]])):
                     child0 = QtGui.QTreeWidgetItem(root)
-                    child0.setText(0,str(expData[expData.keys()[item]][listlength]))
-        self.mainGrid.addWidget(self.treeWidget,0,0,1,2)
+                    child0.setText(0,
+                                   str(expData[expData.keys()[item]][listlength]))
+        self.mainGrid.addWidget(self.treeWidget, 0, 0, 1, 2)
+
+
Index: src/viewer/sample.py
===================================================================
--- src/viewer/sample.py	(revision 2b41ffeb36a5e52980441e46fafca007f1479f36)
+++ src/viewer/sample.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,2 +1,5 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
 '''
 Created on 2015.9.25
@@ -11,4 +14,5 @@
 from model.readData import *
 
+
 class CSNSSamplePage(QtGui.QWidget):
 
@@ -17,8 +21,8 @@
         self.setupUi(self)
 
-    def setupUi(self,QWidget):
+    def setupUi(self, QWidget):
         self.verticalLayout = QtGui.QVBoxLayout(self)
 
-        self.sampleLabel = QtGui.QLabel("Sample")
+        self.sampleLabel = QtGui.QLabel('Sample')
 
         self.sampleTableView = QtGui.QTableWidget(self)
@@ -26,11 +30,11 @@
         self.sampleTableView.setMinimumHeight(CSNStableMinimumHeight)
 
-        sampleList, peakList, areaList = sampleModel()
-        _npoint=len(sampleList)
-        self.sampleTableView.setColumnCount(_npoint+1)
-        _header=[]
-        _header.append(" ")
+        (sampleList, peakList, areaList) = sampleModel()
+        _npoint = len(sampleList)
+        self.sampleTableView.setColumnCount(_npoint + 1)
+        _header = []
+        _header.append(' ')
         for i in range(_npoint):
-            _header.append(str(i+1))
+            _header.append(str(i + 1))
         self.sampleTableView.setHorizontalHeaderLabels(_header)
 
@@ -38,110 +42,127 @@
         self.sampleTableView.insertRow(1)
         self.sampleTableView.insertRow(2)
-        _tmp=QtGui.QTableWidgetItem("Position")
+        _tmp = QtGui.QTableWidgetItem('Position')
         self.sampleTableView.setItem(0, 0, _tmp)
-        _tmp=QtGui.QTableWidgetItem("Peak")
+        _tmp = QtGui.QTableWidgetItem('Peak')
         self.sampleTableView.setItem(1, 0, _tmp)
-        _tmp=QtGui.QTableWidgetItem("Area")
+        _tmp = QtGui.QTableWidgetItem('Area')
         self.sampleTableView.setItem(2, 0, _tmp)
 
         for i in range(_npoint):
-            _tmp=QtGui.QTableWidgetItem(str(sampleList[i]))
-            self.sampleTableView.setItem(0, i+1, _tmp)
-            _tmp=QtGui.QTableWidgetItem(str(peakList[i]))
-            self.sampleTableView.setItem(1, i+1, _tmp)
-            _tmp=QtGui.QTableWidgetItem(str(areaList[i]))
-            self.sampleTableView.setItem(2, i+1, _tmp)
+            _tmp = QtGui.QTableWidgetItem(str(sampleList[i]))
+            self.sampleTableView.setItem(0, i + 1, _tmp)
+            _tmp = QtGui.QTableWidgetItem(str(peakList[i]))
+            self.sampleTableView.setItem(1, i + 1, _tmp)
+            _tmp = QtGui.QTableWidgetItem(str(areaList[i]))
+            self.sampleTableView.setItem(2, i + 1, _tmp)
 
         # self.sampleTableView.resizeColumnsToContents()
 
-        '''
-        # canvas for 3D
-        self.sampleFigure = Figure((8,4), dpi=150, facecolor="white", edgecolor=None, linewidth=1.0, frameon=False, tight_layout=False)
-        self.sampleCanvas = FigureCanvas(self.sampleFigure)
-        self.sampleAxes = self.sampleFigure.add_subplot(111,projection='3d')
-        self.sampleFigure.subplots_adjust(left=0.05,bottom=0.05,right=0.95,top=0.95)
-        self.sampleAxes.tick_params(axis='both', which='major', labelsize=5)
+        # canvas for sample 1
 
-        dataX, dataY, dataZ = CSNSRead3DData("./dat/3d1.dat")
-        self.sampleAxes.clear()
-        self.sampleAxes.plot_surface(dataX, dataY, dataZ, rstride=1, cstride=1, alpha=0.7, cmap=cm.coolwarm, linewidth=0, antialiased=True)
-        #cset = self.sampleAxes.contourf(dataX, dataY, dataZ, zdir='z', offset=0, cmap=cm.coolwarm)
-        self.sampleCanvas.draw()
-        '''
-
-        # canvas for sample 1
-        self.samplePeakFigure = Figure((4,3), dpi=150, facecolor="white", edgecolor=None, linewidth=1.0, frameon=False, tight_layout=False)
+        self.samplePeakFigure = Figure(
+            (4, 3),
+            dpi=150,
+            facecolor='white',
+            edgecolor=None,
+            linewidth=1.0,
+            frameon=False,
+            tight_layout=False,
+            )
         self.samplePeakCanvas = FigureCanvas(self.samplePeakFigure)
         self.samplePeakAxes = self.samplePeakFigure.add_subplot(111)
-        self.samplePeakFigure.subplots_adjust(left=0.12,bottom=0.15,right=0.95,top=0.95)
-        self.samplePeakAxes.tick_params(axis='both', which='major', labelsize=5)
-        self.samplePeakAxes.plot(sampleList,peakList,color='red',marker='+')
-        self.samplePeakAxes.set_xlabel("Vertical",fontsize=5)
-        self.samplePeakAxes.set_ylabel("Horizental",fontsize=5)
+        self.samplePeakFigure.subplots_adjust(left=0.12, bottom=0.15,
+                right=0.95, top=0.95)
+        self.samplePeakAxes.tick_params(axis='both', which='major',
+                labelsize=5)
+        self.samplePeakAxes.plot(sampleList, peakList, color='red',
+                                 marker='+')
+        self.samplePeakAxes.set_xlabel('Vertical', fontsize=5)
+        self.samplePeakAxes.set_ylabel('Horizental', fontsize=5)
         self.samplePeakCanvas.draw()
 
         # canvas for sample 2
-        self.sampleAreaFigure = Figure((4,3), dpi=150, facecolor="white", edgecolor=None, linewidth=1.0, frameon=False, tight_layout=False)
+
+        self.sampleAreaFigure = Figure(
+            (4, 3),
+            dpi=150,
+            facecolor='white',
+            edgecolor=None,
+            linewidth=1.0,
+            frameon=False,
+            tight_layout=False,
+            )
         self.sampleAreaCanvas = FigureCanvas(self.sampleAreaFigure)
         self.sampleAreaAxes = self.sampleAreaFigure.add_subplot(111)
-        self.sampleAreaFigure.subplots_adjust(left=0.12,bottom=0.15,right=0.95,top=0.95)
-        self.sampleAreaAxes.tick_params(axis='both', which='major', labelsize=5)
-        self.sampleAreaAxes.plot(sampleList,areaList,color='green',marker='+')
-        self.sampleAreaAxes.set_xlabel("Vertical",fontsize=5)
-        self.sampleAreaAxes.set_ylabel("Horizental",fontsize=5)
+        self.sampleAreaFigure.subplots_adjust(left=0.12, bottom=0.15,
+                right=0.95, top=0.95)
+        self.sampleAreaAxes.tick_params(axis='both', which='major',
+                labelsize=5)
+        self.sampleAreaAxes.plot(sampleList, areaList, color='green',
+                                 marker='+')
+        self.sampleAreaAxes.set_xlabel('Vertical', fontsize=5)
+        self.sampleAreaAxes.set_ylabel('Horizental', fontsize=5)
         self.sampleAreaCanvas.draw()
 
-        self.mainWidget= QtGui.QWidget(self)
+        self.mainWidget = QtGui.QWidget(self)
         self.mainGrid = QtGui.QGridLayout(self.mainWidget)
         self.mainGrid.setVerticalSpacing(1)
 
-        self.roiLabel =  QtGui.QLabel("<font color=red>Beam ROI: </font>")
-        self.roiLeftLabel=QtGui.QLabel("Left: ")
-        self.roiLeftText=QtGui.QLabel("10")
-        self.roiRightLabel=QtGui.QLabel("Right: ")
-        self.roiRightText=QtGui.QLabel("14")
-        self.roiTopLabel=QtGui.QLabel("Top: ")
-        self.roiTopText=QtGui.QLabel("65")
-        self.roiBottomLabel=QtGui.QLabel("Bottom: ")
-        self.roiBottomText=QtGui.QLabel("35")
+        self.roiLabel = QtGui.QLabel('<font color=red>Beam ROI: </font>'
+                )
+        self.roiLeftLabel = QtGui.QLabel('Left: ')
+        self.roiLeftText = QtGui.QLabel('10')
+        self.roiRightLabel = QtGui.QLabel('Right: ')
+        self.roiRightText = QtGui.QLabel('14')
+        self.roiTopLabel = QtGui.QLabel('Top: ')
+        self.roiTopText = QtGui.QLabel('65')
+        self.roiBottomLabel = QtGui.QLabel('Bottom: ')
+        self.roiBottomText = QtGui.QLabel('35')
 
-        self.positionLabel =  QtGui.QLabel("<font color=red>Sample Position: </font>")
-        self.positionCenterLabel=QtGui.QLabel("Center")
-        self.positionCenterText=QtGui.QLabel("1.67 mm")
-        self.positionErrorLabel=QtGui.QLabel("Offset")
-        self.positionErrorText=QtGui.QLabel("+/- 0.02 mm")
+        self.positionLabel = \
+            QtGui.QLabel('<font color=red>Sample Position: </font>')
+        self.positionCenterLabel = QtGui.QLabel('Center')
+        self.positionCenterText = QtGui.QLabel('1.67 mm')
+        self.positionErrorLabel = QtGui.QLabel('Offset')
+        self.positionErrorText = QtGui.QLabel('+/- 0.02 mm')
 
-        self.mainGrid.addWidget(self.samplePeakCanvas, 0,0,1,4)
-        self.mainGrid.addWidget(self.sampleAreaCanvas, 0,4,1,4)
+        self.mainGrid.addWidget(self.samplePeakCanvas, 0, 0, 1, 4)
+        self.mainGrid.addWidget(self.sampleAreaCanvas, 0, 4, 1, 4)
 
-        self.mainGrid.addItem(QtGui.QSpacerItem(-1, -1, QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Expanding), 1, 0)
+        self.mainGrid.addItem(QtGui.QSpacerItem(-1, -1,
+                              QtGui.QSizePolicy.Ignored,
+                              QtGui.QSizePolicy.Expanding), 1, 0)
 
-        self.mainGrid.addWidget(self.roiLabel, 2,0,1,2)
-        ncol=-1
-        ncol+=1
-        self.mainGrid.addWidget(self.roiLeftLabel,   3,ncol,1,1)
-        ncol+=1
-        self.mainGrid.addWidget(self.roiLeftText,    3,ncol,1,1)
-        ncol+=1
-        self.mainGrid.addWidget(self.roiRightLabel,  3,ncol,1,1)
-        ncol+=1
-        self.mainGrid.addWidget(self.roiRightText,   3,ncol,1,1)
-        ncol+=1
-        self.mainGrid.addWidget(self.roiBottomLabel, 3,ncol,1,1)
-        ncol+=1
-        self.mainGrid.addWidget(self.roiBottomText,  3,ncol,1,1)
-        ncol+=1
-        self.mainGrid.addWidget(self.roiTopLabel,    3,ncol,1,1)
-        ncol+=1
-        self.mainGrid.addWidget(self.roiTopText,     3,ncol,1,1)
+        self.mainGrid.addWidget(self.roiLabel, 2, 0, 1, 2)
+        ncol = -1
+        ncol += 1
+        self.mainGrid.addWidget(self.roiLeftLabel, 3, ncol, 1, 1)
+        ncol += 1
+        self.mainGrid.addWidget(self.roiLeftText, 3, ncol, 1, 1)
+        ncol += 1
+        self.mainGrid.addWidget(self.roiRightLabel, 3, ncol, 1, 1)
+        ncol += 1
+        self.mainGrid.addWidget(self.roiRightText, 3, ncol, 1, 1)
+        ncol += 1
+        self.mainGrid.addWidget(self.roiBottomLabel, 3, ncol, 1, 1)
+        ncol += 1
+        self.mainGrid.addWidget(self.roiBottomText, 3, ncol, 1, 1)
+        ncol += 1
+        self.mainGrid.addWidget(self.roiTopLabel, 3, ncol, 1, 1)
+        ncol += 1
+        self.mainGrid.addWidget(self.roiTopText, 3, ncol, 1, 1)
 
-        self.mainGrid.addWidget(self.positionLabel, 4,0,1,2)
-        self.mainGrid.addWidget(self.positionCenterLabel,   5,0,1,1)
-        self.mainGrid.addWidget(self.positionCenterText,    5,1,1,1)
-        self.mainGrid.addWidget(self.positionErrorLabel,    5,2,1,1)
-        self.mainGrid.addWidget(self.positionErrorText,     5,3,1,1)
+        self.mainGrid.addWidget(self.positionLabel, 4, 0, 1, 2)
+        self.mainGrid.addWidget(self.positionCenterLabel, 5, 0, 1, 1)
+        self.mainGrid.addWidget(self.positionCenterText, 5, 1, 1, 1)
+        self.mainGrid.addWidget(self.positionErrorLabel, 5, 2, 1, 1)
+        self.mainGrid.addWidget(self.positionErrorText, 5, 3, 1, 1)
 
         self.verticalLayout.addWidget(self.sampleLabel)
         self.verticalLayout.addWidget(self.sampleTableView)
+
 #        self.verticalLayout.addWidget(self.sampleCanvas)
+
         self.verticalLayout.addWidget(self.mainWidget)
+
+
Index: src/viewer/subTab.py
===================================================================
--- src/viewer/subTab.py	(revision c0dd1c210bbe5f17d723a81d5cf226c7bca89d62)
+++ src/viewer/subTab.py	(revision 29a7166d69a034de6b1fb3bc3411d1fa34109be2)
@@ -1,6 +1,10 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 # configure
+
 from conf import *
 
 from guishell import *
+
 
 class CSNSSubTab(QtGui.QTabWidget):
@@ -10,10 +14,10 @@
         self.setupUi(self)
 
-    def setupUi(self,QTabWidget):
+    def setupUi(self, QTabWidget):
         self.logPage = QtGui.QTextEdit(self)
         self.ipythonPage = ConsoleWidget(self)
 
-        self.addTab(self.logPage, "Log Window")
-        self.addTab(self.ipythonPage, "Console Window")
+        self.addTab(self.logPage, 'Log Window')
+        self.addTab(self.ipythonPage, 'Console Window')
 
 
