def __init__(self, parent): wx.Frame.__init__(self, parent, title=Options.GetTitle(), size=Options.GetSize()) # Define all the most important variable to be stored here self.DataFiles = [] self.ProbeData = PROBE_DATA self.DatalogProgram = DATALOG_PROGRAM self.Data = None self.ModelModes = [] # Add a menu bar menuBar = wx.MenuBar() # Setup the file menu menu = wx.Menu() menuBar.Append(menu, "&File") file_import_data = menu.Append(wx.ID_ANY, "Import data...", "Load data to be analyzed") file_exit = menu.Append(wx.ID_ANY, "Exit") data_menu = wx.Menu() # Now build the menu for the data elaboration menuBar.Append(data_menu, "&Data Elaboration") DM_load_probe_file = data_menu.Append( wx.ID_ANY, "Import Probe Spectrum", "Load the spectrum of the probe") DM_set_analyzer_script = data_menu.Append( wx.ID_ANY, "Set analyzer script", "Set the script to be runned when analizing a single data file.") DM_setup_model = data_menu.Append( wx.ID_ANY, "Setup molecule model", "Set the expected frequency to be shown in the figures") data_menu.AppendSeparator() DM_GetProbeDataTable = data_menu.Append( wx.ID_ANY, "Get Probe Spectrum Table", "Build the table for the selected probe specrum file") DM_analyze_mode_dependence = data_menu.Append( wx.ID_ANY, "Analyze mode intensity", "Mean in a region of the signal spectrum and show the dependence of the signal intensity on the other variable (usually the probe spectrum)" ) DM_setup_flags = data_menu.Append( wx.ID_ANY, "Setup Analisys' flags", "Setup the flags to be used into the analisys") DM_GetCAFromData = data_menu.Append( wx.ID_ANY, "Get Coherent Artifact from data", "Get a table with the chirp evaluated using CA") DM_GetLambdaAnalisys = data_menu.Append( wx.ID_ANY, "Get Spectrum Analisys", "Perform a spectrum analisys at each small probe range") self.SetMenuBar(menuBar) # Binding menu events self.Bind(wx.EVT_MENU, self.OnClose, file_exit) self.Bind(wx.EVT_MENU, self.OnAddFile, file_import_data) self.Bind(wx.EVT_MENU, self.OnLoadProbeFile, DM_load_probe_file) self.Bind(wx.EVT_MENU, self.OnSetupMoleculeModel, DM_setup_model) self.Bind(wx.EVT_MENU, self.OnSetAnalyzerScript, DM_set_analyzer_script) self.Bind(wx.EVT_MENU, self.OnGetProbeDataTable, DM_GetProbeDataTable) self.Bind(wx.EVT_MENU, self.OnAnalyzeModeDependence, DM_analyze_mode_dependence) self.Bind(wx.EVT_MENU, self.OnSetupFlags, DM_setup_flags) self.Bind(wx.EVT_MENU, self.OnGetCAFromData, DM_GetCAFromData) self.Bind(wx.EVT_MENU, self.OnGetLambdaAnalisys, DM_GetLambdaAnalisys) self.main_panel = wx.Panel(self) self.options_panel = wx.Panel(self.main_panel) self.results_panel = wx.Panel(self.main_panel) # Setup the options panel # Select the probe lambda selection probe_lambda_label = wx.StaticText(self.options_panel, label="Probe wavelength window:") lambda_0 = wx.StaticText(self.options_panel, label=u"\u03BB_0") lambda_1 = wx.StaticText(self.options_panel, label=u"\u03BB_1") N_lambda = wx.StaticText(self.options_panel, label=u"N_\u03BB") self.probe_wl_start_txt = wx.TextCtrl(self.options_panel) self.probe_wl_end_txt = wx.TextCtrl(self.options_panel) self.probe_wl_start_txt.SetValue("%d" % (Options.GetDefaultLambdaProbe()[0])) self.probe_wl_end_txt.SetValue("%d" % (Options.GetDefaultLambdaProbe()[1])) self.probe_N_wl = wx.TextCtrl(self.options_panel) self.probe_N_wl.SetValue("%d" % Options.GetDefaultNLambdaProbe()) # The starting time and the ending time of the simulation time_label = wx.StaticText(self.options_panel, label="Time window (ps):") t_0_label = wx.StaticText(self.options_panel, label="t_0") T_label = wx.StaticText(self.options_panel, label="Total time") self.t0_txt = wx.TextCtrl(self.options_panel) self.T_txt = wx.TextCtrl(self.options_panel) self.t0_txt.SetValue("%.2f" % (Options.GetDefaultTime()[0])) self.T_txt.SetValue("%.2f" % (Options.GetDefaultTime()[1])) # Add Options Flag button # TODO # Zero padding - Kaiser Window zp_label = wx.StaticText(self.options_panel, label="Zero padding length x ") self.zp_txt = wx.TextCtrl(self.options_panel) self.zp_txt.SetValue("%d" % Options.GetDefaultZP()) kw_label = wx.StaticText(self.options_panel, label=u"Kaiser-Bessel window \u03B2 = ") self.kw_txt = wx.TextCtrl(self.options_panel) self.kw_txt.SetValue("%.2f" % Options.GetDefaultKW()) # Select files to be analyzed FileList_label = wx.StaticText(self.options_panel, label="Files to be analyzed") self.FileList = wx.ListBox(self.options_panel, style=wx.LB_EXTENDED | wx.LB_NEEDED_SB) self.FileList.Bind(wx.EVT_CONTEXT_MENU, self.OnShowPopupMenu) # bind the menu AddButton = wx.Button(self.options_panel, label="Add data file") DeleteButton = wx.Button(self.options_panel, label="Delete data file") # Add the Analyze button AnalButton = wx.Button(self.options_panel, label="Analyze data") # Now prepare the figure on the results panel self.figure_top = mpl.figure.Figure() self.figure_bottom = mpl.figure.Figure() self.axes_top = self.figure_top.add_subplot(111) self.axes_bottom = self.figure_bottom.add_subplot(111) # Get the correct size of the panel FigureWidth = Options.GetSize()[0] / 2 FigureHeight = int(Options.GetSize()[1] * 3 / 10.) FigureSize = (FigureWidth, FigureHeight) PFigureSize = ( FigureWidth, FigureHeight * 4 / 3 ) # The panel needs also the toolbar (it must be bigger than the figure) self.c_panel_top = wx.Panel(self.results_panel, size=PFigureSize) self.c_panel_bottom = wx.Panel(self.results_panel, size=PFigureSize) self.canvas_top = FigureCanvas(self.c_panel_top, wx.ID_ANY, self.figure_top) self.canvas_bottom = FigureCanvas(self.c_panel_bottom, wx.ID_ANY, self.figure_bottom) #self.canvas_top.SetSize(FigureSize) #self.canvas_bottom.SetSize(FigureSize) toolbar_top = NavigationToolbar2Wx(self.canvas_top) toolbar_bottom = NavigationToolbar2Wx(self.canvas_bottom) toolbar_top.Realize() toolbar_bottom.Realize() # Add the toolbar to the figure panel CPTSizer = wx.BoxSizer(wx.VERTICAL) CPBSizer = wx.BoxSizer(wx.VERTICAL) CPTSizer.Add(self.canvas_top, 1, wx.GROW) CPTSizer.Add(toolbar_top, 0, wx.GROW) CPBSizer.Add(self.canvas_bottom, 1, wx.GROW) CPBSizer.Add(toolbar_bottom, 0, wx.GROW) self.c_panel_top.SetSizer(CPTSizer) self.c_panel_bottom.SetSizer(CPBSizer) toolbar_top.update() toolbar_bottom.update() # Select range of probe wavelength in which see the mean wl0_mean_lb = wx.StaticText(self.results_panel, label=u"Mean: \u03BB_0") wl1_mean_lb = wx.StaticText(self.results_panel, label=u"\u03BB_1") self.wl0_mean_txt = wx.TextCtrl(self.results_panel) self.wl0_mean_txt.SetValue("%d" % Options.GetDefaultLambdaProbe()[0]) self.wl1_mean_txt = wx.TextCtrl(self.results_panel) self.wl1_mean_txt.SetValue("%d" % Options.GetDefaultLambdaProbe()[1]) ApplyButton = wx.Button(self.results_panel, label="Apply") # Select the w range for the fft spectrum to be shown w0_zoom_lb = wx.StaticText(self.results_panel, label=u"FFT zoom (cm^-1): \u03C9_0") w1_zoom_lb = wx.StaticText(self.results_panel, label=u"\u03C9_1") Nw_lb = wx.StaticText(self.results_panel, label=u"\u03C9 subdivision") self.w0_zoom_txt = wx.TextCtrl(self.results_panel) self.w0_zoom_txt.SetValue("%d" % Options.GetWRange()[0]) self.w1_zoom_txt = wx.TextCtrl(self.results_panel) self.w1_zoom_txt.SetValue("%d" % Options.GetWRange()[1]) self.Nw_txt = wx.TextCtrl(self.results_panel) self.Nw_txt.SetValue("%d" % Options.GetNWDefault()) SetWRangeBtn = wx.Button(self.results_panel, label=u"Set \u03C9 range") # SETUP SIZERS # Place the lambda probe into a sizer LambdaProbeSizer = wx.BoxSizer(wx.HORIZONTAL) LambdaProbeSizer.Add(probe_lambda_label, 5, wx.ALIGN_LEFT | wx.LEFT) LambdaProbeSizer.AddStretchSpacer(1) LambdaProbeSizer.Add(lambda_0, 0, wx.ALIGN_RIGHT | wx.RIGHT) LambdaProbeSizer.Add(self.probe_wl_start_txt, 3, wx.RIGHT | wx.ALIGN_RIGHT) LambdaProbeSizer.AddStretchSpacer(1) LambdaProbeSizer.Add(lambda_1, 0, wx.ALIGN_RIGHT | wx.RIGHT) LambdaProbeSizer.Add(self.probe_wl_end_txt, 3, wx.RIGHT | wx.ALIGN_RIGHT) LambdaProbeSizer.AddStretchSpacer(1) LambdaProbeSizer.Add(N_lambda, 0, wx.ALIGN_RIGHT) LambdaProbeSizer.Add(self.probe_N_wl, 3, wx.ALIGN_RIGHT) TimeSizer = wx.BoxSizer(wx.HORIZONTAL) TimeSizer.Add(time_label, 5, wx.ALIGN_LEFT | wx.LEFT) TimeSizer.AddStretchSpacer(1) TimeSizer.Add(t_0_label, 1, wx.ALIGN_RIGHT | wx.RIGHT) TimeSizer.Add(self.t0_txt, 3, wx.RIGHT | wx.ALIGN_RIGHT) TimeSizer.AddStretchSpacer(1) TimeSizer.Add(T_label, 2, wx.ALIGN_RIGHT | wx.RIGHT) TimeSizer.Add(self.T_txt, 2, wx.RIGHT | wx.ALIGN_RIGHT) AdvancedOptionsSizer = wx.BoxSizer(wx.HORIZONTAL) AdvancedOptionsSizer.Add(zp_label, 4, wx.LEFT | wx.ALIGN_LEFT | wx.ALIGN_BOTTOM) AdvancedOptionsSizer.Add(self.zp_txt, 3, wx.LEFT | wx.ALIGN_LEFT | wx.ALIGN_BOTTOM) AdvancedOptionsSizer.AddStretchSpacer(1) AdvancedOptionsSizer.Add(kw_label, 4, wx.RIGHT | wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) AdvancedOptionsSizer.Add(self.kw_txt, 3, wx.RIGHT | wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) FileListButtonSizer = wx.BoxSizer(wx.HORIZONTAL) FileListButtonSizer.Add(AddButton, 1, wx.ALIGN_LEFT) FileListButtonSizer.AddStretchSpacer(4) FileListButtonSizer.Add(DeleteButton, 1, wx.ALIGN_RIGHT) FileListSizer = wx.BoxSizer(wx.VERTICAL) FileListSizer.Add(FileList_label, 1, wx.ALIGN_TOP) FileListSizer.Add(self.FileList, 5, wx.EXPAND) FileListSizer.Add(FileListButtonSizer, 1, wx.EXPAND) # Setup the Options Sizer OptionsPanelSizer = wx.BoxSizer(wx.VERTICAL) OptionsPanelSizer.Add(LambdaProbeSizer, 1, wx.ALIGN_TOP | wx.TOP | wx.EXPAND) OptionsPanelSizer.Add(TimeSizer, 1, wx.ALIGN_TOP | wx.TOP | wx.EXPAND) OptionsPanelSizer.Add(AdvancedOptionsSizer, 1, wx.ALIGN_TOP | wx.TOP | wx.EXPAND) OptionsPanelSizer.Add(wx.StaticLine(self.options_panel), 1, wx.EXPAND) OptionsPanelSizer.Add(FileListSizer, 5, wx.EXPAND) OptionsPanelSizer.AddStretchSpacer(1) OptionsPanelSizer.Add(AnalButton, 1, wx.ALIGN_LEFT | wx.ALIGN_BOTTOM) # Setup the sizer in the results sizer region # Setup the figure canvas sizer FigureSizer = wx.BoxSizer(wx.VERTICAL) FigureSizer.Add(self.c_panel_top, 10, wx.TOP | wx.EXPAND) #FigureSizer.Add(wx.StaticLine(self.results_panel), 0) FigureSizer.Add(self.c_panel_bottom, 10, wx.TOP | wx.EXPAND) # Setup the lambda mean sizer LambdaMeanSizer = wx.BoxSizer(wx.HORIZONTAL) LambdaMeanSizer.Add(wl0_mean_lb, 0, wx.ALIGN_LEFT) LambdaMeanSizer.Add(self.wl0_mean_txt, 2, wx.ALIGN_LEFT) LambdaMeanSizer.AddStretchSpacer(1) LambdaMeanSizer.Add(wl1_mean_lb, 0, wx.ALIGN_RIGHT) LambdaMeanSizer.Add(self.wl1_mean_txt, 2, wx.ALIGN_LEFT) LambdaMeanSizer.Add(ApplyButton, 0, wx.ALIGN_RIGHT | wx.RIGHT) # Setup the w setting WSettingSizer = wx.BoxSizer(wx.HORIZONTAL) WSettingSizer.Add(w0_zoom_lb, 0, wx.ALIGN_LEFT) WSettingSizer.Add(self.w0_zoom_txt, 5, wx.ALIGN_LEFT) WSettingSizer.AddStretchSpacer(1) WSettingSizer.Add(w1_zoom_lb, 0, wx.ALIGN_RIGHT) WSettingSizer.Add(self.w1_zoom_txt, 5, wx.ALIGN_LEFT) WSettingSizer.AddStretchSpacer(1) WSettingSizer.Add(Nw_lb, 0, wx.ALIGN_RIGHT) WSettingSizer.Add(self.Nw_txt, 4, wx.ALIGN_LEFT) WSettingSizer.Add(SetWRangeBtn, 0, wx.ALIGN_RIGHT | wx.RIGHT) # Setup the Results Sizer ResultsPanelSizer = wx.BoxSizer(wx.VERTICAL) ResultsPanelSizer.Add(FigureSizer, 1, wx.TOP | wx.EXPAND) ResultsPanelSizer.Add(LambdaMeanSizer, 0, wx.BOTTOM | wx.ALIGN_BOTTOM | wx.EXPAND) ResultsPanelSizer.Add(WSettingSizer, 0, wx.BOTTOM | wx.ALIGN_BOTTOM | wx.EXPAND) self.options_panel.SetSizer(OptionsPanelSizer) self.results_panel.SetSizer(ResultsPanelSizer) self.results_panel.Layout() # Setup the main panel FirstBox = wx.BoxSizer(wx.HORIZONTAL) FirstBox.Add(self.options_panel, 1, wx.ALIGN_LEFT | wx.LEFT | wx.EXPAND) #FirstBox.Add(wx.StaticLine(self.main_panel, style = wx.LI_VERTICAL), 1, wx.TOP) FirstBox.Add(self.results_panel, 1, wx.ALIGN_RIGHT | wx.RIGHT | wx.EXPAND) self.main_panel.SetSizer(FirstBox) self.main_panel.Layout() # Event binding self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_BUTTON, self.OnAddFile, AddButton) self.Bind(wx.EVT_BUTTON, self.OnDeleteFile, DeleteButton) self.Bind(wx.EVT_BUTTON, self.OnAnalyzeData, AnalButton) self.Bind(wx.EVT_BUTTON, self.OnMeanLambda, ApplyButton) self.Bind(wx.EVT_BUTTON, self.OnSetWRange, SetWRangeBtn)