Index: pr_inversion/Doxyfile
===================================================================
--- pr_inversion/Doxyfile	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
+++ pr_inversion/Doxyfile	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -0,0 +1,263 @@
+# Doxyfile 1.5.1-p1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = sanspr
+PROJECT_NUMBER         = 
+OUTPUT_DIRECTORY       = doc
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+USE_WINDOWS_ENCODING   = NO
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = YES
+STRIP_FROM_PATH        = 
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 4
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = NO
+OPTIMIZE_OUTPUT_JAVA   = YES
+BUILTIN_STL_SUPPORT    = NO
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = NO
+EXTRACT_PRIVATE        = NO
+EXTRACT_STATIC         = NO
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = NO
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = YES
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = .
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py
+RECURSIVE              = YES
+EXCLUDE                = build \
+                         dist \
+                         test
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = 
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = *
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = doc
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION    = NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = NO
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = YES
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = 
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = YES
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = NO
+GROUP_GRAPHS           = YES
+UML_LOOK               = YES
+TEMPLATE_RELATIONS     = YES
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = YES
+CALLER_GRAPH           = YES
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+MAX_DOT_GRAPH_DEPTH    = 1000
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO
Index: pr_inversion/__init__.py
===================================================================
--- pr_inversion/__init__.py	(revision 9a11937a59823081f8f1d4dd70374e3284ddcc7f)
+++ pr_inversion/__init__.py	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -15,7 +15,11 @@
 # 
 # [1] P.B. Moore, J.Appl. Cryst (1980) 13, 168-175.
+#
 # [2] O. Glatter, J.Appl. Cryst (1977) 10, 415-421.
+#
 # [3] D.I. Svergun, J.Appl. Cryst (1991) 24, 485-492.
+#
 # [4] D.I. Svergun, J.Appl. Cryst (1992) 25, 495-503.
+#
 # [5] S. Hansen and J. Skov Pedersen, J.Appl. Cryst (1991) 24, 541-548.
 #
@@ -41,4 +45,36 @@
 #
 #
+# \subsection Tutorial
+# To create an inversion object:
+# \verbatim
+#from sans.pr.invertor import Invertor
+#    invertor = Invertor()
+# \endverbatim
+#
+# To set the maximum distance between any two points:
+# \verbatim
+#    invertor.d_max = 160.0
+# \endverbatim
+#
+# To set the regularization constant:
+# \verbatim
+#    invertor.alpha = 0.0007
+# \endverbatim
+#
+# To set the q, I(q) and error on I(q):
+# \verbatim
+#    invertor.x = q_vector
+#    invertor.y = Iq_vector
+#    invertor.err = dIq_vector
+# \endverbatim
+#
+# To perform the inversion. In this example, we choose
+# a P(r) expension wit 10 base functions.
+# \verbatim
+#    c_out, c_cov = invertor.invert(10)
+# \endverbatim
+# The c_out and c_cov are the set of coefficients and the covariance 
+# matrix for those coefficients, respectively.
+#
 # Examples are available as unit tests under sans.pr_inversion.test.
 #
Index: pr_inversion/c_extensions/Cinvertor.c
===================================================================
--- pr_inversion/c_extensions/Cinvertor.c	(revision 43c0a8eb8df558118a4b4ec7f771a56fd0e81893)
+++ pr_inversion/c_extensions/Cinvertor.c	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -1,3 +1,8 @@
-
+/**
+ * C implementation of the P(r) inversion
+ * Cinvertor is the base class for the Invertor class
+ * and provides the underlying computations.
+ * 
+ */
 #include <Python.h>
 #include "structmember.h"
@@ -29,6 +34,13 @@
 
 // Class definition
+/**
+ * C implementation of the P(r) inversion
+ * Cinvertor is the base class for the Invertor class
+ * and provides the underlying computations.
+ * 
+ */
 typedef struct {
     PyObject_HEAD    
+    /// Internal data structure
     Invertor_params params; 
 } Cinvertor;
@@ -70,4 +82,8 @@
 };
 
+const char set_x_doc[] = 
+	"Function to set the x data\n"
+	"Takes an array of doubles as input.\n"
+	" @return: number of entries found";
 
 /**
@@ -102,4 +118,9 @@
 	return Py_BuildValue("i", self->params.npoints);	
 }
+
+const char get_x_doc[] = 
+	"Function to get the x data\n"
+	"Takes an array of doubles as input.\n"
+	" @return: number of entries found";
 
 static PyObject * get_x(Cinvertor *self, PyObject *args) {
@@ -126,4 +147,9 @@
 }
 
+const char set_y_doc[] = 
+	"Function to set the y data\n"
+	"Takes an array of doubles as input.\n"
+	" @return: number of entries found";
+
 /**
  * Function to set the y data
@@ -157,4 +183,9 @@
 	return Py_BuildValue("i", self->params.ny);	
 }
+
+const char get_y_doc[] = 
+	"Function to get the y data\n"
+	"Takes an array of doubles as input.\n"
+	" @return: number of entries found";
 
 static PyObject * get_y(Cinvertor *self, PyObject *args) {
@@ -181,4 +212,9 @@
 }
 
+const char set_err_doc[] = 
+	"Function to set the err data\n"
+	"Takes an array of doubles as input.\n"
+	" @return: number of entries found";
+
 /**
  * Function to set the x data
@@ -212,4 +248,9 @@
 	return Py_BuildValue("i", self->params.nerr);	
 }
+
+const char get_err_doc[] = 
+	"Function to get the err data\n"
+	"Takes an array of doubles as input.\n"
+	" @return: number of entries found";
 
 static PyObject * get_err(Cinvertor *self, PyObject *args) {
@@ -235,4 +276,8 @@
 	return Py_BuildValue("i", self->params.npoints);	
 }
+
+const char is_valid_doc[] = 
+	"Check the validity of the stored data\n"
+	" @return: Returns the number of points if it's all good, -1 otherwise";
 
 /**
@@ -249,4 +294,7 @@
 }
 
+const char set_dmax_doc[] = 
+	"Sets the maximum distance\n";
+
 /**
  * Sets the maximum distance
@@ -260,4 +308,7 @@
 }
 
+const char get_dmax_doc[] = 
+	"Gets the maximum distance\n";
+
 /**
  * Gets the maximum distance
@@ -266,4 +317,7 @@
 	return Py_BuildValue("d", self->params.d_max);	
 }
+
+const char set_qmin_doc[] = 
+	"Sets the minimum q\n";
 
 /**
@@ -278,4 +332,7 @@
 }
 
+const char get_qmin_doc[] = 
+	"Gets the minimum q\n";
+
 /**
  * Gets the minimum q
@@ -285,4 +342,6 @@
 }
 
+const char set_qmax_doc[] = 
+	"Sets the maximum q\n";
 
 /**
@@ -297,4 +356,7 @@
 }
 
+const char get_qmax_doc[] = 
+	"Gets the maximum q\n";
+
 /**
  * Gets the maximum q
@@ -304,4 +366,6 @@
 }
 
+const char set_alpha_doc[] = 
+	"Sets the alpha parameter\n";
 
 static PyObject * set_alpha(Cinvertor *self, PyObject *args) {
@@ -313,4 +377,7 @@
 }
 
+const char get_alpha_doc[] = 
+	"Gets the alpha parameter\n";
+
 /**
  * Gets the maximum distance
@@ -320,4 +387,7 @@
 }
 
+const char get_nx_doc[] = 
+	"Gets the number of x points\n";
+
 /**
  * Gets the number of x points
@@ -327,4 +397,7 @@
 }
 
+const char get_ny_doc[] = 
+	"Gets the number of y points\n";
+
 /**
  * Gets the number of y points
@@ -334,4 +407,7 @@
 }
 
+const char get_nerr_doc[] = 
+	"Gets the number of err points\n";
+
 /**
  * Gets the number of error points
@@ -341,4 +417,10 @@
 }
 
+
+const char residuals_doc[] = 
+	"Function to call to evaluate the residuals\n"
+	"for P(r) inversion\n"
+	" @param args: input parameters\n"
+	" @return: list of residuals";
 
 /**
@@ -391,4 +473,11 @@
 	return residuals;
 }
+
+const char pr_residuals_doc[] = 
+	"Function to call to evaluate the residuals\n"
+	"for P(r) minimization (for testing purposes)\n"
+	" @param args: input parameters\n"
+	" @return: list of residuals";
+
 /**
  * Function to call to evaluate the residuals
@@ -442,4 +531,9 @@
 }
 
+const char get_iq_doc[] = 
+	"Function to call to evaluate the scattering intensity\n"
+	" @param args: c-parameters, and q\n"
+	" @return: I(q)";
+
 /**
  * Function to call to evaluate the scattering intensity
@@ -460,4 +554,9 @@
 }
 
+const char get_pr_doc[] = 
+	"Function to call to evaluate P(r)\n"
+	" @param args: c-parameters and r\n"
+	" @return: P(r)";
+
 /**
  * Function to call to evaluate P(r)
@@ -478,4 +577,9 @@
 }
 
+const char get_pr_err_doc[] = 
+	"Function to call to evaluate P(r) with errors\n"
+	" @param args: c-parameters and r\n"
+	" @return: (P(r),dP(r))";
+
 /**
  * Function to call to evaluate P(r) with errors
@@ -502,4 +606,9 @@
 }
 
+const char basefunc_ft_doc[] = 
+	"Returns the value of the nth Fourier transofrmed base function\n"
+	" @param args: c-parameters, n and q\n"
+	" @return: nth Fourier transformed base function, evaluated at q";
+
 static PyObject * basefunc_ft(Cinvertor *self, PyObject *args) {
 	double d_max, q;
@@ -511,4 +620,11 @@
 }
 
+const char oscillations_doc[] = 
+	"Returns the value of the oscillation figure of merit for\n"
+	"the given set of coefficients. For a sphere, the oscillation\n"
+	"figure of merit is 1.1.\n"
+	" @param args: c-parameters\n"
+	" @return: oscillation figure of merit";
+
 static PyObject * oscillations(Cinvertor *self, PyObject *args) {
 	double *pars;
@@ -526,4 +642,10 @@
 }
 
+const char get_peaks_doc[] = 
+	"Returns the number of peaks in the output P(r) distrubution\n"
+	"for the given set of coefficients.\n"
+	" @param args: c-parameters\n"
+	" @return: number of P(r) peaks";
+
 static PyObject * get_peaks(Cinvertor *self, PyObject *args) {
 	double *pars;
@@ -540,4 +662,10 @@
 	
 }
+
+const char get_positive_doc[] = 
+	"Returns the fraction of P(r) that is positive over\n"
+	"the full range of r for the given set of coefficients.\n"
+	" @param args: c-parameters\n"
+	" @return: fraction of P(r) that is positive";
 
 static PyObject * get_positive(Cinvertor *self, PyObject *args) {
@@ -555,4 +683,10 @@
 	
 }
+
+const char get_pos_err_doc[] = 
+	"Returns the fraction of P(r) that is 1 standard deviation\n"
+	"above zero over the full range of r for the given set of coefficients.\n"
+	" @param args: c-parameters\n"
+	" @return: fraction of P(r) that is positive";
 
 static PyObject * get_pos_err(Cinvertor *self, PyObject *args) {
@@ -575,33 +709,43 @@
 }
 
+
+const char eeeget_qmin_doc[] = "\
+This is a multiline doc string.\n\
+\n\
+This is the second line.";
+const char eeeset_qmin_doc[] = 
+	"This is a multiline doc string.\n"
+	"\n"
+	"This is the second line.";
+
 static PyMethodDef Cinvertor_methods[] = {
-		   {"residuals", (PyCFunction)residuals, METH_VARARGS, "Get the list of residuals"},
-		   {"pr_residuals", (PyCFunction)pr_residuals, METH_VARARGS, "Get the list of residuals"},
-		   {"set_x", (PyCFunction)set_x, METH_VARARGS, ""},
-		   {"get_x", (PyCFunction)get_x, METH_VARARGS, ""},
-		   {"set_y", (PyCFunction)set_y, METH_VARARGS, ""},
-		   {"get_y", (PyCFunction)get_y, METH_VARARGS, ""},
-		   {"set_err", (PyCFunction)set_err, METH_VARARGS, ""},
-		   {"get_err", (PyCFunction)get_err, METH_VARARGS, ""},
-		   {"set_dmax", (PyCFunction)set_dmax, METH_VARARGS, ""},
-		   {"get_dmax", (PyCFunction)get_dmax, METH_VARARGS, ""},
-		   {"set_qmin", (PyCFunction)set_qmin, METH_VARARGS, ""},
-		   {"get_qmin", (PyCFunction)get_qmin, METH_VARARGS, ""},
-		   {"set_qmax", (PyCFunction)set_qmax, METH_VARARGS, ""},
-		   {"get_qmax", (PyCFunction)get_qmax, METH_VARARGS, ""},
-		   {"set_alpha", (PyCFunction)set_alpha, METH_VARARGS, ""},
-		   {"get_alpha", (PyCFunction)get_alpha, METH_VARARGS, ""},
-		   {"get_nx", (PyCFunction)get_nx, METH_VARARGS, ""},
-		   {"get_ny", (PyCFunction)get_ny, METH_VARARGS, ""},
-		   {"get_nerr", (PyCFunction)get_nerr, METH_VARARGS, ""},
-		   {"iq", (PyCFunction)get_iq, METH_VARARGS, ""},
-		   {"pr", (PyCFunction)get_pr, METH_VARARGS, ""},
-		   {"get_pr_err", (PyCFunction)get_pr_err, METH_VARARGS, ""},
-		   {"is_valid", (PyCFunction)is_valid, METH_VARARGS, ""},
-		   {"basefunc_ft", (PyCFunction)basefunc_ft, METH_VARARGS, ""},
-		   {"oscillations", (PyCFunction)oscillations, METH_VARARGS, ""},
-		   {"get_peaks", (PyCFunction)get_peaks, METH_VARARGS, ""},
-		   {"get_positive", (PyCFunction)get_positive, METH_VARARGS, ""},
-		   {"get_pos_err", (PyCFunction)get_pos_err, METH_VARARGS, ""},
+		   {"residuals", (PyCFunction)residuals, METH_VARARGS, residuals_doc},
+		   {"pr_residuals", (PyCFunction)pr_residuals, METH_VARARGS, pr_residuals_doc},
+		   {"set_x", (PyCFunction)set_x, METH_VARARGS, set_x_doc},
+		   {"get_x", (PyCFunction)get_x, METH_VARARGS, get_x_doc},
+		   {"set_y", (PyCFunction)set_y, METH_VARARGS, set_y_doc},
+		   {"get_y", (PyCFunction)get_y, METH_VARARGS, get_y_doc},
+		   {"set_err", (PyCFunction)set_err, METH_VARARGS, set_err_doc},
+		   {"get_err", (PyCFunction)get_err, METH_VARARGS, get_err_doc},
+		   {"set_dmax", (PyCFunction)set_dmax, METH_VARARGS, set_dmax_doc},
+		   {"get_dmax", (PyCFunction)get_dmax, METH_VARARGS, get_dmax_doc},
+		   {"set_qmin", (PyCFunction)set_qmin, METH_VARARGS, set_qmin_doc},
+		   {"get_qmin", (PyCFunction)get_qmin, METH_VARARGS, get_qmin_doc},
+		   {"set_qmax", (PyCFunction)set_qmax, METH_VARARGS, set_qmax_doc},
+		   {"get_qmax", (PyCFunction)get_qmax, METH_VARARGS, get_qmax_doc},
+		   {"set_alpha", (PyCFunction)set_alpha, METH_VARARGS, set_alpha_doc},
+		   {"get_alpha", (PyCFunction)get_alpha, METH_VARARGS, get_alpha_doc},
+		   {"get_nx", (PyCFunction)get_nx, METH_VARARGS, get_nx_doc},
+		   {"get_ny", (PyCFunction)get_ny, METH_VARARGS, get_ny_doc},
+		   {"get_nerr", (PyCFunction)get_nerr, METH_VARARGS, get_nerr_doc},
+		   {"iq", (PyCFunction)get_iq, METH_VARARGS, get_iq_doc},
+		   {"pr", (PyCFunction)get_pr, METH_VARARGS, get_pr_doc},
+		   {"get_pr_err", (PyCFunction)get_pr_err, METH_VARARGS, get_pr_err_doc},
+		   {"is_valid", (PyCFunction)is_valid, METH_VARARGS, is_valid_doc},
+		   {"basefunc_ft", (PyCFunction)basefunc_ft, METH_VARARGS, basefunc_ft_doc},
+		   {"oscillations", (PyCFunction)oscillations, METH_VARARGS, oscillations_doc},
+		   {"get_peaks", (PyCFunction)get_peaks, METH_VARARGS, get_peaks_doc},
+		   {"get_positive", (PyCFunction)get_positive, METH_VARARGS, get_positive_doc},
+		   {"get_pos_err", (PyCFunction)get_pos_err, METH_VARARGS, get_pos_err_doc},
    
    {NULL}
Index: pr_inversion/c_extensions/__init__.py
===================================================================
--- pr_inversion/c_extensions/__init__.py	(revision 9e8dc223ee841261f4cf577f54920873d455660d)
+++ pr_inversion/c_extensions/__init__.py	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -0,0 +1,3 @@
+"""
+    C extensions to provide the P(r) inversion computations.
+"""
Index: pr_inversion/c_extensions/invertor.h
===================================================================
--- pr_inversion/c_extensions/invertor.h	(revision 43c0a8eb8df558118a4b4ec7f771a56fd0e81893)
+++ pr_inversion/c_extensions/invertor.h	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -2,15 +2,27 @@
 #define invertor_h
 
-
+/**
+ * Internal data structure for P(r) inversion
+ */
 typedef struct {
+	/// Maximum distance between any two points in the system
     double d_max;
+    /// q data
     double *x;
+    /// I(q) data
     double *y;
+    /// dI(q) data
     double *err;
+    /// Number of q points
     int npoints;    
+    /// Number of I(q) points
     int ny;    
+    /// Number of dI(q) points
     int nerr;  
+    /// Alpha value
     double alpha;
+    /// Minimum q to include in inversion
     double q_min;
+    /// Maximum q to include in inversion
     double q_max;
 } Invertor_params; 
Index: pr_inversion/invertor.py
===================================================================
--- pr_inversion/invertor.py	(revision 43c0a8eb8df558118a4b4ec7f771a56fd0e81893)
+++ pr_inversion/invertor.py	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -1,2 +1,6 @@
+"""
+    Module to perform P(r) inversion.
+    The module contains the Invertor class.
+"""
 from sans.pr.core.pr_inversion import Cinvertor
 import numpy
@@ -35,5 +39,8 @@
         
         Methods inherited from Cinvertor:
-        - get_peaks: returns the number of P(r) peaks
+        - get_peaks(pars): returns the number of P(r) peaks
+        - oscillations(pars): returns the oscillation parameters for the output P(r)
+        - get_positive(pars): returns the fraction of P(r) that is above zero
+        - get_pos_err(pars): returns the fraction of P(r) that is 1-sigma above zero
     """
     ## Chisqr of the last computation
@@ -57,5 +64,5 @@
             Set the value of an attribute.
             Access the parent class methods for
-            x, y, err and d_max.
+            x, y, err, d_max, q_min, q_max and alpha
         """
         if   name=='x':
@@ -194,15 +201,14 @@
     
     def pr_err(self, c, c_cov, r):
-        #import math
-        #c_err = numpy.zeros(len(c))
-        #for i in range(len(c)):
-        #    try:
-        #        c_err[i] = math.sqrt(math.fabs(c_cov[i][i]))
-        #    except:
-        #        import sys
-        #        print sys.exc_value
-        #        print "oups", c_cov[i][i]
-        #        c_err[i] = c[i]
-
+        """    
+            Returns the value of P(r) for a given r, and base function
+            coefficients, with error.
+            
+            @param c: base function coefficients
+            @param c_cov: covariance matrice of the base function coefficients
+            @param r: r-value to evaluate P(r) at
+            @return: P(r)
+            
+        """
         return self.get_pr_err(c, c_cov, r)
        
Index: _inversion/pr_test.py
===================================================================
--- pr_inversion/pr_test.py	(revision 9e8dc223ee841261f4cf577f54920873d455660d)
+++ 	(revision )
@@ -1,252 +1,0 @@
-import math
-import pylab, numpy
-
-class PrInverse:
-    
-    D = 70.0
-    #alpha = 0.0001
-    alpha = 0.0
-    
-    data_x   = []
-    data_y   = []
-    data_err = []
-    
-    r = []
-    pr = []
-    pr_err = []
-    
-    xmult = []
-    
-    c = None
-    
-    def __init__(self, D=60.0):
-        ## Max distance
-        self.D = D
-        self.xmult = pylab.arange(0.001, self.D, self.D/21.0)
-
-    def l_multiplier(self, c):
-        return self.alpha * self._lmult2(c)
-        
-    def _lmult1(self, c):
-        sum = 0
-        for i in range(len(c)-1):
-            sum += (c[i+1]-c[i])**2
-        return sum
-    
-    def _lmult2(self, c):
-        sum = 0
-        for i in range(len(self.xmult)):
-            dp = 0
-            for j in range(len(c)):
-                dp += c[j] * self._ortho_derived(j+1, self.xmult[i])
-            sum += (dp**2)
-        return sum * self.D/len(self.xmult)
-    
-    def _ortho_transformed(self, n, q):
-        """
-            Fourier transform of the nth orthogonal function
-        """
-        return 8.0*math.pi**2/q * self.D * n * (-1)**(n+1) * \
-            math.sin(q*self.D) / ( (math.pi*n)**2 - (q*self.D)**2)
-            
-    def _ortho_derived(self, n, r):
-        
-        return 2.0*math.sin(math.pi*n*r/self.D) + 2.0*r*math.cos(math.pi*n*r/self.D)  
-    
-    def iq(self, c, q):
-        sum = 0.0
-        N = len(c)
-        #str =  ''
-        for i in range(N):
-            # n goes from 1 to N in the formulas
-            sum += c[i] * self._ortho_transformed(i+1, q)
-            #str += "c%i=%g  " % (i, c[i]);
-        #print str
-        #import time
-        #time.sleep(10)
-        return sum
-    
-    def residuals(self, params):
-        """
-            Calculates the vector of residuals for each point 
-            in y for a given set of input parameters.
-            @param params: list of parameter values
-            @return: vector of residuals
-        """
-        residuals = []
-        M = len(self.data_x)
-        #lmult = self.l_multiplier(params)
-        lmult = 0
-        for j in range(M):
-            if self.data_x[j]>0.0:
-                #print j
-                value = (self.data_y[j] - self.iq(params, self.data_x[j]))**2 / self.data_err[j]**2
-                #print self.data_x[j], value, lmult/float(M)
-                value += lmult/float(M)
-                residuals.append( value )
-            
-        return residuals
-    
-    def convert_res(self, res):
-        v = numpy.asarray(res)
-        if not v.flags.contiguous:
-            print "not contiguous" 
-            v = numpy.array(res)
-        
-        print v
-        res = self.c.residuals(v)
-        print res
-        #return self.c.residuals(v)
-        return res
-    
-    def new_fit(self):
-        from sans.pr.invertor import Invertor
-        from scipy import optimize
-        
-        c = Invertor()
-        c.set_dmax(self.D)
-        c.set_x(self.data_x)
-        c.set_y(self.data_y)
-        c.set_err(self.data_err)
-        
-        out, cov_x = c.invert()
-        
-        return out, cov_x
-
-    def new_fit_0(self):
-        from sans.pr.core.pr_inversion import Cinvertor
-        from scipy import optimize
-        
-        self.c = Cinvertor()
-        self.c.set_dmax(self.D)
-        self.c.set_x(self.data_x)
-        self.c.set_y(self.data_y)
-        self.c.set_err(self.data_err)
-        print "Valid", self.c.is_valid()
-        M=10
-        p = numpy.ones(M)
-        
-        p[0] = 10.0
-        
-        out, cov_x, info, mesg, success = optimize.leastsq(self.c.residuals, p, full_output=1, warning=True)
-        #out, cov_x, info, mesg, success = optimize.leastsq(self.convert_res, p, full_output=1, warning=True)
-        
-        
-        return out, cov_x
-    
-    def fit(self):
-        return self.new_fit()
-        
-        import numpy
-        from scipy import optimize
-
-
-        M = len(self.data_x)-3
-        M=3
-        print "Number of functions: ", M
-        p = numpy.zeros(M)
-        p[0] = 1000.0
-        
-        out, cov_x, info, mesg, success = optimize.leastsq(self.residuals, p, full_output=1, warning=True)
-        
-        
-        return out, cov_x
-
-    def pr_theory(self, r, R):
-        """
-           
-        """
-        if r<=2*R:
-            return 12.0* ((0.5*r/R)**2) * ((1.0-0.5*r/R)**2) * ( 2.0 + 0.5*r/R )
-        else:
-            return 0.0
-
-
-    def residuals_pr(self, params):
-        import pylab
-        
-        residuals = []
-        M = len(self.r)
-        
-        
-        for j in range(M):
-            
-            if self.r[j]>0:
-                err2 = (self.pr_err[j])**2
-                if j>0:
-                    err2 += 0.25*(self.pr[j-1]-self.pr[j-1])**2
-                value = (self.pr[j]-self.pr_calc(params, self.r[j]))**2/err2
-                residuals.append( value )
-            
-        return residuals        
-
-    def pr_calc(self, c, r):
-        sum = 0
-        N = len(c)
-        for i in range(N):
-            sum += c[i]*2.0*r*math.sin(math.pi*(i+1)*r/self.D)
-            
-        return sum
-
-    def fill_sphere(self, radius=60):
-        import pylab
-        import numpy
-        self.r = pylab.arange(0.0, radius, radius/50.0)
-        M = len(self.r)
-        self.pr = numpy.zeros(M)
-        self.pr_err = numpy.zeros(M)
-        
-        for j in range(M):
-            self.pr[j] = self.pr_theory(self.r[j], radius)
-            self.pr_err[j] = math.sqrt(self.pr[j])
-        
-
-    def fit_pr(self):
-        import numpy
-        from scipy import optimize
-        
-        
-        M = len(self.r)-3
-        M=2
-        print "Number of functions: ", M
-        p = numpy.ones(M)
-        #p = numpy.ones(15)
-        
-        out, cov_x, info, mesg, success = optimize.leastsq(self.residuals_pr, p, full_output=1, warning=True)
-      
-        return out, cov_x
-        
-        
-
-    def load(self, path = "sphere_test_data.txt"):
-        # Read the data from the data file
-        self.data_x = numpy.zeros(0)
-        self.data_y = numpy.zeros(0)
-        self.data_err = numpy.zeros(0)
-        if not path == None:
-            input_f = open(path,'r')
-            buff = input_f.read()
-            lines = buff.split('\n')
-            for line in lines:
-                try:
-                    toks = line.split()
-                    x = float(toks[0])
-                    y = float(toks[1])
-                    self.data_x = numpy.append(self.data_x, x)
-                    self.data_y = numpy.append(self.data_y, y)
-                    self.data_err = numpy.append(self.data_err, math.sqrt(y)+1000.0)
-                except:
-                    print "Error reading line: ", line
-                   
-        print "Lines read:", len(self.data_x)
-        
-
-if __name__ == "__main__": 
-    from sans.pr.core.pr_inversion import Cinvertor
-    pr = PrInverse()
-    pr.load("sphere_80.txt")
-    out, cov = pr.fit()
-    
-    print "output:"
-    print out
-    
Index: pr_inversion/setup.py
===================================================================
--- pr_inversion/setup.py	(revision 9e8dc223ee841261f4cf577f54920873d455660d)
+++ pr_inversion/setup.py	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -1,2 +1,5 @@
+"""
+    Setup script for the P(r) inversion module
+"""
 import sys, os
 
Index: _inversion/sphere_80.txt
===================================================================
--- pr_inversion/sphere_80.txt	(revision 9e8dc223ee841261f4cf577f54920873d455660d)
+++ 	(revision )
@@ -1,100 +1,0 @@
-<X>   <Y>
-0.0010101  2.14186e+008
-0.0020202  2.13348e+008
-0.0030303  2.11958e+008
-0.0040404  2.10025e+008
-0.00505051  2.07561e+008
-0.00606061  2.04584e+008
-0.00707071  2.01112e+008
-0.00808081  1.97169e+008
-0.00909091  1.92781e+008
-0.010101  1.87975e+008
-0.0111111  1.82783e+008
-0.0121212  1.77237e+008
-0.0131313  1.71373e+008
-0.0141414  1.65226e+008
-0.0151515  1.58833e+008
-0.0161616  1.52233e+008
-0.0171717  1.45465e+008
-0.0181818  1.38567e+008
-0.0191919  1.31578e+008
-0.020202  1.24536e+008
-0.0212121  1.17479e+008
-0.0222222  1.10442e+008
-0.0232323  1.03461e+008
-0.0242424  9.65692e+007
-0.0252525  8.97973e+007
-0.0262626  8.31748e+007
-0.0272727  7.67288e+007
-0.0282828  7.04839e+007
-0.0292929  6.4462e+007
-0.030303  5.86828e+007
-0.0313131  5.31627e+007
-0.0323232  4.79158e+007
-0.0333333  4.29533e+007
-0.0343434  3.82836e+007
-0.0353535  3.39126e+007
-0.0363636  2.98434e+007
-0.0373737  2.60768e+007
-0.0383838  2.2611e+007
-0.0393939  1.9442e+007
-0.040404  1.65639e+007
-0.0414141  1.39687e+007
-0.0424242  1.16467e+007
-0.0434343  9.58662e+006
-0.0444444  7.77602e+006
-0.0454545  6.20118e+006
-0.0464646  4.84751e+006
-0.0474747  3.69971e+006
-0.0484848  2.74197e+006
-0.0494949  1.95815e+006
-0.0505051  1.33203e+006
-0.0515152  847402
-0.0525253  488319
-0.0535354  239201
-0.0545455  84994.7
-0.0555556  11292.7
-0.0565657  4445.63
-0.0575758  51653.5
-0.0585859  141041
-0.059596  261717
-0.0606061  403816
-0.0616162  558522
-0.0626263  718084
-0.0636364  875805
-0.0646465  1.02603e+006
-0.0656566  1.1641e+006
-0.0666667  1.28634e+006
-0.0676768  1.38998e+006
-0.0686869  1.47309e+006
-0.069697  1.53454e+006
-0.0707071  1.57391e+006
-0.0717172  1.59141e+006
-0.0727273  1.5878e+006
-0.0737374  1.5643e+006
-0.0747475  1.52256e+006
-0.0757576  1.46449e+006
-0.0767677  1.39227e+006
-0.0777778  1.30823e+006
-0.0787879  1.21477e+006
-0.079798  1.11433e+006
-0.0808081  1.00933e+006
-0.0818182  902079
-0.0828283  794770
-0.0838384  689421
-0.0848485  587856
-0.0858586  491670
-0.0868687  402219
-0.0878788  320609
-0.0888889  247687
-0.089899  184050
-0.0909091  130047
-0.0919192  85790.3
-0.0929293  51176.4
-0.0939394  25900.5
-0.0949495  9481.12
-0.0959596  1283.93
-0.0969697  547.497
-0.0979798  6409.98
-0.0989899  17935.9
-0.1  34142.4
Index: _inversion/sphere_test_data.txt
===================================================================
--- pr_inversion/sphere_test_data.txt	(revision 9e8dc223ee841261f4cf577f54920873d455660d)
+++ 	(revision )
@@ -1,51 +1,0 @@
-<q>   <I_1D>
-0.01  1.30173e+008
-0.02  9.59565e+007
-0.03  5.57754e+007
-0.04  2.37208e+007
-0.05  6.0257e+006
-0.06  332209
-0.07  335963
-0.08  1.03749e+006
-0.09  816241
-0.1  234630
-0.11  230.644
-0.12  100168
-0.13  182129
-0.14  111803
-0.15  16326.8
-0.16  6931.71
-0.17  45283.6
-0.18  50971.8
-0.19  19812.5
-0.2  146.532
-0.21  9676.19
-0.22  21749.2
-0.23  15602.5
-0.24  2700.12
-0.25  1044.09
-0.26  8110.76
-0.27  10054.2
-0.28  4251.65
-0.29  38.5548
-0.3  2295.45
-0.31  5499.87
-0.32  4158.67
-0.33  752.025
-0.34  308.434
-0.35  2475.65
-0.36  3174.91
-0.37  1380.1
-0.38  11.2373
-0.39  815.932
-0.4  1988.73
-0.41  1531.36
-0.42  276.75
-0.43  127.297
-0.44  1001.82
-0.45  1297.13
-0.46  566.229
-0.47  3.50245
-0.48  365.098
-0.49  887.09
-0.5  684.787
Index: pr_inversion/test/sphere_test_data.txt
===================================================================
--- pr_inversion/test/sphere_test_data.txt	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
+++ pr_inversion/test/sphere_test_data.txt	(revision 896abb329f95875c87beccd0ba690ce449d0d8a2)
@@ -0,0 +1,51 @@
+<q>   <I_1D>
+0.01  1.30173e+008
+0.02  9.59565e+007
+0.03  5.57754e+007
+0.04  2.37208e+007
+0.05  6.0257e+006
+0.06  332209
+0.07  335963
+0.08  1.03749e+006
+0.09  816241
+0.1  234630
+0.11  230.644
+0.12  100168
+0.13  182129
+0.14  111803
+0.15  16326.8
+0.16  6931.71
+0.17  45283.6
+0.18  50971.8
+0.19  19812.5
+0.2  146.532
+0.21  9676.19
+0.22  21749.2
+0.23  15602.5
+0.24  2700.12
+0.25  1044.09
+0.26  8110.76
+0.27  10054.2
+0.28  4251.65
+0.29  38.5548
+0.3  2295.45
+0.31  5499.87
+0.32  4158.67
+0.33  752.025
+0.34  308.434
+0.35  2475.65
+0.36  3174.91
+0.37  1380.1
+0.38  11.2373
+0.39  815.932
+0.4  1988.73
+0.41  1531.36
+0.42  276.75
+0.43  127.297
+0.44  1001.82
+0.45  1297.13
+0.46  566.229
+0.47  3.50245
+0.48  365.098
+0.49  887.09
+0.5  684.787
