Esempio n. 1
0
 def Populate_Frame(self):
     
     ##############################################
     #Load and process logo
     Logo = Image.open(os.path.join(File.GetRuntimeDir(),
                                     'Images',
                                     'R-Data_Logo.jpg'))
                                     
     Logo = Logo.resize((370, 200),
                        Image.ANTIALIAS)
                        
     Logo = ImageTk.PhotoImage(Logo)
     
     ##############################################
     #Create the panel and palce it
     Logo_Panel          = tk.Label(self.Frame,
                                    image = Logo)
     
     Logo_Panel.image    = Logo
     
     Logo_Panel.grid(    row         = 0,
                         column      = 0,
                         columnspan  = 10,
                         rowspan     = 1)
                         
     ##############################################
     #Create the Version apanel and place it
     Version_Panel    = ttk.Label(self.Frame,
                                 text = 'version: '+File.ReadIni(2),
                                 anchor = tk.W)
                                 
     Version_Panel.grid(row          = 1,
                        column       = 0,
                        columnspan   = 10,
                        sticky       = tk.E+tk.W)
Esempio n. 2
0
 def SetOut(self):
     
     '''
     ######################################################
     This will ask for a folder to be set dfault out folder.
     ######################################################    
     '''
     DirName =  tkFileDialog.askdirectory(**self.dir_opt)
     File.SetIni(DirName,1)
     VisOut.TextBox(Title='log',Text = 'Set the default out folder to '+DirName,L = 20,state = 1,close = False)
Esempio n. 3
0
    def Load_Processed(self,Path = None):
        
        ######################################################
        #zmpty path
        if Path == None:
        
            #interface to ask for path
            Paths = tkFileDialog.askopenfilenames( **self.file_opt)
        
            print Paths
        ######################################################
        #full path
        for Path in Paths:
            
            #check if the path corresponds to a file
            if File.IsFile(Path):
                
                #Create a new dataclass
                self.DataClassList.append(DataClass.Data())
            
                #Routine to load the actual fil
                VisOut.TextBox(Title='log',Text = self.DataClassList[-1].Load(Path),
                               L = 20,
                               state = 1,
                               close = False)
            
                #push it out
                VisOut.TextBox(Title='log',Text = 'Raman depth measurement file was loaded from:\n'+Path,
                               L = 20,
                               state = 1,
                               close = False)
                
                #process the submenu
                self.Menu_Data_Process(ID = len(self.DataClassList) - 1)
            
            else:
            
                pass

        ######################################################
        #prompt the user what to do:
        
        #let us add a window manager as a differnet group
        self.Action_Prompt_Manager = self.Window_Manager.Add_Manager()
        
        #create the window
        self.Action_Prompt_Window = self.Action_Prompt_Manager.Add_Window()
        
        #initialise the class
        self.Action_Prompt_Class = Action_Prompt(Action_Prompt,
                                                 self)
        
        #Link the class to it
        self.Action_Prompt_Window.Link_to_Class(self.Action_Prompt_Class)
Esempio n. 4
0
    def IterSolver(self, A, W, H, k, it):

        #if we are windows or linux we can do Mu quick
        #print 'I was here 0'
        if File.IsWindows():

            AtW = A.T.dot(W)

            HWtW = H.dot(W.T.dot(W)) + self.eps

            H = H * AtW

            H = H / HWtW

            AH = A.dot(H)

            WHtH = W.dot(H.T.dot(H)) + self.eps

            W = W * AH

            W = W / WHtH

        #If we are mac we have a multiprocessing issue
        else:

            AtW = MatMult(A.T, W)

            HWtW = MatMult(H, MatMult(W.T, W)) + self.eps

            H = H * AtW

            H = H / HWtW

            AH = MatMult(A, H)

            WHtH = MatMult(W, MatMult(H.T, H)) + self.eps

            W = W * AH

            W = W / WHtH

        return (W, H)
Esempio n. 5
0
    def Initialize(self, PythonClass):

        ##############################################
        #initialise root
        self.Managers.append(Root_WindowManager(self))

        #grab back root as wew will need it
        self.Root_Window = self.Managers[0].Windows[0]
        self.Root = self.Managers[0].Windows[0].Root

        ##############################################
        #set the application icon (does not work under mac os X)
        try:
            self.Root.iconbitmap(
                os.path.join(File.GetRuntimeDir(), 'Images', 'R-Logo.ico'))
        except:
            pass
        ##############################################
        #Python UI class associated to root
        self.Root_Window.Link_to_Class(PythonClass)
#essential python updates for math

import numpy
from numpy.random import poisson as poisson
import Utility_File as File
import os
import sys

#set the folder path
PathIn = 'Dropbox/Data/G - Reports/2018 - Projects/2018_02_20 - Depth Simulation Output/Real Spectra/NNO_NGO_Simulation/Out - 1mum Sub_1/'

PathOut = 'Dropbox/Data/G - Reports/2018 - Projects/2018_02_20 - Depth Simulation Output/Real Spectra/NNO_NGO_Simulation/Out - 1mum Sub_1 Noise/'

Factor = 1e15
#grab the list of files in this folder
PathList = File.GetFileNames(PathIn, '.txt')

#make the out directory if it doesnt exist
try:
    os.stat(PathOut)
except:
    os.mkdir(PathOut)

#open each file
for Element in PathList:

    #########################
    #handle the input

    #open the file
    f = open(Element, 'r')
Esempio n. 7
0
    def Populate_Frame(self):

        #############################################
        #Load the container frames
        self.Padding = '10p'

        #this will be the treeframe
        self.FolderFrame = ttk.Frame(self.Frame, padding=self.Padding)

        self.FilterFrame = ttk.Frame(self.Frame, padding=self.Padding)

        self.TreeFrame = ttk.Frame(self.Frame, padding=self.Padding)

        self.LogFrame = ttk.Frame(self.Frame, padding=self.Padding)

        #############################################
        #############################################
        #Top Path select frame
        self.FolderLabel = ttk.Label(self.FolderFrame,
                                     text='Selected Folder: ')

        self.FolderEntry = ttk.Entry(self.FolderFrame)

        self.FolderButton = ttk.Button(self.FolderFrame,
                                       text='...',
                                       command=self.Browse)

        self.Run = ttk.Button(self.FolderFrame, text='Run', command=self.Run)

        self.FolderLabel.grid(row=0,
                              column=0,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.FolderEntry.grid(row=0,
                              column=1,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.FolderButton.grid(row=0,
                               column=2,
                               sticky=tk.N + tk.S + tk.E + tk.W)

        self.Run.grid(row=0, column=3, sticky=tk.N + tk.S + tk.E + tk.W)

        self.FolderFrame.grid_columnconfigure(1, weight=1)

        #############################################
        #############################################
        #Top selector frame
        #initialise the variable
        self.SetFilters()

        #############################################
        #############################################
        # create a treeview with dual scrollbars

        #create the header array
        self.Header = [
            'Type', 'Laser', 'Power', 'Grating', 'Objectif', 'Time', 'N. x',
            'Sam ID', 'Sample', 'Substrate', 'Sam. Info.', 'Sub. Info.'
        ]

        #create the tree
        self.tree = ttk.Treeview(self.TreeFrame,
                                 columns=self.Header,
                                 show="headings")

        for col in self.Header:

            self.tree.heading(
                col,
                text=col.title(),
                command=lambda c=col: self.SortBy(self.tree, c, 0))

            # adjust the column's width to the header string
            self.tree.column(col,
                             width=tkFont.Font().measure(col.title()) + 20)

        #set the scrollbars
        vsb = ttk.Scrollbar(self.TreeFrame,
                            orient="vertical",
                            command=self.tree.yview)

        hsb = ttk.Scrollbar(self.TreeFrame,
                            orient="horizontal",
                            command=self.tree.xview)

        #link the scrollbar
        self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)

        self.tree.bind("<1>", self.OnClick)
        self.tree.bind(File.RightClickStr(), self.rClick)

        #grid it all
        self.tree.grid(column=0, row=0, sticky='nsew')
        vsb.grid(column=1, row=0, sticky='ns')
        hsb.grid(column=0, row=1, sticky='ew')

        #cofigure the treeframe
        self.TreeFrame.grid_columnconfigure(0, weight=1)
        self.TreeFrame.grid_rowconfigure(0, weight=1)

        #############################################
        #############################################
        #Bottom scrolled text

        #insert the textfield
        self.LogField = ScrolledText.ScrolledText(master=self.LogFrame,
                                                  wrap=tk.WORD,
                                                  height=12)

        #grid it
        self.LogField.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S)

        self.LogFrame.grid_columnconfigure(0, weight=1)
        self.LogFrame.grid_rowconfigure(0, weight=1)

        #############################################
        #############################################
        #grid and configure
        self.FolderFrame.grid(row=0,
                              column=0,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.FilterFrame.grid(row=1,
                              column=0,
                              sticky=tk.N + tk.S + tk.E + tk.W)

        self.TreeFrame.grid(row=2, column=0, sticky=tk.N + tk.S + tk.E + tk.W)

        self.LogFrame.grid(row=3, column=0, sticky=tk.N + tk.S + tk.E + tk.W)

        self.Root.grid_rowconfigure(2, weight=1)

        self.Root.grid_columnconfigure(0, weight=1)
Esempio n. 8
0
    def Populate_Frame(self):

        #Import all the images
        ContourImage = Image.open(
            os.path.join(File.GetRuntimeDir(), 'Images', 'Contour.jpg'))

        ContourImage = ContourImage.resize((80, 80), Image.ANTIALIAS)

        ContourImage = ImageTk.PhotoImage(ContourImage)

        CascadeImage = Image.open(
            os.path.join(File.GetRuntimeDir(), 'Images', 'Cascade.png'))

        CascadeImage = CascadeImage.resize((80, 80), Image.ANTIALIAS)

        CascadeImage = ImageTk.PhotoImage(CascadeImage)

        PCANMFImage = Image.open(
            os.path.join(File.GetRuntimeDir(), 'Images', 'PCANMF.jpg'))

        PCANMFImage = PCANMFImage.resize((80, 80), Image.ANTIALIAS)

        PCANMFImage = ImageTk.PhotoImage(PCANMFImage)

        FittingImage = Image.open(
            os.path.join(File.GetRuntimeDir(), 'Images', 'Fiting.jpg'))

        FittingImage = FittingImage.resize((80, 80), Image.ANTIALIAS)

        FittingImage = ImageTk.PhotoImage(FittingImage)

        InfoImage = Image.open(
            os.path.join(File.GetRuntimeDir(), 'Images', 'Info.jpg'))

        InfoImage = InfoImage.resize((80, 80), Image.ANTIALIAS)

        InfoImage = ImageTk.PhotoImage(InfoImage)

        ##############################
        #set The Contour Button
        self.ContourButton = tk.Button(self.Frame,
                                       image=ContourImage,
                                       command=partial(self.Close_Window, 0),
                                       padx=5,
                                       pady=5)

        self.ContourButton.image = ContourImage
        self.ContourButton.grid(row=1, column=0, sticky=tk.E + tk.W)

        ##############################
        #set The Contour Button
        self.CascadeButton = tk.Button(self.Frame,
                                       image=CascadeImage,
                                       command=partial(self.Close_Window, 1),
                                       padx=5,
                                       pady=5)

        self.CascadeButton.image = CascadeImage
        self.CascadeButton.grid(row=1, column=1, sticky=tk.E + tk.W)

        ##############################
        #set The PCA NMF Button
        self.PCANMFButton = tk.Button(self.Frame,
                                      image=PCANMFImage,
                                      command=partial(self.Close_Window, 2),
                                      padx=5,
                                      pady=5)

        self.PCANMFButton.image = PCANMFImage
        self.PCANMFButton.grid(row=1, column=2, sticky=tk.E + tk.W)

        ##############################
        #set The Fitting Button
        self.FitButton = tk.Button(self.Frame,
                                   image=FittingImage,
                                   command=partial(self.Close_Window, 3),
                                   padx=5,
                                   pady=5)

        self.FitButton.image = FittingImage
        self.FitButton.grid(row=1, column=3, sticky=tk.E + tk.W)

        ##############################
        #set The Fitting Button
        self.InfoButton = tk.Button(self.Frame,
                                    image=InfoImage,
                                    command=partial(self.Close_Window, 4),
                                    padx=5,
                                    pady=5)

        self.InfoButton.image = InfoImage
        self.InfoButton.grid(row=1, column=4, sticky=tk.E + tk.W)

        #pack all
        self.Frame.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        ##############################################
        #Set positioning
        self.Window.Place(['Center', 'Center'])
Esempio n. 9
0
    def Populate_Menue(self):

    
        ##################################################
        #Here we build the cascade subMenues
        
        self.FileSubMenu      = tk.Menu(self.Menu,
                                        tearoff=False,
                                        bg = 'white')
                                        
        self.InfoSubMenu      = tk.Menu(self.Menu,
                                        tearoff=False,
                                        bg = 'white')
                                        
        self.AnalysisSubMenu  = tk.Menu(self.Menu,
                                        tearoff=False,
                                        bg = 'white')
                                        
        self.DataSubMenu      = tk.Menu(self.Menu,
                                        tearoff=False,
                                        bg = 'white')
                                        
        self.HelpSubMenu      = tk.Menu(self.Menu,
                                        tearoff=False,
                                        bg = 'white')
        
        
        
        ##################################################
        #Here we declare the cascades
    
        self.Menu.add_cascade(label = 'File',
                              menu = self.FileSubMenu)
                              
        self.Menu.add_cascade(label = 'Info',
                              menu = self.InfoSubMenu)
                              
        self.Menu.add_cascade(label = 'Analysis',
                              menu = self.AnalysisSubMenu)
                              
        self.Menu.add_cascade(label = 'Data',
                              menu = self.DataSubMenu)
                              
        self.Menu.add_cascade(label = 'Help',
                              menu = self.HelpSubMenu)
        
    
        ##################################################
        #Add the commands
        
        if File.IsWindows() or File.IsLinux():
            
            self.FileSubMenu.add_command(label = 'Convert New Raw Data ...',
                                         command = self.Load_Raw)
                                         
            self.FileSubMenu.add_separator()
            
            self.FileSubMenu.add_command(label = 'Open Processed Data',
                                         command = self.Load_Processed)
                                         
            self.FileSubMenu.add_command(label = 'Open Data Browser',
                                         command = self.Launch_Browser)
                                         
            self.FileSubMenu.add_separator()
            
            self.FileSubMenu.add_command(label = 'Signal Generator (in work)')
            
            self.FileSubMenu.add_command(label = 'Simulation Generator',
                                         command = self.Launch_Sim_Interface  )
                                         
            self.FileSubMenu.add_command(label = 'Signal Generator (in work)')
            
            self.FileSubMenu.add_separator()
            
            self.FileSubMenu.add_command(label = 'Settings',
                                         command = self.Do_Nothing)
                                         
            self.FileSubMenu.add_command(label = 'Set Input',
                                         command = self.SetIn)
                                         
            self.FileSubMenu.add_command(label = 'Set Output',
                                         command = self.SetOut)
                                         
            self.FileSubMenu.add_separator()
            
            self.FileSubMenu.add_command(label = 'Quit',
                                         command = self.Exit)
            
            self.InfoSubMenu.add_command(label = 'Data Info',
                                         command = self.Info)
                                         
            self.InfoSubMenu.add_command(label = 'Application Info',
                                         command = self.Do_Nothing)
                                         
            self.InfoSubMenu.add_command(label = 'Developer Info',
                                         command = self.Do_Nothing)
            
            self.AnalysisSubMenu.add_command(label = 'Visualize Contour',
                                             command = partial(self.Launch_Contour))
                                             
            self.AnalysisSubMenu.add_command(label = 'Visualize Cascade',
                                             command = partial(self.Launch_Cascade))
                                             
            self.AnalysisSubMenu.add_command(label = 'Launch PCA/NMF',
                                             command = partial(self.Launch_PCA))
                                             
            self.AnalysisSubMenu.add_command(label = 'Launch Fit',
                                             command = partial(self.Launch_Fit))
            
            self.DataSubMenu.add_command(label = 'Loaded Datasets ...',
                                         state = tk.DISABLED)
            
            self.HelpSubMenu.add_command(label = 'How To',
                                         command = self.Do_Nothing)
                                         
            self.HelpSubMenu.add_command(label = 'Version History',
                                         command = self.Do_Nothing)



        
        else:
            
            self.FileSubMenu.add_command(label = 'Convert New Raw Data ...',
                                         command = self.Load_Raw)
                                         
            self.FileSubMenu.add_separator()
            
            self.FileSubMenu.add_command(label = 'Open Processed Data',
                                         command = self.Load_Processed)
                                         
            self.FileSubMenu.add_command(label = 'Open Data Browser',
                                         command = self.Launch_Browser)
                                         
            self.FileSubMenu.add_separator()
            
            self.FileSubMenu.add_command(label = 'Signal Generator (in work)')
            
            self.FileSubMenu.add_command(label = 'Simulation Generator',
                                         command = self.Launch_Sim_Interface  )
            
            self.FileSubMenu.add_command(label = 'Signal Generator (in work)')
            
            self.FileSubMenu.add_separator()
            
            self.FileSubMenu.add_command(label = 'Settings',
                                         command = self.Do_Nothing)
                                         
            self.FileSubMenu.add_command(label = 'Set Input',
                                         command = self.SetIn)
                                         
            self.FileSubMenu.add_command(label = 'Set Output',
                                         command = self.SetOut)
                                         
            self.FileSubMenu.add_separator()
                                         
            self.FileSubMenu.add_command(label = 'Quit',
                                         command = self.Exit)
            
            self.InfoSubMenu.add_command(label = 'Data Info',
                                         command = self.Info)
                                         
            self.InfoSubMenu.add_command(label = 'Application Info',
                                         command = self.Do_Nothing)
                                         
            self.InfoSubMenu.add_command(label = 'Developer Info',
                                         command = self.Do_Nothing)
            
            self.AnalysisSubMenu.add_command(label = 'Visualize Contour',
                                             command = partial(self.Launch_Contour)  )
                                             
            self.AnalysisSubMenu.add_command(label = 'Visualize Cascade',
                                             command = partial(self.Launch_Cascade))
                                             
            self.AnalysisSubMenu.add_command(label = 'Launch PCA/NMF',
                                             command = partial(self.Launch_PCA)  )
                                             
            self.AnalysisSubMenu.add_command(label = 'Launch Fit',
                                             command = partial(self.Launch_Fit)  )

            self.DataSubMenu.add_command(label = 'Loaded Datasets ...',
                                         state = tk.DISABLED)
            
            
            self.HelpSubMenu.add_command(label = 'How To',
                                         command = self.Do_Nothing)
                                         
            self.HelpSubMenu.add_command(label = 'Version History',
                                         command = self.Do_Nothing)
                                         
            
            self.HelpSubMenu.add_command(label = 'How To',
                                         command = self.Do_Nothing)