Index: nsmodels/src/python_wrapper/CBCCrystalModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CBCCrystalModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,620 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CBCCrystalModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY bcc.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "bcc.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CBCCrystalModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    BCCrystalModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CBCCrystalModel;
-
-
-static void
-CBCCrystalModel_dealloc(CBCCrystalModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CBCCrystalModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CBCCrystalModel *self;
-    
-    self = (CBCCrystalModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CBCCrystalModel_init(CBCCrystalModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new BCCrystalModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"dnn",Py_BuildValue("d",220.000000000000));
-        PyDict_SetItemString(self->params,"sldSph",Py_BuildValue("d",0.000003000000));
-        PyDict_SetItemString(self->params,"d_factor",Py_BuildValue("d",0.060000000000));
-        PyDict_SetItemString(self->params,"psi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",40.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000006300000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->phi.dispersion->accept_as_source(visitor, self->model->phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->psi.dispersion->accept_as_source(visitor, self->model->psi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "psi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->theta.dispersion->accept_as_source(visitor, self->model->theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "theta", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CBCCrystalModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CBCCrystalModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CBCCrystalModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CBCCrystalModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CBCCrystalModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(BCCrystalModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( BCCrystalModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CBCCrystalModelError, 
-                   "CBCCrystalModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CBCCrystalModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBCCrystalModelError, 
-	    	"CBCCrystalModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CBCCrystalModelError, 
-                   "CBCCrystalModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CBCCrystalModelError, 
-	    		"CBCCrystalModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CBCCrystalModelError, 
-                   "CBCCrystalModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CBCCrystalModelError, 
-                   "CBCCrystalModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CBCCrystalModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBCCrystalModelError, 
-	    	"CBCCrystalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CBCCrystalModelError, 
-	    		"CBCCrystalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CBCCrystalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CBCCrystalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CBCCrystalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CBCCrystalModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CBCCrystalModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBCCrystalModelError, 
-	    	"CBCCrystalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CBCCrystalModelError, 
-	    		"CBCCrystalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CBCCrystalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CBCCrystalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CBCCrystalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CBCCrystalModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CBCCrystalModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CBCCrystalModelError,
-	    	"CBCCrystalModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "phi")) {
-        self->model->phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "psi")) {
-        self->model->psi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "theta")) {
-        self->model->theta.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CBCCrystalModelError,
-	    	"CBCCrystalModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CBCCrystalModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CBCCrystalModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CBCCrystalModel",             /*tp_name*/
-    sizeof(CBCCrystalModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CBCCrystalModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CBCCrystalModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CBCCrystalModel_methods,             /* tp_methods */
-    CBCCrystalModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CBCCrystalModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CBCCrystalModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCBCCrystalModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CBCCrystalModelType) < 0)
-        return;
-
-    Py_INCREF(&CBCCrystalModelType);
-    PyModule_AddObject(module, "CBCCrystalModel", (PyObject *)&CBCCrystalModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CBCCrystalModel.error";
-    CBCCrystalModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CBCCrystalModelError", CBCCrystalModelError);
-}
-
Index: nsmodels/src/python_wrapper/CBarBellModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CBarBellModel.cpp	(revision 43ccd258f324d2df0daf578c7351aa1576ea3151)
+++ 	(revision )
@@ -1,628 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CBarBellModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/barbell.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-}
-
-#include "barbell.h"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CBarBellModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    BarBellModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CBarBellModel;
-
-
-static void
-CBarBellModel_dealloc(CBarBellModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CBarBellModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CBarBellModel *self;
-    
-    self = (CBarBellModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CBarBellModel_init(CBarBellModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new BarBellModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sld_barbell",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"len_bar",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"rad_bell",Py_BuildValue("d",40.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"rad_bar",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006300000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->rad_bar.dispersion->accept_as_source(visitor, self->model->rad_bar.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rad_bar", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->len_bar.dispersion->accept_as_source(visitor, self->model->len_bar.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "len_bar", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->rad_bell.dispersion->accept_as_source(visitor, self->model->rad_bell.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rad_bell", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->phi.dispersion->accept_as_source(visitor, self->model->phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->theta.dispersion->accept_as_source(visitor, self->model->theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "theta", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CBarBellModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CBarBellModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CBarBellModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CBarBellModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CBarBellModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(BarBellModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( BarBellModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CBarBellModelError, 
-                   "CBarBellModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CBarBellModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
-    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
-    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
-    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
-    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
-    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBarBellModelError, 
-	    	"CBarBellModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CBarBellModelError, 
-                   "CBarBellModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CBarBellModelError, 
-	    		"CBarBellModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CBarBellModelError, 
-                   "CBarBellModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CBarBellModelError, 
-                   "CBarBellModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CBarBellModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
-    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
-    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
-    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
-    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
-    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBarBellModelError, 
-	    	"CBarBellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CBarBellModelError, 
-	    		"CBarBellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CBarBellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CBarBellModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
-    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
-    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
-    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
-    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
-    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CBarBellModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
-    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
-    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
-    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
-    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
-    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBarBellModelError, 
-	    	"CBarBellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CBarBellModelError, 
-	    		"CBarBellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CBarBellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CBarBellModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CBarBellModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CBarBellModelError,
-	    	"CBarBellModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "rad_bar")) {
-        self->model->rad_bar.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "len_bar")) {
-        self->model->len_bar.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "rad_bell")) {
-        self->model->rad_bell.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "phi")) {
-        self->model->phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "theta")) {
-        self->model->theta.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CBarBellModelError,
-	    	"CBarBellModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CBarBellModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CBarBellModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CBarBellModel",             /*tp_name*/
-    sizeof(CBarBellModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CBarBellModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CBarBellModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CBarBellModel_methods,             /* tp_methods */
-    CBarBellModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CBarBellModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CBarBellModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCBarBellModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CBarBellModelType) < 0)
-        return;
-
-    Py_INCREF(&CBarBellModelType);
-    PyModule_AddObject(module, "CBarBellModel", (PyObject *)&CBarBellModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CBarBellModel.error";
-    CBarBellModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CBarBellModelError", CBarBellModelError);
-}
-
Index: nsmodels/src/python_wrapper/CBinaryHSModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CBinaryHSModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,584 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CBinaryHSModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY binaryHS.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "binaryHS.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CBinaryHSModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    BinaryHSModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CBinaryHSModel;
-
-
-static void
-CBinaryHSModel_dealloc(CBinaryHSModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CBinaryHSModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CBinaryHSModel *self;
-    
-    self = (CBinaryHSModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CBinaryHSModel_init(CBinaryHSModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new BinaryHSModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"vol_frac_ls",Py_BuildValue("d",0.100000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"vol_frac_ss",Py_BuildValue("d",0.200000000000));
-        PyDict_SetItemString(self->params,"solvent_sld",Py_BuildValue("d",0.000006360000));
-        PyDict_SetItemString(self->params,"ls_sld",Py_BuildValue("d",0.000003500000));
-        PyDict_SetItemString(self->params,"ss_sld",Py_BuildValue("d",0.000000500000));
-        PyDict_SetItemString(self->params,"s_radius",Py_BuildValue("d",25.000000000000));
-        PyDict_SetItemString(self->params,"l_radius",Py_BuildValue("d",100.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->l_radius.dispersion->accept_as_source(visitor, self->model->l_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "l_radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->s_radius.dispersion->accept_as_source(visitor, self->model->s_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "s_radius", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CBinaryHSModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CBinaryHSModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CBinaryHSModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CBinaryHSModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CBinaryHSModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(BinaryHSModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( BinaryHSModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CBinaryHSModelError, 
-                   "CBinaryHSModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CBinaryHSModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
-    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
-    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
-    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
-    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
-    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBinaryHSModelError, 
-	    	"CBinaryHSModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CBinaryHSModelError, 
-                   "CBinaryHSModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CBinaryHSModelError, 
-	    		"CBinaryHSModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CBinaryHSModelError, 
-                   "CBinaryHSModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CBinaryHSModelError, 
-                   "CBinaryHSModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CBinaryHSModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
-    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
-    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
-    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
-    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
-    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBinaryHSModelError, 
-	    	"CBinaryHSModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CBinaryHSModelError, 
-	    		"CBinaryHSModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CBinaryHSModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CBinaryHSModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CBinaryHSModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CBinaryHSModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
-    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
-    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
-    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
-    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
-    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CBinaryHSModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
-    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
-    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
-    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
-    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
-    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CBinaryHSModelError, 
-	    	"CBinaryHSModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CBinaryHSModelError, 
-	    		"CBinaryHSModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CBinaryHSModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CBinaryHSModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CBinaryHSModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CBinaryHSModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CBinaryHSModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CBinaryHSModelError,
-	    	"CBinaryHSModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "l_radius")) {
-        self->model->l_radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "s_radius")) {
-        self->model->s_radius.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CBinaryHSModelError,
-	    	"CBinaryHSModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CBinaryHSModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CBinaryHSModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CBinaryHSModel",             /*tp_name*/
-    sizeof(CBinaryHSModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CBinaryHSModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CBinaryHSModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CBinaryHSModel_methods,             /* tp_methods */
-    CBinaryHSModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CBinaryHSModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CBinaryHSModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCBinaryHSModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CBinaryHSModelType) < 0)
-        return;
-
-    Py_INCREF(&CBinaryHSModelType);
-    PyModule_AddObject(module, "CBinaryHSModel", (PyObject *)&CBinaryHSModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CBinaryHSModel.error";
-    CBinaryHSModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CBinaryHSModelError", CBinaryHSModelError);
-}
-
Index: nsmodels/src/python_wrapper/CCSParallelepipedModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCSParallelepipedModel.cpp	(revision df88829ada69c0e2705c41d796e0095d12a231db)
+++ 	(revision )
@@ -1,676 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CCSParallelepipedModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/csparallelepiped.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-}
-
-#include "csparallelepiped.h"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CCSParallelepipedModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    CSParallelepipedModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CCSParallelepipedModel;
-
-
-static void
-CCSParallelepipedModel_dealloc(CCSParallelepipedModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CCSParallelepipedModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CCSParallelepipedModel *self;
-    
-    self = (CCSParallelepipedModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CCSParallelepipedModel_init(CCSParallelepipedModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new CSParallelepipedModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"sld_rimB",Py_BuildValue("d",0.000004000000));
-        PyDict_SetItemString(self->params,"sld_rimC",Py_BuildValue("d",0.000002000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.060000000000));
-        PyDict_SetItemString(self->params,"parallel_psi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"midB",Py_BuildValue("d",75.000000000000));
-        PyDict_SetItemString(self->params,"parallel_theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"parallel_phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sld_pcore",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"sld_rimA",Py_BuildValue("d",0.000002000000));
-        PyDict_SetItemString(self->params,"shortA",Py_BuildValue("d",35.000000000000));
-        PyDict_SetItemString(self->params,"rimB",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"rimC",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"longC",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006000000));
-        PyDict_SetItemString(self->params,"rimA",Py_BuildValue("d",10.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->shortA.dispersion->accept_as_source(visitor, self->model->shortA.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "shortA", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->midB.dispersion->accept_as_source(visitor, self->model->midB.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "midB", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->longC.dispersion->accept_as_source(visitor, self->model->longC.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "longC", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->parallel_phi.dispersion->accept_as_source(visitor, self->model->parallel_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "parallel_phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->parallel_psi.dispersion->accept_as_source(visitor, self->model->parallel_psi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "parallel_psi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->parallel_theta.dispersion->accept_as_source(visitor, self->model->parallel_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "parallel_theta", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CCSParallelepipedModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CCSParallelepipedModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CCSParallelepipedModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CCSParallelepipedModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CCSParallelepipedModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(CSParallelepipedModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( CSParallelepipedModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CCSParallelepipedModelError, 
-                   "CCSParallelepipedModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CCSParallelepipedModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimB") );
-    self->model->sld_rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimC") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->midB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "midB") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->sld_pcore = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pcore") );
-    self->model->sld_rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimA") );
-    self->model->shortA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shortA") );
-    self->model->rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimB") );
-    self->model->rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimC") );
-    self->model->longC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longC") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimA") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "shortA");
-    self->model->shortA.dispersion->accept_as_destination(visitor, self->model->shortA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "midB");
-    self->model->midB.dispersion->accept_as_destination(visitor, self->model->midB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "longC");
-    self->model->longC.dispersion->accept_as_destination(visitor, self->model->longC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCSParallelepipedModelError, 
-	    	"CCSParallelepipedModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CCSParallelepipedModelError, 
-                   "CCSParallelepipedModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CCSParallelepipedModelError, 
-	    		"CCSParallelepipedModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CCSParallelepipedModelError, 
-                   "CCSParallelepipedModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CCSParallelepipedModelError, 
-                   "CCSParallelepipedModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CCSParallelepipedModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimB") );
-    self->model->sld_rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimC") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->midB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "midB") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->sld_pcore = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pcore") );
-    self->model->sld_rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimA") );
-    self->model->shortA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shortA") );
-    self->model->rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimB") );
-    self->model->rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimC") );
-    self->model->longC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longC") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimA") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "shortA");
-    self->model->shortA.dispersion->accept_as_destination(visitor, self->model->shortA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "midB");
-    self->model->midB.dispersion->accept_as_destination(visitor, self->model->midB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "longC");
-    self->model->longC.dispersion->accept_as_destination(visitor, self->model->longC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCSParallelepipedModelError, 
-	    	"CCSParallelepipedModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCSParallelepipedModelError, 
-	    		"CCSParallelepipedModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CCSParallelepipedModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CCSParallelepipedModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CCSParallelepipedModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CCSParallelepipedModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimB") );
-    self->model->sld_rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimC") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->midB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "midB") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->sld_pcore = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pcore") );
-    self->model->sld_rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimA") );
-    self->model->shortA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shortA") );
-    self->model->rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimB") );
-    self->model->rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimC") );
-    self->model->longC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longC") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimA") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "shortA");
-    self->model->shortA.dispersion->accept_as_destination(visitor, self->model->shortA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "midB");
-    self->model->midB.dispersion->accept_as_destination(visitor, self->model->midB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "longC");
-    self->model->longC.dispersion->accept_as_destination(visitor, self->model->longC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CCSParallelepipedModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimB") );
-    self->model->sld_rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimC") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->midB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "midB") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->sld_pcore = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pcore") );
-    self->model->sld_rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_rimA") );
-    self->model->shortA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shortA") );
-    self->model->rimB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimB") );
-    self->model->rimC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimC") );
-    self->model->longC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "longC") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rimA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rimA") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "shortA");
-    self->model->shortA.dispersion->accept_as_destination(visitor, self->model->shortA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "midB");
-    self->model->midB.dispersion->accept_as_destination(visitor, self->model->midB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "longC");
-    self->model->longC.dispersion->accept_as_destination(visitor, self->model->longC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCSParallelepipedModelError, 
-	    	"CCSParallelepipedModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCSParallelepipedModelError, 
-	    		"CCSParallelepipedModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CCSParallelepipedModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CCSParallelepipedModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CCSParallelepipedModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CCSParallelepipedModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CCSParallelepipedModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CCSParallelepipedModelError,
-	    	"CCSParallelepipedModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "shortA")) {
-        self->model->shortA.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "midB")) {
-        self->model->midB.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "longC")) {
-        self->model->longC.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "parallel_phi")) {
-        self->model->parallel_phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "parallel_psi")) {
-        self->model->parallel_psi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "parallel_theta")) {
-        self->model->parallel_theta.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CCSParallelepipedModelError,
-	    	"CCSParallelepipedModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CCSParallelepipedModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CCSParallelepipedModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CCSParallelepipedModel",             /*tp_name*/
-    sizeof(CCSParallelepipedModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CCSParallelepipedModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CCSParallelepipedModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CCSParallelepipedModel_methods,             /* tp_methods */
-    CCSParallelepipedModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CCSParallelepipedModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CCSParallelepipedModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCCSParallelepipedModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CCSParallelepipedModelType) < 0)
-        return;
-
-    Py_INCREF(&CCSParallelepipedModelType);
-    PyModule_AddObject(module, "CCSParallelepipedModel", (PyObject *)&CCSParallelepipedModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CCSParallelepipedModel.error";
-    CCSParallelepipedModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CCSParallelepipedModelError", CCSParallelepipedModelError);
-}
-
Index: nsmodels/src/python_wrapper/CCappedCylinderModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCappedCylinderModel.cpp	(revision 0c2389e37de84233866b9c1d939767aaa933ec16)
+++ 	(revision )
@@ -1,628 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CCappedCylinderModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/capcyl.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-}
-
-#include "capcyl.h"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CCappedCylinderModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    CappedCylinderModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CCappedCylinderModel;
-
-
-static void
-CCappedCylinderModel_dealloc(CCappedCylinderModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CCappedCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CCappedCylinderModel *self;
-    
-    self = (CCappedCylinderModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CCappedCylinderModel_init(CCappedCylinderModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new CappedCylinderModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"len_cyl",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"sld_capcyl",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"rad_cap",Py_BuildValue("d",40.000000000000));
-        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"rad_cyl",Py_BuildValue("d",20.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->rad_cyl.dispersion->accept_as_source(visitor, self->model->rad_cyl.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rad_cyl", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->len_cyl.dispersion->accept_as_source(visitor, self->model->len_cyl.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "len_cyl", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->rad_cap.dispersion->accept_as_source(visitor, self->model->rad_cap.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rad_cap", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->phi.dispersion->accept_as_source(visitor, self->model->phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->theta.dispersion->accept_as_source(visitor, self->model->theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "theta", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CCappedCylinderModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CCappedCylinderModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CCappedCylinderModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CCappedCylinderModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CCappedCylinderModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(CappedCylinderModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( CappedCylinderModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CCappedCylinderModelError, 
-                   "CCappedCylinderModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CCappedCylinderModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
-    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
-    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
-    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
-    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCappedCylinderModelError, 
-	    	"CCappedCylinderModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CCappedCylinderModelError, 
-                   "CCappedCylinderModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CCappedCylinderModelError, 
-	    		"CCappedCylinderModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CCappedCylinderModelError, 
-                   "CCappedCylinderModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CCappedCylinderModelError, 
-                   "CCappedCylinderModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CCappedCylinderModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
-    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
-    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
-    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
-    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCappedCylinderModelError, 
-	    	"CCappedCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCappedCylinderModelError, 
-	    		"CCappedCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CCappedCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CCappedCylinderModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
-    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
-    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
-    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
-    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CCappedCylinderModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
-    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
-    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
-    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
-    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCappedCylinderModelError, 
-	    	"CCappedCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCappedCylinderModelError, 
-	    		"CCappedCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CCappedCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CCappedCylinderModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CCappedCylinderModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CCappedCylinderModelError,
-	    	"CCappedCylinderModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "rad_cyl")) {
-        self->model->rad_cyl.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "len_cyl")) {
-        self->model->len_cyl.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "rad_cap")) {
-        self->model->rad_cap.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "phi")) {
-        self->model->phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "theta")) {
-        self->model->theta.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CCappedCylinderModelError,
-	    	"CCappedCylinderModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CCappedCylinderModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CCappedCylinderModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CCappedCylinderModel",             /*tp_name*/
-    sizeof(CCappedCylinderModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CCappedCylinderModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CCappedCylinderModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CCappedCylinderModel_methods,             /* tp_methods */
-    CCappedCylinderModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CCappedCylinderModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CCappedCylinderModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCCappedCylinderModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CCappedCylinderModelType) < 0)
-        return;
-
-    Py_INCREF(&CCappedCylinderModelType);
-    PyModule_AddObject(module, "CCappedCylinderModel", (PyObject *)&CCappedCylinderModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CCappedCylinderModel.error";
-    CCappedCylinderModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CCappedCylinderModelError", CCappedCylinderModelError);
-}
-
Index: nsmodels/src/python_wrapper/CCoreFourShellModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCoreFourShellModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,648 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CCoreFourShellModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY corefourshell.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "corefourshell.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CCoreFourShellModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    CoreFourShellModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CCoreFourShellModel;
-
-
-static void
-CCoreFourShellModel_dealloc(CCoreFourShellModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CCoreFourShellModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CCoreFourShellModel *self;
-    
-    self = (CCoreFourShellModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CCoreFourShellModel_init(CCoreFourShellModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new CoreFourShellModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"thick_shell4",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"sld_shell4",Py_BuildValue("d",0.000004000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sld_shell2",Py_BuildValue("d",0.000002000000));
-        PyDict_SetItemString(self->params,"thick_shell1",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell2",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"sld_shell1",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"thick_shell3",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"sld_core0",Py_BuildValue("d",0.000006400000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"rad_core0",Py_BuildValue("d",60.000000000000));
-        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006400000));
-        PyDict_SetItemString(self->params,"sld_shell3",Py_BuildValue("d",0.000003000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->rad_core0.dispersion->accept_as_source(visitor, self->model->rad_core0.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rad_core0", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell1.dispersion->accept_as_source(visitor, self->model->thick_shell1.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell1", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell2.dispersion->accept_as_source(visitor, self->model->thick_shell2.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell2", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell3.dispersion->accept_as_source(visitor, self->model->thick_shell3.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell3", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell4.dispersion->accept_as_source(visitor, self->model->thick_shell4.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell4", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CCoreFourShellModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CCoreFourShellModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CCoreFourShellModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CCoreFourShellModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CCoreFourShellModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(CoreFourShellModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( CoreFourShellModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CCoreFourShellModelError, 
-                   "CCoreFourShellModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CCoreFourShellModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->sld_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell4") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell2") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreFourShellModelError, 
-	    	"CCoreFourShellModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CCoreFourShellModelError, 
-                   "CCoreFourShellModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CCoreFourShellModelError, 
-	    		"CCoreFourShellModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CCoreFourShellModelError, 
-                   "CCoreFourShellModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CCoreFourShellModelError, 
-                   "CCoreFourShellModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CCoreFourShellModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->sld_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell4") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell2") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreFourShellModelError, 
-	    	"CCoreFourShellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreFourShellModelError, 
-	    		"CCoreFourShellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CCoreFourShellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CCoreFourShellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CCoreFourShellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CCoreFourShellModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->sld_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell4") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell2") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CCoreFourShellModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->sld_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell4") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell2") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreFourShellModelError, 
-	    	"CCoreFourShellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreFourShellModelError, 
-	    		"CCoreFourShellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CCoreFourShellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CCoreFourShellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CCoreFourShellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CCoreFourShellModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CCoreFourShellModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CCoreFourShellModelError,
-	    	"CCoreFourShellModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "rad_core0")) {
-        self->model->rad_core0.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell1")) {
-        self->model->thick_shell1.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell2")) {
-        self->model->thick_shell2.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell3")) {
-        self->model->thick_shell3.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell4")) {
-        self->model->thick_shell4.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CCoreFourShellModelError,
-	    	"CCoreFourShellModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CCoreFourShellModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CCoreFourShellModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CCoreFourShellModel",             /*tp_name*/
-    sizeof(CCoreFourShellModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CCoreFourShellModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CCoreFourShellModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CCoreFourShellModel_methods,             /* tp_methods */
-    CCoreFourShellModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CCoreFourShellModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CCoreFourShellModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCCoreFourShellModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CCoreFourShellModelType) < 0)
-        return;
-
-    Py_INCREF(&CCoreFourShellModelType);
-    PyModule_AddObject(module, "CCoreFourShellModel", (PyObject *)&CCoreFourShellModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CCoreFourShellModel.error";
-    CCoreFourShellModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CCoreFourShellModelError", CCoreFourShellModelError);
-}
-
Index: nsmodels/src/python_wrapper/CCoreShellCylinderModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCoreShellCylinderModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,633 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CCoreShellCylinderModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY core_shell_cylinder.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "core_shell_cylinder.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CCoreShellCylinderModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    CoreShellCylinderModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CCoreShellCylinderModel;
-
-
-static void
-CCoreShellCylinderModel_dealloc(CCoreShellCylinderModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CCoreShellCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CCoreShellCylinderModel *self;
-    
-    self = (CCoreShellCylinderModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CCoreShellCylinderModel_init(CCoreShellCylinderModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new CoreShellCylinderModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",90.000000000000));
-        PyDict_SetItemString(self->params,"solvent_sld",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"thickness",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"shell_sld",Py_BuildValue("d",0.000004000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thickness.dispersion->accept_as_source(visitor, self->model->thickness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thickness", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CCoreShellCylinderModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CCoreShellCylinderModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CCoreShellCylinderModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CCoreShellCylinderModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CCoreShellCylinderModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(CoreShellCylinderModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( CoreShellCylinderModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CCoreShellCylinderModelError, 
-                   "CCoreShellCylinderModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CCoreShellCylinderModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellCylinderModelError, 
-	    	"CCoreShellCylinderModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CCoreShellCylinderModelError, 
-                   "CCoreShellCylinderModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CCoreShellCylinderModelError, 
-	    		"CCoreShellCylinderModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CCoreShellCylinderModelError, 
-                   "CCoreShellCylinderModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CCoreShellCylinderModelError, 
-                   "CCoreShellCylinderModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CCoreShellCylinderModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellCylinderModelError, 
-	    	"CCoreShellCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreShellCylinderModelError, 
-	    		"CCoreShellCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CCoreShellCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CCoreShellCylinderModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CCoreShellCylinderModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellCylinderModelError, 
-	    	"CCoreShellCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreShellCylinderModelError, 
-	    		"CCoreShellCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CCoreShellCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CCoreShellCylinderModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CCoreShellCylinderModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CCoreShellCylinderModelError,
-	    	"CCoreShellCylinderModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thickness")) {
-        self->model->thickness.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "length")) {
-        self->model->length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_theta")) {
-        self->model->axis_theta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_phi")) {
-        self->model->axis_phi.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CCoreShellCylinderModelError,
-	    	"CCoreShellCylinderModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CCoreShellCylinderModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CCoreShellCylinderModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CCoreShellCylinderModel",             /*tp_name*/
-    sizeof(CCoreShellCylinderModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CCoreShellCylinderModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CCoreShellCylinderModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CCoreShellCylinderModel_methods,             /* tp_methods */
-    CCoreShellCylinderModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CCoreShellCylinderModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CCoreShellCylinderModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCCoreShellCylinderModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CCoreShellCylinderModelType) < 0)
-        return;
-
-    Py_INCREF(&CCoreShellCylinderModelType);
-    PyModule_AddObject(module, "CCoreShellCylinderModel", (PyObject *)&CCoreShellCylinderModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CCoreShellCylinderModel.error";
-    CCoreShellCylinderModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CCoreShellCylinderModelError", CCoreShellCylinderModelError);
-}
-
Index: nsmodels/src/python_wrapper/CCoreShellEllipsoidModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCoreShellEllipsoidModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,651 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CCoreShellEllipsoidModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY spheroid.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "spheroid.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CCoreShellEllipsoidModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    CoreShellEllipsoidModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CCoreShellEllipsoidModel;
-
-
-static void
-CCoreShellEllipsoidModel_dealloc(CCoreShellEllipsoidModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CCoreShellEllipsoidModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CCoreShellEllipsoidModel *self;
-    
-    self = (CCoreShellEllipsoidModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CCoreShellEllipsoidModel_init(CCoreShellEllipsoidModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new CoreShellEllipsoidModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sld_core",Py_BuildValue("d",0.000002000000));
-        PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"polar_shell",Py_BuildValue("d",30.000000000000));
-        PyDict_SetItemString(self->params,"sld_solvent",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"equat_shell",Py_BuildValue("d",250.000000000000));
-        PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"equat_core",Py_BuildValue("d",200.000000000000));
-        PyDict_SetItemString(self->params,"polar_core",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"sld_shell",Py_BuildValue("d",0.000001000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->equat_core.dispersion->accept_as_source(visitor, self->model->equat_core.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "equat_core", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->polar_core.dispersion->accept_as_source(visitor, self->model->polar_core.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "polar_core", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->equat_shell.dispersion->accept_as_source(visitor, self->model->equat_shell.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "equat_shell", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->polar_shell.dispersion->accept_as_source(visitor, self->model->polar_shell.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "polar_shell", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CCoreShellEllipsoidModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CCoreShellEllipsoidModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CCoreShellEllipsoidModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CCoreShellEllipsoidModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CCoreShellEllipsoidModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(CoreShellEllipsoidModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( CoreShellEllipsoidModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CCoreShellEllipsoidModelError, 
-                   "CCoreShellEllipsoidModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CCoreShellEllipsoidModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->polar_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_shell") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->equat_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_shell") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->equat_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_core") );
-    self->model->polar_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_core") );
-    self->model->sld_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_core");
-    self->model->equat_core.dispersion->accept_as_destination(visitor, self->model->equat_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_core");
-    self->model->polar_core.dispersion->accept_as_destination(visitor, self->model->polar_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_shell");
-    self->model->equat_shell.dispersion->accept_as_destination(visitor, self->model->equat_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_shell");
-    self->model->polar_shell.dispersion->accept_as_destination(visitor, self->model->polar_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellEllipsoidModelError, 
-	    	"CCoreShellEllipsoidModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CCoreShellEllipsoidModelError, 
-                   "CCoreShellEllipsoidModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CCoreShellEllipsoidModelError, 
-	    		"CCoreShellEllipsoidModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CCoreShellEllipsoidModelError, 
-                   "CCoreShellEllipsoidModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CCoreShellEllipsoidModelError, 
-                   "CCoreShellEllipsoidModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CCoreShellEllipsoidModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->polar_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_shell") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->equat_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_shell") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->equat_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_core") );
-    self->model->polar_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_core") );
-    self->model->sld_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_core");
-    self->model->equat_core.dispersion->accept_as_destination(visitor, self->model->equat_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_core");
-    self->model->polar_core.dispersion->accept_as_destination(visitor, self->model->polar_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_shell");
-    self->model->equat_shell.dispersion->accept_as_destination(visitor, self->model->equat_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_shell");
-    self->model->polar_shell.dispersion->accept_as_destination(visitor, self->model->polar_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellEllipsoidModelError, 
-	    	"CCoreShellEllipsoidModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreShellEllipsoidModelError, 
-	    		"CCoreShellEllipsoidModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CCoreShellEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CCoreShellEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CCoreShellEllipsoidModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CCoreShellEllipsoidModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->polar_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_shell") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->equat_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_shell") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->equat_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_core") );
-    self->model->polar_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_core") );
-    self->model->sld_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_core");
-    self->model->equat_core.dispersion->accept_as_destination(visitor, self->model->equat_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_core");
-    self->model->polar_core.dispersion->accept_as_destination(visitor, self->model->polar_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_shell");
-    self->model->equat_shell.dispersion->accept_as_destination(visitor, self->model->equat_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_shell");
-    self->model->polar_shell.dispersion->accept_as_destination(visitor, self->model->polar_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CCoreShellEllipsoidModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->polar_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_shell") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->equat_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_shell") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->equat_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "equat_core") );
-    self->model->polar_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "polar_core") );
-    self->model->sld_shell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_core");
-    self->model->equat_core.dispersion->accept_as_destination(visitor, self->model->equat_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_core");
-    self->model->polar_core.dispersion->accept_as_destination(visitor, self->model->polar_core.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "equat_shell");
-    self->model->equat_shell.dispersion->accept_as_destination(visitor, self->model->equat_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "polar_shell");
-    self->model->polar_shell.dispersion->accept_as_destination(visitor, self->model->polar_shell.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellEllipsoidModelError, 
-	    	"CCoreShellEllipsoidModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreShellEllipsoidModelError, 
-	    		"CCoreShellEllipsoidModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CCoreShellEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CCoreShellEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CCoreShellEllipsoidModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CCoreShellEllipsoidModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CCoreShellEllipsoidModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CCoreShellEllipsoidModelError,
-	    	"CCoreShellEllipsoidModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "equat_core")) {
-        self->model->equat_core.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "polar_core")) {
-        self->model->polar_core.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "equat_shell")) {
-        self->model->equat_shell.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "polar_shell")) {
-        self->model->polar_shell.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_phi")) {
-        self->model->axis_phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_theta")) {
-        self->model->axis_theta.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CCoreShellEllipsoidModelError,
-	    	"CCoreShellEllipsoidModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CCoreShellEllipsoidModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CCoreShellEllipsoidModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CCoreShellEllipsoidModel",             /*tp_name*/
-    sizeof(CCoreShellEllipsoidModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CCoreShellEllipsoidModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CCoreShellEllipsoidModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CCoreShellEllipsoidModel_methods,             /* tp_methods */
-    CCoreShellEllipsoidModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CCoreShellEllipsoidModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CCoreShellEllipsoidModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCCoreShellEllipsoidModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CCoreShellEllipsoidModelType) < 0)
-        return;
-
-    Py_INCREF(&CCoreShellEllipsoidModelType);
-    PyModule_AddObject(module, "CCoreShellEllipsoidModel", (PyObject *)&CCoreShellEllipsoidModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CCoreShellEllipsoidModel.error";
-    CCoreShellEllipsoidModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CCoreShellEllipsoidModelError", CCoreShellEllipsoidModelError);
-}
-
Index: nsmodels/src/python_wrapper/CCoreShellModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCoreShellModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,579 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CCoreShellModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY core_shell.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "core_shell.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CCoreShellModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    CoreShellModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CCoreShellModel;
-
-
-static void
-CCoreShellModel_dealloc(CCoreShellModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CCoreShellModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CCoreShellModel *self;
-    
-    self = (CCoreShellModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CCoreShellModel_init(CCoreShellModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new CoreShellModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"thickness",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"solvent_sld",Py_BuildValue("d",0.000003000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",60.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"shell_sld",Py_BuildValue("d",0.000002000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thickness.dispersion->accept_as_source(visitor, self->model->thickness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thickness", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CCoreShellModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CCoreShellModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CCoreShellModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CCoreShellModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CCoreShellModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(CoreShellModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( CoreShellModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CCoreShellModelError, 
-                   "CCoreShellModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CCoreShellModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellModelError, 
-	    	"CCoreShellModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CCoreShellModelError, 
-                   "CCoreShellModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CCoreShellModelError, 
-	    		"CCoreShellModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CCoreShellModelError, 
-                   "CCoreShellModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CCoreShellModelError, 
-                   "CCoreShellModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CCoreShellModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellModelError, 
-	    	"CCoreShellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreShellModelError, 
-	    		"CCoreShellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CCoreShellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CCoreShellModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CCoreShellModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCoreShellModelError, 
-	    	"CCoreShellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCoreShellModelError, 
-	    		"CCoreShellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CCoreShellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CCoreShellModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CCoreShellModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CCoreShellModelError,
-	    	"CCoreShellModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thickness")) {
-        self->model->thickness.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CCoreShellModelError,
-	    	"CCoreShellModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CCoreShellModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CCoreShellModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CCoreShellModel",             /*tp_name*/
-    sizeof(CCoreShellModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CCoreShellModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CCoreShellModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CCoreShellModel_methods,             /* tp_methods */
-    CCoreShellModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CCoreShellModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CCoreShellModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCCoreShellModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CCoreShellModelType) < 0)
-        return;
-
-    Py_INCREF(&CCoreShellModelType);
-    PyModule_AddObject(module, "CCoreShellModel", (PyObject *)&CCoreShellModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CCoreShellModel.error";
-    CCoreShellModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CCoreShellModelError", CCoreShellModelError);
-}
-
Index: nsmodels/src/python_wrapper/CCylinderModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCylinderModel.cpp	(revision dbddbf5ca23038d32d3e3e085da7bc8c67ddd7c0)
+++ 	(revision )
@@ -1,610 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CCylinderModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/cylinder.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-}
-
-#include "cylinder.h"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CCylinderModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    CylinderModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CCylinderModel;
-
-
-static void
-CCylinderModel_dealloc(CCylinderModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CCylinderModel *self;
-    
-    self = (CCylinderModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CCylinderModel_init(CCylinderModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new CylinderModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sldCyl",Py_BuildValue("d",0.000004000000));
-        PyDict_SetItemString(self->params,"cyl_theta",Py_BuildValue("d",60.000000000000));
-        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"cyl_phi",Py_BuildValue("d",60.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->cyl_theta.dispersion->accept_as_source(visitor, self->model->cyl_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "cyl_theta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->cyl_phi.dispersion->accept_as_source(visitor, self->model->cyl_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "cyl_phi", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CCylinderModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CCylinderModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CCylinderModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CCylinderModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CCylinderModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(CylinderModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( CylinderModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CCylinderModelError, 
-                   "CCylinderModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CCylinderModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCylinderModelError, 
-	    	"CCylinderModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CCylinderModelError, 
-                   "CCylinderModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CCylinderModelError, 
-	    		"CCylinderModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CCylinderModelError, 
-                   "CCylinderModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CCylinderModelError, 
-                   "CCylinderModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CCylinderModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCylinderModelError, 
-	    	"CCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCylinderModelError, 
-	    		"CCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CCylinderModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CCylinderModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CCylinderModelError, 
-	    	"CCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CCylinderModelError, 
-	    		"CCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CCylinderModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CCylinderModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CCylinderModelError,
-	    	"CCylinderModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "length")) {
-        self->model->length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "cyl_theta")) {
-        self->model->cyl_theta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "cyl_phi")) {
-        self->model->cyl_phi.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CCylinderModelError,
-	    	"CCylinderModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CCylinderModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CCylinderModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CCylinderModel",             /*tp_name*/
-    sizeof(CCylinderModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CCylinderModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CCylinderModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CCylinderModel_methods,             /* tp_methods */
-    CCylinderModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CCylinderModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CCylinderModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCCylinderModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CCylinderModelType) < 0)
-        return;
-
-    Py_INCREF(&CCylinderModelType);
-    PyModule_AddObject(module, "CCylinderModel", (PyObject *)&CCylinderModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CCylinderModel.error";
-    CCylinderModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CCylinderModelError", CCylinderModelError);
-}
-
Index: nsmodels/src/python_wrapper/CDiamCylFunc.cpp
===================================================================
--- sansmodels/src/python_wrapper/CDiamCylFunc.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,554 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CDiamCylFunc
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY DiamCyl.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "DiamCyl.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CDiamCylFuncError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    DiamCylFunc * model;
-    /// Log for unit testing
-    PyObject * log;
-} CDiamCylFunc;
-
-
-static void
-CDiamCylFunc_dealloc(CDiamCylFunc* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CDiamCylFunc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CDiamCylFunc *self;
-    
-    self = (CDiamCylFunc *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CDiamCylFunc_init(CDiamCylFunc *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new DiamCylFunc();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "length", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CDiamCylFunc_members[] = {
-    {name_params, T_OBJECT, offsetof(CDiamCylFunc, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CDiamCylFunc, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CDiamCylFunc, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CDiamCylFunc_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(DiamCylFunc* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( DiamCylFunc* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CDiamCylFuncError, 
-                   "CDiamCylFunc.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CDiamCylFunc *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CDiamCylFuncError, 
-	    	"CDiamCylFunc.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CDiamCylFuncError, 
-                   "CDiamCylFunc.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CDiamCylFuncError, 
-	    		"CDiamCylFunc.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CDiamCylFuncError, 
-                   "CDiamCylFunc.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CDiamCylFuncError, 
-                   "CDiamCylFunc.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CDiamCylFunc *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CDiamCylFuncError, 
-	    	"CDiamCylFunc.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CDiamCylFuncError, 
-	    		"CDiamCylFunc.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CDiamCylFunc_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CDiamCylFunc_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CDiamCylFunc_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CDiamCylFunc *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CDiamCylFunc *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CDiamCylFuncError, 
-	    	"CDiamCylFunc.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CDiamCylFuncError, 
-	    		"CDiamCylFunc.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CDiamCylFunc_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CDiamCylFunc_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CDiamCylFunc_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CDiamCylFunc *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CDiamCylFunc *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CDiamCylFuncError,
-	    	"CDiamCylFunc.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "length")) {
-        self->model->length.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CDiamCylFuncError,
-	    	"CDiamCylFunc.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CDiamCylFunc_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CDiamCylFuncType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CDiamCylFunc",             /*tp_name*/
-    sizeof(CDiamCylFunc),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CDiamCylFunc_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CDiamCylFunc objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CDiamCylFunc_methods,             /* tp_methods */
-    CDiamCylFunc_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CDiamCylFunc_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CDiamCylFunc_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCDiamCylFunc(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CDiamCylFuncType) < 0)
-        return;
-
-    Py_INCREF(&CDiamCylFuncType);
-    PyModule_AddObject(module, "CDiamCylFunc", (PyObject *)&CDiamCylFuncType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CDiamCylFunc.error";
-    CDiamCylFuncError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CDiamCylFuncError", CDiamCylFuncError);
-}
-
Index: nsmodels/src/python_wrapper/CDiamEllipFunc.cpp
===================================================================
--- sansmodels/src/python_wrapper/CDiamEllipFunc.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,554 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CDiamEllipFunc
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY DiamEllip.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "DiamEllip.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CDiamEllipFuncError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    DiamEllipFunc * model;
-    /// Log for unit testing
-    PyObject * log;
-} CDiamEllipFunc;
-
-
-static void
-CDiamEllipFunc_dealloc(CDiamEllipFunc* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CDiamEllipFunc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CDiamEllipFunc *self;
-    
-    self = (CDiamEllipFunc *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CDiamEllipFunc_init(CDiamEllipFunc *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new DiamEllipFunc();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"radius_b",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"radius_a",Py_BuildValue("d",20.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius_a.dispersion->accept_as_source(visitor, self->model->radius_a.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius_a", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->radius_b.dispersion->accept_as_source(visitor, self->model->radius_b.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius_b", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CDiamEllipFunc_members[] = {
-    {name_params, T_OBJECT, offsetof(CDiamEllipFunc, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CDiamEllipFunc, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CDiamEllipFunc, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CDiamEllipFunc_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(DiamEllipFunc* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( DiamEllipFunc* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CDiamEllipFuncError, 
-                   "CDiamEllipFunc.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CDiamEllipFunc *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CDiamEllipFuncError, 
-	    	"CDiamEllipFunc.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CDiamEllipFuncError, 
-                   "CDiamEllipFunc.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CDiamEllipFuncError, 
-	    		"CDiamEllipFunc.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CDiamEllipFuncError, 
-                   "CDiamEllipFunc.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CDiamEllipFuncError, 
-                   "CDiamEllipFunc.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CDiamEllipFunc *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CDiamEllipFuncError, 
-	    	"CDiamEllipFunc.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CDiamEllipFuncError, 
-	    		"CDiamEllipFunc.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CDiamEllipFunc_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CDiamEllipFunc_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CDiamEllipFunc_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CDiamEllipFunc *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CDiamEllipFunc *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CDiamEllipFuncError, 
-	    	"CDiamEllipFunc.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CDiamEllipFuncError, 
-	    		"CDiamEllipFunc.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CDiamEllipFunc_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CDiamEllipFunc_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CDiamEllipFunc_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CDiamEllipFunc *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CDiamEllipFunc *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CDiamEllipFuncError,
-	    	"CDiamEllipFunc.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius_a")) {
-        self->model->radius_a.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "radius_b")) {
-        self->model->radius_b.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CDiamEllipFuncError,
-	    	"CDiamEllipFunc.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CDiamEllipFunc_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CDiamEllipFuncType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CDiamEllipFunc",             /*tp_name*/
-    sizeof(CDiamEllipFunc),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CDiamEllipFunc_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CDiamEllipFunc objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CDiamEllipFunc_methods,             /* tp_methods */
-    CDiamEllipFunc_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CDiamEllipFunc_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CDiamEllipFunc_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCDiamEllipFunc(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CDiamEllipFuncType) < 0)
-        return;
-
-    Py_INCREF(&CDiamEllipFuncType);
-    PyModule_AddObject(module, "CDiamEllipFunc", (PyObject *)&CDiamEllipFuncType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CDiamEllipFunc.error";
-    CDiamEllipFuncError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CDiamEllipFuncError", CDiamEllipFuncError);
-}
-
Index: nsmodels/src/python_wrapper/CEllipsoidModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CEllipsoidModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,610 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CEllipsoidModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ellipsoid.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "ellipsoid.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CEllipsoidModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    EllipsoidModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CEllipsoidModel;
-
-
-static void
-CEllipsoidModel_dealloc(CEllipsoidModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CEllipsoidModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CEllipsoidModel *self;
-    
-    self = (CEllipsoidModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CEllipsoidModel_init(CEllipsoidModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new EllipsoidModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",90.000000000000));
-        PyDict_SetItemString(self->params,"radius_b",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"radius_a",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sldEll",Py_BuildValue("d",0.000004000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius_a.dispersion->accept_as_source(visitor, self->model->radius_a.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius_a", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->radius_b.dispersion->accept_as_source(visitor, self->model->radius_b.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius_b", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CEllipsoidModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CEllipsoidModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CEllipsoidModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CEllipsoidModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CEllipsoidModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(EllipsoidModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( EllipsoidModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CEllipsoidModelError, 
-                   "CEllipsoidModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CEllipsoidModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CEllipsoidModelError, 
-	    	"CEllipsoidModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CEllipsoidModelError, 
-                   "CEllipsoidModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CEllipsoidModelError, 
-	    		"CEllipsoidModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CEllipsoidModelError, 
-                   "CEllipsoidModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CEllipsoidModelError, 
-                   "CEllipsoidModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CEllipsoidModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CEllipsoidModelError, 
-	    	"CEllipsoidModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CEllipsoidModelError, 
-	    		"CEllipsoidModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CEllipsoidModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CEllipsoidModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CEllipsoidModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
-    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
-    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
-    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CEllipsoidModelError, 
-	    	"CEllipsoidModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CEllipsoidModelError, 
-	    		"CEllipsoidModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CEllipsoidModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CEllipsoidModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CEllipsoidModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CEllipsoidModelError,
-	    	"CEllipsoidModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius_a")) {
-        self->model->radius_a.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "radius_b")) {
-        self->model->radius_b.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_theta")) {
-        self->model->axis_theta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_phi")) {
-        self->model->axis_phi.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CEllipsoidModelError,
-	    	"CEllipsoidModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CEllipsoidModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CEllipsoidModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CEllipsoidModel",             /*tp_name*/
-    sizeof(CEllipsoidModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CEllipsoidModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CEllipsoidModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CEllipsoidModel_methods,             /* tp_methods */
-    CEllipsoidModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CEllipsoidModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CEllipsoidModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCEllipsoidModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CEllipsoidModelType) < 0)
-        return;
-
-    Py_INCREF(&CEllipsoidModelType);
-    PyModule_AddObject(module, "CEllipsoidModel", (PyObject *)&CEllipsoidModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CEllipsoidModel.error";
-    CEllipsoidModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CEllipsoidModelError", CEllipsoidModelError);
-}
-
Index: nsmodels/src/python_wrapper/CEllipticalCylinderModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CEllipticalCylinderModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,646 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CEllipticalCylinderModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY elliptical_cylinder.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "elliptical_cylinder.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CEllipticalCylinderModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    EllipticalCylinderModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CEllipticalCylinderModel;
-
-
-static void
-CEllipticalCylinderModel_dealloc(CEllipticalCylinderModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CEllipticalCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CEllipticalCylinderModel *self;
-    
-    self = (CEllipticalCylinderModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CEllipticalCylinderModel_init(CEllipticalCylinderModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new EllipticalCylinderModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sldCyl",Py_BuildValue("d",0.000004000000));
-        PyDict_SetItemString(self->params,"cyl_psi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"r_minor",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"cyl_theta",Py_BuildValue("d",90.000000000000));
-        PyDict_SetItemString(self->params,"r_ratio",Py_BuildValue("d",1.500000000000));
-        PyDict_SetItemString(self->params,"cyl_phi",Py_BuildValue("d",0.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->r_minor.dispersion->accept_as_source(visitor, self->model->r_minor.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "r_minor", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->r_ratio.dispersion->accept_as_source(visitor, self->model->r_ratio.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "r_ratio", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->cyl_theta.dispersion->accept_as_source(visitor, self->model->cyl_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "cyl_theta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->cyl_phi.dispersion->accept_as_source(visitor, self->model->cyl_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "cyl_phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->cyl_psi.dispersion->accept_as_source(visitor, self->model->cyl_psi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "cyl_psi", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CEllipticalCylinderModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CEllipticalCylinderModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CEllipticalCylinderModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CEllipticalCylinderModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CEllipticalCylinderModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(EllipticalCylinderModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( EllipticalCylinderModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CEllipticalCylinderModelError, 
-                   "CEllipticalCylinderModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CEllipticalCylinderModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_psi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->r_minor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_minor") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->r_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_ratio") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_minor");
-    self->model->r_minor.dispersion->accept_as_destination(visitor, self->model->r_minor.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_ratio");
-    self->model->r_ratio.dispersion->accept_as_destination(visitor, self->model->r_ratio.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_psi");
-    self->model->cyl_psi.dispersion->accept_as_destination(visitor, self->model->cyl_psi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CEllipticalCylinderModelError, 
-	    	"CEllipticalCylinderModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CEllipticalCylinderModelError, 
-                   "CEllipticalCylinderModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CEllipticalCylinderModelError, 
-	    		"CEllipticalCylinderModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CEllipticalCylinderModelError, 
-                   "CEllipticalCylinderModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CEllipticalCylinderModelError, 
-                   "CEllipticalCylinderModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CEllipticalCylinderModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_psi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->r_minor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_minor") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->r_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_ratio") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_minor");
-    self->model->r_minor.dispersion->accept_as_destination(visitor, self->model->r_minor.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_ratio");
-    self->model->r_ratio.dispersion->accept_as_destination(visitor, self->model->r_ratio.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_psi");
-    self->model->cyl_psi.dispersion->accept_as_destination(visitor, self->model->cyl_psi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CEllipticalCylinderModelError, 
-	    	"CEllipticalCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CEllipticalCylinderModelError, 
-	    		"CEllipticalCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CEllipticalCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CEllipticalCylinderModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_psi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->r_minor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_minor") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->r_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_ratio") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_minor");
-    self->model->r_minor.dispersion->accept_as_destination(visitor, self->model->r_minor.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_ratio");
-    self->model->r_ratio.dispersion->accept_as_destination(visitor, self->model->r_ratio.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_psi");
-    self->model->cyl_psi.dispersion->accept_as_destination(visitor, self->model->cyl_psi.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CEllipticalCylinderModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->cyl_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_psi") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->r_minor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_minor") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->cyl_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_theta") );
-    self->model->r_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "r_ratio") );
-    self->model->cyl_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cyl_phi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_minor");
-    self->model->r_minor.dispersion->accept_as_destination(visitor, self->model->r_minor.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "r_ratio");
-    self->model->r_ratio.dispersion->accept_as_destination(visitor, self->model->r_ratio.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_theta");
-    self->model->cyl_theta.dispersion->accept_as_destination(visitor, self->model->cyl_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_phi");
-    self->model->cyl_phi.dispersion->accept_as_destination(visitor, self->model->cyl_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "cyl_psi");
-    self->model->cyl_psi.dispersion->accept_as_destination(visitor, self->model->cyl_psi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CEllipticalCylinderModelError, 
-	    	"CEllipticalCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CEllipticalCylinderModelError, 
-	    		"CEllipticalCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CEllipticalCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CEllipticalCylinderModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CEllipticalCylinderModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CEllipticalCylinderModelError,
-	    	"CEllipticalCylinderModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "r_minor")) {
-        self->model->r_minor.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "r_ratio")) {
-        self->model->r_ratio.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "length")) {
-        self->model->length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "cyl_theta")) {
-        self->model->cyl_theta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "cyl_phi")) {
-        self->model->cyl_phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "cyl_psi")) {
-        self->model->cyl_psi.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CEllipticalCylinderModelError,
-	    	"CEllipticalCylinderModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CEllipticalCylinderModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CEllipticalCylinderModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CEllipticalCylinderModel",             /*tp_name*/
-    sizeof(CEllipticalCylinderModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CEllipticalCylinderModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CEllipticalCylinderModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CEllipticalCylinderModel_methods,             /* tp_methods */
-    CEllipticalCylinderModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CEllipticalCylinderModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CEllipticalCylinderModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCEllipticalCylinderModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CEllipticalCylinderModelType) < 0)
-        return;
-
-    Py_INCREF(&CEllipticalCylinderModelType);
-    PyModule_AddObject(module, "CEllipticalCylinderModel", (PyObject *)&CEllipticalCylinderModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CEllipticalCylinderModel.error";
-    CEllipticalCylinderModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CEllipticalCylinderModelError", CEllipticalCylinderModelError);
-}
-
Index: nsmodels/src/python_wrapper/CFCCrystalModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CFCCrystalModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,620 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CFCCrystalModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY fcc.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "fcc.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CFCCrystalModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    FCCrystalModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CFCCrystalModel;
-
-
-static void
-CFCCrystalModel_dealloc(CFCCrystalModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CFCCrystalModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CFCCrystalModel *self;
-    
-    self = (CFCCrystalModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CFCCrystalModel_init(CFCCrystalModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new FCCrystalModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"dnn",Py_BuildValue("d",220.000000000000));
-        PyDict_SetItemString(self->params,"sldSph",Py_BuildValue("d",0.000003000000));
-        PyDict_SetItemString(self->params,"d_factor",Py_BuildValue("d",0.060000000000));
-        PyDict_SetItemString(self->params,"psi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",40.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000006300000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->phi.dispersion->accept_as_source(visitor, self->model->phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->psi.dispersion->accept_as_source(visitor, self->model->psi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "psi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->theta.dispersion->accept_as_source(visitor, self->model->theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "theta", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CFCCrystalModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CFCCrystalModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CFCCrystalModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CFCCrystalModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CFCCrystalModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(FCCrystalModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( FCCrystalModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CFCCrystalModelError, 
-                   "CFCCrystalModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CFCCrystalModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFCCrystalModelError, 
-	    	"CFCCrystalModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CFCCrystalModelError, 
-                   "CFCCrystalModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CFCCrystalModelError, 
-	    		"CFCCrystalModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CFCCrystalModelError, 
-                   "CFCCrystalModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CFCCrystalModelError, 
-                   "CFCCrystalModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CFCCrystalModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFCCrystalModelError, 
-	    	"CFCCrystalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFCCrystalModelError, 
-	    		"CFCCrystalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CFCCrystalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CFCCrystalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CFCCrystalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CFCCrystalModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CFCCrystalModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->dnn = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dnn") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->d_factor = PyFloat_AsDouble( PyDict_GetItemString(self->params, "d_factor") );
-    self->model->psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "psi") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
-    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "psi");
-    self->model->psi.dispersion->accept_as_destination(visitor, self->model->psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
-    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFCCrystalModelError, 
-	    	"CFCCrystalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFCCrystalModelError, 
-	    		"CFCCrystalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CFCCrystalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CFCCrystalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CFCCrystalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CFCCrystalModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CFCCrystalModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CFCCrystalModelError,
-	    	"CFCCrystalModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "phi")) {
-        self->model->phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "psi")) {
-        self->model->psi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "theta")) {
-        self->model->theta.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CFCCrystalModelError,
-	    	"CFCCrystalModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CFCCrystalModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CFCCrystalModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CFCCrystalModel",             /*tp_name*/
-    sizeof(CFCCrystalModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CFCCrystalModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CFCCrystalModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CFCCrystalModel_methods,             /* tp_methods */
-    CFCCrystalModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CFCCrystalModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CFCCrystalModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCFCCrystalModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CFCCrystalModelType) < 0)
-        return;
-
-    Py_INCREF(&CFCCrystalModelType);
-    PyModule_AddObject(module, "CFCCrystalModel", (PyObject *)&CFCCrystalModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CFCCrystalModel.error";
-    CFCCrystalModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CFCCrystalModelError", CFCCrystalModelError);
-}
-
Index: nsmodels/src/python_wrapper/CFlexCylEllipXModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CFlexCylEllipXModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,610 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CFlexCylEllipXModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY flexcyl_ellipX.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "flexcyl_ellipX.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CFlexCylEllipXModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    FlexCylEllipXModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CFlexCylEllipXModel;
-
-
-static void
-CFlexCylEllipXModel_dealloc(CFlexCylEllipXModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CFlexCylEllipXModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CFlexCylEllipXModel *self;
-    
-    self = (CFlexCylEllipXModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CFlexCylEllipXModel_init(CFlexCylEllipXModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new FlexCylEllipXModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sldCyl",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"axis_ratio",Py_BuildValue("d",1.500000000000));
-        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",1000.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000100000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"kuhn_length",Py_BuildValue("d",100.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->kuhn_length.dispersion->accept_as_source(visitor, self->model->kuhn_length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "kuhn_length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_ratio.dispersion->accept_as_source(visitor, self->model->axis_ratio.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_ratio", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CFlexCylEllipXModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CFlexCylEllipXModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CFlexCylEllipXModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CFlexCylEllipXModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CFlexCylEllipXModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(FlexCylEllipXModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( FlexCylEllipXModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CFlexCylEllipXModelError, 
-                   "CFlexCylEllipXModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CFlexCylEllipXModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->axis_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_ratio") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_ratio");
-    self->model->axis_ratio.dispersion->accept_as_destination(visitor, self->model->axis_ratio.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFlexCylEllipXModelError, 
-	    	"CFlexCylEllipXModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CFlexCylEllipXModelError, 
-                   "CFlexCylEllipXModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CFlexCylEllipXModelError, 
-	    		"CFlexCylEllipXModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CFlexCylEllipXModelError, 
-                   "CFlexCylEllipXModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CFlexCylEllipXModelError, 
-                   "CFlexCylEllipXModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CFlexCylEllipXModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->axis_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_ratio") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_ratio");
-    self->model->axis_ratio.dispersion->accept_as_destination(visitor, self->model->axis_ratio.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFlexCylEllipXModelError, 
-	    	"CFlexCylEllipXModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFlexCylEllipXModelError, 
-	    		"CFlexCylEllipXModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CFlexCylEllipXModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CFlexCylEllipXModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CFlexCylEllipXModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CFlexCylEllipXModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->axis_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_ratio") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_ratio");
-    self->model->axis_ratio.dispersion->accept_as_destination(visitor, self->model->axis_ratio.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CFlexCylEllipXModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->axis_ratio = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_ratio") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_ratio");
-    self->model->axis_ratio.dispersion->accept_as_destination(visitor, self->model->axis_ratio.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFlexCylEllipXModelError, 
-	    	"CFlexCylEllipXModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFlexCylEllipXModelError, 
-	    		"CFlexCylEllipXModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CFlexCylEllipXModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CFlexCylEllipXModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CFlexCylEllipXModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CFlexCylEllipXModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CFlexCylEllipXModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CFlexCylEllipXModelError,
-	    	"CFlexCylEllipXModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "length")) {
-        self->model->length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "kuhn_length")) {
-        self->model->kuhn_length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_ratio")) {
-        self->model->axis_ratio.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CFlexCylEllipXModelError,
-	    	"CFlexCylEllipXModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CFlexCylEllipXModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CFlexCylEllipXModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CFlexCylEllipXModel",             /*tp_name*/
-    sizeof(CFlexCylEllipXModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CFlexCylEllipXModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CFlexCylEllipXModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CFlexCylEllipXModel_methods,             /* tp_methods */
-    CFlexCylEllipXModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CFlexCylEllipXModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CFlexCylEllipXModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCFlexCylEllipXModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CFlexCylEllipXModelType) < 0)
-        return;
-
-    Py_INCREF(&CFlexCylEllipXModelType);
-    PyModule_AddObject(module, "CFlexCylEllipXModel", (PyObject *)&CFlexCylEllipXModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CFlexCylEllipXModel.error";
-    CFlexCylEllipXModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CFlexCylEllipXModelError", CFlexCylEllipXModelError);
-}
-
Index: nsmodels/src/python_wrapper/CFlexibleCylinderModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CFlexibleCylinderModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,592 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CFlexibleCylinderModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY flexible_cylinder.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "flexible_cylinder.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CFlexibleCylinderModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    FlexibleCylinderModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CFlexibleCylinderModel;
-
-
-static void
-CFlexibleCylinderModel_dealloc(CFlexibleCylinderModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CFlexibleCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CFlexibleCylinderModel *self;
-    
-    self = (CFlexibleCylinderModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CFlexibleCylinderModel_init(CFlexibleCylinderModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new FlexibleCylinderModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sldCyl",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",1000.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000100000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"kuhn_length",Py_BuildValue("d",100.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->kuhn_length.dispersion->accept_as_source(visitor, self->model->kuhn_length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "kuhn_length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CFlexibleCylinderModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CFlexibleCylinderModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CFlexibleCylinderModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CFlexibleCylinderModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CFlexibleCylinderModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(FlexibleCylinderModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( FlexibleCylinderModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CFlexibleCylinderModelError, 
-                   "CFlexibleCylinderModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CFlexibleCylinderModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFlexibleCylinderModelError, 
-	    	"CFlexibleCylinderModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CFlexibleCylinderModelError, 
-                   "CFlexibleCylinderModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CFlexibleCylinderModelError, 
-	    		"CFlexibleCylinderModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CFlexibleCylinderModelError, 
-                   "CFlexibleCylinderModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CFlexibleCylinderModelError, 
-                   "CFlexibleCylinderModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CFlexibleCylinderModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFlexibleCylinderModelError, 
-	    	"CFlexibleCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFlexibleCylinderModelError, 
-	    		"CFlexibleCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CFlexibleCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CFlexibleCylinderModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CFlexibleCylinderModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
-    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFlexibleCylinderModelError, 
-	    	"CFlexibleCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFlexibleCylinderModelError, 
-	    		"CFlexibleCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CFlexibleCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CFlexibleCylinderModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CFlexibleCylinderModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CFlexibleCylinderModelError,
-	    	"CFlexibleCylinderModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "length")) {
-        self->model->length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "kuhn_length")) {
-        self->model->kuhn_length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CFlexibleCylinderModelError,
-	    	"CFlexibleCylinderModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CFlexibleCylinderModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CFlexibleCylinderModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CFlexibleCylinderModel",             /*tp_name*/
-    sizeof(CFlexibleCylinderModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CFlexibleCylinderModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CFlexibleCylinderModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CFlexibleCylinderModel_methods,             /* tp_methods */
-    CFlexibleCylinderModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CFlexibleCylinderModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CFlexibleCylinderModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCFlexibleCylinderModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CFlexibleCylinderModelType) < 0)
-        return;
-
-    Py_INCREF(&CFlexibleCylinderModelType);
-    PyModule_AddObject(module, "CFlexibleCylinderModel", (PyObject *)&CFlexibleCylinderModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CFlexibleCylinderModel.error";
-    CFlexibleCylinderModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CFlexibleCylinderModelError", CFlexibleCylinderModelError);
-}
-
Index: nsmodels/src/python_wrapper/CFractalModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CFractalModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,566 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CFractalModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY fractal.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "fractal.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CFractalModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    FractalModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CFractalModel;
-
-
-static void
-CFractalModel_dealloc(CFractalModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CFractalModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CFractalModel *self;
-    
-    self = (CFractalModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CFractalModel_init(CFractalModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new FractalModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",0.050000000000));
-        PyDict_SetItemString(self->params,"fractal_dim",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000006350000));
-        PyDict_SetItemString(self->params,"cor_length",Py_BuildValue("d",100.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",5.000000000000));
-        PyDict_SetItemString(self->params,"sldBlock",Py_BuildValue("d",0.000002000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CFractalModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CFractalModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CFractalModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CFractalModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CFractalModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(FractalModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( FractalModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CFractalModelError, 
-                   "CFractalModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CFractalModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->fractal_dim = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fractal_dim") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->cor_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cor_length") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->sldBlock = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldBlock") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFractalModelError, 
-	    	"CFractalModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CFractalModelError, 
-                   "CFractalModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CFractalModelError, 
-	    		"CFractalModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CFractalModelError, 
-                   "CFractalModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CFractalModelError, 
-                   "CFractalModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CFractalModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->fractal_dim = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fractal_dim") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->cor_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cor_length") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->sldBlock = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldBlock") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFractalModelError, 
-	    	"CFractalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFractalModelError, 
-	    		"CFractalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CFractalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CFractalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CFractalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CFractalModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->fractal_dim = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fractal_dim") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->cor_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cor_length") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->sldBlock = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldBlock") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CFractalModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->fractal_dim = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fractal_dim") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->cor_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "cor_length") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->sldBlock = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldBlock") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFractalModelError, 
-	    	"CFractalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFractalModelError, 
-	    		"CFractalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CFractalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CFractalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CFractalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CFractalModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CFractalModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CFractalModelError,
-	    	"CFractalModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CFractalModelError,
-	    	"CFractalModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CFractalModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CFractalModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CFractalModel",             /*tp_name*/
-    sizeof(CFractalModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CFractalModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CFractalModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CFractalModel_methods,             /* tp_methods */
-    CFractalModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CFractalModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CFractalModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCFractalModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CFractalModelType) < 0)
-        return;
-
-    Py_INCREF(&CFractalModelType);
-    PyModule_AddObject(module, "CFractalModel", (PyObject *)&CFractalModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CFractalModel.error";
-    CFractalModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CFractalModelError", CFractalModelError);
-}
-
Index: nsmodels/src/python_wrapper/CFuzzySphereModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CFuzzySphereModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,574 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CFuzzySphereModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY fuzzysphere.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "fuzzysphere.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CFuzzySphereModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    FuzzySphereModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CFuzzySphereModel;
-
-
-static void
-CFuzzySphereModel_dealloc(CFuzzySphereModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CFuzzySphereModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CFuzzySphereModel *self;
-    
-    self = (CFuzzySphereModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CFuzzySphereModel_init(CFuzzySphereModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new FuzzySphereModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",0.010000000000));
-        PyDict_SetItemString(self->params,"sldSph",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",60.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000003000000));
-        PyDict_SetItemString(self->params,"fuzziness",Py_BuildValue("d",10.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->fuzziness.dispersion->accept_as_source(visitor, self->model->fuzziness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "fuzziness", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CFuzzySphereModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CFuzzySphereModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CFuzzySphereModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CFuzzySphereModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CFuzzySphereModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(FuzzySphereModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( FuzzySphereModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CFuzzySphereModelError, 
-                   "CFuzzySphereModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CFuzzySphereModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->fuzziness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fuzziness") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "fuzziness");
-    self->model->fuzziness.dispersion->accept_as_destination(visitor, self->model->fuzziness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFuzzySphereModelError, 
-	    	"CFuzzySphereModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CFuzzySphereModelError, 
-                   "CFuzzySphereModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CFuzzySphereModelError, 
-	    		"CFuzzySphereModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CFuzzySphereModelError, 
-                   "CFuzzySphereModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CFuzzySphereModelError, 
-                   "CFuzzySphereModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CFuzzySphereModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->fuzziness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fuzziness") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "fuzziness");
-    self->model->fuzziness.dispersion->accept_as_destination(visitor, self->model->fuzziness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFuzzySphereModelError, 
-	    	"CFuzzySphereModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFuzzySphereModelError, 
-	    		"CFuzzySphereModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CFuzzySphereModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CFuzzySphereModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CFuzzySphereModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CFuzzySphereModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->fuzziness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fuzziness") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "fuzziness");
-    self->model->fuzziness.dispersion->accept_as_destination(visitor, self->model->fuzziness.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CFuzzySphereModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldSph = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSph") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->fuzziness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fuzziness") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "fuzziness");
-    self->model->fuzziness.dispersion->accept_as_destination(visitor, self->model->fuzziness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CFuzzySphereModelError, 
-	    	"CFuzzySphereModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CFuzzySphereModelError, 
-	    		"CFuzzySphereModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CFuzzySphereModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CFuzzySphereModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CFuzzySphereModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CFuzzySphereModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CFuzzySphereModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CFuzzySphereModelError,
-	    	"CFuzzySphereModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "fuzziness")) {
-        self->model->fuzziness.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CFuzzySphereModelError,
-	    	"CFuzzySphereModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CFuzzySphereModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CFuzzySphereModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CFuzzySphereModel",             /*tp_name*/
-    sizeof(CFuzzySphereModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CFuzzySphereModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CFuzzySphereModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CFuzzySphereModel_methods,             /* tp_methods */
-    CFuzzySphereModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CFuzzySphereModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CFuzzySphereModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCFuzzySphereModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CFuzzySphereModelType) < 0)
-        return;
-
-    Py_INCREF(&CFuzzySphereModelType);
-    PyModule_AddObject(module, "CFuzzySphereModel", (PyObject *)&CFuzzySphereModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CFuzzySphereModel.error";
-    CFuzzySphereModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CFuzzySphereModelError", CFuzzySphereModelError);
-}
-
Index: nsmodels/src/python_wrapper/CGaussian.cpp
===================================================================
--- sansmodels/src/python_wrapper/CGaussian.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,533 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CGaussian
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY gaussian.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "gaussian.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CGaussianError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    Gaussian * model;
-    /// Log for unit testing
-    PyObject * log;
-} CGaussian;
-
-
-static void
-CGaussian_dealloc(CGaussian* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CGaussian_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CGaussian *self;
-    
-    self = (CGaussian *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CGaussian_init(CGaussian *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new Gaussian();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sigma",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"center",Py_BuildValue("d",0.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CGaussian_members[] = {
-    {name_params, T_OBJECT, offsetof(CGaussian, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CGaussian, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CGaussian, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CGaussian_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(Gaussian* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( Gaussian* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CGaussianError, 
-                   "CGaussian.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CGaussian *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CGaussianError, 
-	    	"CGaussian.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CGaussianError, 
-                   "CGaussian.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CGaussianError, 
-	    		"CGaussian.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CGaussianError, 
-                   "CGaussian.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CGaussianError, 
-                   "CGaussian.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CGaussian *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CGaussianError, 
-	    	"CGaussian.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CGaussianError, 
-	    		"CGaussian.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CGaussian_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CGaussian_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CGaussian_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CGaussian *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CGaussian *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CGaussianError, 
-	    	"CGaussian.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CGaussianError, 
-	    		"CGaussian.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CGaussian_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CGaussian_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CGaussian_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CGaussian *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CGaussian *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CGaussianError,
-	    	"CGaussian.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
- {
-	    PyErr_SetString(CGaussianError,
-	    	"CGaussian.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CGaussian_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CGaussianType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CGaussian",             /*tp_name*/
-    sizeof(CGaussian),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CGaussian_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CGaussian objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CGaussian_methods,             /* tp_methods */
-    CGaussian_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CGaussian_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CGaussian_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCGaussian(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CGaussianType) < 0)
-        return;
-
-    Py_INCREF(&CGaussianType);
-    PyModule_AddObject(module, "CGaussian", (PyObject *)&CGaussianType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CGaussian.error";
-    CGaussianError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CGaussianError", CGaussianError);
-}
-
Index: nsmodels/src/python_wrapper/CHardsphereStructure.cpp
===================================================================
--- sansmodels/src/python_wrapper/CHardsphereStructure.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,541 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CHardsphereStructure
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY Hardsphere.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "Hardsphere.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CHardsphereStructureError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    HardsphereStructure * model;
-    /// Log for unit testing
-    PyObject * log;
-} CHardsphereStructure;
-
-
-static void
-CHardsphereStructure_dealloc(CHardsphereStructure* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CHardsphereStructure_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CHardsphereStructure *self;
-    
-    self = (CHardsphereStructure *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CHardsphereStructure_init(CHardsphereStructure *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new HardsphereStructure();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"effect_radius",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"volfraction",Py_BuildValue("d",0.200000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->effect_radius.dispersion->accept_as_source(visitor, self->model->effect_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "effect_radius", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CHardsphereStructure_members[] = {
-    {name_params, T_OBJECT, offsetof(CHardsphereStructure, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CHardsphereStructure, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CHardsphereStructure, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CHardsphereStructure_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(HardsphereStructure* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( HardsphereStructure* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CHardsphereStructureError, 
-                   "CHardsphereStructure.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CHardsphereStructure *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHardsphereStructureError, 
-	    	"CHardsphereStructure.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CHardsphereStructureError, 
-                   "CHardsphereStructure.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CHardsphereStructureError, 
-	    		"CHardsphereStructure.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CHardsphereStructureError, 
-                   "CHardsphereStructure.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CHardsphereStructureError, 
-                   "CHardsphereStructure.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CHardsphereStructure *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHardsphereStructureError, 
-	    	"CHardsphereStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CHardsphereStructureError, 
-	    		"CHardsphereStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CHardsphereStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CHardsphereStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CHardsphereStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CHardsphereStructure *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CHardsphereStructure *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHardsphereStructureError, 
-	    	"CHardsphereStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CHardsphereStructureError, 
-	    		"CHardsphereStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CHardsphereStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CHardsphereStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CHardsphereStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CHardsphereStructure *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CHardsphereStructure *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CHardsphereStructureError,
-	    	"CHardsphereStructure.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "effect_radius")) {
-        self->model->effect_radius.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CHardsphereStructureError,
-	    	"CHardsphereStructure.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CHardsphereStructure_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CHardsphereStructureType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CHardsphereStructure",             /*tp_name*/
-    sizeof(CHardsphereStructure),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CHardsphereStructure_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CHardsphereStructure objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CHardsphereStructure_methods,             /* tp_methods */
-    CHardsphereStructure_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CHardsphereStructure_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CHardsphereStructure_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCHardsphereStructure(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CHardsphereStructureType) < 0)
-        return;
-
-    Py_INCREF(&CHardsphereStructureType);
-    PyModule_AddObject(module, "CHardsphereStructure", (PyObject *)&CHardsphereStructureType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CHardsphereStructure.error";
-    CHardsphereStructureError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CHardsphereStructureError", CHardsphereStructureError);
-}
-
Index: nsmodels/src/python_wrapper/CHayterMSAStructure.cpp
===================================================================
--- sansmodels/src/python_wrapper/CHayterMSAStructure.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,561 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CHayterMSAStructure
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY HayterMSA.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "HayterMSA.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CHayterMSAStructureError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    HayterMSAStructure * model;
-    /// Log for unit testing
-    PyObject * log;
-} CHayterMSAStructure;
-
-
-static void
-CHayterMSAStructure_dealloc(CHayterMSAStructure* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CHayterMSAStructure_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CHayterMSAStructure *self;
-    
-    self = (CHayterMSAStructure *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CHayterMSAStructure_init(CHayterMSAStructure *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new HayterMSAStructure();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"temperature",Py_BuildValue("d",318.160000000000));
-        PyDict_SetItemString(self->params,"saltconc",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"dielectconst",Py_BuildValue("d",71.080000000000));
-        PyDict_SetItemString(self->params,"volfraction",Py_BuildValue("d",0.019200000000));
-        PyDict_SetItemString(self->params,"charge",Py_BuildValue("d",19.000000000000));
-        PyDict_SetItemString(self->params,"effect_radius",Py_BuildValue("d",20.750000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->effect_radius.dispersion->accept_as_source(visitor, self->model->effect_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "effect_radius", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CHayterMSAStructure_members[] = {
-    {name_params, T_OBJECT, offsetof(CHayterMSAStructure, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CHayterMSAStructure, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CHayterMSAStructure, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CHayterMSAStructure_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(HayterMSAStructure* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( HayterMSAStructure* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CHayterMSAStructureError, 
-                   "CHayterMSAStructure.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CHayterMSAStructure *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->temperature = PyFloat_AsDouble( PyDict_GetItemString(self->params, "temperature") );
-    self->model->saltconc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "saltconc") );
-    self->model->dielectconst = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dielectconst") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->charge = PyFloat_AsDouble( PyDict_GetItemString(self->params, "charge") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHayterMSAStructureError, 
-	    	"CHayterMSAStructure.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CHayterMSAStructureError, 
-                   "CHayterMSAStructure.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CHayterMSAStructureError, 
-	    		"CHayterMSAStructure.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CHayterMSAStructureError, 
-                   "CHayterMSAStructure.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CHayterMSAStructureError, 
-                   "CHayterMSAStructure.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CHayterMSAStructure *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->temperature = PyFloat_AsDouble( PyDict_GetItemString(self->params, "temperature") );
-    self->model->saltconc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "saltconc") );
-    self->model->dielectconst = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dielectconst") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->charge = PyFloat_AsDouble( PyDict_GetItemString(self->params, "charge") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHayterMSAStructureError, 
-	    	"CHayterMSAStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CHayterMSAStructureError, 
-	    		"CHayterMSAStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CHayterMSAStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CHayterMSAStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CHayterMSAStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CHayterMSAStructure *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->temperature = PyFloat_AsDouble( PyDict_GetItemString(self->params, "temperature") );
-    self->model->saltconc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "saltconc") );
-    self->model->dielectconst = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dielectconst") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->charge = PyFloat_AsDouble( PyDict_GetItemString(self->params, "charge") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CHayterMSAStructure *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->temperature = PyFloat_AsDouble( PyDict_GetItemString(self->params, "temperature") );
-    self->model->saltconc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "saltconc") );
-    self->model->dielectconst = PyFloat_AsDouble( PyDict_GetItemString(self->params, "dielectconst") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->charge = PyFloat_AsDouble( PyDict_GetItemString(self->params, "charge") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHayterMSAStructureError, 
-	    	"CHayterMSAStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CHayterMSAStructureError, 
-	    		"CHayterMSAStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CHayterMSAStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CHayterMSAStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CHayterMSAStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CHayterMSAStructure *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CHayterMSAStructure *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CHayterMSAStructureError,
-	    	"CHayterMSAStructure.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "effect_radius")) {
-        self->model->effect_radius.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CHayterMSAStructureError,
-	    	"CHayterMSAStructure.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CHayterMSAStructure_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CHayterMSAStructureType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CHayterMSAStructure",             /*tp_name*/
-    sizeof(CHayterMSAStructure),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CHayterMSAStructure_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CHayterMSAStructure objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CHayterMSAStructure_methods,             /* tp_methods */
-    CHayterMSAStructure_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CHayterMSAStructure_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CHayterMSAStructure_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCHayterMSAStructure(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CHayterMSAStructureType) < 0)
-        return;
-
-    Py_INCREF(&CHayterMSAStructureType);
-    PyModule_AddObject(module, "CHayterMSAStructure", (PyObject *)&CHayterMSAStructureType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CHayterMSAStructure.error";
-    CHayterMSAStructureError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CHayterMSAStructureError", CHayterMSAStructureError);
-}
-
Index: nsmodels/src/python_wrapper/CHollowCylinderModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CHollowCylinderModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,628 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CHollowCylinderModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY hollow_cylinder.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "hollow_cylinder.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CHollowCylinderModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    HollowCylinderModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CHollowCylinderModel;
-
-
-static void
-CHollowCylinderModel_dealloc(CHollowCylinderModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CHollowCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CHollowCylinderModel *self;
-    
-    self = (CHollowCylinderModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CHollowCylinderModel_init(CHollowCylinderModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new HollowCylinderModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sldCyl",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"core_radius",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",90.000000000000));
-        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.010000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",30.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->core_radius.dispersion->accept_as_source(visitor, self->model->core_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "core_radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CHollowCylinderModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CHollowCylinderModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CHollowCylinderModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CHollowCylinderModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CHollowCylinderModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(HollowCylinderModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( HollowCylinderModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CHollowCylinderModelError, 
-                   "CHollowCylinderModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CHollowCylinderModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHollowCylinderModelError, 
-	    	"CHollowCylinderModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CHollowCylinderModelError, 
-                   "CHollowCylinderModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CHollowCylinderModelError, 
-	    		"CHollowCylinderModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CHollowCylinderModelError, 
-                   "CHollowCylinderModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CHollowCylinderModelError, 
-                   "CHollowCylinderModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CHollowCylinderModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHollowCylinderModelError, 
-	    	"CHollowCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CHollowCylinderModelError, 
-	    		"CHollowCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CHollowCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CHollowCylinderModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CHollowCylinderModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sldCyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldCyl") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "length");
-    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CHollowCylinderModelError, 
-	    	"CHollowCylinderModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CHollowCylinderModelError, 
-	    		"CHollowCylinderModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CHollowCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CHollowCylinderModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CHollowCylinderModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CHollowCylinderModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CHollowCylinderModelError,
-	    	"CHollowCylinderModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "core_radius")) {
-        self->model->core_radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "length")) {
-        self->model->length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_theta")) {
-        self->model->axis_theta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_phi")) {
-        self->model->axis_phi.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CHollowCylinderModelError,
-	    	"CHollowCylinderModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CHollowCylinderModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CHollowCylinderModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CHollowCylinderModel",             /*tp_name*/
-    sizeof(CHollowCylinderModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CHollowCylinderModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CHollowCylinderModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CHollowCylinderModel_methods,             /* tp_methods */
-    CHollowCylinderModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CHollowCylinderModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CHollowCylinderModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCHollowCylinderModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CHollowCylinderModelType) < 0)
-        return;
-
-    Py_INCREF(&CHollowCylinderModelType);
-    PyModule_AddObject(module, "CHollowCylinderModel", (PyObject *)&CHollowCylinderModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CHollowCylinderModel.error";
-    CHollowCylinderModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CHollowCylinderModelError", CHollowCylinderModelError);
-}
-
Index: nsmodels/src/python_wrapper/CLamellarFFHGModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CLamellarFFHGModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,579 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CLamellarFFHGModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY lamellarFF_HG.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "lamellarFF_HG.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CLamellarFFHGModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    LamellarFFHGModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CLamellarFFHGModel;
-
-
-static void
-CLamellarFFHGModel_dealloc(CLamellarFFHGModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CLamellarFFHGModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CLamellarFFHGModel *self;
-    
-    self = (CLamellarFFHGModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CLamellarFFHGModel_init(CLamellarFFHGModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new LamellarFFHGModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"h_thickness",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"sld_tail",Py_BuildValue("d",0.000000400000));
-        PyDict_SetItemString(self->params,"sld_solvent",Py_BuildValue("d",0.000006000000));
-        PyDict_SetItemString(self->params,"t_length",Py_BuildValue("d",15.000000000000));
-        PyDict_SetItemString(self->params,"sld_head",Py_BuildValue("d",0.000003000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->t_length.dispersion->accept_as_source(visitor, self->model->t_length.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "t_length", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->h_thickness.dispersion->accept_as_source(visitor, self->model->h_thickness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "h_thickness", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CLamellarFFHGModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CLamellarFFHGModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CLamellarFFHGModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CLamellarFFHGModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CLamellarFFHGModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(LamellarFFHGModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( LamellarFFHGModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CLamellarFFHGModelError, 
-                   "CLamellarFFHGModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CLamellarFFHGModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
-    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
-    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarFFHGModelError, 
-	    	"CLamellarFFHGModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CLamellarFFHGModelError, 
-                   "CLamellarFFHGModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CLamellarFFHGModelError, 
-	    		"CLamellarFFHGModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CLamellarFFHGModelError, 
-                   "CLamellarFFHGModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CLamellarFFHGModelError, 
-                   "CLamellarFFHGModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CLamellarFFHGModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
-    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
-    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarFFHGModelError, 
-	    	"CLamellarFFHGModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarFFHGModelError, 
-	    		"CLamellarFFHGModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CLamellarFFHGModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CLamellarFFHGModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
-    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
-    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CLamellarFFHGModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->h_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "h_thickness") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->t_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "t_length") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "t_length");
-    self->model->t_length.dispersion->accept_as_destination(visitor, self->model->t_length.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "h_thickness");
-    self->model->h_thickness.dispersion->accept_as_destination(visitor, self->model->h_thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarFFHGModelError, 
-	    	"CLamellarFFHGModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarFFHGModelError, 
-	    		"CLamellarFFHGModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CLamellarFFHGModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CLamellarFFHGModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CLamellarFFHGModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CLamellarFFHGModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CLamellarFFHGModelError,
-	    	"CLamellarFFHGModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "t_length")) {
-        self->model->t_length.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "h_thickness")) {
-        self->model->h_thickness.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CLamellarFFHGModelError,
-	    	"CLamellarFFHGModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CLamellarFFHGModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CLamellarFFHGModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CLamellarFFHGModel",             /*tp_name*/
-    sizeof(CLamellarFFHGModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CLamellarFFHGModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CLamellarFFHGModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CLamellarFFHGModel_methods,             /* tp_methods */
-    CLamellarFFHGModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CLamellarFFHGModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CLamellarFFHGModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCLamellarFFHGModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CLamellarFFHGModelType) < 0)
-        return;
-
-    Py_INCREF(&CLamellarFFHGModelType);
-    PyModule_AddObject(module, "CLamellarFFHGModel", (PyObject *)&CLamellarFFHGModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CLamellarFFHGModel.error";
-    CLamellarFFHGModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CLamellarFFHGModelError", CLamellarFFHGModelError);
-}
-
Index: nsmodels/src/python_wrapper/CLamellarModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CLamellarModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,556 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CLamellarModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY lamellar.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "lamellar.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CLamellarModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    LamellarModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CLamellarModel;
-
-
-static void
-CLamellarModel_dealloc(CLamellarModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CLamellarModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CLamellarModel *self;
-    
-    self = (CLamellarModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CLamellarModel_init(CLamellarModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new LamellarModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"sld_sol",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"bi_thick",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sld_bi",Py_BuildValue("d",0.000001000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->bi_thick.dispersion->accept_as_source(visitor, self->model->bi_thick.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "bi_thick", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CLamellarModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CLamellarModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CLamellarModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CLamellarModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CLamellarModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(LamellarModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( LamellarModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CLamellarModelError, 
-                   "CLamellarModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CLamellarModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bi_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bi_thick") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "bi_thick");
-    self->model->bi_thick.dispersion->accept_as_destination(visitor, self->model->bi_thick.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarModelError, 
-	    	"CLamellarModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CLamellarModelError, 
-                   "CLamellarModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CLamellarModelError, 
-	    		"CLamellarModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CLamellarModelError, 
-                   "CLamellarModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CLamellarModelError, 
-                   "CLamellarModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CLamellarModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bi_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bi_thick") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "bi_thick");
-    self->model->bi_thick.dispersion->accept_as_destination(visitor, self->model->bi_thick.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarModelError, 
-	    	"CLamellarModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarModelError, 
-	    		"CLamellarModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CLamellarModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CLamellarModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CLamellarModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CLamellarModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bi_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bi_thick") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "bi_thick");
-    self->model->bi_thick.dispersion->accept_as_destination(visitor, self->model->bi_thick.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CLamellarModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bi_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bi_thick") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "bi_thick");
-    self->model->bi_thick.dispersion->accept_as_destination(visitor, self->model->bi_thick.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarModelError, 
-	    	"CLamellarModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarModelError, 
-	    		"CLamellarModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CLamellarModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CLamellarModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CLamellarModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CLamellarModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CLamellarModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CLamellarModelError,
-	    	"CLamellarModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "bi_thick")) {
-        self->model->bi_thick.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CLamellarModelError,
-	    	"CLamellarModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CLamellarModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CLamellarModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CLamellarModel",             /*tp_name*/
-    sizeof(CLamellarModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CLamellarModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CLamellarModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CLamellarModel_methods,             /* tp_methods */
-    CLamellarModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CLamellarModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CLamellarModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCLamellarModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CLamellarModelType) < 0)
-        return;
-
-    Py_INCREF(&CLamellarModelType);
-    PyModule_AddObject(module, "CLamellarModel", (PyObject *)&CLamellarModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CLamellarModel.error";
-    CLamellarModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CLamellarModelError", CLamellarModelError);
-}
-
Index: nsmodels/src/python_wrapper/CLamellarPCrystalModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CLamellarPCrystalModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,571 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CLamellarPCrystalModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY lamellarPC.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "lamellarPC.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CLamellarPCrystalModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    LamellarPCrystalModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CLamellarPCrystalModel;
-
-
-static void
-CLamellarPCrystalModel_dealloc(CLamellarPCrystalModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CLamellarPCrystalModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CLamellarPCrystalModel *self;
-    
-    self = (CLamellarPCrystalModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CLamellarPCrystalModel_init(CLamellarPCrystalModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new LamellarPCrystalModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"Nlayers",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"spacing",Py_BuildValue("d",250.000000000000));
-        PyDict_SetItemString(self->params,"sld_solvent",Py_BuildValue("d",0.000006340000));
-        PyDict_SetItemString(self->params,"thickness",Py_BuildValue("d",33.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"pd_spacing",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sld_layer",Py_BuildValue("d",0.000001000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->thickness.dispersion->accept_as_source(visitor, self->model->thickness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thickness", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CLamellarPCrystalModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CLamellarPCrystalModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CLamellarPCrystalModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CLamellarPCrystalModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CLamellarPCrystalModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(LamellarPCrystalModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( LamellarPCrystalModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CLamellarPCrystalModelError, 
-                   "CLamellarPCrystalModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CLamellarPCrystalModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->Nlayers = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nlayers") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->pd_spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "pd_spacing") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_layer = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_layer") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPCrystalModelError, 
-	    	"CLamellarPCrystalModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CLamellarPCrystalModelError, 
-                   "CLamellarPCrystalModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CLamellarPCrystalModelError, 
-	    		"CLamellarPCrystalModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CLamellarPCrystalModelError, 
-                   "CLamellarPCrystalModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CLamellarPCrystalModelError, 
-                   "CLamellarPCrystalModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CLamellarPCrystalModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->Nlayers = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nlayers") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->pd_spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "pd_spacing") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_layer = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_layer") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPCrystalModelError, 
-	    	"CLamellarPCrystalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarPCrystalModelError, 
-	    		"CLamellarPCrystalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CLamellarPCrystalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CLamellarPCrystalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CLamellarPCrystalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CLamellarPCrystalModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->Nlayers = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nlayers") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->pd_spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "pd_spacing") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_layer = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_layer") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CLamellarPCrystalModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->Nlayers = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nlayers") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->pd_spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "pd_spacing") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_layer = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_layer") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPCrystalModelError, 
-	    	"CLamellarPCrystalModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarPCrystalModelError, 
-	    		"CLamellarPCrystalModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CLamellarPCrystalModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CLamellarPCrystalModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CLamellarPCrystalModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CLamellarPCrystalModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CLamellarPCrystalModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CLamellarPCrystalModelError,
-	    	"CLamellarPCrystalModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "thickness")) {
-        self->model->thickness.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CLamellarPCrystalModelError,
-	    	"CLamellarPCrystalModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CLamellarPCrystalModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CLamellarPCrystalModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CLamellarPCrystalModel",             /*tp_name*/
-    sizeof(CLamellarPCrystalModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CLamellarPCrystalModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CLamellarPCrystalModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CLamellarPCrystalModel_methods,             /* tp_methods */
-    CLamellarPCrystalModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CLamellarPCrystalModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CLamellarPCrystalModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCLamellarPCrystalModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CLamellarPCrystalModelType) < 0)
-        return;
-
-    Py_INCREF(&CLamellarPCrystalModelType);
-    PyModule_AddObject(module, "CLamellarPCrystalModel", (PyObject *)&CLamellarPCrystalModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CLamellarPCrystalModel.error";
-    CLamellarPCrystalModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CLamellarPCrystalModelError", CLamellarPCrystalModelError);
-}
-
Index: nsmodels/src/python_wrapper/CLamellarPSHGModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CLamellarPSHGModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,607 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CLamellarPSHGModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY lamellarPS_HG.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "lamellarPS_HG.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CLamellarPSHGModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    LamellarPSHGModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CLamellarPSHGModel;
-
-
-static void
-CLamellarPSHGModel_dealloc(CLamellarPSHGModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CLamellarPSHGModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CLamellarPSHGModel *self;
-    
-    self = (CLamellarPSHGModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CLamellarPSHGModel_init(CLamellarPSHGModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new LamellarPSHGModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"n_plates",Py_BuildValue("d",30.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"deltaT",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"spacing",Py_BuildValue("d",40.000000000000));
-        PyDict_SetItemString(self->params,"sld_tail",Py_BuildValue("d",0.000000400000));
-        PyDict_SetItemString(self->params,"sld_solvent",Py_BuildValue("d",0.000006000000));
-        PyDict_SetItemString(self->params,"caille",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"sld_head",Py_BuildValue("d",0.000002000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"deltaH",Py_BuildValue("d",2.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->deltaT.dispersion->accept_as_source(visitor, self->model->deltaT.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "deltaT", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->deltaH.dispersion->accept_as_source(visitor, self->model->deltaH.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "deltaH", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->spacing.dispersion->accept_as_source(visitor, self->model->spacing.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "spacing", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CLamellarPSHGModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CLamellarPSHGModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CLamellarPSHGModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CLamellarPSHGModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CLamellarPSHGModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(LamellarPSHGModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( LamellarPSHGModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CLamellarPSHGModelError, 
-                   "CLamellarPSHGModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CLamellarPSHGModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->deltaT = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaT") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->deltaH = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaH") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaT");
-    self->model->deltaT.dispersion->accept_as_destination(visitor, self->model->deltaT.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaH");
-    self->model->deltaH.dispersion->accept_as_destination(visitor, self->model->deltaH.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPSHGModelError, 
-	    	"CLamellarPSHGModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CLamellarPSHGModelError, 
-                   "CLamellarPSHGModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CLamellarPSHGModelError, 
-	    		"CLamellarPSHGModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CLamellarPSHGModelError, 
-                   "CLamellarPSHGModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CLamellarPSHGModelError, 
-                   "CLamellarPSHGModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CLamellarPSHGModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->deltaT = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaT") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->deltaH = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaH") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaT");
-    self->model->deltaT.dispersion->accept_as_destination(visitor, self->model->deltaT.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaH");
-    self->model->deltaH.dispersion->accept_as_destination(visitor, self->model->deltaH.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPSHGModelError, 
-	    	"CLamellarPSHGModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarPSHGModelError, 
-	    		"CLamellarPSHGModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CLamellarPSHGModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CLamellarPSHGModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CLamellarPSHGModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CLamellarPSHGModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->deltaT = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaT") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->deltaH = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaH") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaT");
-    self->model->deltaT.dispersion->accept_as_destination(visitor, self->model->deltaT.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaH");
-    self->model->deltaH.dispersion->accept_as_destination(visitor, self->model->deltaH.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CLamellarPSHGModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->deltaT = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaT") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
-    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->deltaH = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaH") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaT");
-    self->model->deltaT.dispersion->accept_as_destination(visitor, self->model->deltaT.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "deltaH");
-    self->model->deltaH.dispersion->accept_as_destination(visitor, self->model->deltaH.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPSHGModelError, 
-	    	"CLamellarPSHGModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarPSHGModelError, 
-	    		"CLamellarPSHGModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CLamellarPSHGModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CLamellarPSHGModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CLamellarPSHGModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CLamellarPSHGModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CLamellarPSHGModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CLamellarPSHGModelError,
-	    	"CLamellarPSHGModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "deltaT")) {
-        self->model->deltaT.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "deltaH")) {
-        self->model->deltaH.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "spacing")) {
-        self->model->spacing.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CLamellarPSHGModelError,
-	    	"CLamellarPSHGModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CLamellarPSHGModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CLamellarPSHGModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CLamellarPSHGModel",             /*tp_name*/
-    sizeof(CLamellarPSHGModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CLamellarPSHGModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CLamellarPSHGModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CLamellarPSHGModel_methods,             /* tp_methods */
-    CLamellarPSHGModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CLamellarPSHGModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CLamellarPSHGModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCLamellarPSHGModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CLamellarPSHGModelType) < 0)
-        return;
-
-    Py_INCREF(&CLamellarPSHGModelType);
-    PyModule_AddObject(module, "CLamellarPSHGModel", (PyObject *)&CLamellarPSHGModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CLamellarPSHGModel.error";
-    CLamellarPSHGModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CLamellarPSHGModelError", CLamellarPSHGModelError);
-}
-
Index: nsmodels/src/python_wrapper/CLamellarPSModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CLamellarPSModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,584 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CLamellarPSModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY lamellarPS.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "lamellarPS.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CLamellarPSModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    LamellarPSModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CLamellarPSModel;
-
-
-static void
-CLamellarPSModel_dealloc(CLamellarPSModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CLamellarPSModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CLamellarPSModel *self;
-    
-    self = (CLamellarPSModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CLamellarPSModel_init(CLamellarPSModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new LamellarPSModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"n_plates",Py_BuildValue("d",20.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sld_sol",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"delta",Py_BuildValue("d",30.000000000000));
-        PyDict_SetItemString(self->params,"spacing",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"caille",Py_BuildValue("d",0.100000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sld_bi",Py_BuildValue("d",0.000006300000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->delta.dispersion->accept_as_source(visitor, self->model->delta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "delta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->spacing.dispersion->accept_as_source(visitor, self->model->spacing.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "spacing", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CLamellarPSModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CLamellarPSModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CLamellarPSModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CLamellarPSModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CLamellarPSModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(LamellarPSModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( LamellarPSModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CLamellarPSModelError, 
-                   "CLamellarPSModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CLamellarPSModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->delta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "delta") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "delta");
-    self->model->delta.dispersion->accept_as_destination(visitor, self->model->delta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPSModelError, 
-	    	"CLamellarPSModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CLamellarPSModelError, 
-                   "CLamellarPSModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CLamellarPSModelError, 
-	    		"CLamellarPSModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CLamellarPSModelError, 
-                   "CLamellarPSModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CLamellarPSModelError, 
-                   "CLamellarPSModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CLamellarPSModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->delta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "delta") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "delta");
-    self->model->delta.dispersion->accept_as_destination(visitor, self->model->delta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPSModelError, 
-	    	"CLamellarPSModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarPSModelError, 
-	    		"CLamellarPSModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CLamellarPSModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CLamellarPSModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CLamellarPSModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CLamellarPSModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->delta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "delta") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "delta");
-    self->model->delta.dispersion->accept_as_destination(visitor, self->model->delta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CLamellarPSModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sld_sol = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_sol") );
-    self->model->delta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "delta") );
-    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
-    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_bi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_bi") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "delta");
-    self->model->delta.dispersion->accept_as_destination(visitor, self->model->delta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
-    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLamellarPSModelError, 
-	    	"CLamellarPSModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLamellarPSModelError, 
-	    		"CLamellarPSModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CLamellarPSModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CLamellarPSModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CLamellarPSModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CLamellarPSModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CLamellarPSModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CLamellarPSModelError,
-	    	"CLamellarPSModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "delta")) {
-        self->model->delta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "spacing")) {
-        self->model->spacing.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CLamellarPSModelError,
-	    	"CLamellarPSModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CLamellarPSModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CLamellarPSModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CLamellarPSModel",             /*tp_name*/
-    sizeof(CLamellarPSModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CLamellarPSModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CLamellarPSModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CLamellarPSModel_methods,             /* tp_methods */
-    CLamellarPSModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CLamellarPSModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CLamellarPSModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCLamellarPSModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CLamellarPSModelType) < 0)
-        return;
-
-    Py_INCREF(&CLamellarPSModelType);
-    PyModule_AddObject(module, "CLamellarPSModel", (PyObject *)&CLamellarPSModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CLamellarPSModel.error";
-    CLamellarPSModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CLamellarPSModelError", CLamellarPSModelError);
-}
-
Index: nsmodels/src/python_wrapper/CLogNormal.cpp
===================================================================
--- sansmodels/src/python_wrapper/CLogNormal.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,533 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CLogNormal
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY logNormal.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "logNormal.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CLogNormalError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    LogNormal * model;
-    /// Log for unit testing
-    PyObject * log;
-} CLogNormal;
-
-
-static void
-CLogNormal_dealloc(CLogNormal* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CLogNormal_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CLogNormal *self;
-    
-    self = (CLogNormal *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CLogNormal_init(CLogNormal *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new LogNormal();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sigma",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"center",Py_BuildValue("d",0.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CLogNormal_members[] = {
-    {name_params, T_OBJECT, offsetof(CLogNormal, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CLogNormal, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CLogNormal, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CLogNormal_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(LogNormal* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( LogNormal* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CLogNormalError, 
-                   "CLogNormal.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CLogNormal *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLogNormalError, 
-	    	"CLogNormal.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CLogNormalError, 
-                   "CLogNormal.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CLogNormalError, 
-	    		"CLogNormal.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CLogNormalError, 
-                   "CLogNormal.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CLogNormalError, 
-                   "CLogNormal.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CLogNormal *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLogNormalError, 
-	    	"CLogNormal.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLogNormalError, 
-	    		"CLogNormal.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CLogNormal_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CLogNormal_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CLogNormal_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CLogNormal *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CLogNormal *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLogNormalError, 
-	    	"CLogNormal.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLogNormalError, 
-	    		"CLogNormal.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CLogNormal_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CLogNormal_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CLogNormal_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CLogNormal *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CLogNormal *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CLogNormalError,
-	    	"CLogNormal.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
- {
-	    PyErr_SetString(CLogNormalError,
-	    	"CLogNormal.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CLogNormal_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CLogNormalType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CLogNormal",             /*tp_name*/
-    sizeof(CLogNormal),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CLogNormal_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CLogNormal objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CLogNormal_methods,             /* tp_methods */
-    CLogNormal_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CLogNormal_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CLogNormal_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCLogNormal(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CLogNormalType) < 0)
-        return;
-
-    Py_INCREF(&CLogNormalType);
-    PyModule_AddObject(module, "CLogNormal", (PyObject *)&CLogNormalType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CLogNormal.error";
-    CLogNormalError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CLogNormalError", CLogNormalError);
-}
-
Index: nsmodels/src/python_wrapper/CLorentzian.cpp
===================================================================
--- sansmodels/src/python_wrapper/CLorentzian.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,533 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CLorentzian
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY lorentzian.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "lorentzian.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CLorentzianError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    Lorentzian * model;
-    /// Log for unit testing
-    PyObject * log;
-} CLorentzian;
-
-
-static void
-CLorentzian_dealloc(CLorentzian* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CLorentzian_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CLorentzian *self;
-    
-    self = (CLorentzian *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CLorentzian_init(CLorentzian *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new Lorentzian();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"center",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"gamma",Py_BuildValue("d",1.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CLorentzian_members[] = {
-    {name_params, T_OBJECT, offsetof(CLorentzian, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CLorentzian, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CLorentzian, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CLorentzian_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(Lorentzian* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( Lorentzian* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CLorentzianError, 
-                   "CLorentzian.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CLorentzian *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    self->model->gamma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "gamma") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLorentzianError, 
-	    	"CLorentzian.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CLorentzianError, 
-                   "CLorentzian.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CLorentzianError, 
-	    		"CLorentzian.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CLorentzianError, 
-                   "CLorentzian.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CLorentzianError, 
-                   "CLorentzian.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CLorentzian *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    self->model->gamma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "gamma") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLorentzianError, 
-	    	"CLorentzian.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLorentzianError, 
-	    		"CLorentzian.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CLorentzian_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CLorentzian_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CLorentzian_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CLorentzian *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    self->model->gamma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "gamma") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CLorentzian *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    self->model->gamma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "gamma") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CLorentzianError, 
-	    	"CLorentzian.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CLorentzianError, 
-	    		"CLorentzian.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CLorentzian_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CLorentzian_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CLorentzian_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CLorentzian *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CLorentzian *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CLorentzianError,
-	    	"CLorentzian.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
- {
-	    PyErr_SetString(CLorentzianError,
-	    	"CLorentzian.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CLorentzian_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CLorentzianType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CLorentzian",             /*tp_name*/
-    sizeof(CLorentzian),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CLorentzian_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CLorentzian objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CLorentzian_methods,             /* tp_methods */
-    CLorentzian_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CLorentzian_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CLorentzian_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCLorentzian(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CLorentzianType) < 0)
-        return;
-
-    Py_INCREF(&CLorentzianType);
-    PyModule_AddObject(module, "CLorentzian", (PyObject *)&CLorentzianType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CLorentzian.error";
-    CLorentzianError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CLorentzianError", CLorentzianError);
-}
-
Index: nsmodels/src/python_wrapper/CMultiShellModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CMultiShellModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,597 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CMultiShellModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY multishell.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "multishell.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CMultiShellModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    MultiShellModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CMultiShellModel;
-
-
-static void
-CMultiShellModel_dealloc(CMultiShellModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CMultiShellModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CMultiShellModel *self;
-    
-    self = (CMultiShellModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CMultiShellModel_init(CMultiShellModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new MultiShellModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000006400000));
-        PyDict_SetItemString(self->params,"core_radius",Py_BuildValue("d",60.000000000000));
-        PyDict_SetItemString(self->params,"n_pairs",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"w_thickness",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"s_thickness",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"shell_sld",Py_BuildValue("d",0.000000400000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->core_radius.dispersion->accept_as_source(visitor, self->model->core_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "core_radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->s_thickness.dispersion->accept_as_source(visitor, self->model->s_thickness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "s_thickness", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->w_thickness.dispersion->accept_as_source(visitor, self->model->w_thickness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "w_thickness", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CMultiShellModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CMultiShellModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CMultiShellModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CMultiShellModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CMultiShellModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(MultiShellModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( MultiShellModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CMultiShellModelError, 
-                   "CMultiShellModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CMultiShellModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->n_pairs = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_pairs") );
-    self->model->w_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "w_thickness") );
-    self->model->s_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_thickness");
-    self->model->s_thickness.dispersion->accept_as_destination(visitor, self->model->s_thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "w_thickness");
-    self->model->w_thickness.dispersion->accept_as_destination(visitor, self->model->w_thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CMultiShellModelError, 
-	    	"CMultiShellModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CMultiShellModelError, 
-                   "CMultiShellModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CMultiShellModelError, 
-	    		"CMultiShellModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CMultiShellModelError, 
-                   "CMultiShellModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CMultiShellModelError, 
-                   "CMultiShellModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CMultiShellModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->n_pairs = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_pairs") );
-    self->model->w_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "w_thickness") );
-    self->model->s_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_thickness");
-    self->model->s_thickness.dispersion->accept_as_destination(visitor, self->model->s_thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "w_thickness");
-    self->model->w_thickness.dispersion->accept_as_destination(visitor, self->model->w_thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CMultiShellModelError, 
-	    	"CMultiShellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CMultiShellModelError, 
-	    		"CMultiShellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CMultiShellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CMultiShellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CMultiShellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CMultiShellModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->n_pairs = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_pairs") );
-    self->model->w_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "w_thickness") );
-    self->model->s_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_thickness");
-    self->model->s_thickness.dispersion->accept_as_destination(visitor, self->model->s_thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "w_thickness");
-    self->model->w_thickness.dispersion->accept_as_destination(visitor, self->model->w_thickness.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CMultiShellModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
-    self->model->n_pairs = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_pairs") );
-    self->model->w_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "w_thickness") );
-    self->model->s_thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
-    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "s_thickness");
-    self->model->s_thickness.dispersion->accept_as_destination(visitor, self->model->s_thickness.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "w_thickness");
-    self->model->w_thickness.dispersion->accept_as_destination(visitor, self->model->w_thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CMultiShellModelError, 
-	    	"CMultiShellModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CMultiShellModelError, 
-	    		"CMultiShellModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CMultiShellModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CMultiShellModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CMultiShellModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CMultiShellModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CMultiShellModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CMultiShellModelError,
-	    	"CMultiShellModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "core_radius")) {
-        self->model->core_radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "s_thickness")) {
-        self->model->s_thickness.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "w_thickness")) {
-        self->model->w_thickness.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CMultiShellModelError,
-	    	"CMultiShellModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CMultiShellModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CMultiShellModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CMultiShellModel",             /*tp_name*/
-    sizeof(CMultiShellModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CMultiShellModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CMultiShellModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CMultiShellModel_methods,             /* tp_methods */
-    CMultiShellModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CMultiShellModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CMultiShellModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCMultiShellModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CMultiShellModelType) < 0)
-        return;
-
-    Py_INCREF(&CMultiShellModelType);
-    PyModule_AddObject(module, "CMultiShellModel", (PyObject *)&CMultiShellModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CMultiShellModel.error";
-    CMultiShellModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CMultiShellModelError", CMultiShellModelError);
-}
-
Index: nsmodels/src/python_wrapper/COnionModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/COnionModel.cpp	(revision c637521b288a6e3976fc9c0d461b44f70bb58c10)
+++ 	(revision )
@@ -1,941 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** COnionModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/onion.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-}
-
-#include "onion.h"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * COnionModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    OnionModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} COnionModel;
-
-
-static void
-COnionModel_dealloc(COnionModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-COnionModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    COnionModel *self;
-    
-    self = (COnionModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-COnionModel_init(COnionModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new OnionModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"thick_shell4",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell5",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell9",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell7",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"sld_core0",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"rad_core0",Py_BuildValue("d",200.000000000000));
-        PyDict_SetItemString(self->params,"A_shell10",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell1",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"func_shell4",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"func_shell5",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"func_shell6",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"func_shell1",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell10",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"func_shell3",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"func_shell8",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"func_shell9",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"sld_in_shell5",Py_BuildValue("d",0.000003700000));
-        PyDict_SetItemString(self->params,"func_shell10",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"sld_in_shell4",Py_BuildValue("d",0.000003200000));
-        PyDict_SetItemString(self->params,"sld_in_shell7",Py_BuildValue("d",0.000004700000));
-        PyDict_SetItemString(self->params,"sld_out_shell9",Py_BuildValue("d",0.000006000000));
-        PyDict_SetItemString(self->params,"sld_out_shell8",Py_BuildValue("d",0.000005500000));
-        PyDict_SetItemString(self->params,"thick_shell6",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"sld_out_shell2",Py_BuildValue("d",0.000002500000));
-        PyDict_SetItemString(self->params,"sld_in_shell9",Py_BuildValue("d",0.000005700000));
-        PyDict_SetItemString(self->params,"sld_in_shell8",Py_BuildValue("d",0.000005200000));
-        PyDict_SetItemString(self->params,"thick_shell2",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell3",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"sld_out_shell1",Py_BuildValue("d",0.000002000000));
-        PyDict_SetItemString(self->params,"sld_out_shell5",Py_BuildValue("d",0.000004000000));
-        PyDict_SetItemString(self->params,"sld_out_shell3",Py_BuildValue("d",0.000003000000));
-        PyDict_SetItemString(self->params,"sld_in_shell6",Py_BuildValue("d",0.000004200000));
-        PyDict_SetItemString(self->params,"sld_in_shell1",Py_BuildValue("d",0.000001700000));
-        PyDict_SetItemString(self->params,"sld_out_shell4",Py_BuildValue("d",0.000003500000));
-        PyDict_SetItemString(self->params,"sld_in_shell3",Py_BuildValue("d",0.000002700000));
-        PyDict_SetItemString(self->params,"sld_out_shell6",Py_BuildValue("d",0.000004500000));
-        PyDict_SetItemString(self->params,"func_shell7",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"sld_out_shell7",Py_BuildValue("d",0.000005000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"n_shells",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sld_in_shell2",Py_BuildValue("d",0.000002200000));
-        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006400000));
-        PyDict_SetItemString(self->params,"func_shell2",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"thick_shell8",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"sld_out_shell10",Py_BuildValue("d",0.000006200000));
-        PyDict_SetItemString(self->params,"sld_in_shell10",Py_BuildValue("d",0.000006000000));
-        PyDict_SetItemString(self->params,"A_shell8",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell9",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell6",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell7",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell4",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell5",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell2",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell3",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"A_shell1",Py_BuildValue("d",1.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->rad_core0.dispersion->accept_as_source(visitor, self->model->rad_core0.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rad_core0", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell1.dispersion->accept_as_source(visitor, self->model->thick_shell1.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell1", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell2.dispersion->accept_as_source(visitor, self->model->thick_shell2.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell2", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell3.dispersion->accept_as_source(visitor, self->model->thick_shell3.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell3", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell4.dispersion->accept_as_source(visitor, self->model->thick_shell4.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell4", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell5.dispersion->accept_as_source(visitor, self->model->thick_shell5.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell5", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell6.dispersion->accept_as_source(visitor, self->model->thick_shell6.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell6", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell7.dispersion->accept_as_source(visitor, self->model->thick_shell7.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell7", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell8.dispersion->accept_as_source(visitor, self->model->thick_shell8.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell8", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell9.dispersion->accept_as_source(visitor, self->model->thick_shell9.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell9", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thick_shell10.dispersion->accept_as_source(visitor, self->model->thick_shell10.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thick_shell10", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef COnionModel_members[] = {
-    {name_params, T_OBJECT, offsetof(COnionModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(COnionModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(COnionModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double COnionModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(OnionModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( OnionModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(COnionModelError, 
-                   "COnionModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(COnionModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->thick_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell5") );
-    self->model->thick_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell9") );
-    self->model->thick_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell7") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->A_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell10") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->func_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell4") );
-    self->model->func_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell5") );
-    self->model->func_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell6") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->func_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell1") );
-    self->model->thick_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell10") );
-    self->model->func_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell3") );
-    self->model->func_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell8") );
-    self->model->func_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell9") );
-    self->model->sld_in_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell5") );
-    self->model->func_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell10") );
-    self->model->sld_in_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell4") );
-    self->model->sld_in_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell7") );
-    self->model->sld_out_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell9") );
-    self->model->sld_out_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell8") );
-    self->model->thick_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell6") );
-    self->model->sld_out_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell2") );
-    self->model->sld_in_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell9") );
-    self->model->sld_in_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell8") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_out_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell1") );
-    self->model->sld_out_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell5") );
-    self->model->sld_out_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell3") );
-    self->model->sld_in_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell6") );
-    self->model->sld_in_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell1") );
-    self->model->sld_out_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell4") );
-    self->model->sld_in_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell3") );
-    self->model->sld_out_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell6") );
-    self->model->func_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell7") );
-    self->model->sld_out_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell7") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->n_shells = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_shells") );
-    self->model->sld_in_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell2") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->func_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell2") );
-    self->model->thick_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell8") );
-    self->model->sld_out_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell10") );
-    self->model->sld_in_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell10") );
-    self->model->A_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell8") );
-    self->model->A_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell9") );
-    self->model->A_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell6") );
-    self->model->A_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell7") );
-    self->model->A_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell4") );
-    self->model->A_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell5") );
-    self->model->A_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell2") );
-    self->model->A_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell3") );
-    self->model->A_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell1") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell5");
-    self->model->thick_shell5.dispersion->accept_as_destination(visitor, self->model->thick_shell5.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell6");
-    self->model->thick_shell6.dispersion->accept_as_destination(visitor, self->model->thick_shell6.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell7");
-    self->model->thick_shell7.dispersion->accept_as_destination(visitor, self->model->thick_shell7.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell8");
-    self->model->thick_shell8.dispersion->accept_as_destination(visitor, self->model->thick_shell8.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell9");
-    self->model->thick_shell9.dispersion->accept_as_destination(visitor, self->model->thick_shell9.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell10");
-    self->model->thick_shell10.dispersion->accept_as_destination(visitor, self->model->thick_shell10.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(COnionModelError, 
-	    	"COnionModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(COnionModelError, 
-                   "COnionModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(COnionModelError, 
-	    		"COnionModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(COnionModelError, 
-                   "COnionModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(COnionModelError, 
-                   "COnionModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(COnionModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->thick_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell5") );
-    self->model->thick_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell9") );
-    self->model->thick_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell7") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->A_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell10") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->func_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell4") );
-    self->model->func_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell5") );
-    self->model->func_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell6") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->func_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell1") );
-    self->model->thick_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell10") );
-    self->model->func_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell3") );
-    self->model->func_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell8") );
-    self->model->func_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell9") );
-    self->model->sld_in_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell5") );
-    self->model->func_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell10") );
-    self->model->sld_in_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell4") );
-    self->model->sld_in_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell7") );
-    self->model->sld_out_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell9") );
-    self->model->sld_out_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell8") );
-    self->model->thick_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell6") );
-    self->model->sld_out_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell2") );
-    self->model->sld_in_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell9") );
-    self->model->sld_in_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell8") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_out_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell1") );
-    self->model->sld_out_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell5") );
-    self->model->sld_out_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell3") );
-    self->model->sld_in_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell6") );
-    self->model->sld_in_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell1") );
-    self->model->sld_out_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell4") );
-    self->model->sld_in_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell3") );
-    self->model->sld_out_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell6") );
-    self->model->func_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell7") );
-    self->model->sld_out_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell7") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->n_shells = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_shells") );
-    self->model->sld_in_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell2") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->func_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell2") );
-    self->model->thick_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell8") );
-    self->model->sld_out_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell10") );
-    self->model->sld_in_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell10") );
-    self->model->A_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell8") );
-    self->model->A_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell9") );
-    self->model->A_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell6") );
-    self->model->A_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell7") );
-    self->model->A_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell4") );
-    self->model->A_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell5") );
-    self->model->A_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell2") );
-    self->model->A_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell3") );
-    self->model->A_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell1") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell5");
-    self->model->thick_shell5.dispersion->accept_as_destination(visitor, self->model->thick_shell5.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell6");
-    self->model->thick_shell6.dispersion->accept_as_destination(visitor, self->model->thick_shell6.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell7");
-    self->model->thick_shell7.dispersion->accept_as_destination(visitor, self->model->thick_shell7.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell8");
-    self->model->thick_shell8.dispersion->accept_as_destination(visitor, self->model->thick_shell8.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell9");
-    self->model->thick_shell9.dispersion->accept_as_destination(visitor, self->model->thick_shell9.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell10");
-    self->model->thick_shell10.dispersion->accept_as_destination(visitor, self->model->thick_shell10.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(COnionModelError, 
-	    	"COnionModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(COnionModelError, 
-	    		"COnionModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = COnionModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = COnionModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = COnionModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(COnionModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->thick_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell5") );
-    self->model->thick_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell9") );
-    self->model->thick_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell7") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->A_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell10") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->func_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell4") );
-    self->model->func_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell5") );
-    self->model->func_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell6") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->func_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell1") );
-    self->model->thick_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell10") );
-    self->model->func_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell3") );
-    self->model->func_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell8") );
-    self->model->func_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell9") );
-    self->model->sld_in_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell5") );
-    self->model->func_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell10") );
-    self->model->sld_in_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell4") );
-    self->model->sld_in_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell7") );
-    self->model->sld_out_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell9") );
-    self->model->sld_out_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell8") );
-    self->model->thick_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell6") );
-    self->model->sld_out_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell2") );
-    self->model->sld_in_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell9") );
-    self->model->sld_in_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell8") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_out_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell1") );
-    self->model->sld_out_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell5") );
-    self->model->sld_out_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell3") );
-    self->model->sld_in_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell6") );
-    self->model->sld_in_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell1") );
-    self->model->sld_out_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell4") );
-    self->model->sld_in_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell3") );
-    self->model->sld_out_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell6") );
-    self->model->func_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell7") );
-    self->model->sld_out_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell7") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->n_shells = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_shells") );
-    self->model->sld_in_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell2") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->func_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell2") );
-    self->model->thick_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell8") );
-    self->model->sld_out_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell10") );
-    self->model->sld_in_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell10") );
-    self->model->A_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell8") );
-    self->model->A_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell9") );
-    self->model->A_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell6") );
-    self->model->A_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell7") );
-    self->model->A_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell4") );
-    self->model->A_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell5") );
-    self->model->A_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell2") );
-    self->model->A_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell3") );
-    self->model->A_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell1") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell5");
-    self->model->thick_shell5.dispersion->accept_as_destination(visitor, self->model->thick_shell5.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell6");
-    self->model->thick_shell6.dispersion->accept_as_destination(visitor, self->model->thick_shell6.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell7");
-    self->model->thick_shell7.dispersion->accept_as_destination(visitor, self->model->thick_shell7.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell8");
-    self->model->thick_shell8.dispersion->accept_as_destination(visitor, self->model->thick_shell8.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell9");
-    self->model->thick_shell9.dispersion->accept_as_destination(visitor, self->model->thick_shell9.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell10");
-    self->model->thick_shell10.dispersion->accept_as_destination(visitor, self->model->thick_shell10.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(COnionModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->thick_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell4") );
-    self->model->thick_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell5") );
-    self->model->thick_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell9") );
-    self->model->thick_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell7") );
-    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
-    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
-    self->model->A_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell10") );
-    self->model->thick_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell1") );
-    self->model->func_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell4") );
-    self->model->func_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell5") );
-    self->model->func_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell6") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->func_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell1") );
-    self->model->thick_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell10") );
-    self->model->func_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell3") );
-    self->model->func_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell8") );
-    self->model->func_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell9") );
-    self->model->sld_in_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell5") );
-    self->model->func_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell10") );
-    self->model->sld_in_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell4") );
-    self->model->sld_in_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell7") );
-    self->model->sld_out_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell9") );
-    self->model->sld_out_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell8") );
-    self->model->thick_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell6") );
-    self->model->sld_out_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell2") );
-    self->model->sld_in_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell9") );
-    self->model->sld_in_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell8") );
-    self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
-    self->model->sld_out_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell1") );
-    self->model->sld_out_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell5") );
-    self->model->sld_out_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell3") );
-    self->model->sld_in_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell6") );
-    self->model->sld_in_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell1") );
-    self->model->sld_out_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell4") );
-    self->model->sld_in_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell3") );
-    self->model->sld_out_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell6") );
-    self->model->func_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell7") );
-    self->model->sld_out_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell7") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->n_shells = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_shells") );
-    self->model->sld_in_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell2") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    self->model->func_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_shell2") );
-    self->model->thick_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell8") );
-    self->model->sld_out_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_out_shell10") );
-    self->model->sld_in_shell10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_in_shell10") );
-    self->model->A_shell8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell8") );
-    self->model->A_shell9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell9") );
-    self->model->A_shell6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell6") );
-    self->model->A_shell7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell7") );
-    self->model->A_shell4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell4") );
-    self->model->A_shell5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell5") );
-    self->model->A_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell2") );
-    self->model->A_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell3") );
-    self->model->A_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "A_shell1") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
-    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
-    self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell2");
-    self->model->thick_shell2.dispersion->accept_as_destination(visitor, self->model->thick_shell2.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell3");
-    self->model->thick_shell3.dispersion->accept_as_destination(visitor, self->model->thick_shell3.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell4");
-    self->model->thick_shell4.dispersion->accept_as_destination(visitor, self->model->thick_shell4.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell5");
-    self->model->thick_shell5.dispersion->accept_as_destination(visitor, self->model->thick_shell5.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell6");
-    self->model->thick_shell6.dispersion->accept_as_destination(visitor, self->model->thick_shell6.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell7");
-    self->model->thick_shell7.dispersion->accept_as_destination(visitor, self->model->thick_shell7.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell8");
-    self->model->thick_shell8.dispersion->accept_as_destination(visitor, self->model->thick_shell8.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell9");
-    self->model->thick_shell9.dispersion->accept_as_destination(visitor, self->model->thick_shell9.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell10");
-    self->model->thick_shell10.dispersion->accept_as_destination(visitor, self->model->thick_shell10.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(COnionModelError, 
-	    	"COnionModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(COnionModelError, 
-	    		"COnionModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = COnionModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = COnionModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = COnionModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(COnionModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(COnionModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(COnionModelError,
-	    	"COnionModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "rad_core0")) {
-        self->model->rad_core0.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell1")) {
-        self->model->thick_shell1.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell2")) {
-        self->model->thick_shell2.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell3")) {
-        self->model->thick_shell3.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell4")) {
-        self->model->thick_shell4.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell5")) {
-        self->model->thick_shell5.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell6")) {
-        self->model->thick_shell6.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell7")) {
-        self->model->thick_shell7.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell8")) {
-        self->model->thick_shell8.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell9")) {
-        self->model->thick_shell9.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thick_shell10")) {
-        self->model->thick_shell10.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(COnionModelError,
-	    	"COnionModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef COnionModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject COnionModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "COnionModel",             /*tp_name*/
-    sizeof(COnionModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)COnionModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "COnionModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    COnionModel_methods,             /* tp_methods */
-    COnionModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)COnionModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    COnionModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCOnionModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&COnionModelType) < 0)
-        return;
-
-    Py_INCREF(&COnionModelType);
-    PyModule_AddObject(module, "COnionModel", (PyObject *)&COnionModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "COnionModel.error";
-    COnionModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "COnionModelError", COnionModelError);
-}
-
Index: nsmodels/src/python_wrapper/CParallelepipedModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CParallelepipedModel.cpp	(revision 8343e18b86d18130057f1d8c582e4042eec09721)
+++ 	(revision )
@@ -1,646 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CParallelepipedModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/parallelepiped.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-}
-
-#include "parallelepiped.h"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CParallelepipedModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    ParallelepipedModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CParallelepipedModel;
-
-
-static void
-CParallelepipedModel_dealloc(CParallelepipedModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CParallelepipedModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CParallelepipedModel *self;
-    
-    self = (CParallelepipedModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CParallelepipedModel_init(CParallelepipedModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new ParallelepipedModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"short_a",Py_BuildValue("d",35.000000000000));
-        PyDict_SetItemString(self->params,"short_b",Py_BuildValue("d",75.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"long_c",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"sldPipe",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"parallel_psi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"parallel_phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"parallel_theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->short_a.dispersion->accept_as_source(visitor, self->model->short_a.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "short_a", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->short_b.dispersion->accept_as_source(visitor, self->model->short_b.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "short_b", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->long_c.dispersion->accept_as_source(visitor, self->model->long_c.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "long_c", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->parallel_phi.dispersion->accept_as_source(visitor, self->model->parallel_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "parallel_phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->parallel_psi.dispersion->accept_as_source(visitor, self->model->parallel_psi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "parallel_psi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->parallel_theta.dispersion->accept_as_source(visitor, self->model->parallel_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "parallel_theta", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CParallelepipedModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CParallelepipedModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CParallelepipedModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CParallelepipedModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CParallelepipedModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(ParallelepipedModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( ParallelepipedModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CParallelepipedModelError, 
-                   "CParallelepipedModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CParallelepipedModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") );
-    self->model->short_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_b") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->long_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_c") );
-    self->model->sldPipe = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldPipe") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_a");
-    self->model->short_a.dispersion->accept_as_destination(visitor, self->model->short_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_b");
-    self->model->short_b.dispersion->accept_as_destination(visitor, self->model->short_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "long_c");
-    self->model->long_c.dispersion->accept_as_destination(visitor, self->model->long_c.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CParallelepipedModelError, 
-	    	"CParallelepipedModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CParallelepipedModelError, 
-                   "CParallelepipedModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CParallelepipedModelError, 
-	    		"CParallelepipedModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CParallelepipedModelError, 
-                   "CParallelepipedModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CParallelepipedModelError, 
-                   "CParallelepipedModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CParallelepipedModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") );
-    self->model->short_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_b") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->long_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_c") );
-    self->model->sldPipe = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldPipe") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_a");
-    self->model->short_a.dispersion->accept_as_destination(visitor, self->model->short_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_b");
-    self->model->short_b.dispersion->accept_as_destination(visitor, self->model->short_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "long_c");
-    self->model->long_c.dispersion->accept_as_destination(visitor, self->model->long_c.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CParallelepipedModelError, 
-	    	"CParallelepipedModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CParallelepipedModelError, 
-	    		"CParallelepipedModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CParallelepipedModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CParallelepipedModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CParallelepipedModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CParallelepipedModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") );
-    self->model->short_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_b") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->long_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_c") );
-    self->model->sldPipe = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldPipe") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_a");
-    self->model->short_a.dispersion->accept_as_destination(visitor, self->model->short_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_b");
-    self->model->short_b.dispersion->accept_as_destination(visitor, self->model->short_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "long_c");
-    self->model->long_c.dispersion->accept_as_destination(visitor, self->model->long_c.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CParallelepipedModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->short_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_a") );
-    self->model->short_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "short_b") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->long_c = PyFloat_AsDouble( PyDict_GetItemString(self->params, "long_c") );
-    self->model->sldPipe = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldPipe") );
-    self->model->parallel_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_psi") );
-    self->model->parallel_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_phi") );
-    self->model->parallel_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "parallel_theta") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_a");
-    self->model->short_a.dispersion->accept_as_destination(visitor, self->model->short_a.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "short_b");
-    self->model->short_b.dispersion->accept_as_destination(visitor, self->model->short_b.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "long_c");
-    self->model->long_c.dispersion->accept_as_destination(visitor, self->model->long_c.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_phi");
-    self->model->parallel_phi.dispersion->accept_as_destination(visitor, self->model->parallel_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_psi");
-    self->model->parallel_psi.dispersion->accept_as_destination(visitor, self->model->parallel_psi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "parallel_theta");
-    self->model->parallel_theta.dispersion->accept_as_destination(visitor, self->model->parallel_theta.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CParallelepipedModelError, 
-	    	"CParallelepipedModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CParallelepipedModelError, 
-	    		"CParallelepipedModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CParallelepipedModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CParallelepipedModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CParallelepipedModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CParallelepipedModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CParallelepipedModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CParallelepipedModelError,
-	    	"CParallelepipedModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "short_a")) {
-        self->model->short_a.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "short_b")) {
-        self->model->short_b.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "long_c")) {
-        self->model->long_c.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "parallel_phi")) {
-        self->model->parallel_phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "parallel_psi")) {
-        self->model->parallel_psi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "parallel_theta")) {
-        self->model->parallel_theta.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CParallelepipedModelError,
-	    	"CParallelepipedModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CParallelepipedModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CParallelepipedModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CParallelepipedModel",             /*tp_name*/
-    sizeof(CParallelepipedModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CParallelepipedModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CParallelepipedModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CParallelepipedModel_methods,             /* tp_methods */
-    CParallelepipedModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CParallelepipedModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CParallelepipedModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCParallelepipedModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CParallelepipedModelType) < 0)
-        return;
-
-    Py_INCREF(&CParallelepipedModelType);
-    PyModule_AddObject(module, "CParallelepipedModel", (PyObject *)&CParallelepipedModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CParallelepipedModel.error";
-    CParallelepipedModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CParallelepipedModelError", CParallelepipedModelError);
-}
-
Index: nsmodels/src/python_wrapper/CPearlNecklaceModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CPearlNecklaceModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,589 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CPearlNecklaceModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY pearlnecklace.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "pearlnecklace.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CPearlNecklaceModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    PearlNecklaceModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CPearlNecklaceModel;
-
-
-static void
-CPearlNecklaceModel_dealloc(CPearlNecklaceModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CPearlNecklaceModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CPearlNecklaceModel *self;
-    
-    self = (CPearlNecklaceModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CPearlNecklaceModel_init(CPearlNecklaceModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new PearlNecklaceModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"num_pearls",Py_BuildValue("d",3.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"thick_string",Py_BuildValue("d",2.500000000000));
-        PyDict_SetItemString(self->params,"sld_string",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"edge_separation",Py_BuildValue("d",350.000000000000));
-        PyDict_SetItemString(self->params,"sld_pearl",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",80.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006300000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->edge_separation.dispersion->accept_as_source(visitor, self->model->edge_separation.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "edge_separation", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CPearlNecklaceModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CPearlNecklaceModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CPearlNecklaceModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CPearlNecklaceModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CPearlNecklaceModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(PearlNecklaceModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( PearlNecklaceModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CPearlNecklaceModelError, 
-                   "CPearlNecklaceModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CPearlNecklaceModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->num_pearls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "num_pearls") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->thick_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_string") );
-    self->model->sld_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_string") );
-    self->model->edge_separation = PyFloat_AsDouble( PyDict_GetItemString(self->params, "edge_separation") );
-    self->model->sld_pearl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pearl") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "edge_separation");
-    self->model->edge_separation.dispersion->accept_as_destination(visitor, self->model->edge_separation.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CPearlNecklaceModelError, 
-	    	"CPearlNecklaceModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CPearlNecklaceModelError, 
-                   "CPearlNecklaceModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CPearlNecklaceModelError, 
-	    		"CPearlNecklaceModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CPearlNecklaceModelError, 
-                   "CPearlNecklaceModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CPearlNecklaceModelError, 
-                   "CPearlNecklaceModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CPearlNecklaceModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->num_pearls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "num_pearls") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->thick_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_string") );
-    self->model->sld_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_string") );
-    self->model->edge_separation = PyFloat_AsDouble( PyDict_GetItemString(self->params, "edge_separation") );
-    self->model->sld_pearl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pearl") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "edge_separation");
-    self->model->edge_separation.dispersion->accept_as_destination(visitor, self->model->edge_separation.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CPearlNecklaceModelError, 
-	    	"CPearlNecklaceModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CPearlNecklaceModelError, 
-	    		"CPearlNecklaceModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CPearlNecklaceModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CPearlNecklaceModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CPearlNecklaceModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CPearlNecklaceModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->num_pearls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "num_pearls") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->thick_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_string") );
-    self->model->sld_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_string") );
-    self->model->edge_separation = PyFloat_AsDouble( PyDict_GetItemString(self->params, "edge_separation") );
-    self->model->sld_pearl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pearl") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "edge_separation");
-    self->model->edge_separation.dispersion->accept_as_destination(visitor, self->model->edge_separation.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CPearlNecklaceModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->num_pearls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "num_pearls") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->thick_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_string") );
-    self->model->sld_string = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_string") );
-    self->model->edge_separation = PyFloat_AsDouble( PyDict_GetItemString(self->params, "edge_separation") );
-    self->model->sld_pearl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_pearl") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "edge_separation");
-    self->model->edge_separation.dispersion->accept_as_destination(visitor, self->model->edge_separation.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CPearlNecklaceModelError, 
-	    	"CPearlNecklaceModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CPearlNecklaceModelError, 
-	    		"CPearlNecklaceModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CPearlNecklaceModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CPearlNecklaceModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CPearlNecklaceModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CPearlNecklaceModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CPearlNecklaceModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CPearlNecklaceModelError,
-	    	"CPearlNecklaceModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "edge_separation")) {
-        self->model->edge_separation.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CPearlNecklaceModelError,
-	    	"CPearlNecklaceModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CPearlNecklaceModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CPearlNecklaceModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CPearlNecklaceModel",             /*tp_name*/
-    sizeof(CPearlNecklaceModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CPearlNecklaceModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CPearlNecklaceModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CPearlNecklaceModel_methods,             /* tp_methods */
-    CPearlNecklaceModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CPearlNecklaceModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CPearlNecklaceModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCPearlNecklaceModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CPearlNecklaceModelType) < 0)
-        return;
-
-    Py_INCREF(&CPearlNecklaceModelType);
-    PyModule_AddObject(module, "CPearlNecklaceModel", (PyObject *)&CPearlNecklaceModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CPearlNecklaceModel.error";
-    CPearlNecklaceModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CPearlNecklaceModelError", CPearlNecklaceModelError);
-}
-
Index: nsmodels/src/python_wrapper/CPoly_GaussCoil.cpp
===================================================================
--- sansmodels/src/python_wrapper/CPoly_GaussCoil.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,551 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CPoly_GaussCoil
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY polygausscoil.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "polygausscoil.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CPoly_GaussCoilError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    Poly_GaussCoil * model;
-    /// Log for unit testing
-    PyObject * log;
-} CPoly_GaussCoil;
-
-
-static void
-CPoly_GaussCoil_dealloc(CPoly_GaussCoil* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CPoly_GaussCoil_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CPoly_GaussCoil *self;
-    
-    self = (CPoly_GaussCoil *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CPoly_GaussCoil_init(CPoly_GaussCoil *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new Poly_GaussCoil();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"poly_m",Py_BuildValue("d",2.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"rg",Py_BuildValue("d",60.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->rg.dispersion->accept_as_source(visitor, self->model->rg.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rg", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CPoly_GaussCoil_members[] = {
-    {name_params, T_OBJECT, offsetof(CPoly_GaussCoil, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CPoly_GaussCoil, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CPoly_GaussCoil, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CPoly_GaussCoil_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(Poly_GaussCoil* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( Poly_GaussCoil* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CPoly_GaussCoilError, 
-                   "CPoly_GaussCoil.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CPoly_GaussCoil *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->poly_m = PyFloat_AsDouble( PyDict_GetItemString(self->params, "poly_m") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->rg = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rg") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rg");
-    self->model->rg.dispersion->accept_as_destination(visitor, self->model->rg.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CPoly_GaussCoilError, 
-	    	"CPoly_GaussCoil.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CPoly_GaussCoilError, 
-                   "CPoly_GaussCoil.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CPoly_GaussCoilError, 
-	    		"CPoly_GaussCoil.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CPoly_GaussCoilError, 
-                   "CPoly_GaussCoil.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CPoly_GaussCoilError, 
-                   "CPoly_GaussCoil.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CPoly_GaussCoil *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->poly_m = PyFloat_AsDouble( PyDict_GetItemString(self->params, "poly_m") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->rg = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rg") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rg");
-    self->model->rg.dispersion->accept_as_destination(visitor, self->model->rg.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CPoly_GaussCoilError, 
-	    	"CPoly_GaussCoil.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CPoly_GaussCoilError, 
-	    		"CPoly_GaussCoil.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CPoly_GaussCoil_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CPoly_GaussCoil_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CPoly_GaussCoil_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CPoly_GaussCoil *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->poly_m = PyFloat_AsDouble( PyDict_GetItemString(self->params, "poly_m") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->rg = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rg") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rg");
-    self->model->rg.dispersion->accept_as_destination(visitor, self->model->rg.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CPoly_GaussCoil *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->poly_m = PyFloat_AsDouble( PyDict_GetItemString(self->params, "poly_m") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->rg = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rg") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rg");
-    self->model->rg.dispersion->accept_as_destination(visitor, self->model->rg.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CPoly_GaussCoilError, 
-	    	"CPoly_GaussCoil.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CPoly_GaussCoilError, 
-	    		"CPoly_GaussCoil.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CPoly_GaussCoil_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CPoly_GaussCoil_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CPoly_GaussCoil_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CPoly_GaussCoil *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CPoly_GaussCoil *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CPoly_GaussCoilError,
-	    	"CPoly_GaussCoil.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "rg")) {
-        self->model->rg.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CPoly_GaussCoilError,
-	    	"CPoly_GaussCoil.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CPoly_GaussCoil_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CPoly_GaussCoilType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CPoly_GaussCoil",             /*tp_name*/
-    sizeof(CPoly_GaussCoil),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CPoly_GaussCoil_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CPoly_GaussCoil objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CPoly_GaussCoil_methods,             /* tp_methods */
-    CPoly_GaussCoil_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CPoly_GaussCoil_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CPoly_GaussCoil_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCPoly_GaussCoil(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CPoly_GaussCoilType) < 0)
-        return;
-
-    Py_INCREF(&CPoly_GaussCoilType);
-    PyModule_AddObject(module, "CPoly_GaussCoil", (PyObject *)&CPoly_GaussCoilType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CPoly_GaussCoil.error";
-    CPoly_GaussCoilError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CPoly_GaussCoilError", CPoly_GaussCoilError);
-}
-
Index: nsmodels/src/python_wrapper/CRPAModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CRPAModel.cpp	(revision 7ffa819613fbe742c39f7848cd58549d0a0af183)
+++ 	(revision )
@@ -1,676 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CRPAModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/rpa.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-
-}
-
-#include "rpa.h"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CRPAModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    RPAModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CRPAModel;
-
-
-static void
-CRPAModel_dealloc(CRPAModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CRPAModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CRPAModel *self;
-    
-    self = (CRPAModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CRPAModel_init(CRPAModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new RPAModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"va",Py_BuildValue("d",100.000000000000));
-        PyDict_SetItemString(self->params,"vb",Py_BuildValue("d",100.000000000000));
-        PyDict_SetItemString(self->params,"vc",Py_BuildValue("d",100.000000000000));
-        PyDict_SetItemString(self->params,"Lb",Py_BuildValue("d",0.000000000001));
-        PyDict_SetItemString(self->params,"Lc",Py_BuildValue("d",0.000000000001));
-        PyDict_SetItemString(self->params,"La",Py_BuildValue("d",0.000000000001));
-        PyDict_SetItemString(self->params,"Na",Py_BuildValue("d",1000.000000000000));
-        PyDict_SetItemString(self->params,"Nb",Py_BuildValue("d",1000.000000000000));
-        PyDict_SetItemString(self->params,"Nc",Py_BuildValue("d",1000.000000000000));
-        PyDict_SetItemString(self->params,"Nd",Py_BuildValue("d",1000.000000000000));
-        PyDict_SetItemString(self->params,"Ld",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"Kcd",Py_BuildValue("d",-0.000400000000));
-        PyDict_SetItemString(self->params,"vd",Py_BuildValue("d",100.000000000000));
-        PyDict_SetItemString(self->params,"Phib",Py_BuildValue("d",0.250000000000));
-        PyDict_SetItemString(self->params,"Kac",Py_BuildValue("d",-0.000400000000));
-        PyDict_SetItemString(self->params,"Kab",Py_BuildValue("d",-0.000400000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"bb",Py_BuildValue("d",5.000000000000));
-        PyDict_SetItemString(self->params,"Kad",Py_BuildValue("d",-0.000400000000));
-        PyDict_SetItemString(self->params,"bd",Py_BuildValue("d",5.000000000000));
-        PyDict_SetItemString(self->params,"Phid",Py_BuildValue("d",0.250000000000));
-        PyDict_SetItemString(self->params,"Phic",Py_BuildValue("d",0.250000000000));
-        PyDict_SetItemString(self->params,"ba",Py_BuildValue("d",5.000000000000));
-        PyDict_SetItemString(self->params,"Phia",Py_BuildValue("d",0.250000000000));
-        PyDict_SetItemString(self->params,"bc",Py_BuildValue("d",5.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"Kbc",Py_BuildValue("d",-0.000400000000));
-        PyDict_SetItemString(self->params,"Kbd",Py_BuildValue("d",-0.000400000000));
-        PyDict_SetItemString(self->params,"lcase_n",Py_BuildValue("d",0.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->background.dispersion->accept_as_source(visitor, self->model->background.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "background", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CRPAModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CRPAModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CRPAModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CRPAModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CRPAModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(RPAModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( RPAModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CRPAModelError, 
-                   "CRPAModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CRPAModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->va = PyFloat_AsDouble( PyDict_GetItemString(self->params, "va") );
-    self->model->vb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vb") );
-    self->model->vc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vc") );
-    self->model->Lb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lb") );
-    self->model->Lc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lc") );
-    self->model->La = PyFloat_AsDouble( PyDict_GetItemString(self->params, "La") );
-    self->model->Na = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Na") );
-    self->model->Nb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nb") );
-    self->model->Nc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nc") );
-    self->model->Nd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nd") );
-    self->model->Ld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Ld") );
-    self->model->Kcd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kcd") );
-    self->model->vd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vd") );
-    self->model->Phib = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phib") );
-    self->model->Kac = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kac") );
-    self->model->Kab = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kab") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bb") );
-    self->model->Kad = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kad") );
-    self->model->bd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bd") );
-    self->model->Phid = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phid") );
-    self->model->Phic = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phic") );
-    self->model->ba = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ba") );
-    self->model->Phia = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phia") );
-    self->model->bc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bc") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->Kbc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbc") );
-    self->model->Kbd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbd") );
-    self->model->lcase_n = PyFloat_AsDouble( PyDict_GetItemString(self->params, "lcase_n") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "background");
-    self->model->background.dispersion->accept_as_destination(visitor, self->model->background.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CRPAModelError, 
-	    	"CRPAModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CRPAModelError, 
-                   "CRPAModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CRPAModelError, 
-	    		"CRPAModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CRPAModelError, 
-                   "CRPAModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CRPAModelError, 
-                   "CRPAModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CRPAModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->va = PyFloat_AsDouble( PyDict_GetItemString(self->params, "va") );
-    self->model->vb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vb") );
-    self->model->vc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vc") );
-    self->model->Lb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lb") );
-    self->model->Lc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lc") );
-    self->model->La = PyFloat_AsDouble( PyDict_GetItemString(self->params, "La") );
-    self->model->Na = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Na") );
-    self->model->Nb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nb") );
-    self->model->Nc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nc") );
-    self->model->Nd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nd") );
-    self->model->Ld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Ld") );
-    self->model->Kcd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kcd") );
-    self->model->vd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vd") );
-    self->model->Phib = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phib") );
-    self->model->Kac = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kac") );
-    self->model->Kab = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kab") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bb") );
-    self->model->Kad = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kad") );
-    self->model->bd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bd") );
-    self->model->Phid = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phid") );
-    self->model->Phic = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phic") );
-    self->model->ba = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ba") );
-    self->model->Phia = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phia") );
-    self->model->bc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bc") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->Kbc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbc") );
-    self->model->Kbd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbd") );
-    self->model->lcase_n = PyFloat_AsDouble( PyDict_GetItemString(self->params, "lcase_n") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "background");
-    self->model->background.dispersion->accept_as_destination(visitor, self->model->background.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CRPAModelError, 
-	    	"CRPAModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CRPAModelError, 
-	    		"CRPAModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CRPAModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CRPAModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CRPAModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CRPAModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->va = PyFloat_AsDouble( PyDict_GetItemString(self->params, "va") );
-    self->model->vb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vb") );
-    self->model->vc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vc") );
-    self->model->Lb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lb") );
-    self->model->Lc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lc") );
-    self->model->La = PyFloat_AsDouble( PyDict_GetItemString(self->params, "La") );
-    self->model->Na = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Na") );
-    self->model->Nb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nb") );
-    self->model->Nc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nc") );
-    self->model->Nd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nd") );
-    self->model->Ld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Ld") );
-    self->model->Kcd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kcd") );
-    self->model->vd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vd") );
-    self->model->Phib = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phib") );
-    self->model->Kac = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kac") );
-    self->model->Kab = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kab") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bb") );
-    self->model->Kad = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kad") );
-    self->model->bd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bd") );
-    self->model->Phid = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phid") );
-    self->model->Phic = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phic") );
-    self->model->ba = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ba") );
-    self->model->Phia = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phia") );
-    self->model->bc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bc") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->Kbc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbc") );
-    self->model->Kbd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbd") );
-    self->model->lcase_n = PyFloat_AsDouble( PyDict_GetItemString(self->params, "lcase_n") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "background");
-    self->model->background.dispersion->accept_as_destination(visitor, self->model->background.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CRPAModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->va = PyFloat_AsDouble( PyDict_GetItemString(self->params, "va") );
-    self->model->vb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vb") );
-    self->model->vc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vc") );
-    self->model->Lb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lb") );
-    self->model->Lc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Lc") );
-    self->model->La = PyFloat_AsDouble( PyDict_GetItemString(self->params, "La") );
-    self->model->Na = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Na") );
-    self->model->Nb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nb") );
-    self->model->Nc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nc") );
-    self->model->Nd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Nd") );
-    self->model->Ld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Ld") );
-    self->model->Kcd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kcd") );
-    self->model->vd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vd") );
-    self->model->Phib = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phib") );
-    self->model->Kac = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kac") );
-    self->model->Kab = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kab") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->bb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bb") );
-    self->model->Kad = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kad") );
-    self->model->bd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bd") );
-    self->model->Phid = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phid") );
-    self->model->Phic = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phic") );
-    self->model->ba = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ba") );
-    self->model->Phia = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Phia") );
-    self->model->bc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "bc") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->Kbc = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbc") );
-    self->model->Kbd = PyFloat_AsDouble( PyDict_GetItemString(self->params, "Kbd") );
-    self->model->lcase_n = PyFloat_AsDouble( PyDict_GetItemString(self->params, "lcase_n") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "background");
-    self->model->background.dispersion->accept_as_destination(visitor, self->model->background.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CRPAModelError, 
-	    	"CRPAModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CRPAModelError, 
-	    		"CRPAModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CRPAModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CRPAModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CRPAModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CRPAModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CRPAModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CRPAModelError,
-	    	"CRPAModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "background")) {
-        self->model->background.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CRPAModelError,
-	    	"CRPAModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CRPAModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CRPAModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CRPAModel",             /*tp_name*/
-    sizeof(CRPAModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CRPAModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CRPAModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CRPAModel_methods,             /* tp_methods */
-    CRPAModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CRPAModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CRPAModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCRPAModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CRPAModelType) < 0)
-        return;
-
-    Py_INCREF(&CRPAModelType);
-    PyModule_AddObject(module, "CRPAModel", (PyObject *)&CRPAModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CRPAModel.error";
-    CRPAModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CRPAModelError", CRPAModelError);
-}
-
Index: nsmodels/src/python_wrapper/CSLDCalFunc.cpp
===================================================================
--- sansmodels/src/python_wrapper/CSLDCalFunc.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,561 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CSLDCalFunc
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY sld_cal.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "sld_cal.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CSLDCalFuncError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    SLDCalFunc * model;
-    /// Log for unit testing
-    PyObject * log;
-} CSLDCalFunc;
-
-
-static void
-CSLDCalFunc_dealloc(CSLDCalFunc* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CSLDCalFunc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CSLDCalFunc *self;
-    
-    self = (CSLDCalFunc *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CSLDCalFunc_init(CSLDCalFunc *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new SLDCalFunc();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"fun_type",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"nu_inter",Py_BuildValue("d",2.500000000000));
-        PyDict_SetItemString(self->params,"shell_num",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sld_right",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sld_left",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"npts_inter",Py_BuildValue("d",21.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->npts_inter.dispersion->accept_as_source(visitor, self->model->npts_inter.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "npts_inter", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CSLDCalFunc_members[] = {
-    {name_params, T_OBJECT, offsetof(CSLDCalFunc, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CSLDCalFunc, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CSLDCalFunc, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CSLDCalFunc_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(SLDCalFunc* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( SLDCalFunc* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CSLDCalFuncError, 
-                   "CSLDCalFunc.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CSLDCalFunc *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->fun_type = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fun_type") );
-    self->model->nu_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "nu_inter") );
-    self->model->shell_num = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_num") );
-    self->model->sld_right = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_right") );
-    self->model->sld_left = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_left") );
-    self->model->npts_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "npts_inter") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "npts_inter");
-    self->model->npts_inter.dispersion->accept_as_destination(visitor, self->model->npts_inter.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSLDCalFuncError, 
-	    	"CSLDCalFunc.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CSLDCalFuncError, 
-                   "CSLDCalFunc.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CSLDCalFuncError, 
-	    		"CSLDCalFunc.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CSLDCalFuncError, 
-                   "CSLDCalFunc.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CSLDCalFuncError, 
-                   "CSLDCalFunc.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CSLDCalFunc *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->fun_type = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fun_type") );
-    self->model->nu_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "nu_inter") );
-    self->model->shell_num = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_num") );
-    self->model->sld_right = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_right") );
-    self->model->sld_left = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_left") );
-    self->model->npts_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "npts_inter") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "npts_inter");
-    self->model->npts_inter.dispersion->accept_as_destination(visitor, self->model->npts_inter.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSLDCalFuncError, 
-	    	"CSLDCalFunc.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CSLDCalFuncError, 
-	    		"CSLDCalFunc.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CSLDCalFunc_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CSLDCalFunc_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CSLDCalFunc_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CSLDCalFunc *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->fun_type = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fun_type") );
-    self->model->nu_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "nu_inter") );
-    self->model->shell_num = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_num") );
-    self->model->sld_right = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_right") );
-    self->model->sld_left = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_left") );
-    self->model->npts_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "npts_inter") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "npts_inter");
-    self->model->npts_inter.dispersion->accept_as_destination(visitor, self->model->npts_inter.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CSLDCalFunc *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->fun_type = PyFloat_AsDouble( PyDict_GetItemString(self->params, "fun_type") );
-    self->model->nu_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "nu_inter") );
-    self->model->shell_num = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_num") );
-    self->model->sld_right = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_right") );
-    self->model->sld_left = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_left") );
-    self->model->npts_inter = PyFloat_AsDouble( PyDict_GetItemString(self->params, "npts_inter") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "npts_inter");
-    self->model->npts_inter.dispersion->accept_as_destination(visitor, self->model->npts_inter.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSLDCalFuncError, 
-	    	"CSLDCalFunc.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CSLDCalFuncError, 
-	    		"CSLDCalFunc.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CSLDCalFunc_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CSLDCalFunc_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CSLDCalFunc_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CSLDCalFunc *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CSLDCalFunc *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CSLDCalFuncError,
-	    	"CSLDCalFunc.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "npts_inter")) {
-        self->model->npts_inter.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CSLDCalFuncError,
-	    	"CSLDCalFunc.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CSLDCalFunc_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CSLDCalFuncType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CSLDCalFunc",             /*tp_name*/
-    sizeof(CSLDCalFunc),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CSLDCalFunc_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CSLDCalFunc objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CSLDCalFunc_methods,             /* tp_methods */
-    CSLDCalFunc_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CSLDCalFunc_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CSLDCalFunc_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCSLDCalFunc(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CSLDCalFuncType) < 0)
-        return;
-
-    Py_INCREF(&CSLDCalFuncType);
-    PyModule_AddObject(module, "CSLDCalFunc", (PyObject *)&CSLDCalFuncType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CSLDCalFunc.error";
-    CSLDCalFuncError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CSLDCalFuncError", CSLDCalFuncError);
-}
-
Index: nsmodels/src/python_wrapper/CSchulz.cpp
===================================================================
--- sansmodels/src/python_wrapper/CSchulz.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,533 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CSchulz
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY schulz.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "schulz.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CSchulzError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    Schulz * model;
-    /// Log for unit testing
-    PyObject * log;
-} CSchulz;
-
-
-static void
-CSchulz_dealloc(CSchulz* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CSchulz_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CSchulz *self;
-    
-    self = (CSchulz *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CSchulz_init(CSchulz *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new Schulz();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"sigma",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"center",Py_BuildValue("d",0.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CSchulz_members[] = {
-    {name_params, T_OBJECT, offsetof(CSchulz, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CSchulz, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CSchulz, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CSchulz_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(Schulz* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( Schulz* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CSchulzError, 
-                   "CSchulz.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CSchulz *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSchulzError, 
-	    	"CSchulz.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CSchulzError, 
-                   "CSchulz.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CSchulzError, 
-	    		"CSchulz.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CSchulzError, 
-                   "CSchulz.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CSchulzError, 
-                   "CSchulz.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CSchulz *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSchulzError, 
-	    	"CSchulz.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CSchulzError, 
-	    		"CSchulz.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CSchulz_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CSchulz_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CSchulz_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CSchulz *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CSchulz *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->sigma = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma") );
-    self->model->center = PyFloat_AsDouble( PyDict_GetItemString(self->params, "center") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSchulzError, 
-	    	"CSchulz.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CSchulzError, 
-	    		"CSchulz.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CSchulz_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CSchulz_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CSchulz_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CSchulz *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CSchulz *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CSchulzError,
-	    	"CSchulz.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
- {
-	    PyErr_SetString(CSchulzError,
-	    	"CSchulz.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CSchulz_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CSchulzType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CSchulz",             /*tp_name*/
-    sizeof(CSchulz),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CSchulz_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CSchulz objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CSchulz_methods,             /* tp_methods */
-    CSchulz_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CSchulz_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CSchulz_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCSchulz(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CSchulzType) < 0)
-        return;
-
-    Py_INCREF(&CSchulzType);
-    PyModule_AddObject(module, "CSchulz", (PyObject *)&CSchulzType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CSchulz.error";
-    CSchulzError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CSchulzError", CSchulzError);
-}
-
Index: nsmodels/src/python_wrapper/CSquareWellStructure.cpp
===================================================================
--- sansmodels/src/python_wrapper/CSquareWellStructure.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,551 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CSquareWellStructure
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY SquareWell.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "SquareWell.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CSquareWellStructureError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    SquareWellStructure * model;
-    /// Log for unit testing
-    PyObject * log;
-} CSquareWellStructure;
-
-
-static void
-CSquareWellStructure_dealloc(CSquareWellStructure* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CSquareWellStructure_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CSquareWellStructure *self;
-    
-    self = (CSquareWellStructure *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CSquareWellStructure_init(CSquareWellStructure *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new SquareWellStructure();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"welldepth",Py_BuildValue("d",1.500000000000));
-        PyDict_SetItemString(self->params,"effect_radius",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"volfraction",Py_BuildValue("d",0.040000000000));
-        PyDict_SetItemString(self->params,"wellwidth",Py_BuildValue("d",1.200000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->effect_radius.dispersion->accept_as_source(visitor, self->model->effect_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "effect_radius", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CSquareWellStructure_members[] = {
-    {name_params, T_OBJECT, offsetof(CSquareWellStructure, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CSquareWellStructure, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CSquareWellStructure, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CSquareWellStructure_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(SquareWellStructure* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( SquareWellStructure* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CSquareWellStructureError, 
-                   "CSquareWellStructure.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CSquareWellStructure *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->welldepth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "welldepth") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->wellwidth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "wellwidth") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSquareWellStructureError, 
-	    	"CSquareWellStructure.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CSquareWellStructureError, 
-                   "CSquareWellStructure.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CSquareWellStructureError, 
-	    		"CSquareWellStructure.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CSquareWellStructureError, 
-                   "CSquareWellStructure.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CSquareWellStructureError, 
-                   "CSquareWellStructure.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CSquareWellStructure *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->welldepth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "welldepth") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->wellwidth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "wellwidth") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSquareWellStructureError, 
-	    	"CSquareWellStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CSquareWellStructureError, 
-	    		"CSquareWellStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CSquareWellStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CSquareWellStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CSquareWellStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CSquareWellStructure *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->welldepth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "welldepth") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->wellwidth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "wellwidth") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CSquareWellStructure *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->welldepth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "welldepth") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->wellwidth = PyFloat_AsDouble( PyDict_GetItemString(self->params, "wellwidth") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CSquareWellStructureError, 
-	    	"CSquareWellStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CSquareWellStructureError, 
-	    		"CSquareWellStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CSquareWellStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CSquareWellStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CSquareWellStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CSquareWellStructure *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CSquareWellStructure *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CSquareWellStructureError,
-	    	"CSquareWellStructure.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "effect_radius")) {
-        self->model->effect_radius.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CSquareWellStructureError,
-	    	"CSquareWellStructure.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CSquareWellStructure_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CSquareWellStructureType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CSquareWellStructure",             /*tp_name*/
-    sizeof(CSquareWellStructure),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CSquareWellStructure_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CSquareWellStructure objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CSquareWellStructure_methods,             /* tp_methods */
-    CSquareWellStructure_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CSquareWellStructure_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CSquareWellStructure_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCSquareWellStructure(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CSquareWellStructureType) < 0)
-        return;
-
-    Py_INCREF(&CSquareWellStructureType);
-    PyModule_AddObject(module, "CSquareWellStructure", (PyObject *)&CSquareWellStructureType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CSquareWellStructure.error";
-    CSquareWellStructureError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CSquareWellStructureError", CSquareWellStructureError);
-}
-
Index: nsmodels/src/python_wrapper/CStackedDisksModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CStackedDisksModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,643 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CStackedDisksModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY stacked_disks.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "stacked_disks.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CStackedDisksModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    StackedDisksModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CStackedDisksModel;
-
-
-static void
-CStackedDisksModel_dealloc(CStackedDisksModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CStackedDisksModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CStackedDisksModel *self;
-    
-    self = (CStackedDisksModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CStackedDisksModel_init(CStackedDisksModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new StackedDisksModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000004000000));
-        PyDict_SetItemString(self->params,"core_thick",Py_BuildValue("d",10.000000000000));
-        PyDict_SetItemString(self->params,"layer_thick",Py_BuildValue("d",15.000000000000));
-        PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"layer_sld",Py_BuildValue("d",-0.000000400000));
-        PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"solvent_sld",Py_BuildValue("d",0.000005000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",0.010000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",3000.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"sigma_d",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"n_stacking",Py_BuildValue("d",1.000000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->core_thick.dispersion->accept_as_source(visitor, self->model->core_thick.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "core_thick", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->layer_thick.dispersion->accept_as_source(visitor, self->model->layer_thick.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "layer_thick", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CStackedDisksModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CStackedDisksModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CStackedDisksModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CStackedDisksModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CStackedDisksModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(StackedDisksModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( StackedDisksModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CStackedDisksModelError, 
-                   "CStackedDisksModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CStackedDisksModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_thick") );
-    self->model->layer_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_thick") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sigma_d = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma_d") );
-    self->model->n_stacking = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_stacking") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_thick");
-    self->model->core_thick.dispersion->accept_as_destination(visitor, self->model->core_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "layer_thick");
-    self->model->layer_thick.dispersion->accept_as_destination(visitor, self->model->layer_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CStackedDisksModelError, 
-	    	"CStackedDisksModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CStackedDisksModelError, 
-                   "CStackedDisksModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CStackedDisksModelError, 
-	    		"CStackedDisksModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CStackedDisksModelError, 
-                   "CStackedDisksModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CStackedDisksModelError, 
-                   "CStackedDisksModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CStackedDisksModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_thick") );
-    self->model->layer_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_thick") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sigma_d = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma_d") );
-    self->model->n_stacking = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_stacking") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_thick");
-    self->model->core_thick.dispersion->accept_as_destination(visitor, self->model->core_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "layer_thick");
-    self->model->layer_thick.dispersion->accept_as_destination(visitor, self->model->layer_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CStackedDisksModelError, 
-	    	"CStackedDisksModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CStackedDisksModelError, 
-	    		"CStackedDisksModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CStackedDisksModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CStackedDisksModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CStackedDisksModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CStackedDisksModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_thick") );
-    self->model->layer_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_thick") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sigma_d = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma_d") );
-    self->model->n_stacking = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_stacking") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_thick");
-    self->model->core_thick.dispersion->accept_as_destination(visitor, self->model->core_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "layer_thick");
-    self->model->layer_thick.dispersion->accept_as_destination(visitor, self->model->layer_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CStackedDisksModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->core_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_thick") );
-    self->model->layer_thick = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_thick") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->layer_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "layer_sld") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sigma_d = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sigma_d") );
-    self->model->n_stacking = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_stacking") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "core_thick");
-    self->model->core_thick.dispersion->accept_as_destination(visitor, self->model->core_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "layer_thick");
-    self->model->layer_thick.dispersion->accept_as_destination(visitor, self->model->layer_thick.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CStackedDisksModelError, 
-	    	"CStackedDisksModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CStackedDisksModelError, 
-	    		"CStackedDisksModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CStackedDisksModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CStackedDisksModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CStackedDisksModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CStackedDisksModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CStackedDisksModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CStackedDisksModelError,
-	    	"CStackedDisksModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "core_thick")) {
-        self->model->core_thick.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "layer_thick")) {
-        self->model->layer_thick.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_theta")) {
-        self->model->axis_theta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_phi")) {
-        self->model->axis_phi.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CStackedDisksModelError,
-	    	"CStackedDisksModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CStackedDisksModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CStackedDisksModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CStackedDisksModel",             /*tp_name*/
-    sizeof(CStackedDisksModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CStackedDisksModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CStackedDisksModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CStackedDisksModel_methods,             /* tp_methods */
-    CStackedDisksModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CStackedDisksModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CStackedDisksModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCStackedDisksModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CStackedDisksModelType) < 0)
-        return;
-
-    Py_INCREF(&CStackedDisksModelType);
-    PyModule_AddObject(module, "CStackedDisksModel", (PyObject *)&CStackedDisksModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CStackedDisksModel.error";
-    CStackedDisksModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CStackedDisksModelError", CStackedDisksModelError);
-}
-
Index: nsmodels/src/python_wrapper/CStickyHSStructure.cpp
===================================================================
--- sansmodels/src/python_wrapper/CStickyHSStructure.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,551 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CStickyHSStructure
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY StickyHS.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "StickyHS.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CStickyHSStructureError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    StickyHSStructure * model;
-    /// Log for unit testing
-    PyObject * log;
-} CStickyHSStructure;
-
-
-static void
-CStickyHSStructure_dealloc(CStickyHSStructure* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CStickyHSStructure_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CStickyHSStructure *self;
-    
-    self = (CStickyHSStructure *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CStickyHSStructure_init(CStickyHSStructure *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new StickyHSStructure();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"stickiness",Py_BuildValue("d",0.200000000000));
-        PyDict_SetItemString(self->params,"effect_radius",Py_BuildValue("d",50.000000000000));
-        PyDict_SetItemString(self->params,"volfraction",Py_BuildValue("d",0.100000000000));
-        PyDict_SetItemString(self->params,"perturb",Py_BuildValue("d",0.050000000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->effect_radius.dispersion->accept_as_source(visitor, self->model->effect_radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "effect_radius", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CStickyHSStructure_members[] = {
-    {name_params, T_OBJECT, offsetof(CStickyHSStructure, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CStickyHSStructure, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CStickyHSStructure, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CStickyHSStructure_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(StickyHSStructure* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( StickyHSStructure* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CStickyHSStructureError, 
-                   "CStickyHSStructure.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CStickyHSStructure *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->stickiness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "stickiness") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->perturb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "perturb") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CStickyHSStructureError, 
-	    	"CStickyHSStructure.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CStickyHSStructureError, 
-                   "CStickyHSStructure.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CStickyHSStructureError, 
-	    		"CStickyHSStructure.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CStickyHSStructureError, 
-                   "CStickyHSStructure.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CStickyHSStructureError, 
-                   "CStickyHSStructure.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CStickyHSStructure *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->stickiness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "stickiness") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->perturb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "perturb") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CStickyHSStructureError, 
-	    	"CStickyHSStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CStickyHSStructureError, 
-	    		"CStickyHSStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CStickyHSStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CStickyHSStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CStickyHSStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CStickyHSStructure *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->stickiness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "stickiness") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->perturb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "perturb") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CStickyHSStructure *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->stickiness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "stickiness") );
-    self->model->effect_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "effect_radius") );
-    self->model->volfraction = PyFloat_AsDouble( PyDict_GetItemString(self->params, "volfraction") );
-    self->model->perturb = PyFloat_AsDouble( PyDict_GetItemString(self->params, "perturb") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "effect_radius");
-    self->model->effect_radius.dispersion->accept_as_destination(visitor, self->model->effect_radius.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CStickyHSStructureError, 
-	    	"CStickyHSStructure.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CStickyHSStructureError, 
-	    		"CStickyHSStructure.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CStickyHSStructure_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CStickyHSStructure_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CStickyHSStructure_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CStickyHSStructure *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CStickyHSStructure *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CStickyHSStructureError,
-	    	"CStickyHSStructure.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "effect_radius")) {
-        self->model->effect_radius.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CStickyHSStructureError,
-	    	"CStickyHSStructure.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CStickyHSStructure_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CStickyHSStructureType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CStickyHSStructure",             /*tp_name*/
-    sizeof(CStickyHSStructure),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CStickyHSStructure_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CStickyHSStructure objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CStickyHSStructure_methods,             /* tp_methods */
-    CStickyHSStructure_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CStickyHSStructure_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CStickyHSStructure_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCStickyHSStructure(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CStickyHSStructureType) < 0)
-        return;
-
-    Py_INCREF(&CStickyHSStructureType);
-    PyModule_AddObject(module, "CStickyHSStructure", (PyObject *)&CStickyHSStructureType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CStickyHSStructure.error";
-    CStickyHSStructureError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CStickyHSStructureError", CStickyHSStructureError);
-}
-
Index: nsmodels/src/python_wrapper/CTriaxialEllipsoidModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CTriaxialEllipsoidModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,646 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CTriaxialEllipsoidModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY triaxial_ellipsoid.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "triaxial_ellipsoid.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CTriaxialEllipsoidModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    TriaxialEllipsoidModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CTriaxialEllipsoidModel;
-
-
-static void
-CTriaxialEllipsoidModel_dealloc(CTriaxialEllipsoidModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CTriaxialEllipsoidModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CTriaxialEllipsoidModel *self;
-    
-    self = (CTriaxialEllipsoidModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CTriaxialEllipsoidModel_init(CTriaxialEllipsoidModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new TriaxialEllipsoidModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"axis_psi",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"axis_theta",Py_BuildValue("d",57.325000000000));
-        PyDict_SetItemString(self->params,"semi_axisA",Py_BuildValue("d",35.000000000000));
-        PyDict_SetItemString(self->params,"semi_axisB",Py_BuildValue("d",100.000000000000));
-        PyDict_SetItemString(self->params,"semi_axisC",Py_BuildValue("d",400.000000000000));
-        PyDict_SetItemString(self->params,"axis_phi",Py_BuildValue("d",57.325000000000));
-        PyDict_SetItemString(self->params,"sldSolv",Py_BuildValue("d",0.000006300000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"sldEll",Py_BuildValue("d",0.000001000000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->semi_axisA.dispersion->accept_as_source(visitor, self->model->semi_axisA.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "semi_axisA", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->semi_axisB.dispersion->accept_as_source(visitor, self->model->semi_axisB.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "semi_axisB", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->semi_axisC.dispersion->accept_as_source(visitor, self->model->semi_axisC.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "semi_axisC", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_theta.dispersion->accept_as_source(visitor, self->model->axis_theta.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_theta", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_phi.dispersion->accept_as_source(visitor, self->model->axis_phi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_phi", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->axis_psi.dispersion->accept_as_source(visitor, self->model->axis_psi.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "axis_psi", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CTriaxialEllipsoidModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CTriaxialEllipsoidModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CTriaxialEllipsoidModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CTriaxialEllipsoidModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CTriaxialEllipsoidModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(TriaxialEllipsoidModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( TriaxialEllipsoidModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CTriaxialEllipsoidModelError, 
-                   "CTriaxialEllipsoidModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CTriaxialEllipsoidModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_psi") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") );
-    self->model->semi_axisB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisB") );
-    self->model->semi_axisC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisC") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisA");
-    self->model->semi_axisA.dispersion->accept_as_destination(visitor, self->model->semi_axisA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisB");
-    self->model->semi_axisB.dispersion->accept_as_destination(visitor, self->model->semi_axisB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisC");
-    self->model->semi_axisC.dispersion->accept_as_destination(visitor, self->model->semi_axisC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_psi");
-    self->model->axis_psi.dispersion->accept_as_destination(visitor, self->model->axis_psi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CTriaxialEllipsoidModelError, 
-	    	"CTriaxialEllipsoidModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CTriaxialEllipsoidModelError, 
-                   "CTriaxialEllipsoidModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CTriaxialEllipsoidModelError, 
-	    		"CTriaxialEllipsoidModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CTriaxialEllipsoidModelError, 
-                   "CTriaxialEllipsoidModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CTriaxialEllipsoidModelError, 
-                   "CTriaxialEllipsoidModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CTriaxialEllipsoidModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_psi") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") );
-    self->model->semi_axisB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisB") );
-    self->model->semi_axisC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisC") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisA");
-    self->model->semi_axisA.dispersion->accept_as_destination(visitor, self->model->semi_axisA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisB");
-    self->model->semi_axisB.dispersion->accept_as_destination(visitor, self->model->semi_axisB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisC");
-    self->model->semi_axisC.dispersion->accept_as_destination(visitor, self->model->semi_axisC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_psi");
-    self->model->axis_psi.dispersion->accept_as_destination(visitor, self->model->axis_psi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CTriaxialEllipsoidModelError, 
-	    	"CTriaxialEllipsoidModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CTriaxialEllipsoidModelError, 
-	    		"CTriaxialEllipsoidModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CTriaxialEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CTriaxialEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CTriaxialEllipsoidModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CTriaxialEllipsoidModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_psi") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") );
-    self->model->semi_axisB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisB") );
-    self->model->semi_axisC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisC") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisA");
-    self->model->semi_axisA.dispersion->accept_as_destination(visitor, self->model->semi_axisA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisB");
-    self->model->semi_axisB.dispersion->accept_as_destination(visitor, self->model->semi_axisB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisC");
-    self->model->semi_axisC.dispersion->accept_as_destination(visitor, self->model->semi_axisC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_psi");
-    self->model->axis_psi.dispersion->accept_as_destination(visitor, self->model->axis_psi.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CTriaxialEllipsoidModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->axis_psi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_psi") );
-    self->model->axis_theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_theta") );
-    self->model->semi_axisA = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisA") );
-    self->model->semi_axisB = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisB") );
-    self->model->semi_axisC = PyFloat_AsDouble( PyDict_GetItemString(self->params, "semi_axisC") );
-    self->model->axis_phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "axis_phi") );
-    self->model->sldSolv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldSolv") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->sldEll = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldEll") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisA");
-    self->model->semi_axisA.dispersion->accept_as_destination(visitor, self->model->semi_axisA.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisB");
-    self->model->semi_axisB.dispersion->accept_as_destination(visitor, self->model->semi_axisB.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "semi_axisC");
-    self->model->semi_axisC.dispersion->accept_as_destination(visitor, self->model->semi_axisC.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_theta");
-    self->model->axis_theta.dispersion->accept_as_destination(visitor, self->model->axis_theta.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_phi");
-    self->model->axis_phi.dispersion->accept_as_destination(visitor, self->model->axis_phi.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "axis_psi");
-    self->model->axis_psi.dispersion->accept_as_destination(visitor, self->model->axis_psi.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CTriaxialEllipsoidModelError, 
-	    	"CTriaxialEllipsoidModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CTriaxialEllipsoidModelError, 
-	    		"CTriaxialEllipsoidModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CTriaxialEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CTriaxialEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CTriaxialEllipsoidModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CTriaxialEllipsoidModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CTriaxialEllipsoidModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CTriaxialEllipsoidModelError,
-	    	"CTriaxialEllipsoidModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "semi_axisA")) {
-        self->model->semi_axisA.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "semi_axisB")) {
-        self->model->semi_axisB.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "semi_axisC")) {
-        self->model->semi_axisC.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_theta")) {
-        self->model->axis_theta.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_phi")) {
-        self->model->axis_phi.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "axis_psi")) {
-        self->model->axis_psi.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CTriaxialEllipsoidModelError,
-	    	"CTriaxialEllipsoidModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CTriaxialEllipsoidModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CTriaxialEllipsoidModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CTriaxialEllipsoidModel",             /*tp_name*/
-    sizeof(CTriaxialEllipsoidModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CTriaxialEllipsoidModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CTriaxialEllipsoidModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CTriaxialEllipsoidModel_methods,             /* tp_methods */
-    CTriaxialEllipsoidModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CTriaxialEllipsoidModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CTriaxialEllipsoidModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCTriaxialEllipsoidModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CTriaxialEllipsoidModelType) < 0)
-        return;
-
-    Py_INCREF(&CTriaxialEllipsoidModelType);
-    PyModule_AddObject(module, "CTriaxialEllipsoidModel", (PyObject *)&CTriaxialEllipsoidModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CTriaxialEllipsoidModel.error";
-    CTriaxialEllipsoidModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CTriaxialEllipsoidModelError", CTriaxialEllipsoidModelError);
-}
-
Index: nsmodels/src/python_wrapper/CVesicleModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CVesicleModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,574 +1,0 @@
-/**
-	This software was developed by the University of Tennessee as part of the
-	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-	project funded by the US National Science Foundation.
-
-	If you use DANSE applications to do scientific research that leads to
-	publication, we ask that you acknowledge the use of the software with the
-	following sentence:
-
-	"This work benefited from DANSE software developed under NSF award DMR-0520547."
-
-	copyright 2008, University of Tennessee
- */
-
-/** CVesicleModel
- *
- * C extension 
- *
- * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY vesicle.h
- *          AND RE-RUN THE GENERATOR SCRIPT
- *
- */
-#define NO_IMPORT_ARRAY
-#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
- 
-extern "C" {
-#include <Python.h>
-#include <arrayobject.h>
-#include "structmember.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include "vesicle.h"
-}
-
-#include "models.hh"
-#include "dispersion_visitor.hh"
-
-/// Error object for raised exceptions
-static PyObject * CVesicleModelError = NULL;
-
-
-// Class definition
-typedef struct {
-    PyObject_HEAD
-    /// Parameters
-    PyObject * params;
-    /// Dispersion parameters
-    PyObject * dispersion;
-    /// Underlying model object
-    VesicleModel * model;
-    /// Log for unit testing
-    PyObject * log;
-} CVesicleModel;
-
-
-static void
-CVesicleModel_dealloc(CVesicleModel* self)
-{
-    Py_DECREF(self->params);
-    Py_DECREF(self->dispersion);
-    Py_DECREF(self->log);
-    delete self->model;
-    self->ob_type->tp_free((PyObject*)self);
-    
-
-}
-
-static PyObject *
-CVesicleModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    CVesicleModel *self;
-    
-    self = (CVesicleModel *)type->tp_alloc(type, 0);
-   
-    return (PyObject *)self;
-}
-
-static int
-CVesicleModel_init(CVesicleModel *self, PyObject *args, PyObject *kwds)
-{
-    if (self != NULL) {
-    	
-    	// Create parameters
-        self->params = PyDict_New();
-        self->dispersion = PyDict_New();
-        self->model = new VesicleModel();
-        
-        // Initialize parameter dictionary
-        PyDict_SetItemString(self->params,"core_sld",Py_BuildValue("d",0.000006360000));
-        PyDict_SetItemString(self->params,"thickness",Py_BuildValue("d",30.000000000000));
-        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
-        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",100.000000000000));
-        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
-        PyDict_SetItemString(self->params,"shell_sld",Py_BuildValue("d",0.000000500000));
-        // Initialize dispersion / averaging parameter dict
-        DispersionVisitor* visitor = new DispersionVisitor();
-        PyObject * disp_dict;
-        disp_dict = PyDict_New();
-        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
-        disp_dict = PyDict_New();
-        self->model->thickness.dispersion->accept_as_source(visitor, self->model->thickness.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "thickness", disp_dict);
-
-
-         
-        // Create empty log
-        self->log = PyDict_New();
-        
-        
-
-    }
-    return 0;
-}
-
-static char name_params[] = "params";
-static char def_params[] = "Parameters";
-static char name_dispersion[] = "dispersion";
-static char def_dispersion[] = "Dispersion parameters";
-static char name_log[] = "log";
-static char def_log[] = "Log";
-
-static PyMemberDef CVesicleModel_members[] = {
-    {name_params, T_OBJECT, offsetof(CVesicleModel, params), 0, def_params},
-	{name_dispersion, T_OBJECT, offsetof(CVesicleModel, dispersion), 0, def_dispersion},     
-    {name_log, T_OBJECT, offsetof(CVesicleModel, log), 0, def_log},
-    {NULL}  /* Sentinel */
-};
-
-/** Read double from PyObject
-    @param p PyObject
-    @return double
-*/
-double CVesicleModel_readDouble(PyObject *p) {
-    if (PyFloat_Check(p)==1) {
-        return (double)(((PyFloatObject *)(p))->ob_fval);
-    } else if (PyInt_Check(p)==1) {
-        return (double)(((PyIntObject *)(p))->ob_ival);
-    } else if (PyLong_Check(p)==1) {
-        return (double)PyLong_AsLong(p);
-    } else {
-        return 0.0;
-    }
-}
-/**
- * Function to call to evaluate model
- * @param args: input numpy array q[] 
- * @return: numpy array object 
- */
- 
-static PyObject *evaluateOneDim(VesicleModel* model, PyArrayObject *q){
-    PyArrayObject *result;
-   
-    // Check validity of array q , q must be of dimension 1, an array of double
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
-    {
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        //PyErr_SetString(PyExc_ValueError , message);
-        return NULL;
-    }
-    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), PyArray_DOUBLE);
-	if (result == NULL) {
-        const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-		return NULL;
-	}
-#pragma omp parallel for
-	 for (int i = 0; i < q->dimensions[0]; i++){
-      double q_value  = *(double *)(q->data + i*q->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      *result_value =(*model)(q_value);
-	}
-    return PyArray_Return(result); 
- }
-
- /**
- * Function to call to evaluate model
- * @param args: input numpy array  [x[],y[]]
- * @return: numpy array object 
- */
- static PyObject * evaluateTwoDimXY( VesicleModel* model, 
-                              PyArrayObject *x, PyArrayObject *y)
- {
-    PyArrayObject *result;
-    int x_len, y_len, dims[1];
-    //check validity of input vectors
-    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
-        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
-        || y->dimensions[0] != x->dimensions[0]){
-        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
-        PyErr_SetString(PyExc_ValueError , message); 
-        return NULL;
-    }
-   
-	if (PyArray_Check(x) && PyArray_Check(y)) {
-		
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[0]= y->dimensions[0];
-	    
-	    // Make a new double matrix of same dims
-        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
-        if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	    }
-       
-        /* Do the calculation. */
-#pragma omp parallel for
-        for (int i=0; i< x_len; i++) {
-            double x_value = *(double *)(x->data + i*x->strides[0]);
-  		    double y_value = *(double *)(y->data + i*y->strides[0]);
-  			double *result_value = (double *)(result->data +
-  			      i*result->strides[0]);
-  			*result_value = (*model)(x_value, y_value);
-        }           
-        return PyArray_Return(result); 
-        
-        }else{
-		    PyErr_SetString(CVesicleModelError, 
-                   "CVesicleModel.evaluateTwoDimXY couldn't run.");
-	        return NULL;
-		}      	
-}
-/**
- *  evalDistribution function evaluate a model function with input vector
- *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
- *
- */ 
-static PyObject * evalDistribution(CVesicleModel *self, PyObject *args){
-	PyObject *qx, *qy;
-	PyArrayObject * pars;
-	int npars ,mpars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CVesicleModelError, 
-	    	"CVesicleModel.evalDistribution expects a q value.");
-		return NULL;
-	}
-    // Check params
-	
-    if(PyArray_Check(pars)==1) {
-		
-	    // Length of list should 1 or 2
-	    npars = pars->nd; 
-	    if(npars==1) {
-	        // input is a numpy array
-	        if (PyArray_Check(pars)) {
-		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
-		    }
-		}else{
-		    PyErr_SetString(CVesicleModelError, 
-                   "CVesicleModel.evalDistribution expect numpy array of one dimension.");
-	        return NULL;
-		}
-    }else if( PyList_Check(pars)==1) {
-    	// Length of list should be 2 for I(qx,qy)
-	    mpars = PyList_GET_SIZE(pars); 
-	    if(mpars!=2) {
-	    	PyErr_SetString(CVesicleModelError, 
-	    		"CVesicleModel.evalDistribution expects a list of dimension 2.");
-	    	return NULL;
-	    }
-	     qx = PyList_GET_ITEM(pars,0);
-	     qy = PyList_GET_ITEM(pars,1);
-	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
-	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
-		           (PyArrayObject*)qy);
-		 }else{
-		    PyErr_SetString(CVesicleModelError, 
-                   "CVesicleModel.evalDistribution expect 2 numpy arrays in list.");
-	        return NULL;
-	     }
-	}
-	PyErr_SetString(CVesicleModelError, 
-                   "CVesicleModel.evalDistribution couln't be run.");
-	return NULL;
-	
-}
-
-/**
- * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
- */
-static PyObject * run(CVesicleModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CVesicleModelError, 
-	    	"CVesicleModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(q,phi)
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CVesicleModelError, 
-	    		"CVesicleModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the q and phi values at which
-	    // to evaluate I(q,phi)
-	    q_value = CVesicleModel_readDouble(PyList_GET_ITEM(pars,0));
-	    phi_value = CVesicleModel_readDouble(PyList_GET_ITEM(pars,1));
-	    // Skip zero
-	    if (q_value==0) {
-	    	return Py_BuildValue("d",0.0);
-	    }
-		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		q_value = CVesicleModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(q_value));
-	}	
-}
-/**
- * Function to call to calculate_ER
- * @return: effective radius value 
- */
-static PyObject * calculate_ER(CVesicleModel *self) {
-
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-		
-	return Py_BuildValue("d",(*(self->model)).calculate_ER());
-
-}
-/**
- * Function to call to evaluate model in cartesian coordinates
- * @param args: input q or [qx, qy]]
- * @return: function value
- */
-static PyObject * runXY(CVesicleModel *self, PyObject *args) {
-	double qx_value, qy_value;
-	PyObject* pars;
-	int npars;
-	
-	// Get parameters
-	
-	    // Reader parameter dictionary
-    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
-    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
-    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
-    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
-    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
-    // Read in dispersion parameters
-    PyObject* disp_dict;
-    DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
-    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
-    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
-    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.dispersion, disp_dict);
-
-	
-	// Get input and determine whether we have to supply a 1D or 2D return value.
-	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
-	    PyErr_SetString(CVesicleModelError, 
-	    	"CVesicleModel.run expects a q value.");
-		return NULL;
-	}
-	  
-	// Check params
-	if( PyList_Check(pars)==1) {
-		
-		// Length of list should be 2 for I(qx, qy))
-	    npars = PyList_GET_SIZE(pars); 
-	    if(npars!=2) {
-	    	PyErr_SetString(CVesicleModelError, 
-	    		"CVesicleModel.run expects a double or a list of dimension 2.");
-	    	return NULL;
-	    }
-	    // We have a vector q, get the qx and qy values at which
-	    // to evaluate I(qx,qy)
-	    qx_value = CVesicleModel_readDouble(PyList_GET_ITEM(pars,0));
-	    qy_value = CVesicleModel_readDouble(PyList_GET_ITEM(pars,1));
-	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
-
-	} else {
-
-		// We have a scalar q, we will evaluate I(q)
-		qx_value = CVesicleModel_readDouble(pars);		
-		
-		return Py_BuildValue("d",(*(self->model))(qx_value));
-	}	
-}
-
-static PyObject * reset(CVesicleModel *self, PyObject *args) {
-    
-
-    return Py_BuildValue("d",0.0);
-}
-
-static PyObject * set_dispersion(CVesicleModel *self, PyObject *args) {
-	PyObject * disp;
-	const char * par_name;
-
-	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
-	    PyErr_SetString(CVesicleModelError,
-	    	"CVesicleModel.set_dispersion expects a DispersionModel object.");
-		return NULL;
-	}
-	void *temp = PyCObject_AsVoidPtr(disp);
-	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
-
-
-	// Ugliness necessary to go from python to C
-	    // TODO: refactor this
-    if (!strcmp(par_name, "radius")) {
-        self->model->radius.dispersion = dispersion;
-    } else    if (!strcmp(par_name, "thickness")) {
-        self->model->thickness.dispersion = dispersion;
-    } else {
-	    PyErr_SetString(CVesicleModelError,
-	    	"CVesicleModel.set_dispersion expects a valid parameter name.");
-		return NULL;
-	}
-
-	DispersionVisitor* visitor = new DispersionVisitor();
-	PyObject * disp_dict = PyDict_New();
-	dispersion->accept_as_source(visitor, dispersion, disp_dict);
-	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
-    return Py_BuildValue("i",1);
-}
-
-
-static PyMethodDef CVesicleModel_methods[] = {
-    {"run",      (PyCFunction)run     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy"},
-    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
-      "Evaluate the model at a given Q or Q, phi"},
-      
-    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
-      "Evaluate the model at a given Q or Qx, Qy vector "},
-    {"reset",    (PyCFunction)reset   , METH_VARARGS,
-      "Reset pair correlation"},
-    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
-      "Set the dispersion model for a given parameter"},
-   {NULL}
-};
-
-static PyTypeObject CVesicleModelType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "CVesicleModel",             /*tp_name*/
-    sizeof(CVesicleModel),             /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)CVesicleModel_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    0,                         /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
-    "CVesicleModel objects",           /* tp_doc */
-    0,		               /* tp_traverse */
-    0,		               /* tp_clear */
-    0,		               /* tp_richcompare */
-    0,		               /* tp_weaklistoffset */
-    0,		               /* tp_iter */
-    0,		               /* tp_iternext */
-    CVesicleModel_methods,             /* tp_methods */
-    CVesicleModel_members,             /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)CVesicleModel_init,      /* tp_init */
-    0,                         /* tp_alloc */
-    CVesicleModel_new,                 /* tp_new */
-};
-
-
-//static PyMethodDef module_methods[] = {
-//    {NULL} 
-//};
-
-/**
- * Function used to add the model class to a module
- * @param module: module to add the class to
- */ 
-void addCVesicleModel(PyObject *module) {
-	PyObject *d;
-	
-    if (PyType_Ready(&CVesicleModelType) < 0)
-        return;
-
-    Py_INCREF(&CVesicleModelType);
-    PyModule_AddObject(module, "CVesicleModel", (PyObject *)&CVesicleModelType);
-    
-    d = PyModule_GetDict(module);
-    static char error_name[] = "CVesicleModel.error";
-    CVesicleModelError = PyErr_NewException(error_name, NULL, NULL);
-    PyDict_SetItemString(d, "CVesicleModelError", CVesicleModelError);
-}
-
Index: sansmodels/src/python_wrapper/WrapperGenerator.py
===================================================================
--- sansmodels/src/python_wrapper/WrapperGenerator.py	(revision 2d1b7008c4fcc2791722e1581f47a3559d64f820)
+++ sansmodels/src/python_wrapper/WrapperGenerator.py	(revision 642a025e2c955d964469990e58aa29e9deef7407)
@@ -56,5 +56,5 @@
     """
     
-    def __init__(self, filename, output_dir='.'):
+    def __init__(self, filename, output_dir='.', c_wrapper_dir='.'):
         """ Initialization """
         
@@ -92,4 +92,5 @@
         ## output directory for wrappers
         self.output_dir = output_dir
+        self.c_wrapper_dir = c_wrapper_dir
         
         
@@ -291,5 +292,5 @@
             The file is written in C[PYTHONCLASS].c
         """
-        file_path = os.path.join(self.output_dir, "C"+self.pythonClass+'.cpp')
+        file_path = os.path.join(self.c_wrapper_dir, "C"+self.pythonClass+'.cpp')
         file = open(file_path, 'w')
         
@@ -417,5 +418,5 @@
             The file is written in ../[PYTHONCLASS].py
         """
-        file_path = os.path.join(self.output_dir, "../sans/models/"+self.pythonClass+'.py')
+        file_path = os.path.join(self.output_dir, self.pythonClass+'.py')
         file = open(file_path, 'w')
         template = open(os.path.join(os.path.dirname(__file__), "modelTemplate.txt"), 'r')
Index: sansmodels/src/python_wrapper/wrapping.py
===================================================================
--- sansmodels/src/python_wrapper/wrapping.py	(revision 2d1b7008c4fcc2791722e1581f47a3559d64f820)
+++ sansmodels/src/python_wrapper/wrapping.py	(revision 642a025e2c955d964469990e58aa29e9deef7407)
@@ -4,5 +4,5 @@
 from WrapperGenerator import WrapperGenerator
 
-def generate_wrappers(header_dir, output_dir='.'):
+def generate_wrappers(header_dir, output_dir='.', c_wrapper_dir='.'):
     nModels=0
     for item in os.listdir(header_dir):
@@ -11,5 +11,7 @@
             nModels += 1
             name = toks[0]
-            app = WrapperGenerator(os.path.join(header_dir, name+".h"), output_dir=output_dir)
+            app = WrapperGenerator(os.path.join(header_dir, name+".h"), 
+                                   output_dir=output_dir,
+                                   c_wrapper_dir=c_wrapper_dir)
             app.read()
             app.write_c_wrapper()
@@ -20,5 +22,5 @@
 if __name__ == '__main__':
     header_dir = os.path.join('..', 'c_extensions')
-    generate_wrappers(header_dir)
+    generate_wrappers(header_dir, output_dir="../sans/models/", c_wrapper_dir='.')
 
 
Index: setup.py
===================================================================
--- setup.py	(revision 2d1b7008c4fcc2791722e1581f47a3559d64f820)
+++ setup.py	(revision 642a025e2c955d964469990e58aa29e9deef7407)
@@ -216,9 +216,12 @@
 c_model_dir = os.path.join("sansmodels", "src", "c_models")
 smear_dir  = os.path.join("sansmodels", "src", "c_smearer")
-wrapper_dir  = os.path.join("sansmodels", "src", "python_wrapper")
-
-sys.path.append(wrapper_dir)
+wrapper_dir  = os.path.join("sansmodels", "src", "python_wrapper", "generated")
+os.makedirs(wrapper_dir)
+
+sys.path.append(os.path.join("sansmodels", "src", "python_wrapper"))
 from wrapping import generate_wrappers
-generate_wrappers(header_dir=srcdir, output_dir=wrapper_dir)
+generate_wrappers(header_dir=srcdir, 
+                  output_dir=os.path.join("sansmodels", "src", "sans", "models"), 
+                  c_wrapper_dir=wrapper_dir)
 
 IGNORED_FILES = ["a.exe",
