def load_delay(self, event, vc=False): """The variable delay list loading GUI element. @param event: The wx event. @type event: wx event """ # VD # VC time is not a number if vc: try: vc_factor = float(self.vc_time.GetValue()) except: error_message('VC time is not a number.') return # VD else: vc_factor = 1 # The dialog. dialog = RelaxFileDialog(parent=self, style=wx.FD_OPEN) # Show the dialog and catch if no file has been selected. if status.show_gui and dialog.ShowModal() != wx.ID_OK: # Don't do anything. return # The files. filename = dialog.get_file() # Open the file file = open(filename, 'r') # Read entries index = 0 for line in file: # Evaluate if line is a number try: t = float(line.replace('/n', '')) except: continue # Write delay to peak list grid self.grid.SetCellValue(index, 1, str(t*vc_factor)) # Next peak list index = index + 1 # Too many entries in VD list if index == self.num_rows: error_message('Too many entries in list.') return
def execute(self, event): """Set up, execute, and process the automatic Rx analysis. @param event: The wx event. @type event: wx event """ # Flush the GUI interpreter internal queue to make sure all user functions are complete. self.gui.interpreter.flush() # relax execution lock. if status.exec_lock.locked(): error_message("relax is currently executing.", "relax execution lock") event.Skip() return # User warning to close windows. self.gui.close_windows() # Synchronise the frame data to the relax data store. self.sync_ds(upload=True) # Assemble all the data needed for the auto-analysis. data, missing, model_mismatch = self.assemble_data() # Missing data. if len(missing): self.missing_data = Missing_data(missing) return # Model mismatch. if len(model_mismatch): # Generate the text. text = '' for model, exp in model_mismatch: text += "The '%s' %s model cannot be used as no %s experiment types have been set up.\n" % ( model, exp, exp) # The error message. error_message(text, caption='Model mismatch') return # Display the relax controller, and go to the end of the log window. self.gui.show_controller(None) self.gui.controller.log_panel.on_goto_end(None) # Start the thread. self.thread = Execute_relax_disp(self.gui, data, self.data_index) self.thread.start() # Terminate the event. event.Skip()
def execute(self, event): """Set up, execute, and process the automatic Rx analysis. @param event: The wx event. @type event: wx event """ # Flush the GUI interpreter internal queue to make sure all user functions are complete. self.gui.interpreter.flush() # relax execution lock. if status.exec_lock.locked(): error_message("relax is currently executing.", "relax execution lock") event.Skip() return # User warning to close windows. self.gui.close_windows() # Synchronise the frame data to the relax data store. self.sync_ds(upload=True) # Assemble all the data needed for the auto-analysis. data, missing, model_mismatch = self.assemble_data() # Missing data. if len(missing): self.missing_data = Missing_data(missing) return # Model mismatch. if len(model_mismatch): # Generate the text. text = '' for model, exp in model_mismatch: text += "The '%s' %s model cannot be used as no %s experiment types have been set up.\n" % (model, exp, exp) # The error message. error_message(text, caption='Model mismatch') return # Display the relax controller, and go to the end of the log window. self.gui.show_controller(None) self.gui.controller.log_panel.on_goto_end(None) # Start the thread. self.thread = Execute_relax_disp(self.gui, data, self.data_index) self.thread.start() # Terminate the event. event.Skip()
def on_page_changing(self, event): """Block page changing if needed. @param event: The wx event. @type event: wx event """ # Execution lock. if status.exec_lock.locked(): # Show an error message. error_message("Cannot change analyses, relax is currently executing.", "relax execution lock") # Veto the event. event.Veto()
def relax_manual(self, event=None): """Display the relax manual. @keyword event: The wx event. @type event: wx event """ # The PDF manual. file = status.install_path + sep+"docs"+sep+"relax.pdf" # Test if it exists. if not access(file, F_OK): error_message("The relax manual '%s' cannot be found. Please compile using the scons program." % file) return # Open the relax PDF manual using the native PDF reader. open_file(file)
def execute(self, event): """Set up, execute, and process the automatic Rx analysis. @param event: The wx event. @type event: wx event """ # Flush the GUI interpreter internal queue to make sure all user functions are complete. self.gui.interpreter.flush() # relax execution lock. if status.exec_lock.locked(): error_message("relax is currently executing.", "relax execution lock") event.Skip() return # User warning to close windows. self.gui.close_windows() # Synchronise the frame data to the relax data store. self.sync_ds(upload=True) # Assemble all the data needed for the auto-analysis. data, missing = self.assemble_data() # Missing data. if len(missing): self.missing_data = Missing_data(missing) return # Display the relax controller, and go to the end of the log window. self.gui.show_controller(None) self.gui.controller.log_panel.on_goto_end(None) # Start the thread. self.thread = Execute_rx(self.gui, data, self.data_index) self.thread.start() # Terminate the event. event.Skip()
def load_peaklist(self, event): """Function to load peak lists to data grid. @param event: The wx event. @type event: wx event """ # The dialog. dialog = RelaxFileDialog(parent=self, message='Select the %s peak list file' % self.label, style=wx.FD_OPEN | wx.FD_MULTIPLE) # Show the dialog and catch if no file has been selected. if status.show_gui and dialog.ShowModal() != wx.ID_OK: # Don't do anything. return # The files. files = dialog.get_file() # Fill values in data grid index = 0 for i in range(self.num_rows): # Add entry if nothing is filled in already if str(self.grid.GetCellValue(i, 0)) == '': # Write peak file self.grid.SetCellValue(i, 0, str(files[index])) # Next file index = index + 1 # Stop if no files left if index == len(files): break # Error message if not all files were loaded if index < (len(files) - 1): error_message('Not all files could be loaded.')
def load_peaklist(self, event): """Function to load peak lists to data grid. @param event: The wx event. @type event: wx event """ # The dialog. dialog = RelaxFileDialog(parent=self, message='Select the %s peak list file'%self.label, style=wx.FD_OPEN|wx.FD_MULTIPLE) # Show the dialog and catch if no file has been selected. if status.show_gui and dialog.ShowModal() != wx.ID_OK: # Don't do anything. return # The files. files = dialog.get_file() # Fill values in data grid index = 0 for i in range(self.num_rows): # Add entry if nothing is filled in already if str(self.grid.GetCellValue(i, 0)) == '': # Write peak file self.grid.SetCellValue(i, 0, str(files[index])) # Next file index = index + 1 # Stop if no files left if index == len(files): break # Error message if not all files were loaded if index < (len(files)-1): error_message('Not all files could be loaded.')
def new_analysis(self, analysis_type=None, analysis_name=None, pipe_name=None, pipe_bundle=None, uf_exec=[], index=None): """Initialise a new analysis. @keyword analysis_type: The type of analysis to initialise. This can be one of 'noe', 'r1', 'r2', 'mf' or 'relax_disp'. @type analysis_type: str @keyword analysis_name: The name of the analysis to initialise. @type analysis_name: str @keyword pipe_name: The name of the original data pipe to create for the analysis. @type pipe_name: str @keyword pipe_bundle: The name of the data pipe bundle to associate with this analysis. @type pipe_bundle: str @keyword uf_exec: The list of user function on_execute methods returned from the new analysis wizard. @type uf_exec: list of methods @keyword index: The index of the analysis in the relax data store (set to None if no data currently exists). @type index: None or int """ # Check the C modules. if analysis_type in ['r1', 'r2'] and not dep_check.C_module_exp_fn: error_message("Relaxation curve fitting is not available. Try compiling the C modules on your platform.") return # Check the C modules. if analysis_type == 'relax_disp' and not dep_check.C_module_exp_fn: error_message("Relaxation curve fitting will not available for this dispersion analysis. Try compiling the C modules on your platform if you have measured full exponential curves.") # Freeze the GUI. wx.Yield() wx.BeginBusyCursor() self.gui.Freeze() # Starting from the initial state. if self.init_state: # A new sizer for the notebook (to replace the current sizer). sizer = wx.BoxSizer(wx.VERTICAL) # Create a notebook and add it to the sizer. self.notebook = wx.Notebook(self.gui, -1, style=wx.NB_TOP) sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 0) # Bind changing events. self.gui.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.on_page_changing) self.gui.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_page_changed) # Delete the previous sizer. old_sizer = self.gui.GetSizer() old_sizer.DeleteWindows() # Add the new sizer to the main window. self.gui.SetSizer(sizer) sizer.Layout() # The analysis classes. classes = { 'noe': Auto_noe, 'r1': Auto_r1, 'r2': Auto_r2, 'mf': Auto_model_free, 'relax_disp': Auto_relax_disp } # Bad analysis type. if analysis_type not in classes: raise RelaxError("The analysis '%s' is unknown." % analysis_type) # Initialise the class. analysis = classes[analysis_type](parent=self.notebook, id=-1, gui=self.gui, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle, uf_exec=uf_exec, data_index=index) # Failure. if not analysis.init_flag: # Reset. if self.init_state: self.set_init_state() # Stop operation. return # Append the class object to the analysis window object. self._analyses.append(analysis) # Add to the notebook. self.notebook.AddPage(self._analyses[-1], analysis_name) # Increment the number of analyses. self._num_analyses += 1 # Switch to the new page. if self._switch_flag: self.switch_page(self._num_analyses-1) # Set the initialisation flag. self.init_state = False # Reset the main window layout. self.gui.Layout() # Thaw the GUI. self.gui.Thaw() if wx.IsBusy(): wx.EndBusyCursor() # Notify the observers of the change. status.observers.gui_analysis.notify()
def new_analysis(self, analysis_type=None, analysis_name=None, pipe_name=None, pipe_bundle=None, uf_exec=[], index=None): """Initialise a new analysis. @keyword analysis_type: The type of analysis to initialise. This can be one of 'noe', 'r1', 'r2', 'mf' or 'relax_disp'. @type analysis_type: str @keyword analysis_name: The name of the analysis to initialise. @type analysis_name: str @keyword pipe_name: The name of the original data pipe to create for the analysis. @type pipe_name: str @keyword pipe_bundle: The name of the data pipe bundle to associate with this analysis. @type pipe_bundle: str @keyword uf_exec: The list of user function on_execute methods returned from the new analysis wizard. @type uf_exec: list of methods @keyword index: The index of the analysis in the relax data store (set to None if no data currently exists). @type index: None or int """ # Check the C modules. if analysis_type in ['r1', 'r2'] and not dep_check.C_module_exp_fn: error_message("Relaxation curve fitting is not available. Try compiling the C modules on your platform.") return # Check the C modules. if analysis_type == 'relax_disp' and not dep_check.C_module_exp_fn: error_message("Relaxation curve fitting will not available for this dispersion analysis. Try compiling the C modules on your platform if you have measured full exponential curves.") # Freeze the GUI. wx.Yield() wx.BeginBusyCursor() self.gui.Freeze() # Starting from the initial state. if self.init_state: # A new sizer for the notebook (to replace the current sizer). sizer = wx.BoxSizer(wx.VERTICAL) # Create a notebook and add it to the sizer. self.notebook = wx.Notebook(self.gui, -1, style=wx.NB_TOP) sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 0) # Bind changing events. self.gui.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.on_page_changing) self.gui.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_page_changed) # Delete the previous sizer. old_sizer = self.gui.GetSizer() old_sizer.DeleteWindows() # Add the new sizer to the main window. self.gui.SetSizer(sizer) sizer.Layout() # The analysis classes. classes = { 'noe': Auto_noe, 'r1': Auto_r1, 'r2': Auto_r2, 'mf': Auto_model_free, 'relax_disp': Auto_relax_disp } # Bad analysis type. if analysis_type not in classes.keys(): raise RelaxError("The analysis '%s' is unknown." % analysis_type) # Initialise the class. analysis = classes[analysis_type](parent=self.notebook, id=-1, gui=self.gui, analysis_name=analysis_name, pipe_name=pipe_name, pipe_bundle=pipe_bundle, uf_exec=uf_exec, data_index=index) # Failure. if not analysis.init_flag: # Reset. if self.init_state: self.set_init_state() # Stop operation. return # Append the class object to the analysis window object. self._analyses.append(analysis) # Add to the notebook. self.notebook.AddPage(self._analyses[-1], analysis_name) # Increment the number of analyses. self._num_analyses += 1 # Switch to the new page. if self._switch_flag: self.switch_page(self._num_analyses-1) # Set the initialisation flag. self.init_state = False # Reset the main window layout. self.gui.Layout() # Thaw the GUI. self.gui.Thaw() if wx.IsBusy(): wx.EndBusyCursor() # Notify the observers of the change. status.observers.gui_analysis.notify()