Index: prview/perspectives/pr/inversion_panel.py
===================================================================
--- prview/perspectives/pr/inversion_panel.py	(revision 660b1e60ab822e113405bbf2f810f6667b460fe6)
+++ prview/perspectives/pr/inversion_panel.py	(revision b65955159b1d1b4d2bd00638c586ef52777d1d45)
@@ -414,8 +414,14 @@
         button_OK.SetToolTipString("Perform P(r) inversion.")
         self.Bind(wx.EVT_BUTTON, self._on_invert, id = id)   
+        
+        id = wx.NewId()
+        button_Reset = wx.Button(self, id, "Reset")
+        button_Reset.SetToolTipString("Reset inversion parameters to default.")
+        self.Bind(wx.EVT_BUTTON, self._on_reset, id = id)   
         #button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
         
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
         sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_Reset, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10)
         sizer_button.Add(button_OK, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10)
         #sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
@@ -442,6 +448,23 @@
             pass
         
-        
-    def _on_pars_changed(self, evt):
+    def _on_reset(self, evt):
+        """
+            Resets inversion parameters
+        """
+        self.nfunc = self.manager.DEFAULT_NFUNC
+        self.d_max = self.manager.DEFAULT_DMAX
+        self.alpha = self.manager.DEFAULT_ALPHA
+        self.qmin_ctl.SetValue("")
+        self.qmax_ctl.SetValue("")
+        self.time_ctl.SetValue("")
+        self.chi2_ctl.SetValue("")
+        self.osc_ctl.SetValue("")
+        self.pos_ctl.SetValue("")
+        self.pos_err_ctl.SetValue("")
+        self.alpha_estimate_ctl.Enable(False)
+        self.alpha_estimate_ctl.SetLabel("")
+        self._on_pars_changed()
+        
+    def _on_pars_changed(self, evt=None):
         """
             Called when an input parameter has changed
@@ -495,4 +518,9 @@
         try:
             nfunc = int(self.nfunc_ctl.GetValue())
+            npts = self.manager.get_npts()
+            if npts>0 and nfunc>npts:
+                message = "Number of function terms should be smaller than the number of points"
+                wx.PostEvent(self.manager.parent, StatusEvent(status=message))
+                raise ValueError, message
             self.nfunc_ctl.SetBackgroundColour(wx.WHITE)
             self.nfunc_ctl.Refresh()
@@ -610,4 +638,78 @@
         self.Centre()
 
+class PrDistDialog(wx.Dialog):
+    """
+        Property dialog to let the user change the number
+        of points on the P(r) plot.
+    """
+    def __init__(self, parent, id):
+        from sans.pr.invertor import help
+        wx.Dialog.__init__(self, parent, id, size=(250, 120))
+        self.SetTitle("P(r) distribution") 
+        
+
+        vbox = wx.BoxSizer(wx.VERTICAL)
+        
+        label_npts = wx.StaticText(self, -1, "Number of points")
+        self.npts_ctl = wx.TextCtrl(self, -1, size=(100,20))
+                 
+        pars_sizer = wx.GridBagSizer(5,5)
+        iy = 0
+        pars_sizer.Add(label_npts,      (iy,0), (1,1), wx.LEFT, 15)
+        pars_sizer.Add(self.npts_ctl,   (iy,1), (1,1), wx.RIGHT, 0)
+        
+        vbox.Add(pars_sizer, 0, wx.ALL|wx.EXPAND, 15)
+
+
+        static_line = wx.StaticLine(self, -1)
+        vbox.Add(static_line, 0, wx.EXPAND, 0)
+        
+        button_OK = wx.Button(self, wx.ID_OK, "OK")
+        self.Bind(wx.EVT_BUTTON, self._checkValues, button_OK)
+        button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
+        
+        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
+        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
+        sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
+        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
+
+        self.SetSizer(vbox)
+        self.SetAutoLayout(True)
+        
+        self.Layout()
+        self.Centre()
+
+    def _checkValues(self, event):
+        """
+            Check the dialog content.
+        """
+        flag = True
+        try:
+            int(self.npts_ctl.GetValue())
+            self.npts_ctl.SetBackgroundColour(wx.WHITE)
+            self.npts_ctl.Refresh()
+        except:
+            flag = False
+            self.npts_ctl.SetBackgroundColour("pink")
+            self.npts_ctl.Refresh()
+        if flag:
+            event.Skip(True)
+
+    def get_content(self):
+        """
+            Return the content of the dialog.
+            At this point the values have already been
+            checked.
+        """
+        value = int(self.npts_ctl.GetValue())
+        return value
+    
+    def set_content(self, npts):
+        """
+            Initialize the content of the dialog.
+        """
+        self.npts_ctl.SetValue("%i" % npts)
+
 
 class ParsDialog(wx.Panel):
@@ -751,5 +853,5 @@
     def OnInit(self):
         wx.InitAllImageHandlers()
-        dialog = HelpDialog(None, -1)
+        dialog = PrDistDialog(None, -1)
         if dialog.ShowModal() == wx.ID_OK:
             pass
Index: prview/perspectives/pr/pr.py
===================================================================
--- prview/perspectives/pr/pr.py	(revision 660b1e60ab822e113405bbf2f810f6667b460fe6)
+++ prview/perspectives/pr/pr.py	(revision b65955159b1d1b4d2bd00638c586ef52777d1d45)
@@ -13,4 +13,8 @@
 class Plugin:
     
+    DEFAULT_ALPHA = 0.0001
+    DEFAULT_NFUNC = 10
+    DEFAULT_DMAX  = 140.0
+    
     def __init__(self):
         ## Plug-in name
@@ -27,7 +31,7 @@
         
         ## State data
-        self.alpha      = 0.0001
-        self.nfunc      = 10
-        self.max_length = 140.0
+        self.alpha      = self.DEFAULT_ALPHA
+        self.nfunc      = self.DEFAULT_NFUNC
+        self.max_length = self.DEFAULT_DMAX
         self.q_min      = None
         self.q_max      = None
@@ -48,4 +52,6 @@
         ## Currently views plottable
         self.current_plottable = None
+        ## Number of P(r) points to display on the output plot
+        self._pr_npts = 51
 
     def populate_menu(self, id, owner):
@@ -118,5 +124,5 @@
 
         # Show input P(r)
-        new_plot = Data1D(pr.x, pr.y, pr.err)
+        new_plot = Data1D(pr.x, pr.y, dy=pr.err)
         new_plot.name = "P_{obs}(r)"
         new_plot.xaxis("\\rm{r}", 'A')
@@ -157,4 +163,13 @@
         #Put this call in plottables/guitools    
         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Sphere P(r)"))
+        
+    def get_npts(self):
+        """
+            Returns the number of points in the I(q) data
+        """
+        try:
+            return len(self.pr.x)
+        except:
+            return 0
         
     def show_iq(self, out, pr, q=None):
@@ -203,4 +218,17 @@
         
         
+    def _on_pr_npts(self, evt):
+        """
+            Redisplay P(r) with a different number of points
+        """   
+        from inversion_panel import PrDistDialog
+        dialog = PrDistDialog(None, -1)
+        dialog.set_content(self._pr_npts)
+        if dialog.ShowModal() == wx.ID_OK:
+            self._pr_npts= dialog.get_content()
+            dialog.Destroy()
+            self.show_pr(self.pr.out, self.pr, self.pr.cov)
+        else:
+            dialog.Destroy()
         
         
@@ -213,5 +241,5 @@
         
         # Show P(r)
-        x = pylab.arange(0.0, pr.d_max, pr.d_max/51.0)
+        x = pylab.arange(0.0, pr.d_max, pr.d_max/self._pr_npts)
     
         y = numpy.zeros(len(x))
@@ -253,5 +281,5 @@
         return self.parent.choose_file()
                 
-    def load(self, path = "sphere_test_data.txt"):
+    def load(self, path = "sphere_60_q0_2.txt"):
         import numpy, math, sys
         # Read the data from the data file
@@ -259,4 +287,6 @@
         data_y   = numpy.zeros(0)
         data_err = numpy.zeros(0)
+        scale    = None
+        min_err  = 0.0
         if not path == None:
             input_f = open(path,'r')
@@ -268,18 +298,21 @@
                     x = float(toks[0])
                     y = float(toks[1])
-                    try:
-                        scale = 0.05/math.sqrt(data_x[0])
-                    except:
-                        scale = 1.0
-                    #data_err = numpy.append(data_err, 10.0*math.sqrt(y)+1000.0)
+                    if len(toks)>2:
+                        err = float(toks[2])
+                    else:
+                        if scale==None:
+                            scale = 0.05*math.sqrt(y)
+                            #scale = 0.05/math.sqrt(y)
+                            min_err = 0.01*y
+                        err = scale*math.sqrt(y)+min_err
+                        #err = 0
+                        
                     data_x = numpy.append(data_x, x)
                     data_y = numpy.append(data_y, y)
-                    data_err = numpy.append(data_err, scale*math.sqrt(math.fabs(y)))
+                    data_err = numpy.append(data_err, err)
                 except:
-                    print "Error reading line: ", line
-                    print sys.exc_value
+                    pass
                    
-        print "Lines read:", len(data_x)
-        return data_x, data_y, data_err
+        return data_x, data_y, data_err     
         
     def pr_theory(self, r, R):
@@ -303,5 +336,6 @@
                 
                 return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion],
-                       ["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data]]
+                       ["Add P(r) data", "Load a data file and display it on this plot", self._on_add_data],
+                       ["Change number of P(r) points", "Change the number of points on the P(r) output", self._on_pr_npts]]
                 
         return [["Compute P(r)", "Compute P(r) from distribution", self._on_context_inversion]]
@@ -318,5 +352,6 @@
         x, y, err = self.parent.load_ascii_1D(path)
         
-        new_plot = Data1D(x, y, dy=err)
+        #new_plot = Data1D(x, y, dy=err)
+        new_plot = Theory1D(x, y)
         new_plot.name = "P_{loaded}(r)"
         new_plot.xaxis("\\rm{r}", 'A')
@@ -369,4 +404,7 @@
         # Save useful info
         self.elapsed = elapsed
+        # Save Pr invertor
+        self.pr = pr
+        
         message = "Computation completed in %g seconds [chi2=%g]" % (elapsed, pr.chi2)
         wx.PostEvent(self.parent, StatusEvent(status=message))
@@ -387,8 +425,9 @@
                 print "%d: %g +- %g" % (i, out[i], math.sqrt(math.fabs(cov[i][i])))
             except: 
+                print sys.exc_value
                 print "%d: %g +- ?" % (i, out[i])        
         
         # Make a plot of I(q) data
-        new_plot = Data1D(self.pr.x, self.pr.y, self.pr.err)
+        new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err)
         new_plot.name = "I_{obs}(q)"
         new_plot.xaxis("\\rm{Q}", 'A^{-1}')
@@ -411,5 +450,5 @@
               
         # Make a plot of I(q) data
-        new_plot = Data1D(self.pr.x, self.pr.y, self.pr.err)
+        new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err)
         new_plot.name = "I_{obs}(q)"
         new_plot.xaxis("\\rm{Q}", 'A^{-1}')
