Index: src/sas/perspectives/fitting/basepage.py
===================================================================
--- src/sas/perspectives/fitting/basepage.py	(revision c1694f88ee64a0dfcedb2f35de163aba684dc2a4)
+++ src/sas/perspectives/fitting/basepage.py	(revision 7cd87c2443f7f4bd500bede68980342c174a9588)
@@ -11,4 +11,5 @@
 import string
 import json
+import logging
 from collections import defaultdict
 from wx.lib.scrolledpanel import ScrolledPanel
@@ -56,5 +57,5 @@
     ## Title to appear on top of the window
     window_caption = "Fit Page "
-    
+
     def __init__(self, parent, color='blue', **kwargs):
         """
@@ -65,5 +66,5 @@
         #Set window's font size
         self.SetWindowVariant(variant=FONT_VARIANT)
-      
+
         self.SetBackgroundColour(color)
         ## parent of the page
@@ -127,5 +128,5 @@
         self.Npts_fit = None
         self.Npts_total = None
-        self.theory_qmin = None 
+        self.theory_qmin = None
         self.theory_qmax = None
         self.theory_qmin_x = None
@@ -136,11 +137,11 @@
         self.sld_axes = None
         self.multi_factor = None
-       
+
         self.disp_cb_dict = {}
-   
+
         #self.state = PageState(parent=parent)
         ## dictionary containing list of models
         self.model_list_box = {}
-       
+
         ## Data member to store the dispersion object created
         self._disp_obj_dict = {}
@@ -170,5 +171,5 @@
         self.disp_list = []
         self.disp_name = ""
-        
+
         ## list of orientation parameters
         self.orientation_params = []
@@ -199,5 +200,5 @@
         ## Create context menu for page
         self.popUpMenu = wx.Menu()
-    
+
         id = wx.NewId()
         self._keep = wx.MenuItem(self.popUpMenu, id, "Add bookmark",
@@ -209,5 +210,5 @@
         wx.EVT_MENU(self, id, self.on_bookmark)
         self.popUpMenu.AppendSeparator()
-    
+
         ## Default locations
         self._default_save_location = os.getcwd()
@@ -215,16 +216,16 @@
         #self.onSave(event=None)
         self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu)
-        
+
         # bind key event
         self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
-        
+
         ## create the basic structure of the panel with empty sizer
         self.define_page_structure()
         ## drawing Initial dispersion parameters sizer
         self.set_dispers_sizer()
-        
+
         ## layout
         self.set_layout()
-    
+
     def set_index_model(self, index):
         """
@@ -232,5 +233,5 @@
         """
         self.index_model = index
-        
+
     def create_default_data(self):
         """
@@ -249,5 +250,5 @@
                 else:
                     self._create_default_1d_data()
-                        
+
             if self.model != None:
                 if not self.data.is_data:
@@ -259,5 +260,5 @@
             self.state.pinhole_smearer = self.pinhole_smearer.GetValue()
             self.state.slit_smearer = self.slit_smearer.GetValue()
-        
+
     def _create_default_1d_data(self):
         """
@@ -265,5 +266,5 @@
         Only when the page is on theory mode.
         :warning: This data is never plotted.
-        
+
         """
         x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x,
@@ -275,5 +276,5 @@
         self.data.id = str(self.uid) + " data"
         self.data.group_id = str(self.uid) + " Model1D"
-         
+
     def _create_log_1d_data(self):
         """
@@ -281,16 +282,16 @@
         Only when the page is on theory mode.
         :warning: This data is never plotted.
-        
+
         """
         if self.qmin_x >= 1.e-10:
             qmin = numpy.log10(self.qmin_x)
         else:
-            qmin = -10.    
-            
+            qmin = -10.
+
         if self.qmax_x <= 1.e10:
             qmax = numpy.log10(self.qmax_x)
         else:
-            qmax = 10. 
-               
+            qmax = 10.
+
         x = numpy.logspace(start=qmin, stop=qmax,
                            num=self.npts_x, endpoint=True, base=10.0)
@@ -301,5 +302,5 @@
         self.data.id = str(self.uid) + " data"
         self.data.group_id = str(self.uid) + " Model1D"
-      
+
     def _create_default_2d_data(self):
         """
@@ -359,5 +360,5 @@
         #xstep = x_size / len(x_bins - 1)
         #ystep = y_size / len(y_bins - 1)
-  
+
         self.data.source = Source()
         self.data.data = numpy.ones(len(mask))
@@ -382,5 +383,5 @@
             wx.PostEvent(self._manager.parent, PanelOnFocusEvent(panel=self))
             self.on_tap_focus()
-               
+
     def on_tap_focus(self):
         """
@@ -398,5 +399,5 @@
                     self._manager.menu1.FindItemById(self._manager.id_batchfit)
             batch_menu.Enable(self.batch_on and flag)
-    
+
     class ModelTextCtrl(wx.TextCtrl):
         """
@@ -404,10 +405,10 @@
         Binds the appropriate events for user interactions.
         Default callback methods can be overwritten on initialization
-        
+
         :param kill_focus_callback: callback method for EVT_KILL_FOCUS event
         :param set_focus_callback:  callback method for EVT_SET_FOCUS event
         :param mouse_up_callback:   callback method for EVT_LEFT_UP event
         :param text_enter_callback: callback method for EVT_TEXT_ENTER event
-        
+
         """
         ## Set to True when the mouse is clicked while whole string is selected
@@ -415,6 +416,6 @@
         ## Call back for EVT_SET_FOCUS events
         _on_set_focus_callback = None
-        
-        def __init__(self, parent, id=-1,
+
+        def __init__(self, parent, id= -1,
                      value=wx.EmptyString,
                      pos=wx.DefaultPosition,
@@ -427,8 +428,8 @@
                      mouse_up_callback=None,
                      text_enter_callback=None):
-             
+
             wx.TextCtrl.__init__(self, parent, id, value, pos,
                                   size, style, validator, name)
-            
+
             # Bind appropriate events
             self._on_set_focus_callback = parent.onSetFocus \
@@ -442,23 +443,23 @@
                 self.Bind(wx.EVT_LEFT_UP, self._highlight_text \
                           if mouse_up_callback is None else mouse_up_callback)
-            
+
         def _on_set_focus(self, event):
             """
             Catch when the text control is set in focus to highlight the whole
             text if necessary
-            
+
             :param event: mouse event
-            
+
             """
             event.Skip()
             self.full_selection = True
             return self._on_set_focus_callback(event)
-        
+
         def _highlight_text(self, event):
             """
             Highlight text of a TextCtrl only of no text has be selected
-            
+
             :param event: mouse event
-            
+
             """
             # Make sure the mouse event is available to other listeners
@@ -474,13 +475,13 @@
                     if start == end:
                         control.SetSelection(-1, -1)
-                        
+
         def _silent_kill_focus(self, event):
             """
             Save the state of the page
             """
-            
+
             event.Skip()
             #pass
-    
+
     def set_page_info(self, page_info):
         """
@@ -511,5 +512,5 @@
         ## Data member to store the dispersion object created
         self.populate_box(model_dict=self.model_list_box)
-        
+
     def onContextMenu(self, event):
         """
@@ -518,10 +519,10 @@
         # Skipping the save state functionality for release 0.9.0
         #return
-    
+
         pos = event.GetPosition()
         pos = self.ScreenToClient(pos)
-       
+
         self.PopupMenu(self.popUpMenu, pos)
-      
+
     def onUndo(self, event):
         """
@@ -530,5 +531,5 @@
         event = PreviousStateEvent(page=self)
         wx.PostEvent(self.parent, event)
-        
+
     def onRedo(self, event):
         """
@@ -537,5 +538,5 @@
         event = NextStateEvent(page=self)
         wx.PostEvent(self.parent, event)
-    
+
     def define_page_structure(self):
         """
@@ -550,5 +551,5 @@
         self.sizer5 = wx.BoxSizer(wx.VERTICAL)
         self.sizer6 = wx.BoxSizer(wx.VERTICAL)
-        
+
         self.sizer0.SetMinSize((PANEL_WIDTH, -1))
         self.sizer1.SetMinSize((PANEL_WIDTH, -1))
@@ -558,5 +559,5 @@
         self.sizer5.SetMinSize((PANEL_WIDTH, -1))
         self.sizer6.SetMinSize((PANEL_WIDTH, -1))
-        
+
         self.vbox.Add(self.sizer0)
         self.vbox.Add(self.sizer1)
@@ -566,5 +567,5 @@
         self.vbox.Add(self.sizer5)
         self.vbox.Add(self.sizer6)
-        
+
     def set_layout(self):
         """
@@ -575,20 +576,20 @@
         self.SetSizer(self.vbox)
         self.Centre()
- 
+
     def set_owner(self, owner):
         """
         set owner of fitpage
-        
+
         :param owner: the class responsible of plotting
-        
+
         """
         self.event_owner = owner
         self.state.event_owner = owner
-        
+
     def get_state(self):
         """
         """
         return self.state
-    
+
     def get_data(self):
         """
@@ -596,5 +597,5 @@
         """
         return self.data
-    
+
     def get_data_list(self):
         """
@@ -602,26 +603,26 @@
         """
         return self.data_list
-    
+
     def set_manager(self, manager):
         """
         set panel manager
-        
+
         :param manager: instance of plugin fitting
-        
+
         """
         self._manager = manager
         self.state.manager = manager
-        
+
     def populate_box(self, model_dict):
         """
         Store list of model
-        
+
         :param model_dict: dictionary containing list of models
-        
+
         """
         self.model_list_box = model_dict
         self.state.model_list_box = self.model_list_box
         self.initialize_combox()
-        
+
     def set_model_dictionary(self, model_dict):
         """
@@ -635,5 +636,5 @@
         """
         put default value in the combobox
-        """  
+        """
         ## fill combox box
         if self.model_list_box is None:
@@ -666,5 +667,5 @@
             self.structurebox.Disable()
             self.text2.Disable()
-             
+
             if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]:
                 self.structurebox.Show()
@@ -673,5 +674,5 @@
                 self.text2.Enable()
 
-                
+
     def set_dispers_sizer(self):
         """
@@ -698,5 +699,5 @@
                         self.on_pd_help_clicked, id=self.disp_help_bt.GetId())
         self.disp_help_bt.SetToolTipString("Helps for Polydispersion.")
-        
+
         self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
                      id=self.disable_disp.GetId())
@@ -714,5 +715,5 @@
         sizer_dispersion.Add((25, 20))
         sizer_dispersion.Add(self.disp_help_bt)
-        
+
         ## fill a sizer for dispersion
         boxsizer1.Add(sizer_dispersion, 0,
@@ -727,5 +728,5 @@
         self.sizer4.Layout()
         self.Layout()
-     
+
         self.Refresh()
         ## saving the state of enable dispersity button
@@ -733,5 +734,5 @@
         self.state.disable_disp = self.disable_disp.GetValue()
         self.SetupScrolling()
-    
+
     def onResetModel(self, event):
         """
@@ -751,9 +752,9 @@
             previous_state = self.saved_states[name]
             ## reset state of checkbox,textcrtl  and  regular parameters value
-            
+
             self.reset_page(previous_state)
         self.state.m_name = self.m_name
         self.Show(True)
-               
+
     def on_preview(self, event):
         """
@@ -764,5 +765,5 @@
         # get the report dialog
         self.state.report(images, canvases)
-        
+
     def on_save(self, event):
         """
@@ -782,5 +783,5 @@
             path = dlg.GetPath()
             self._default_save_location = os.path.dirname(path)
-            self._manager.parent._default_save_location =\
+            self._manager.parent._default_save_location = \
                                  self._default_save_location
         else:
@@ -793,5 +794,5 @@
         self._manager.save_fit_state(filepath=fName, fitstate=new_state)
         return new_state
-    
+
     def on_copy(self, event):
         """
@@ -810,5 +811,5 @@
             wx.CallAfter(self.get_copy)
 
-        
+
     def on_paste(self, event):
         """
@@ -822,9 +823,9 @@
         # messages depending on the flag
         #self._copy_info(True)
-        
+
     def _copy_info(self, flag):
         """
         Send event dpemding on flag
-        
+
         : Param flag: flag that distinguish event
         """
@@ -843,5 +844,5 @@
         wx.PostEvent(self._manager.parent,
                     StatusEvent(status=msg, info=infor))
-        
+
     def _get_time_stamp(self):
         """
@@ -853,5 +854,5 @@
         current_date = str(month) + "/" + str(day) + "/" + str(year)
         return current_time, current_date
-      
+
     def on_bookmark(self, event):
         """
@@ -872,5 +873,5 @@
         name += "bookmarked at %s on %s" % (current_time, current_date)
         self.saved_states[name] = new_state
-        
+
         ## Add item in the context menu
         msg = "Model saved at %s on %s" % (current_time, current_date)
@@ -878,5 +879,5 @@
         msg += " Saved! right click on this page to retrieve this model"
         wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
-        
+
         id = wx.NewId()
         self.popUpMenu.Append(id, name, str(msg))
@@ -886,5 +887,5 @@
                                          hint=str(msg),
                                          handler=self._back_to_bookmark))
-    
+
     def _back_to_bookmark(self, event):
         """
@@ -894,5 +895,5 @@
         self.onResetModel(event)
         self._draw_model()
-                
+
     def onSetFocus(self, evt):
         """
@@ -901,16 +902,16 @@
         """
         return
-    
+
     def read_file(self, path):
         """
         Read two columns file
-        
+
         :param path: the path to the file to read
-        
+
         """
         try:
             if path == None:
                 wx.PostEvent(self._manager.parent,
-                            StatusEvent(status= \
+                            StatusEvent(status=\
                             " Selected Distribution was not loaded: %s" % path))
                 return None, None
@@ -930,5 +931,5 @@
                 except:
                     # Skip non-data lines
-                    pass
+                    logging.error(sys.exc_value)
             return numpy.array(angles), numpy.array(weights)
         except:
@@ -940,5 +941,5 @@
         """
         return self.state.clone()
-    
+
     def save_current_state(self):
         """
@@ -951,5 +952,5 @@
             self.state.disp_list = copy.deepcopy(self.disp_list)
             self.state.model = self.model.clone()
-            
+
             #model combobox: complex code because of mac's silent error
             if self.structurebox != None:
@@ -970,5 +971,5 @@
                 self.state.categorycombobox = self.categorybox.\
                 GetString(cb_select)
-        
+
         self.state.enable2D = copy.deepcopy(self.enable2D)
         self.state.values = copy.deepcopy(self.values)
@@ -987,5 +988,5 @@
             self.state.enable_disp = self.enable_disp.GetValue()
             self.state.disable_disp = self.disable_disp.GetValue()
-            
+
         self.state.smearer = copy.deepcopy(self.current_smearer)
         if hasattr(self, "enable_smearer"):
@@ -1002,5 +1003,5 @@
         self.state.dxw = copy.deepcopy(self.dxw)
         self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue())
-                  
+
         if len(self._disp_obj_dict) > 0:
             for k, v in self._disp_obj_dict.iteritems():
@@ -1011,5 +1012,5 @@
         ## save plotting range
         self._save_plotting_range()
-        
+
         self.state.orientation_params = []
         self.state.orientation_params_disp = []
@@ -1026,5 +1027,5 @@
         self._copy_parameters_state(self.orientation_params_disp,
                                      self.state.orientation_params_disp)
-        
+
         self._copy_parameters_state(self.parameters, self.state.parameters)
         self._copy_parameters_state(self.fittable_param,
@@ -1033,5 +1034,5 @@
         #save chisqr
         self.state.tcChi = self.tcChi.GetValue()
-        
+
     def save_current_state_fit(self):
         """
@@ -1045,5 +1046,5 @@
         if hasattr(self, "engine_type"):
             self.state.engine_type = copy.deepcopy(self.engine_type)
-            
+
         self.state.enable2D = copy.deepcopy(self.enable2D)
         self.state.values = copy.deepcopy(self.values)
@@ -1051,9 +1052,9 @@
         ## save data
         self.state.data = copy.deepcopy(self.data)
-        
+
         if hasattr(self, "enable_disp"):
             self.state.enable_disp = self.enable_disp.GetValue()
             self.state.disable_disp = self.disable_disp.GetValue()
-            
+
         self.state.smearer = copy.deepcopy(self.current_smearer)
         if hasattr(self, "enable_smearer"):
@@ -1062,5 +1063,5 @@
             self.state.disable_smearer = \
                                 copy.deepcopy(self.disable_smearer.GetValue())
-            
+
         self.state.pinhole_smearer = \
                                 copy.deepcopy(self.pinhole_smearer.GetValue())
@@ -1085,11 +1086,11 @@
                 for k, v in self._disp_obj_dict.iteritems():
                     self.state._disp_obj_dict[k] = v
-                        
+
             self.state.values = copy.deepcopy(self.values)
             self.state.weights = copy.deepcopy(self.weights)
-           
+
         ## save plotting range
         self._save_plotting_range()
-        
+
         ## save checkbutton state and txtcrtl values
         self._copy_parameters_state(self.orientation_params,
@@ -1101,5 +1102,5 @@
                                              self.state.fittable_param)
         self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
-    
+
     def check_invalid_panel(self):
         """
@@ -1112,5 +1113,5 @@
             wx.MessageBox(msg, 'Info')
             return  True
-        
+
     def set_model_state(self, state):
         """
@@ -1119,5 +1120,5 @@
         self.disp_cb_dict = state.disp_cb_dict
         self.disp_list = state.disp_list
-      
+
         ## set the state of the radio box
         #self.shape_rbutton.SetValue(state.shape_rbutton)
@@ -1125,5 +1126,5 @@
         #self.struct_rbutton.SetValue(state.struct_rbutton)
         #self.plugin_rbutton.SetValue(state.plugin_rbutton)
-        
+
         ## fill model combobox
         self._show_combox_helper()
@@ -1139,5 +1140,5 @@
                     category_pos = int(ind_cat)
                     break
-            
+
         self.categorybox.Select(category_pos)
         try:
@@ -1151,7 +1152,7 @@
                     formfactor_pos = int(ind_form)
                     break
-            
+
         self.formfactorbox.Select(formfactor_pos)
-        
+
         try:
             # to support older version
@@ -1164,10 +1165,10 @@
                     structfactor_pos = int(ind_struct)
                     break
-                
+
         self.structurebox.SetSelection(structfactor_pos)
-        
+
         if state.multi_factor != None:
             self.multifactorbox.SetSelection(state.multi_factor)
-            
+
         ## reset state of checkbox,textcrtl  and  regular parameters value
         self._reset_parameters_state(self.orientation_params_disp,
@@ -1181,5 +1182,5 @@
         self.enable_disp.SetValue(state.enable_disp)
         self.disable_disp.SetValue(state.disable_disp)
-        
+
         if hasattr(self, "disp_box") and self.disp_box != None:
             self.disp_box.SetSelection(state.disp_box)
@@ -1189,9 +1190,9 @@
 
             self._set_dipers_Param(event=None)
-       
+
             if name == "ArrayDispersion":
-                
+
                 for item in self.disp_cb_dict.keys():
-                    
+
                     if hasattr(self.disp_cb_dict[item], "SetValue"):
                         self.disp_cb_dict[item].SetValue(\
@@ -1209,13 +1210,13 @@
                             else:
                                 self._reset_dispersity()
-                        
+
                         self._disp_obj_dict[item] = disp_model
                         # Set the new model as the dispersion object
                         #for the selected parameter
                         self.model.set_dispersion(item, disp_model)
-                    
+
                         self.model._persistency_dict[item] = \
                                                 [state.values, state.weights]
-                    
+
             else:
                 keys = self.model.getParamList()
@@ -1235,10 +1236,10 @@
         self.pinhole_smearer.SetValue(state.pinhole_smearer)
         self.slit_smearer.SetValue(state.slit_smearer)
-        
+
         self.dI_noweight.SetValue(state.dI_noweight)
         self.dI_didata.SetValue(state.dI_didata)
         self.dI_sqrdata.SetValue(state.dI_sqrdata)
         self.dI_idata.SetValue(state.dI_idata)
-        
+
         ## we have two more options for smearing
         if self.pinhole_smearer.GetValue():
@@ -1246,9 +1247,9 @@
         elif self.slit_smearer.GetValue():
             self.onSlitSmear(event=None)
-       
+
         ## reset state of checkbox,textcrtl  and dispersity parameters value
         self._reset_parameters_state(self.fittable_param, state.fittable_param)
         self._reset_parameters_state(self.fixed_param, state.fixed_param)
-        
+
         ## draw the model with previous parameters value
         self._onparamEnter_helper()
@@ -1258,11 +1259,11 @@
         self._lay_out()
         self.Refresh()
-        
+
     def reset_page_helper(self, state):
         """
         Use page_state and change the state of existing page
-        
+
         :precondition: the page is already drawn or created
-        
+
         :postcondition: the state of the underlying data change as well as the
             state of the graphic interface
@@ -1290,5 +1291,5 @@
         else:
             self.set_data(data)
-            
+
         self.enable2D = state.enable2D
         try:
@@ -1301,5 +1302,5 @@
         self.disp_cb_dict = state.disp_cb_dict
         self.disp_list = state.disp_list
-      
+
         ## set the state of the radio box
         #self.shape_rbutton.SetValue(state.shape_rbutton)
@@ -1307,5 +1308,5 @@
         #self.struct_rbutton.SetValue(state.struct_rbutton)
         #self.plugin_rbutton.SetValue(state.plugin_rbutton)
-        
+
         ## fill model combobox
         self._show_combox_helper()
@@ -1321,5 +1322,5 @@
                     category_pos = int(ind_cat)
                     break
-            
+
         self.categorybox.Select(category_pos)
         self._show_combox(None)
@@ -1334,7 +1335,7 @@
                     formfactor_pos = int(ind_form)
                     break
-            
+
         self.formfactorbox.Select(formfactor_pos)
-        
+
         try:
             # to support older version
@@ -1347,5 +1348,5 @@
                     structfactor_pos = int(ind_struct)
                     break
-            
+
         self.structurebox.SetSelection(structfactor_pos)
 
@@ -1357,5 +1358,5 @@
         #draw the pnael according to the new model parameter
         self._on_select_model(event=None)
-            
+
         # take care of 2D button
         if data == None and self.model_view.IsEnabled():
@@ -1365,10 +1366,10 @@
                 self.model_view.SetLabel("1D Mode")
         # else:
-                
+
         if self._manager != None and self.engine_type != None:
             self._manager._on_change_engine(engine=self.engine_type)
         ## set the select all check box to the a given state
         self.cb1.SetValue(state.cb1)
-     
+
         ## reset state of checkbox,textcrtl  and  regular parameters value
         self._reset_parameters_state(self.orientation_params_disp,
@@ -1409,5 +1410,5 @@
             self.dI_sqrdata.SetValue(False)
             self.dI_idata.SetValue(False)
- 
+
         ## we have two more options for smearing
         if self.pinhole_smearer.GetValue():
@@ -1425,13 +1426,13 @@
                 self.smear_slit_height.SetValue(str(self.dxl))
             if self.dxw != None:
-                self.smear_slit_width.SetValue(str(self.dxw))  
+                self.smear_slit_width.SetValue(str(self.dxw))
             else:
-                self.smear_slit_width.SetValue('')  
+                self.smear_slit_width.SetValue('')
             self.onSlitSmear(event=None)
-        
+
         ## reset state of checkbox,textcrtl  and dispersity parameters value
         self._reset_parameters_state(self.fittable_param, state.fittable_param)
         self._reset_parameters_state(self.fixed_param, state.fixed_param)
-        
+
         ## draw the model with previous parameters value
         self._onparamEnter_helper()
@@ -1440,9 +1441,9 @@
         ## reset context menu items
         self._reset_context_menu()
-        
+
         ## set the value of the current state to the state given as parameter
         self.state = state.clone()
         self.state.m_name = self.m_name
-    
+
     def _reset_page_disp_helper(self, state):
         """
@@ -1459,5 +1460,5 @@
         self.values = copy.deepcopy(state.values)
         self.weights = copy.deepcopy(state.weights)
-        
+
         for key, disp in state._disp_obj_dict.iteritems():
             # From saved file, disp_model can not be sent in model obj.
@@ -1479,5 +1480,5 @@
                                  [state.values, state.weights]
             except:
-                pass
+                logging.error(sys.exc_value)
             selection = self._find_polyfunc_selection(disp_model)
             for list in self.fittable_param:
@@ -1496,5 +1497,5 @@
                             list[6].Disable()
                         except:
-                            pass
+                            logging.error(sys.exc_value)
             # For array, disable all fixed params
             if selection == 1:
@@ -1505,13 +1506,13 @@
                             item[2].Disable()
                         except:
-                            pass
-    
+                            logging.error(sys.exc_value)
+
         # Make sure the check box updated when all checked
         if self.cb1.GetValue():
             self.select_all_param(None)
-      
+
     def _selectDlg(self):
         """
-        open a dialog file to selected the customized dispersity 
+        open a dialog file to selected the customized dispersity
         """
         if self.parent != None:
@@ -1538,5 +1539,5 @@
             self.popUpMenu.Append(id, name, msg)
             wx.EVT_MENU(self, id, self.onResetModel)
-    
+
     def _reset_plotting_range(self, state):
         """
@@ -1557,9 +1558,9 @@
         self.state.formfactorcombobox = self.formfactorbox.GetLabel()
         self.state.categorycombobox = self.categorybox.GetLabel()
-       
+
         ## post state to fit panel
         event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
-        
+
     def _save_plotting_range(self):
         """
@@ -1569,5 +1570,5 @@
         self.state.qmax = self.qmax_x
         self.state.npts = self.npts_x
-            
+
     def _onparamEnter_helper(self):
         """
@@ -1592,5 +1593,5 @@
                                                       is_modified)
             except:
-                pass
+                logging.error(sys.exc_value)
 
             # Here we should check whether the boundaries have been modified.
@@ -1606,12 +1607,12 @@
                     self.qmax_x = tempmax
                     is_modified = True
-            
+
                 if is_2Ddata:
                     # set mask
                     is_modified = self._validate_Npts()
-                    
+
             else:
                 self.fitrange = False
-                
+
             if not self.data.is_data:
                 is_modified = True
@@ -1633,5 +1634,5 @@
                 self.Refresh()
         return is_modified
-    
+
     def _update_paramv_on_fit(self):
         """
@@ -1730,12 +1731,12 @@
             msg += " model or Fitting range is not valid!!!  "
             wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
-        
+
         try:
             self.save_current_state()
         except:
-            pass
-   
+            logging.error(sys.exc_value)
+
         return flag
-               
+
     def _is_modified(self, is_modified):
         """
@@ -1743,5 +1744,5 @@
         """
         return is_modified
-                       
+
     def _reset_parameters_state(self, listtorestore, statelist):
         """
@@ -1782,10 +1783,10 @@
                 item_page[5].Show(item_page_info[5][0])
                 item_page[5].SetValue(item_page_info[5][1])
-                
+
             if item_page[6] != None:
                 ## show of hide the text crtl for fitting error
                 item_page[6].Show(item_page_info[6][0])
                 item_page[6].SetValue(item_page_info[6][1])
-                    
+
     def _reset_strparam_state(self, listtorestore, statelist):
         """
@@ -1796,10 +1797,10 @@
 
         listtorestore = copy.deepcopy(statelist)
-        
+
         for j in range(len(listtorestore)):
             item_page = listtorestore[j]
             item_page_info = statelist[j]
             ##change the state of the check box for simple parameters
-            
+
             if item_page[0] != None:
                 item_page[0].SetValue(format_number(item_page_info[0], True))
@@ -1813,18 +1814,18 @@
                 item_page[2].SetValue(selection)
                 self.model.setParam(param_name, selection)
-                                      
+
     def _copy_parameters_state(self, listtocopy, statelist):
         """
         copy the state of button
-        
+
         :param listtocopy: the list of check button to copy
         :param statelist: list of state object to store the current state
-        
+
         """
         if len(listtocopy) == 0:
             return
-       
+
         for item in listtocopy:
-  
+
             checkbox_state = None
             if item[0] != None:
@@ -1842,5 +1843,5 @@
                 error_value = item[4].GetValue()
                 error_state = item[4].IsShown()
-                
+
             min_value = None
             min_state = None
@@ -1848,5 +1849,5 @@
                 min_value = item[5].GetValue()
                 min_state = item[5].IsShown()
-                
+
             max_value = None
             max_state = None
@@ -1857,11 +1858,11 @@
             if item[7] != None:
                 unit = item[7].GetLabel()
-               
+
             statelist.append([checkbox_state, parameter_name, parameter_value,
                               static_text, [error_state, error_value],
                               [min_state, min_value],
                               [max_state, max_value], unit])
-           
-                
+
+
     def _draw_model(self, update_chisqr=True, source='model'):
         """
@@ -1869,9 +1870,9 @@
         The method will use the data member from the model page
         to build a call to the fitting perspective manager.
-        
+
         :param chisqr: update chisqr value [bool]
         """
         wx.CallAfter(self._draw_model_after, update_chisqr, source)
-        
+
     def _draw_model_after(self, update_chisqr=True, source='model'):
         """
@@ -1879,5 +1880,5 @@
         The method will use the data member from the model page
         to build a call to the fitting perspective manager.
-        
+
         :param chisqr: update chisqr value [bool]
         """
@@ -1907,5 +1908,5 @@
                                     source='model',
                                     weight=weight)
-       
+
     def _on_show_sld(self, event=None):
         """
@@ -1922,7 +1923,7 @@
         sld_data.name = 'SLD'
         sld_data.axes = self.sld_axes
-        self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id=-1)
+        self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id= -1)
         self.panel.ShowModal()
-        
+
     def _set_multfactor_combobox(self, multiplicity=10):
         """
@@ -1934,5 +1935,5 @@
             self.multifactorbox.Append(str(idx), int(idx))
         self._hide_multfactor_combobox()
-        
+
     def _show_multfactor_combobox(self):
         """
@@ -1944,5 +1945,5 @@
         if not self.multifactorbox.IsShown():
             self.multifactorbox.Show(True)
-             
+
     def _hide_multfactor_combobox(self):
         """
@@ -1954,5 +1955,5 @@
         if self.multifactorbox.IsShown():
             self.multifactorbox.Hide()
-    
+
     def formfactor_combo_init(self):
         """
@@ -1960,5 +1961,5 @@
         """
         self._show_combox(None)
-                
+
     def _show_combox_helper(self):
         """
@@ -1993,8 +1994,8 @@
                          StatusEvent(status=msg, info="error"))
         self._populate_box(self.formfactorbox, m_list)
-    
-    def _on_modify_cat(self, event=None):  
-        self._manager.parent.on_category_panel(event)  
-        
+
+    def _on_modify_cat(self, event=None):
+        self._manager.parent.on_category_panel(event)
+
     def _show_combox(self, event=None):
         """
@@ -2010,9 +2011,9 @@
         self.Layout()
         self.Refresh()
-  
+
     def _populate_box(self, combobox, list):
         """
         fill combox box with dict item
-        
+
         :param list: contains item to fill the combox
             item must model class
@@ -2026,5 +2027,5 @@
                     name = model.name
                 mlist.append((name, models))
-                
+
         # Sort the models
         mlist_sorted = sorted(mlist)
@@ -2032,9 +2033,9 @@
             combobox.Append(item[0], item[1])
         return 0
-    
+
     def _onQrangeEnter(self, event):
         """
         Check validity of value enter in the Q range field
-        
+
         """
         tcrtl = event.GetEventObject()
@@ -2088,10 +2089,10 @@
             self.create_default_data()
         self._draw_model()
-                   
+
     def _theory_qrange_enter(self, event):
         """
         Check validity of value enter in the Q range field
         """
-        
+
         tcrtl = event.GetEventObject()
         #Clear msg if previously shown.
@@ -2144,5 +2145,5 @@
         self.create_default_data()
         self._draw_model()
-                   
+
     def _on_select_model_helper(self):
         """
@@ -2170,5 +2171,5 @@
             self.structurebox.Enable()
             self.text2.Enable()
-            
+
         if form_factor != None:
             # set multifactor for Mutifunctional models
@@ -2187,5 +2188,5 @@
                     # default value
                     m_id = 1
-                    
+
                 self.multi_factor = self.multifactorbox.GetClientData(m_id)
                 if self.multi_factor == None:
@@ -2215,8 +2216,8 @@
             self.show_sld_button.Hide()
             self.multi_factor = None
-              
+
         s_id = self.structurebox.GetCurrentSelection()
         struct_factor = self.structurebox.GetClientData(s_id)
-        
+
         if  struct_factor != None:
             from sas.models.MultiplicationModel import MultiplicationModel
@@ -2233,7 +2234,7 @@
         # check if model has magnetic parameters
         if len(self.model.magnetic_params) > 0:
-            self._has_magnetic = True 
+            self._has_magnetic = True
         else:
-            self._has_magnetic = False  
+            self._has_magnetic = False
         ## post state to fit panel
         self.state.parameters = []
@@ -2245,15 +2246,15 @@
         self.on_set_focus(None)
         self.Layout()
-        
+
     def _validate_qrange(self, qmin_ctrl, qmax_ctrl):
         """
         Verify that the Q range controls have valid values
         and that Qmin < Qmax.
-        
+
         :param qmin_ctrl: text control for Qmin
         :param qmax_ctrl: text control for Qmax
-        
+
         :return: True is the Q range is value, False otherwise
-        
+
         """
         qmin_validity = check_float(qmin_ctrl)
@@ -2279,5 +2280,5 @@
                 return False
         return True
-    
+
     def _validate_Npts(self):
         """
@@ -2314,5 +2315,5 @@
                 self.Npts_fit.SetValue(str(len(index_data[index_data == True])))
                 self.fitrange = True
-            
+
         return flag
 
@@ -2349,7 +2350,7 @@
                 self.Npts_fit.SetValue(str(len(index_data[index_data == True])))
                 self.fitrange = True
-            
+
         return flag
-    
+
     def _check_value_enter(self, list, modified):
         """
@@ -2373,5 +2374,5 @@
             #try:
             name = str(item[1])
-            
+
             if string.find(name, ".npts") == -1 and \
                                         string.find(name, ".nsigmas") == -1:
@@ -2379,5 +2380,5 @@
                 param_min = None
                 param_max = None
-               
+
                 ## check minimun value
                 if item[5] != None and item[5] != "":
@@ -2388,8 +2389,8 @@
                                 if numpy.isfinite(param_min):
                                     item[2].SetValue(format_number(param_min))
-                            
+
                             item[5].SetBackgroundColour(wx.WHITE)
                             item[2].SetBackgroundColour(wx.WHITE)
-                                           
+
                         except:
                             msg = "Wrong fit parameter range entered"
@@ -2406,5 +2407,5 @@
                                 if numpy.isfinite(param_max):
                                     item[2].SetValue(format_number(param_max))
-                            
+
                             item[6].SetBackgroundColour(wx.WHITE)
                             item[2].SetBackgroundColour(wx.WHITE)
@@ -2415,5 +2416,5 @@
                             raise ValueError, msg
                         is_modified = True
-                
+
                 if param_min != None and param_max != None:
                     if not self._validate_qrange(item[5], item[6]):
@@ -2422,5 +2423,5 @@
                         wx.PostEvent(self._manager.parent,
                                      StatusEvent(status=msg))
-                
+
                 if name in self.model.details.keys():
                     self.model.details[name][1:3] = param_min, param_max
@@ -2443,7 +2444,7 @@
                 msg = "Wrong Fit parameter value entered "
                 wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
-                
+
         return is_modified
-        
+
     def _set_dipers_Param(self, event):
         """
@@ -2464,5 +2465,5 @@
 
         self._reset_dispersity()
-    
+
         if self.model == None:
             self.model_disp.Hide()
@@ -2472,7 +2473,7 @@
         if self.enable_disp.GetValue():
             ## layout for model containing no dispersity parameters
-            
+
             self.disp_list = self.model.getDispParamList()
-             
+
             if len(self.disp_list) == 0 and len(self.disp_cb_dict) == 0:
                 self._layout_sizer_noDipers()
@@ -2482,5 +2483,5 @@
         else:
             self.sizer4_4.Clear(True)
-            
+
         ## post state to fit panel
         self.save_current_state()
@@ -2494,5 +2495,5 @@
         self.Layout()
         self.Refresh()
-          
+
     def _layout_sizer_noDipers(self):
         """
@@ -2504,5 +2505,5 @@
         self.fixed_param = []
         self.orientation_params_disp = []
-        
+
         self.sizer4_4.Clear(True)
         text = "No polydispersity available for this model"
@@ -2512,5 +2513,5 @@
         self.sizer4_4.Layout()
         self.sizer4.Layout()
-    
+
     def _reset_dispersity(self):
         """
@@ -2525,5 +2526,5 @@
                 if item in self.param_toFit:
                     self.param_toFit.remove(item)
-         
+
         self.fittable_param = []
         self.fixed_param = []
@@ -2531,5 +2532,5 @@
         self.values = {}
         self.weights = {}
-      
+
         from sas.models.dispersion_models import GaussianDispersion
         if len(self.disp_cb_dict) == 0:
@@ -2543,5 +2544,5 @@
                 # Go back to Gaussian model (with 0 pts)
                 disp_model = GaussianDispersion()
-               
+
                 self._disp_obj_dict[p] = disp_model
                 # Set the new model as the dispersion object
@@ -2550,6 +2551,5 @@
                     self.model.set_dispersion(p, disp_model)
                 except:
-
-                    pass
+                    logging.error(sys.exc_value)
 
         ## save state into
@@ -2557,5 +2557,5 @@
         self.Layout()
         self.Refresh()
-                  
+
     def _on_select_Disp(self, event):
         """
@@ -2570,13 +2570,13 @@
         event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
-        
+
         self.sizer4_4.Layout()
         self.sizer4.Layout()
         self.SetupScrolling()
-    
+
     def _on_disp_func(self, event=None):
         """
         Select a distribution function for the polydispersion
-        
+
         :Param event: ComboBox event
         """
@@ -2594,5 +2594,5 @@
             disp_name = disp_box.GetValue()
             dispersity = disp_box.GetClientData(selection)
-    
+
             #disp_model =  GaussianDispersion()
             disp_model = dispersity()
@@ -2612,5 +2612,5 @@
                 self.model.set_dispersion(param_name, disp_model)
                 self.state._disp_obj_dict[name1] = disp_model
- 
+
                 value1 = str(format_number(self.model.getParam(name1), True))
                 value2 = str(format_number(self.model.getParam(name2)))
@@ -2640,5 +2640,5 @@
             for item in self.fixed_param:
                 if item[1] == name2:
-                    item[2].SetValue(value2) 
+                    item[2].SetValue(value2)
                     # Disable Npts for array
                     if disp_name.lower() == "array":
@@ -2653,5 +2653,5 @@
                     else:
                         item[2].Enable()
-                
+
             # Make sure the check box updated when all checked
             if self.cb1.GetValue():
@@ -2674,9 +2674,9 @@
             wx.PostEvent(self._manager.parent,
                          StatusEvent(status=msg, info="error"))
-        
+
     def _set_array_disp(self, name=None, disp=None):
         """
         Set array dispersion
-        
+
         :param name: name of the parameter for the dispersion to be set
         :param disp: the polydisperion object
@@ -2695,10 +2695,10 @@
         self._default_save_location = os.path.dirname(path)
         if self._manager != None:
-            self._manager.parent._default_save_location =\
+            self._manager.parent._default_save_location = \
                              self._default_save_location
 
         basename = os.path.basename(path)
         values, weights = self.read_file(path)
-        
+
         # If any of the two arrays is empty, notify the user that we won't
         # proceed
@@ -2713,10 +2713,10 @@
                                     values=values, weights=weights)
         return basename
-    
+
     def _set_array_disp_model(self, name=None, disp=None,
                               values=[], weights=[]):
         """
         Set array dispersion model
-        
+
         :param name: name of the parameter for the dispersion to be set
         :param disp: the polydisperion object
@@ -2747,9 +2747,9 @@
         self.state.model._persistency_dict[name.split('.')[0]] = \
                                         [values, weights]
-                                        
+
     def _del_array_values(self, name=None):
         """
         Reset array dispersion
-        
+
         :param name: name of the parameter for the dispersion to be set
         """
@@ -2764,10 +2764,10 @@
             del self.state.model._persistency_dict[name.split('.')[0]]
         except:
-            pass
-                                            
+            logging.error(sys.exc_value)
+
     def _lay_out(self):
         """
         returns self.Layout
-        
+
         :Note: Mac seems to like this better when self.
             Layout is called after fitting.
@@ -2776,5 +2776,5 @@
         self.Layout()
         return
-    
+
     def _sleep4sec(self):
         """
@@ -2785,9 +2785,9 @@
         if ON_MAC == True:
             time.sleep(1)
-            
+
     def _find_polyfunc_selection(self, disp_func=None):
         """
         FInd Comboox selection from disp_func
-        
+
         :param disp_function: dispersion distr. function
         """
@@ -2803,5 +2803,5 @@
         except:
             return 3
-                            
+
     def on_reset_clicked(self, event):
         """
@@ -2815,5 +2815,5 @@
             flag = False
             return
-            
+
         elif self.data.__class__.__name__ == "Data2D":
             data_min = 0
@@ -2821,5 +2821,5 @@
             y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax))
             self.qmin_x = data_min
-            self.qmax_x = math.sqrt(x*x + y*y)
+            self.qmax_x = math.sqrt(x * x + y * y)
             #self.data.mask = numpy.ones(len(self.data.data),dtype=bool)
             # check smearing
@@ -2831,5 +2831,5 @@
                 else:
                     flag = True
-                    
+
         elif self.data == None:
             self.qmin_x = _QMIN_DEFAULT
@@ -2837,5 +2837,5 @@
             self.num_points = _NPTS_DEFAULT
             self.state.npts = self.num_points
-            
+
         elif self.data.__class__.__name__ != "Data2D":
             self.qmin_x = min(self.data.x)
@@ -2853,5 +2853,5 @@
         else:
             flag = False
-            
+
         if flag == False:
             msg = "Cannot Plot :Must enter a number!!!  "
@@ -2870,9 +2870,9 @@
         self.state.qmin = self.qmin_x
         self.state.qmax = self.qmax_x
-        
+
         #reset the q range values
         self._reset_plotting_range(self.state)
         self._draw_model()
-        
+
     def select_log(self, event):
         """
@@ -2883,5 +2883,5 @@
         """
         Get the images of the plots corresponding this panel for report
-        
+
         : return graphs: list of figures
         : Need Move to guiframe
@@ -2907,8 +2907,8 @@
                         # append to the list
                         graphs.append(item2.figure)
-                        canvases.append(item2.canvas)  
+                        canvases.append(item2.canvas)
             except:
                 # Not for control panels
-                pass
+                logging.error(sys.exc_value)
         # Make sure the resduals plot goes to the last
         if res_item != None:
@@ -2921,5 +2921,5 @@
         """
         Function called when 'Help' button is pressed next to model
-        of interest.  This calls DocumentationWindow from 
+        of interest.  This calls DocumentationWindow from
         documentation_window.py. It will load the top level of the model
         help documenation sphinx generated html if no model is presented.
@@ -2930,5 +2930,5 @@
         accessible because webbrowser module does not pass anything after
         the # to the browser.
-        
+
         :param evt: on Help Button pressed event
         """
@@ -2939,6 +2939,6 @@
             name = self.formfactorbox.GetValue()
 
-        if self.model != None:  
-            _docspath='user/models/model_functions.html#' + name
+        if self.model != None:
+            _docspath = 'user/models/model_functions.html#' + name
             _doc_viewer = DocumentationWindow(self, -1, _docspath, name + "Help")
         else:
@@ -2956,5 +2956,5 @@
         behaved model is encountered which has no description then it will
         give the message that none is available.
-        
+
         :param evt: on Description Button pressed event
         """
@@ -2978,25 +2978,25 @@
             wx.MessageBox(msg, info)
 
-    def _on_mag_help(self, event):    
-        """
-        Bring up Magnetic Angle definition bmp image whenever the ? button 
-        is clicked. Calls DocumentationWindow with the path of the location 
-        within the documentation tree (after /doc/ ....". When using old 
+    def _on_mag_help(self, event):
+        """
+        Bring up Magnetic Angle definition bmp image whenever the ? button
+        is clicked. Calls DocumentationWindow with the path of the location
+        within the documentation tree (after /doc/ ....". When using old
         versions of Wx (i.e. before 2.9 and therefore not part of release
         versions distributed via installer) it brings up an image viewer
-        box which allows the user to click through the rest of the images in 
+        box which allows the user to click through the rest of the images in
         the directory.  Not ideal but probably better than alternative which
-        would bring up the entire discussion of how magnetic models work? 
+        would bring up the entire discussion of how magnetic models work?
         Specially since it is not likely to be accessed.  The normal release
         versions bring up the normal image box.
-        
+
         :param evt: Triggers on clicking ? in Magnetic Angles? box
         """
-        
+
         _TreeLocation = "_images/M_angles_pic.bmp"
         _doc_viewer = DocumentationWindow(self, -1, \
-             _TreeLocation,"Magnetic Angle Defintions")
- 
-    def _on_mag_on(self, event):    
+             _TreeLocation, "Magnetic Angle Defintions")
+
+    def _on_mag_on(self, event):
         """
         Magnetic Parameters ON/OFF
@@ -3019,6 +3019,6 @@
                     #reset mag value to zero fo safety
                     self.model.setParam(key, 0.0)
-                    
-        self.Show(False)    
+
+        self.Show(False)
         self.set_model_param_sizer(self.model)
         #self._set_sizer_dispersion() 
@@ -3026,23 +3026,23 @@
         self.SetupScrolling()
         self.Show(True)
-            
+
     def on_pd_help_clicked(self, event):
         """
-        Bring up Polydispersity Documentation whenever the ? button is clicked. 
+        Bring up Polydispersity Documentation whenever the ? button is clicked.
         Calls DocumentationWindow with the path of the location within the
-        documentation tree (after /doc/ ....".  Note that when using old 
-        versions of Wx (before 2.9) and thus not the release version of 
-        istallers, the help comes up at the top level of the file as 
+        documentation tree (after /doc/ ....".  Note that when using old
+        versions of Wx (before 2.9) and thus not the release version of
+        istallers, the help comes up at the top level of the file as
         webbrowser does not pass anything past the # to the browser when it is
         running "file:///...."
-        
+
         :param evt: Triggers on clicking ? in polydispersity box
         """
-                
+
         _TreeLocation = "user/perspectives/fitting/fitting_help.html"
         _TreeLocation += "#polydispersity-distributions"
         _doc_viewer = DocumentationWindow(self, -1, \
-             _TreeLocation,"Polydispersity Help")
-        
+             _TreeLocation, "Polydispersity Help")
+
     def on_left_down(self, event):
         """
@@ -3059,5 +3059,5 @@
         # make event free
         event.Skip()
-        
+
     def get_copy(self):
         """
@@ -3068,5 +3068,5 @@
         self._copy_info(flag)
         return flag
-            
+
     def get_copy_params(self):
         """
@@ -3076,10 +3076,10 @@
         # Do it if params exist
         if  self.parameters != []:
-            
+
             # go through the parameters
             strings = self._get_copy_helper(self.parameters,
                                            self.orientation_params)
             content += strings
-            
+
             # go through the fittables
             strings = self._get_copy_helper(self.fittable_param,
@@ -3091,5 +3091,5 @@
                                            self.orientation_params_disp)
             content += strings
-                
+
             # go through the str params
             strings = self._get_copy_helper(self.str_parameters,
@@ -3124,5 +3124,5 @@
                 content += param[1] #parameter name
                 content += tab
-                content += param[1]+"_err"
+                content += param[1] + "_err"
                 content += tab
 
@@ -3132,7 +3132,7 @@
             for param in self.parameters:
                 content += param[2].GetValue() #value
-                content +=tab
+                content += tab
                 content += param[4].GetValue() #error
-                content +=tab
+                content += tab
 
             return content
@@ -3170,8 +3170,8 @@
 
             for index, param in enumerate(self.parameters):
-                content += param[1].replace('_','\_') #parameter name
+                content += param[1].replace('_', '\_') #parameter name
                 content += ' & '
-                content += param[1].replace('_','\_')+"\_err"
-                if index < len(self.parameters)-1:
+                content += param[1].replace('_', '\_') + "\_err"
+                if index < len(self.parameters) - 1:
                     content += ' & '
             content += '\\\\ \\hline'
@@ -3183,5 +3183,5 @@
                 content += ' & '
                 content += param[4].GetValue() #parameter error
-                if index < len(self.parameters)-1:
+                if index < len(self.parameters) - 1:
                     content += ' & '
             content += '\\\\ \\hline'
@@ -3206,9 +3206,9 @@
             return True
         return None
-    
+
     def _get_copy_helper(self, param, orient_param):
         """
         Helping get value and name of the params
-        
+
         : param param:  parameters
         : param orient_param = oritational params
@@ -3226,6 +3226,6 @@
                     disfunc = str(item[7].GetValue())
             except:
-                pass
-            
+                logging.error(sys.exc_value)
+
             # 2D
             if self.data.__class__.__name__ == "Data2D":
@@ -3249,5 +3249,5 @@
             # add to the content
             if disfunc != '':
-                
+
                 disfunc = ',' + disfunc
             # Need to support array func for copy/paste
@@ -3261,9 +3261,9 @@
                         disfunc += ' ' + str(weight)
             except:
-                pass
+                logging.error(sys.exc_value)
             content += name + ',' + str(check) + ',' + value + disfunc + ':'
 
         return content
-   
+
     def get_clipboard(self):
         """
@@ -3285,5 +3285,5 @@
             wx.TheClipboard.Close()
         return text
-    
+
     def get_paste(self):
         """
@@ -3294,5 +3294,5 @@
         self._copy_info(flag)
         return flag
-        
+
     def get_paste_params(self, text=''):
         """
@@ -3323,5 +3323,5 @@
                     val = [float(a_val) for a_val in array_values[1:]]
                     weit = [float(a_weit) for a_weit in array_weights[1:]]
-                    
+
                     context[name].append(val)
                     context[name].append(weit)
@@ -3346,16 +3346,16 @@
             self._get_paste_helper(self.fixed_param,
                                    self.orientation_params_disp, context)
-            
+
             # go through the str params
             self._get_paste_helper(self.str_parameters,
                                    self.orientation_params, context)
-                
+
             return True
         return None
-    
+
     def _get_paste_helper(self, param, orient_param, content):
         """
         Helping set values of the params
-        
+
         : param param:  parameters
         : param orient_param: oritational params
@@ -3385,5 +3385,5 @@
                             fun_val = self.model.fun_list[content[name][1]]
                             self.model.setParam(name, fun_val)
-                    
+
                     value = content[name][1:]
                     self._paste_poly_help(item, value)
@@ -3431,9 +3431,9 @@
                         if is_true != None:
                             item[0].SetValue(is_true)
-                        
+
     def _paste_poly_help(self, item, value):
         """
         Helps get paste for poly function
-        
+
         :param item: Gui param items
         :param value: the values for parameter ctrols
@@ -3462,5 +3462,5 @@
                             is_array = True
                 except:
-                    pass
+                    logging.error(sys.exc_value)
                 if not is_array:
                     self._disp_obj_dict[name] = disp_model
@@ -3475,8 +3475,9 @@
                                             [self.state.values,
                                              self.state.weights]
-                         
+
             except:
+                logging.error(sys.exc_value)
                 print "Error in BasePage._paste_poly_help: %s" % sys.exc_value
-    
+
     def _set_disp_array_cb(self, item):
         """
@@ -3492,5 +3493,5 @@
         item[6].SetValue('')
         item[6].Enable(False)
-        
+
     def update_pinhole_smear(self):
         """
@@ -3518,5 +3519,5 @@
             if not os.path.isfile(categorization_file):
                 categorization_file = CategoryInstaller.get_default_file()
-            cat_file = open(categorization_file, 'rb')                           
+            cat_file = open(categorization_file, 'rb')
             self.master_category_dict = json.load(cat_file)
             self._regenerate_model_dict()
@@ -3531,5 +3532,5 @@
     def _regenerate_model_dict(self):
         """
-        regenerates self.by_model_dict which has each model name as the 
+        regenerates self.by_model_dict which has each model name as the
         key and the list of categories belonging to that model
         along with the enabled mapping
@@ -3541,5 +3542,5 @@
                 self.by_model_dict[model].append(category)
                 self.model_enabled_dict[model] = enabled
-    
+
     def _populate_listbox(self):
         """
@@ -3553,5 +3554,5 @@
         if not uncat_str in cat_list:
             cat_list.append(uncat_str)
-        
+
         for category in cat_list:
             if category != '':
@@ -3561,5 +3562,5 @@
             self.categorybox.SetSelection(0)
         else:
-            self.categorybox.SetSelection( \
+            self.categorybox.SetSelection(\
                 self.categorybox.GetSelection())
 
@@ -3583,6 +3584,6 @@
 
         else:
-            for (model,enabled) in sorted(self.master_category_dict[category],
-                                      key = lambda name: name[0]):
+            for (model, enabled) in sorted(self.master_category_dict[category],
+                                      key=lambda name: name[0]):
                 if(enabled):
                     self.model_box.Append(model)
@@ -3617,10 +3618,10 @@
         hint = "toggle view of model from 1D to 2D  or 2D to 1D"
         self.model_view.SetToolTipString(hint)
-        
+
         cat_set_box = wx.StaticBox(self, -1, 'Category')
         sizer_cat_box = wx.StaticBoxSizer(cat_set_box, wx.HORIZONTAL)
         sizer_cat_box.SetMinSize((200, 50))
         self.categorybox = wx.ComboBox(self, -1, style=wx.CB_READONLY)
-        self.categorybox.SetToolTip( wx.ToolTip("Select a Category/Type") )
+        self.categorybox.SetToolTip(wx.ToolTip("Select a Category/Type"))
         self._populate_listbox()
         wx.EVT_COMBOBOX(self.categorybox, -1, self._show_combox)
@@ -3631,5 +3632,5 @@
         #self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ")
         #self.plugin_rbutton = wx.RadioButton(self, -1, "Uncategorized")
-                
+
         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
         #                   id=self.shape_rbutton.GetId())
@@ -3641,26 +3642,26 @@
         #                    id=self.plugin_rbutton.GetId())
         #MAC needs SetValue
-        
+
         show_cat_button = wx.Button(self, -1, "Modify")
         cat_tip = "Modify model categories \n"
         cat_tip += "(also accessible from the menu bar)."
-        show_cat_button.SetToolTip( wx.ToolTip(cat_tip) )
+        show_cat_button.SetToolTip(wx.ToolTip(cat_tip))
         show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat)
         sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3)
-        sizer_cat_box.Add((10,10))
+        sizer_cat_box.Add((10, 10))
         sizer_cat_box.Add(show_cat_button)
         #self.shape_rbutton.SetValue(True)
-      
+
         sizer_radiobutton = wx.GridSizer(2, 2, 5, 5)
-        
+
 
         #sizer_radiobutton.Add(self.shape_rbutton)
         #sizer_radiobutton.Add(self.shape_indep_rbutton)
-        sizer_radiobutton.Add((5,5))
+        sizer_radiobutton.Add((5, 5))
         sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5)
         #sizer_radiobutton.Add(self.plugin_rbutton)
         #sizer_radiobutton.Add(self.struct_rbutton)
 #        sizer_radiobutton.Add((5,5))
-        sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT|wx.LEFT, 5)
+        sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT | wx.LEFT, 5)
 #        sizer_radiobutton.Add((5,5))
         sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5)
@@ -3669,5 +3670,5 @@
         sizer_selection = wx.BoxSizer(wx.HORIZONTAL)
         mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL)
-        
+
         self.text1 = wx.StaticText(self, -1, "")
         self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)")
@@ -3678,5 +3679,5 @@
 
         self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)
-        self.formfactorbox.SetToolTip( wx.ToolTip("Select a Model") )
+        self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model"))
         if self.model != None:
             self.formfactorbox.SetValue(self.model.name)
@@ -3692,5 +3693,5 @@
             print "_set_model_sizer_selection: disabled."
             #self._set_model_sizer_selection(self.model)
-        
+
         sizer_selection.Add(self.text1)
         sizer_selection.Add((10, 5))
@@ -3700,5 +3701,5 @@
         sizer_selection.Add((5, 5))
         sizer_selection.Add(self.structurebox)
-       
+
         mutifactor_selection.Add((13, 5))
         mutifactor_selection.Add(self.mutifactor_text)
@@ -3714,5 +3715,5 @@
         boxsizer1.Add((10, 10))
         boxsizer1.Add(mutifactor_selection)
-        
+
         self._set_multfactor_combobox()
         self.multifactorbox.SetSelection(1)
@@ -3720,9 +3721,9 @@
         sizer.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10)
         sizer.Layout()
-        
+
     def on_smear_helper(self, update=False):
         """
         Help for onSmear if implemented
-        
+
         :param update: force or not to update
         """
@@ -3733,5 +3734,5 @@
     def onSmear(self, event):
         """
-        Create a smear object if implemented 
+        Create a smear object if implemented
         """
     def onPinholeSmear(self, event):
