Index: rk_integration/Fitting.py
===================================================================
--- park_integration/Fitting.py	(revision 770530690a37496a90d89a41d399cc96206e8f8d)
+++ 	(revision )
@@ -1,143 +1,0 @@
-#class Fitting
-from sans.guitools.plottables import Data1D
-from Loader import Load
-from scipy import optimize
-from ScipyFitting import ScipyFit
-from ParkFitting import ParkFit
-
-
-class Fit:
-    """ 
-        Wrap class that allows to select the fitting type 
-    """  
-    def __init__(self):
-        
-        # To initialize a type of Fit
-        self._engine=None
-          
-    def fit_engine(self,word):
-        """
-            Select the type of Fit 
-            @param word: the keyword to select the fit type 
-        """
-        if word=="scipy":
-            self._engine=ScipyFit()
-        elif word=="park":
-            self._engine=ParkFit()
-        else:
-            raise ValueError, "enter the keyword scipy or park"
-    def returnEngine(self):
-        return self._engine
-    
-    def fit(self,pars, qmin=None, qmax=None):
-        """ Do the fit """
-      
-    def set_model(self,model,Uid):
-        """ Set model """
-       
-    def set_data(self,data,Uid):
-        """ Receive plottable and create a list of data to fit"""
-            
-    def get_model(self,Uid):
-        """ return list of data"""
-    
-    def set_param(self,model, pars):
-        """ Recieve a dictionary of parameter and save it """
-   
-    def add_constraint(self, constraint):
-        """ User specify contraint to fit """
-        
-    def get_constraint(self):
-        """ return the contraint value """
-  
-    def set_constraint(self,constraint):
-        """ 
-            receive a string as a constraint
-            @param constraint: a string used to constraint some parameters to get a 
-                specific value
-        """
-if __name__ == "__main__": 
-    load= Load()
-    # test scipy 
-    """test fit one data set one model with scipy """
-    #load data 
-    load.set_filename("testdata_line.txt")
-    load.set_values()
-    data1 = Data1D(x=[], y=[], dx=None,dy=None)
-    data1.name = "data1"
-    load.load_data(data1)
-    #choose a model
-    from sans.guitools.LineModel import LineModel
-    model  = LineModel()
-    #Create a Fit engine
-    fitter =Fit()
-    fitter.fit_engine('scipy')
-    engine = fitter.returnEngine()
-    
-    #set the model
-    engine.set_model(model,1)
-    engine.set_data(data1,1)
-    
-    print"fit only one data SCIPY:",engine.fit({'A':2,'B':1},None,None)
-    
-    
-    """ test fit one data set one model with park """
-    fitter.fit_engine('scipy')
-    engine = fitter.returnEngine()
-    #set the model
-    engine.set_model(model,1)
-    engine.set_data(data1,1)
-    
-    print"fit only one data PARK:",engine.fit({'A':2,'B':1},None,None)
-    
-    
-    """test fit with 2 data and one model SCIPY:"""
-    # reinitialize the fitter
-    fitter =Fit()
-    #create an engine
-    fitter.fit_engine("scipy")
-    engine=fitter.returnEngine()
-    #set the model for fit
-    engine.set_model(model,2 )
-    #load 1 st data
-    load.set_filename("testdata1.txt")
-    load.set_values()
-    data2 = Data1D(x=[], y=[], dx=None,dy=None)
-    data2.name = "data2"
-    load.load_data(data2)
-    #load  2nd data
-    load.set_filename("testdata2.txt")
-    load.set_values()
-    data3 = Data1D(x=[], y=[], dx=None,dy=None)
-    data3.name = "data2"
-    load.load_data(data3)
-    
-    #set data in the engine
-    engine.set_data(data2,2)
-    engine.set_data(data3,2)
-    print"fit two data SCIPY:",engine.fit({'A':2,'B':1},None,None)
-    
-    """ test fit with 2 data and one model PARK:"""
-    fitter.fit_engine("park")
-    engine=fitter.returnEngine()
-    #set the model for fit
-    engine.set_model(model,2 )
-    #load 1 st data
-    load.set_filename("testdata1.txt")
-    load.set_values()
-    data2 = Data1D(x=[], y=[], dx=None,dy=None)
-    data2.name = "data2"
-    load.load_data(data2)
-    #load  2nd data
-    load.set_filename("testdata2.txt")
-    load.set_values()
-    data3 = Data1D(x=[], y=[], dx=None,dy=None)
-    data3.name = "data2"
-    load.load_data(data3)
-    
-    #set data in the engine
-    engine.set_data(data2,2)
-    engine.set_data(data3,2)
-    print"fit two data PARK:",engine.fit({'A':2,'B':1},None,None)
-    
-  
Index: rk_integration/Loader.py
===================================================================
--- park_integration/Loader.py	(revision 770530690a37496a90d89a41d399cc96206e8f8d)
+++ 	(revision )
@@ -1,84 +1,0 @@
-# class Loader  to load any king of file
-import wx
-import string,numpy
-class Load:
-    """
-        This class is loading values from given file or value giving by the user
-    """
-    
-    def _init_(self,x=None,y=None,dx=None,dy=None):
-        # variable to store loaded values
-        self.x = x
-        self.y = y
-        self.dx = dx
-        self.dy = dy
-        self.filename = None
-        
-    def set_filename(self,path=None):
-        """
-            Store path into a variable.If the user doesn't give a path as a parameter a pop-up
-            window appears to select the file.
-            @param path: the path given by the user
-        """
-        self.filename = path
-       
-
-    def get_filename(self):
-        """ return the file's path"""
-        return self.filename
-    
-    def set_values(self):
-        """ Store the values loaded from file in local variables """
-        if not self.filename == None:
-            input_f =  open(self.filename,'r')
-            buff = input_f.read()
-            lines = buff.split('\n')
-            self.x=[]
-            self.y=[]
-            self.dx = [] 
-            self.dy=[]
-            for line in lines:
-                try:
-                    toks = line.split()
-                    x = float(toks[0])
-                    y = float(toks[1])
-                    dy = float(toks[2])
-                    
-                    self.x.append(x)
-                    self.y.append(y)
-                    self.dy.append(dy)
-                    self.dx = numpy.zeros(len(self.x))
-                except:
-                    print "READ ERROR", line
-            
-            
-            # Sanity check
-            if not len(self.x) == len(self.dx):
-                raise ValueError, "x and dx have different length"
-            if not len(self.y) == len(self.dy):
-                raise ValueError, "y and dy have different length"
-            
-            
-    def get_values(self):
-        """ Return x, y, dx, dy """
-        return self.x,self.y,self.dx,self.dy
-    
-    def load_data(self,data):
-        """ Return plottable """
-        #load data
-        data.x = self.x
-        data.y = self.y
-        data.dx = self.dx
-        data.dy =self.dy
-        #Load its View class
-        #plottable.reset_view()
-       
-    
-if __name__ == "__main__": 
-    load= Load()
-    load.set_filename("testdata_line.txt")
-    print load.get_filename() 
-    load.set_values()
-    print load.get_values()
-    
-            
Index: rk_integration/ParkFitting.py
===================================================================
--- park_integration/ParkFitting.py	(revision 770530690a37496a90d89a41d399cc96206e8f8d)
+++ 	(revision )
@@ -1,297 +1,0 @@
-#class Fitting
-import time
-
-import numpy
-import park
-from scipy import optimize
-from park import fit,fitresult
-from park import assembly
-
-from sans.guitools.plottables import Data1D
-#from sans.guitools import plottables
-from Loader import Load
-
-class SansParameter(park.Parameter):
-    """
-    SANS model parameters for use in the PARK fitting service.
-    The parameter attribute value is redirected to the underlying
-    parameter value in the SANS model.
-    """
-    def __init__(self, name, model):
-         self._model, self._name = model,name
-    def _getvalue(self): return self._model.getParam(self.name)
-    def _setvalue(self,value): self._model.setParam(self.name, value)
-    value = property(_getvalue,_setvalue)
-    def _getrange(self):
-        lo,hi = self._model.details[self.name][1:]
-        if lo is None: lo = -numpy.inf
-        if hi is None: hi = numpy.inf
-        return lo,hi
-    def _setrange(self,r):
-        self._model.details[self.name][1:] = r
-    range = property(_getrange,_setrange)
-
-class Model(object):
-    """
-        PARK wrapper for SANS models.
-    """
-    def __init__(self, sans_model):
-        self.model = sans_model
-        sansp = sans_model.getParamList()
-        parkp = [SansParameter(p,sans_model) for p in sansp]
-        self.parameterset = park.ParameterSet(sans_model.name,pars=parkp)
-    def eval(self,x):
-        return self.model.run(x)
-    
-class Data(object):
-    """ Wrapper class  for SANS data """
-    def __init__(self, sans_data):
-        self.x= sans_data.x
-        self.y= sans_data.y
-        self.dx= sans_data.dx
-        self.dy= sans_data.dy
-        self.qmin=None
-        self.qmax=None
-       
-    def setFitRange(self,mini=None,maxi=None):
-        """ to set the fit range"""
-        self.qmin=mini
-        self.qmax=maxi
-        
-    def residuals(self, fn):
-        
-        x,y,dy = [numpy.asarray(v) for v in (self.x,self.y,self.dy)]
-        if self.qmin==None and self.qmax==None: 
-            return (y - fn(x))/dy
-        
-        else:
-            idx = x>=self.qmin & x <= self.qmax
-            return (y[idx] - fn(x[idx]))/dy[idx]
-            
-         
-    def residuals_deriv(self, model, pars=[]):
-        """ Return residual derivatives .in this case just return empty array"""
-        return []
-    
-class FitArrange:
-    def __init__(self):
-        """
-            Store a set of data for a given model to perform the Fit
-            @param model: the model selected by the user
-            @param Ldata: a list of data what the user want to fit
-        """
-        self.model = None
-        self.dList =[]
-        
-    def set_model(self,model):
-        """ set the model """
-        self.model = model
-        
-    def add_data(self,data):
-        """ 
-            @param data: Data to add in the list
-            fill a self.dataList with data to fit
-        """
-        if not data in self.dList:
-            self.dList.append(data)
-            
-    def get_model(self):
-        """ Return the model"""
-        return self.model   
-     
-    def get_data(self):
-        """ Return list of data"""
-        return self.dList 
-      
-    def remove_data(self,data):
-        """
-            Remove one element from the list
-            @param data: Data to remove from the the lsit of data
-        """
-        if data in self.dList:
-            self.dList.remove(data)
-            
-class ParkFit:
-    """ 
-        Performs the Fit.he user determine what kind of data 
-    """
-    def __init__(self,data=[]):
-        #this is a dictionary of FitArrange elements
-        self.fitArrangeList={}
-        #the constraint of the Fit
-        self.constraint =None
-        #Specify the use of scipy or park fit
-        self.fitType =None
-        
-    def createProblem(self,pars={}):
-        """
-            Check the contraint value and specify what kind of fit to use
-            return (M1,D1)
-        """
-        mylist=[]
-        for k,value in self.fitArrangeList.iteritems():
-            couple=()
-            model=value.get_model()
-            parameters= self.set_param(model, pars)
-            model = Model(model)
-            #print "model created",model.parameterset[0].value,model.parameterset[1].value
-            # Make all parameters fitting parameters
-            for p in model.parameterset:
-                p.set([-numpy.inf,numpy.inf])
-                #p.set([-10,10])
-            Ldata=value.get_data()
-            data=self._concatenateData(Ldata)
-            #print "this data",data
-            #print "data.residuals in createProblem",Ldata[0].residuals
-            #print "data.residuals in createProblem",data.residuals
-            #couple1=(model,Ldata[0])
-            #mylist.append(couple1)
-            couple=(model,data)
-            mylist.append(couple)
-        #print mylist
-        return mylist
-        #return model,data
-    
-    def fit(self,pars, qmin=None, qmax=None):
-        """
-             Do the fit 
-        """
-        
-        modelList=self.createProblem(pars)
-        #model,data=self.createProblem()
-        #fitness=assembly.Fitness(model,data)
-        
-        problem =  park.Assembly(modelList)
-        print "problem :",problem[0].parameterset,problem[0].parameterset.fitted
-        #problem[0].parameterset['A'].set([0,1000])
-        #print "problem :",problem[0].parameterset,problem[0].parameterset.fitted
-        fit.fit(problem, handler= fitresult.ConsoleUpdate(improvement_delta=0.1))
-        #fit.fit(problem, handler= fitresult.ConsoleUpdate(improvement_delta=0.1))
-       
-    
-    def set_model(self,model,Uid):
-        """ Set model """
-        
-        if self.fitArrangeList.has_key(Uid):
-            self.fitArrangeList[Uid].set_model(model)
-        else:
-            fitproblem= FitArrange()
-            fitproblem.set_model(model)
-            self.fitArrangeList[Uid]=fitproblem
-        
-    def set_data(self,data,Uid):
-        """ Receive plottable and create a list of data to fit"""
-        data=Data(data)
-        if self.fitArrangeList.has_key(Uid):
-            self.fitArrangeList[Uid].add_data(data)
-        else:
-            fitproblem= FitArrange()
-            fitproblem.add_data(data)
-            self.fitArrangeList[Uid]=fitproblem
-            
-    def get_model(self,Uid):
-        """ return list of data"""
-        return self.fitArrangeList[Uid]
-    
-    def set_param(self,model, pars):
-        """ Recieve a dictionary of parameter and save it """
-        parameters=[]
-        if model==None:
-            raise ValueError, "Cannot set parameters for empty model"
-        else:
-            #for key ,value in pars:
-            for key, value in pars.iteritems():
-                param = Parameter(model, key, value)
-                parameters.append(param)
-        return parameters
-    
-    def add_constraint(self, constraint):
-        """ User specify contraint to fit """
-        self.constraint = str(constraint)
-        
-    def get_constraint(self):
-        """ return the contraint value """
-        return self.constraint
-   
-    def set_constraint(self,constraint):
-        """ 
-            receive a string as a constraint
-            @param constraint: a string used to constraint some parameters to get a 
-                specific value
-        """
-        self.constraint= constraint
-    def _concatenateData(self, listdata=[]):
-        """ concatenate each fields of all Data contains ins listdata
-         return data
-        """
-        if listdata==[]:
-            raise ValueError, " data list missing"
-        else:
-            xtemp=[]
-            ytemp=[]
-            dytemp=[]
-            resid=[]
-            resid_deriv=[]
-            
-            for data in listdata:
-                for i in range(len(data.x)):
-                    if not data.x[i] in xtemp:
-                        xtemp.append(data.x[i])
-                       
-                    if not data.y[i] in ytemp:
-                        ytemp.append(data.y[i])
-                        
-                    if not data.dy[i] in dytemp:
-                        dytemp.append(data.dy[i])
-                    
-                   
-            newplottable= Data1D(xtemp,ytemp,None,dytemp)
-            newdata=Data(newplottable)
-           
-            #print "this is new data",newdata.dy
-            return newdata
-class Parameter:
-    """
-        Class to handle model parameters
-    """
-    def __init__(self, model, name, value=None):
-            self.model = model
-            self.name = name
-            if not value==None:
-                self.model.setParam(self.name, value)
-           
-    def set(self, value):
-        """
-            Set the value of the parameter
-        """
-        self.model.setParam(self.name, value)
-
-    def __call__(self):
-        """ 
-            Return the current value of the parameter
-        """
-        return self.model.getParam(self.name)
-    
-
-      
-if __name__ == "__main__": 
-    load= Load()
-    
-    # test fit one data set one model
-    load.set_filename("testdata_line.txt")
-    load.set_values()
-    data1 = Data1D(x=[], y=[], dx=None,dy=None)
-    data1.name = "data1"
-    load.load_data(data1)
-    fitter =ParkFit()
-    
-    from sans.guitools.LineModel import LineModel
-    model  = LineModel()
-    fitter.set_model(model,1)
-    fitter.set_data(data1,1)
-    
-    print"PARK fit result",fitter.fit({'A':2,'B':1},None,None)
-   
-    
-   
-    
Index: rk_integration/ScipyFitting.py
===================================================================
--- park_integration/ScipyFitting.py	(revision 770530690a37496a90d89a41d399cc96206e8f8d)
+++ 	(revision )
@@ -1,282 +1,0 @@
-#class Fitting
-from sans.guitools.plottables import Data1D
-from Loader import Load
-from scipy import optimize
-#from Fitting import Fit
-
-class FitArrange:
-    def __init__(self):
-        """
-            Store a set of data for a given model to perform the Fit
-            @param model: the model selected by the user
-            @param Ldata: a list of data what the user want to fit
-        """
-        self.model = None
-        self.dList =[]
-        
-    def set_model(self,model):
-        """ set the model """
-        self.model = model
-        
-    def add_data(self,data):
-        """ 
-            @param data: Data to add in the list
-            fill a self.dataList with data to fit
-        """
-        if not data in self.dList:
-            self.dList.append(data)
-            
-    def get_model(self):
-        """ Return the model"""
-        return self.model   
-     
-    def get_data(self):
-        """ Return list of data"""
-        return self.dList 
-      
-    def remove_data(self,data):
-        """
-            Remove one element from the list
-            @param data: Data to remove from the the lsit of data
-        """
-        if data in self.dList:
-            self.dList.remove(data)
-            
-class ScipyFit:
-    """ 
-        Performs the Fit.he user determine what kind of data 
-    """
-    def __init__(self,data=[]):
-        #this is a dictionary of FitArrange elements
-        self.fitArrangeList={}
-        #the constraint of the Fit
-        self.constraint =None
-        #Specify the use of scipy or park fit
-        self.fitType =None
-        
-  
-    
-    def fit(self,pars, qmin=None, qmax=None):
-        """
-             Do the fit 
-        """
-        #for item in self.fitArrangeList.:
-        
-        fitproblem=self.fitArrangeList.values()[0]
-        listdata=[]
-        model = fitproblem.get_model()
-        listdata = fitproblem.get_data()
-        
-        parameters = self.set_param(model,pars)
-       
-        # Do the fit with  data set (contains one or more data) and one model 
-        xtemp,ytemp,dytemp=self._concatenateData( listdata)
-        if qmin==None:
-            qmin= min(xtemp)
-        if qmax==None:
-            qmax= max(xtemp)  
-        chisqr, out, cov = fitHelper(model,parameters, xtemp,ytemp, dytemp ,qmin,qmax)
-        return chisqr, out, cov
-    
-    def _concatenateData(self, listdata=[]):
-        """ concatenate each fields of all data contains ins listdata"""
-        if listdata==[]:
-            raise ValueError, " data list missing"
-        else:
-            xtemp=[]
-            ytemp=[]
-            dytemp=[]
-               
-            for data in listdata:
-                for i in range(len(data.x)):
-                    if not data.x[i] in xtemp:
-                        xtemp.append(data.x[i])
-                       
-                    if not data.y[i] in ytemp:
-                        ytemp.append(data.y[i])
-                        
-                    if not data.dy[i] in dytemp:
-                        dytemp.append(data.dy[i])
-            return xtemp, ytemp,dytemp
-        
-    def set_model(self,model,Uid):
-        """ Set model """
-        if self.fitArrangeList.has_key(Uid):
-            self.fitArrangeList[Uid].set_model(model)
-        else:
-            fitproblem= FitArrange()
-            fitproblem.set_model(model)
-            self.fitArrangeList[Uid]=fitproblem
-        
-    def set_data(self,data,Uid):
-        """ Receive plottable and create a list of data to fit"""
-        
-        if self.fitArrangeList.has_key(Uid):
-            self.fitArrangeList[Uid].add_data(data)
-        else:
-            fitproblem= FitArrange()
-            fitproblem.add_data(data)
-            self.fitArrangeList[Uid]=fitproblem
-            
-    def get_model(self,Uid):
-        """ return list of data"""
-        return self.fitArrangeList[Uid]
-    
-    def set_param(self,model, pars):
-        """ Recieve a dictionary of parameter and save it """
-        parameters=[]
-        if model==None:
-            raise ValueError, "Cannot set parameters for empty model"
-        else:
-            #for key ,value in pars:
-            for key, value in pars.iteritems():
-                param = Parameter(model, key, value)
-                parameters.append(param)
-        return parameters
-    
-    def add_constraint(self, constraint):
-        """ User specify contraint to fit """
-        self.constraint = str(constraint)
-        
-    def get_constraint(self):
-        """ return the contraint value """
-        return self.constraint
-   
-    def set_constraint(self,constraint):
-        """ 
-            receive a string as a constraint
-            @param constraint: a string used to constraint some parameters to get a 
-                specific value
-        """
-        self.constraint= constraint
-    
-    def createProblem(self):
-        """
-            Check the contraint value and specify what kind of fit to use
-        """
-        mylist=[]
-        for k,value in self.fitArrangeList.iteritems():
-            couple=()
-            model=value.get_model()
-            data=value.get_data()
-            couple=(model,data)
-            mylist.append(couple)
-        #print mylist
-        return mylist
-    
-                
-
-class Parameter:
-    """
-        Class to handle model parameters
-    """
-    def __init__(self, model, name, value=None):
-            self.model = model
-            self.name = name
-            if not value==None:
-                self.model.setParam(self.name, value)
-           
-    def set(self, value):
-        """
-            Set the value of the parameter
-        """
-        self.model.setParam(self.name, value)
-
-    def __call__(self):
-        """ 
-            Return the current value of the parameter
-        """
-        return self.model.getParam(self.name)
-    
-def fitHelper(model, pars, x, y, err_y ,qmin=None, qmax=None):
-    """
-        Fit function
-        @param model: sans model object
-        @param pars: list of parameters
-        @param x: vector of x data
-        @param y: vector of y data
-        @param err_y: vector of y errors 
-    """
-    def f(params):
-        """
-            Calculates the vector of residuals for each point 
-            in y for a given set of input parameters.
-            @param params: list of parameter values
-            @return: vector of residuals
-        """
-        i = 0
-        for p in pars:
-            p.set(params[i])
-            i += 1
-        
-        residuals = []
-        for j in range(len(x)):
-            if x[j]>qmin and x[j]<qmax:
-                residuals.append( ( y[j] - model.runXY(x[j]) ) / err_y[j] )
-       
-        return residuals
-        
-    def chi2(params):
-        """
-            Calculates chi^2
-            @param params: list of parameter values
-            @return: chi^2
-        """
-        sum = 0
-        res = f(params)
-        for item in res:
-            sum += item*item
-        return sum
-        
-    p = [param() for param in pars]
-    out, cov_x, info, mesg, success = optimize.leastsq(f, p, full_output=1, warning=True)
-    print info, mesg, success
-    # Calculate chi squared
-    if len(pars)>1:
-        chisqr = chi2(out)
-    elif len(pars)==1:
-        chisqr = chi2([out])
-        
-    return chisqr, out, cov_x    
-
-      
-if __name__ == "__main__": 
-    load= Load()
-    
-    # test fit one data set one model
-    load.set_filename("testdata_line.txt")
-    load.set_values()
-    data1 = Data1D(x=[], y=[], dx=None,dy=None)
-    data1.name = "data1"
-    load.load_data(data1)
-    fitter =ScipyFit()
-    from sans.guitools.LineModel import LineModel
-    model  = LineModel()
-    fitter.set_model(model,1)
-    fitter.set_data(data1,1)
-    
-    chisqr, out, cov=fitter.fit({'A':2,'B':1},None,None)
-    print "my list of param",fitter.createProblem()
-    print"fit only one data",chisqr, out, cov 
-    print "this model list of param",model.getParamList()
-    # test fit with 2 data and one model
-    fitter =ScipyFit()
-   
-    fitter.set_model(model,2 )
-    load.set_filename("testdata1.txt")
-    load.set_values()
-    data2 = Data1D(x=[], y=[], dx=None,dy=None)
-    data2.name = "data2"
-    
-    load.load_data(data2)
-    fitter.set_data(data2,2)
-    
-    load.set_filename("testdata2.txt")
-    load.set_values()
-    data3 = Data1D(x=[], y=[], dx=None,dy=None)
-    data3.name = "data2"
-    load.load_data(data3)
-    fitter.set_data(data3,2)
-    chisqr, out, cov=fitter.fit({'A':2,'B':1},None,None)
-    print"fit two data",chisqr, out, cov 
-    
Index: park_integration/docs/ParkFitting.py
===================================================================
--- park_integration/docs/ParkFitting.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
+++ park_integration/docs/ParkFitting.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
@@ -0,0 +1,297 @@
+#class Fitting
+import time
+
+import numpy
+import park
+from scipy import optimize
+from park import fit,fitresult
+from park import assembly
+
+from sans.guitools.plottables import Data1D
+#from sans.guitools import plottables
+from Loader import Load
+
+class SansParameter(park.Parameter):
+    """
+    SANS model parameters for use in the PARK fitting service.
+    The parameter attribute value is redirected to the underlying
+    parameter value in the SANS model.
+    """
+    def __init__(self, name, model):
+         self._model, self._name = model,name
+    def _getvalue(self): return self._model.getParam(self.name)
+    def _setvalue(self,value): self._model.setParam(self.name, value)
+    value = property(_getvalue,_setvalue)
+    def _getrange(self):
+        lo,hi = self._model.details[self.name][1:]
+        if lo is None: lo = -numpy.inf
+        if hi is None: hi = numpy.inf
+        return lo,hi
+    def _setrange(self,r):
+        self._model.details[self.name][1:] = r
+    range = property(_getrange,_setrange)
+
+class Model(object):
+    """
+        PARK wrapper for SANS models.
+    """
+    def __init__(self, sans_model):
+        self.model = sans_model
+        sansp = sans_model.getParamList()
+        parkp = [SansParameter(p,sans_model) for p in sansp]
+        self.parameterset = park.ParameterSet(sans_model.name,pars=parkp)
+    def eval(self,x):
+        return self.model.run(x)
+    
+class Data(object):
+    """ Wrapper class  for SANS data """
+    def __init__(self, sans_data):
+        self.x= sans_data.x
+        self.y= sans_data.y
+        self.dx= sans_data.dx
+        self.dy= sans_data.dy
+        self.qmin=None
+        self.qmax=None
+       
+    def setFitRange(self,mini=None,maxi=None):
+        """ to set the fit range"""
+        self.qmin=mini
+        self.qmax=maxi
+        
+    def residuals(self, fn):
+        
+        x,y,dy = [numpy.asarray(v) for v in (self.x,self.y,self.dy)]
+        if self.qmin==None and self.qmax==None: 
+            return (y - fn(x))/dy
+        
+        else:
+            idx = x>=self.qmin & x <= self.qmax
+            return (y[idx] - fn(x[idx]))/dy[idx]
+            
+         
+    def residuals_deriv(self, model, pars=[]):
+        """ Return residual derivatives .in this case just return empty array"""
+        return []
+    
+class FitArrange:
+    def __init__(self):
+        """
+            Store a set of data for a given model to perform the Fit
+            @param model: the model selected by the user
+            @param Ldata: a list of data what the user want to fit
+        """
+        self.model = None
+        self.dList =[]
+        
+    def set_model(self,model):
+        """ set the model """
+        self.model = model
+        
+    def add_data(self,data):
+        """ 
+            @param data: Data to add in the list
+            fill a self.dataList with data to fit
+        """
+        if not data in self.dList:
+            self.dList.append(data)
+            
+    def get_model(self):
+        """ Return the model"""
+        return self.model   
+     
+    def get_data(self):
+        """ Return list of data"""
+        return self.dList 
+      
+    def remove_data(self,data):
+        """
+            Remove one element from the list
+            @param data: Data to remove from the the lsit of data
+        """
+        if data in self.dList:
+            self.dList.remove(data)
+            
+class ParkFit:
+    """ 
+        Performs the Fit.he user determine what kind of data 
+    """
+    def __init__(self,data=[]):
+        #this is a dictionary of FitArrange elements
+        self.fitArrangeList={}
+        #the constraint of the Fit
+        self.constraint =None
+        #Specify the use of scipy or park fit
+        self.fitType =None
+        
+    def createProblem(self,pars={}):
+        """
+            Check the contraint value and specify what kind of fit to use
+            return (M1,D1)
+        """
+        mylist=[]
+        for k,value in self.fitArrangeList.iteritems():
+            couple=()
+            model=value.get_model()
+            parameters= self.set_param(model, pars)
+            model = Model(model)
+            #print "model created",model.parameterset[0].value,model.parameterset[1].value
+            # Make all parameters fitting parameters
+            for p in model.parameterset:
+                p.set([-numpy.inf,numpy.inf])
+                #p.set([-10,10])
+            Ldata=value.get_data()
+            data=self._concatenateData(Ldata)
+            #print "this data",data
+            #print "data.residuals in createProblem",Ldata[0].residuals
+            #print "data.residuals in createProblem",data.residuals
+            #couple1=(model,Ldata[0])
+            #mylist.append(couple1)
+            couple=(model,data)
+            mylist.append(couple)
+        #print mylist
+        return mylist
+        #return model,data
+    
+    def fit(self,pars, qmin=None, qmax=None):
+        """
+             Do the fit 
+        """
+        
+        modelList=self.createProblem(pars)
+        #model,data=self.createProblem()
+        #fitness=assembly.Fitness(model,data)
+        
+        problem =  park.Assembly(modelList)
+        print "problem :",problem[0].parameterset,problem[0].parameterset.fitted
+        #problem[0].parameterset['A'].set([0,1000])
+        #print "problem :",problem[0].parameterset,problem[0].parameterset.fitted
+        fit.fit(problem, handler= fitresult.ConsoleUpdate(improvement_delta=0.1))
+        #fit.fit(problem, handler= fitresult.ConsoleUpdate(improvement_delta=0.1))
+       
+    
+    def set_model(self,model,Uid):
+        """ Set model """
+        
+        if self.fitArrangeList.has_key(Uid):
+            self.fitArrangeList[Uid].set_model(model)
+        else:
+            fitproblem= FitArrange()
+            fitproblem.set_model(model)
+            self.fitArrangeList[Uid]=fitproblem
+        
+    def set_data(self,data,Uid):
+        """ Receive plottable and create a list of data to fit"""
+        data=Data(data)
+        if self.fitArrangeList.has_key(Uid):
+            self.fitArrangeList[Uid].add_data(data)
+        else:
+            fitproblem= FitArrange()
+            fitproblem.add_data(data)
+            self.fitArrangeList[Uid]=fitproblem
+            
+    def get_model(self,Uid):
+        """ return list of data"""
+        return self.fitArrangeList[Uid]
+    
+    def set_param(self,model, pars):
+        """ Recieve a dictionary of parameter and save it """
+        parameters=[]
+        if model==None:
+            raise ValueError, "Cannot set parameters for empty model"
+        else:
+            #for key ,value in pars:
+            for key, value in pars.iteritems():
+                param = Parameter(model, key, value)
+                parameters.append(param)
+        return parameters
+    
+    def add_constraint(self, constraint):
+        """ User specify contraint to fit """
+        self.constraint = str(constraint)
+        
+    def get_constraint(self):
+        """ return the contraint value """
+        return self.constraint
+   
+    def set_constraint(self,constraint):
+        """ 
+            receive a string as a constraint
+            @param constraint: a string used to constraint some parameters to get a 
+                specific value
+        """
+        self.constraint= constraint
+    def _concatenateData(self, listdata=[]):
+        """ concatenate each fields of all Data contains ins listdata
+         return data
+        """
+        if listdata==[]:
+            raise ValueError, " data list missing"
+        else:
+            xtemp=[]
+            ytemp=[]
+            dytemp=[]
+            resid=[]
+            resid_deriv=[]
+            
+            for data in listdata:
+                for i in range(len(data.x)):
+                    if not data.x[i] in xtemp:
+                        xtemp.append(data.x[i])
+                       
+                    if not data.y[i] in ytemp:
+                        ytemp.append(data.y[i])
+                        
+                    if not data.dy[i] in dytemp:
+                        dytemp.append(data.dy[i])
+                    
+                   
+            newplottable= Data1D(xtemp,ytemp,None,dytemp)
+            newdata=Data(newplottable)
+           
+            #print "this is new data",newdata.dy
+            return newdata
+class Parameter:
+    """
+        Class to handle model parameters
+    """
+    def __init__(self, model, name, value=None):
+            self.model = model
+            self.name = name
+            if not value==None:
+                self.model.setParam(self.name, value)
+           
+    def set(self, value):
+        """
+            Set the value of the parameter
+        """
+        self.model.setParam(self.name, value)
+
+    def __call__(self):
+        """ 
+            Return the current value of the parameter
+        """
+        return self.model.getParam(self.name)
+    
+
+      
+if __name__ == "__main__": 
+    load= Load()
+    
+    # test fit one data set one model
+    load.set_filename("testdata_line.txt")
+    load.set_values()
+    data1 = Data1D(x=[], y=[], dx=None,dy=None)
+    data1.name = "data1"
+    load.load_data(data1)
+    fitter =ParkFit()
+    
+    from sans.guitools.LineModel import LineModel
+    model  = LineModel()
+    fitter.set_model(model,1)
+    fitter.set_data(data1,1)
+    
+    print"PARK fit result",fitter.fit({'A':2,'B':1},None,None)
+   
+    
+   
+    
Index: park_integration/docs/ScipyFitting.py
===================================================================
--- park_integration/docs/ScipyFitting.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
+++ park_integration/docs/ScipyFitting.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
@@ -0,0 +1,282 @@
+#class Fitting
+from sans.guitools.plottables import Data1D
+from Loader import Load
+from scipy import optimize
+#from Fitting import Fit
+
+class FitArrange:
+    def __init__(self):
+        """
+            Store a set of data for a given model to perform the Fit
+            @param model: the model selected by the user
+            @param Ldata: a list of data what the user want to fit
+        """
+        self.model = None
+        self.dList =[]
+        
+    def set_model(self,model):
+        """ set the model """
+        self.model = model
+        
+    def add_data(self,data):
+        """ 
+            @param data: Data to add in the list
+            fill a self.dataList with data to fit
+        """
+        if not data in self.dList:
+            self.dList.append(data)
+            
+    def get_model(self):
+        """ Return the model"""
+        return self.model   
+     
+    def get_data(self):
+        """ Return list of data"""
+        return self.dList 
+      
+    def remove_data(self,data):
+        """
+            Remove one element from the list
+            @param data: Data to remove from the the lsit of data
+        """
+        if data in self.dList:
+            self.dList.remove(data)
+            
+class ScipyFit:
+    """ 
+        Performs the Fit.he user determine what kind of data 
+    """
+    def __init__(self,data=[]):
+        #this is a dictionary of FitArrange elements
+        self.fitArrangeList={}
+        #the constraint of the Fit
+        self.constraint =None
+        #Specify the use of scipy or park fit
+        self.fitType =None
+        
+  
+    
+    def fit(self,pars, qmin=None, qmax=None):
+        """
+             Do the fit 
+        """
+        #for item in self.fitArrangeList.:
+        
+        fitproblem=self.fitArrangeList.values()[0]
+        listdata=[]
+        model = fitproblem.get_model()
+        listdata = fitproblem.get_data()
+        
+        parameters = self.set_param(model,pars)
+       
+        # Do the fit with  data set (contains one or more data) and one model 
+        xtemp,ytemp,dytemp=self._concatenateData( listdata)
+        if qmin==None:
+            qmin= min(xtemp)
+        if qmax==None:
+            qmax= max(xtemp)  
+        chisqr, out, cov = fitHelper(model,parameters, xtemp,ytemp, dytemp ,qmin,qmax)
+        return chisqr, out, cov
+    
+    def _concatenateData(self, listdata=[]):
+        """ concatenate each fields of all data contains ins listdata"""
+        if listdata==[]:
+            raise ValueError, " data list missing"
+        else:
+            xtemp=[]
+            ytemp=[]
+            dytemp=[]
+               
+            for data in listdata:
+                for i in range(len(data.x)):
+                    if not data.x[i] in xtemp:
+                        xtemp.append(data.x[i])
+                       
+                    if not data.y[i] in ytemp:
+                        ytemp.append(data.y[i])
+                        
+                    if not data.dy[i] in dytemp:
+                        dytemp.append(data.dy[i])
+            return xtemp, ytemp,dytemp
+        
+    def set_model(self,model,Uid):
+        """ Set model """
+        if self.fitArrangeList.has_key(Uid):
+            self.fitArrangeList[Uid].set_model(model)
+        else:
+            fitproblem= FitArrange()
+            fitproblem.set_model(model)
+            self.fitArrangeList[Uid]=fitproblem
+        
+    def set_data(self,data,Uid):
+        """ Receive plottable and create a list of data to fit"""
+        
+        if self.fitArrangeList.has_key(Uid):
+            self.fitArrangeList[Uid].add_data(data)
+        else:
+            fitproblem= FitArrange()
+            fitproblem.add_data(data)
+            self.fitArrangeList[Uid]=fitproblem
+            
+    def get_model(self,Uid):
+        """ return list of data"""
+        return self.fitArrangeList[Uid]
+    
+    def set_param(self,model, pars):
+        """ Recieve a dictionary of parameter and save it """
+        parameters=[]
+        if model==None:
+            raise ValueError, "Cannot set parameters for empty model"
+        else:
+            #for key ,value in pars:
+            for key, value in pars.iteritems():
+                param = Parameter(model, key, value)
+                parameters.append(param)
+        return parameters
+    
+    def add_constraint(self, constraint):
+        """ User specify contraint to fit """
+        self.constraint = str(constraint)
+        
+    def get_constraint(self):
+        """ return the contraint value """
+        return self.constraint
+   
+    def set_constraint(self,constraint):
+        """ 
+            receive a string as a constraint
+            @param constraint: a string used to constraint some parameters to get a 
+                specific value
+        """
+        self.constraint= constraint
+    
+    def createProblem(self):
+        """
+            Check the contraint value and specify what kind of fit to use
+        """
+        mylist=[]
+        for k,value in self.fitArrangeList.iteritems():
+            couple=()
+            model=value.get_model()
+            data=value.get_data()
+            couple=(model,data)
+            mylist.append(couple)
+        #print mylist
+        return mylist
+    
+                
+
+class Parameter:
+    """
+        Class to handle model parameters
+    """
+    def __init__(self, model, name, value=None):
+            self.model = model
+            self.name = name
+            if not value==None:
+                self.model.setParam(self.name, value)
+           
+    def set(self, value):
+        """
+            Set the value of the parameter
+        """
+        self.model.setParam(self.name, value)
+
+    def __call__(self):
+        """ 
+            Return the current value of the parameter
+        """
+        return self.model.getParam(self.name)
+    
+def fitHelper(model, pars, x, y, err_y ,qmin=None, qmax=None):
+    """
+        Fit function
+        @param model: sans model object
+        @param pars: list of parameters
+        @param x: vector of x data
+        @param y: vector of y data
+        @param err_y: vector of y errors 
+    """
+    def f(params):
+        """
+            Calculates the vector of residuals for each point 
+            in y for a given set of input parameters.
+            @param params: list of parameter values
+            @return: vector of residuals
+        """
+        i = 0
+        for p in pars:
+            p.set(params[i])
+            i += 1
+        
+        residuals = []
+        for j in range(len(x)):
+            if x[j]>qmin and x[j]<qmax:
+                residuals.append( ( y[j] - model.runXY(x[j]) ) / err_y[j] )
+       
+        return residuals
+        
+    def chi2(params):
+        """
+            Calculates chi^2
+            @param params: list of parameter values
+            @return: chi^2
+        """
+        sum = 0
+        res = f(params)
+        for item in res:
+            sum += item*item
+        return sum
+        
+    p = [param() for param in pars]
+    out, cov_x, info, mesg, success = optimize.leastsq(f, p, full_output=1, warning=True)
+    print info, mesg, success
+    # Calculate chi squared
+    if len(pars)>1:
+        chisqr = chi2(out)
+    elif len(pars)==1:
+        chisqr = chi2([out])
+        
+    return chisqr, out, cov_x    
+
+      
+if __name__ == "__main__": 
+    load= Load()
+    
+    # test fit one data set one model
+    load.set_filename("testdata_line.txt")
+    load.set_values()
+    data1 = Data1D(x=[], y=[], dx=None,dy=None)
+    data1.name = "data1"
+    load.load_data(data1)
+    fitter =ScipyFit()
+    from sans.guitools.LineModel import LineModel
+    model  = LineModel()
+    fitter.set_model(model,1)
+    fitter.set_data(data1,1)
+    
+    chisqr, out, cov=fitter.fit({'A':2,'B':1},None,None)
+    print "my list of param",fitter.createProblem()
+    print"fit only one data",chisqr, out, cov 
+    print "this model list of param",model.getParamList()
+    # test fit with 2 data and one model
+    fitter =ScipyFit()
+   
+    fitter.set_model(model,2 )
+    load.set_filename("testdata1.txt")
+    load.set_values()
+    data2 = Data1D(x=[], y=[], dx=None,dy=None)
+    data2.name = "data2"
+    
+    load.load_data(data2)
+    fitter.set_data(data2,2)
+    
+    load.set_filename("testdata2.txt")
+    load.set_values()
+    data3 = Data1D(x=[], y=[], dx=None,dy=None)
+    data3.name = "data2"
+    load.load_data(data3)
+    fitter.set_data(data3,2)
+    chisqr, out, cov=fitter.fit({'A':2,'B':1},None,None)
+    print"fit two data",chisqr, out, cov 
+    
Index: park_integration/docs/setup.py
===================================================================
--- park_integration/docs/setup.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
+++ park_integration/docs/setup.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
@@ -0,0 +1,22 @@
+"""
+     Installation script for SANS fitting
+"""
+
+# Then build and install the modules
+from distutils.core import setup, Extension
+
+
+setup(
+    name="sans.fit",
+    version = "0.1",
+    description = "Python module for fitting",
+    author = "University of Tennessee",
+    #author_email = "",
+    url = "http://danse.chem.utk.edu",
+    
+    # Use the pure python modules
+    package_dir = {"sans.fit":"."},
+    
+    packages = ["sans.fit"]
+    )
+        
Index: park_integration/docs/testdata_generator.py
===================================================================
--- park_integration/docs/testdata_generator.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
+++ park_integration/docs/testdata_generator.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
@@ -0,0 +1,67 @@
+"""
+    Generate two correlated sets of data
+        1- A line: y = ax + b
+        2- A constant equal to a of set #1
+        
+"""
+
+class Generator:
+    ## Parameter A
+    constant_a = 2.5
+    ## Parameter B
+    constant_b = 4.0
+    ## Randomness factor
+    randomness = 0.15
+    
+    def __init__(self):
+        pass
+    
+    def create(self, filename, xmin=0.0, xmax=10.0, npts=50):
+        """
+            Create files with the generate data
+            The file names will be:
+                - Set #1: [filename]_line.txt
+                - Set #2: [filename]_cst.txt
+                
+            @param filename: string to prepend to the file name
+            @param xmin: minimum x-value
+            @param xmax: maximum x-value
+            @param npts: number of points to generate
+        """
+        import random, time
+        random.seed(time.time())
+        
+        # Write line data set
+        fd = open(filename+'_line.txt', 'w')
+        fd.write("#y=A*x+B\n#A=%g\n#B=%g\n" % (self.constant_a, self.constant_b))
+        
+        for i in range(npts):
+            x = xmin+(xmax-xmin)/(npts-1)*i
+            mu = self.constant_a*x+self.constant_b
+            err = self.randomness*mu
+            y = random.gauss(mu, err)
+            fd.write("%g  %g  %g\n" % (x,y,err))
+            
+        fd.close()
+        
+        # Write constant data set
+        fd = open(filename+'_cst.txt', 'w')
+        fd.write("#y=A\n#A=%g\n" % self.constant_a)
+        
+        for i in range(npts):
+            x = xmin+(xmax-xmin)/(npts-1)*i
+            err = self.randomness*self.constant_a
+            y = random.gauss(self.constant_a, err)
+            fd.write("%g  %g  %g\n" % (x,y,err))
+            
+        fd.close()
+        
+        
+
+if __name__ == "__main__": 
+    gen = Generator()
+    gen.create("testdata")
+    print "Files created"
+
+            
+            
Index: rk_integration/setup.py
===================================================================
--- park_integration/setup.py	(revision fbe6f71a46825770e27f9cacf9661ac4423b405c)
+++ 	(revision )
@@ -1,22 +1,0 @@
-"""
-     Installation script for SANS fitting
-"""
-
-# Then build and install the modules
-from distutils.core import setup, Extension
-
-
-setup(
-    name="sans.fit",
-    version = "0.1",
-    description = "Python module for fitting",
-    author = "University of Tennessee",
-    #author_email = "",
-    url = "http://danse.chem.utk.edu",
-    
-    # Use the pure python modules
-    package_dir = {"sans.fit":"."},
-    
-    packages = ["sans.fit"]
-    )
-        
Index: park_integration/test/Fitting.py
===================================================================
--- park_integration/test/Fitting.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
+++ park_integration/test/Fitting.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
@@ -0,0 +1,143 @@
+#class Fitting
+from sans.guitools.plottables import Data1D
+from Loader import Load
+from scipy import optimize
+from ScipyFitting import ScipyFit
+from ParkFitting import ParkFit
+
+
+class Fit:
+    """ 
+        Wrap class that allows to select the fitting type 
+    """  
+    def __init__(self):
+        
+        # To initialize a type of Fit
+        self._engine=None
+          
+    def fit_engine(self,word):
+        """
+            Select the type of Fit 
+            @param word: the keyword to select the fit type 
+        """
+        if word=="scipy":
+            self._engine=ScipyFit()
+        elif word=="park":
+            self._engine=ParkFit()
+        else:
+            raise ValueError, "enter the keyword scipy or park"
+    def returnEngine(self):
+        return self._engine
+    
+    def fit(self,pars, qmin=None, qmax=None):
+        """ Do the fit """
+      
+    def set_model(self,model,Uid):
+        """ Set model """
+       
+    def set_data(self,data,Uid):
+        """ Receive plottable and create a list of data to fit"""
+            
+    def get_model(self,Uid):
+        """ return list of data"""
+    
+    def set_param(self,model, pars):
+        """ Recieve a dictionary of parameter and save it """
+   
+    def add_constraint(self, constraint):
+        """ User specify contraint to fit """
+        
+    def get_constraint(self):
+        """ return the contraint value """
+  
+    def set_constraint(self,constraint):
+        """ 
+            receive a string as a constraint
+            @param constraint: a string used to constraint some parameters to get a 
+                specific value
+        """
+if __name__ == "__main__": 
+    load= Load()
+    # test scipy 
+    """test fit one data set one model with scipy """
+    #load data 
+    load.set_filename("testdata_line.txt")
+    load.set_values()
+    data1 = Data1D(x=[], y=[], dx=None,dy=None)
+    data1.name = "data1"
+    load.load_data(data1)
+    #choose a model
+    from sans.guitools.LineModel import LineModel
+    model  = LineModel()
+    #Create a Fit engine
+    fitter =Fit()
+    fitter.fit_engine('scipy')
+    engine = fitter.returnEngine()
+    
+    #set the model
+    engine.set_model(model,1)
+    engine.set_data(data1,1)
+    
+    print"fit only one data SCIPY:",engine.fit({'A':2,'B':1},None,None)
+    
+    
+    """ test fit one data set one model with park """
+    fitter.fit_engine('scipy')
+    engine = fitter.returnEngine()
+    #set the model
+    engine.set_model(model,1)
+    engine.set_data(data1,1)
+    
+    print"fit only one data PARK:",engine.fit({'A':2,'B':1},None,None)
+    
+    
+    """test fit with 2 data and one model SCIPY:"""
+    # reinitialize the fitter
+    fitter =Fit()
+    #create an engine
+    fitter.fit_engine("scipy")
+    engine=fitter.returnEngine()
+    #set the model for fit
+    engine.set_model(model,2 )
+    #load 1 st data
+    load.set_filename("testdata1.txt")
+    load.set_values()
+    data2 = Data1D(x=[], y=[], dx=None,dy=None)
+    data2.name = "data2"
+    load.load_data(data2)
+    #load  2nd data
+    load.set_filename("testdata2.txt")
+    load.set_values()
+    data3 = Data1D(x=[], y=[], dx=None,dy=None)
+    data3.name = "data2"
+    load.load_data(data3)
+    
+    #set data in the engine
+    engine.set_data(data2,2)
+    engine.set_data(data3,2)
+    print"fit two data SCIPY:",engine.fit({'A':2,'B':1},None,None)
+    
+    """ test fit with 2 data and one model PARK:"""
+    fitter.fit_engine("park")
+    engine=fitter.returnEngine()
+    #set the model for fit
+    engine.set_model(model,2 )
+    #load 1 st data
+    load.set_filename("testdata1.txt")
+    load.set_values()
+    data2 = Data1D(x=[], y=[], dx=None,dy=None)
+    data2.name = "data2"
+    load.load_data(data2)
+    #load  2nd data
+    load.set_filename("testdata2.txt")
+    load.set_values()
+    data3 = Data1D(x=[], y=[], dx=None,dy=None)
+    data3.name = "data2"
+    load.load_data(data3)
+    
+    #set data in the engine
+    engine.set_data(data2,2)
+    engine.set_data(data3,2)
+    print"fit two data PARK:",engine.fit({'A':2,'B':1},None,None)
+    
+  
Index: park_integration/test/Loader.py
===================================================================
--- park_integration/test/Loader.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
+++ park_integration/test/Loader.py	(revision 1d02586feaebac5162bc206b0b4c7da46ffe6bcb)
@@ -0,0 +1,84 @@
+# class Loader  to load any king of file
+import wx
+import string,numpy
+class Load:
+    """
+        This class is loading values from given file or value giving by the user
+    """
+    
+    def _init_(self,x=None,y=None,dx=None,dy=None):
+        # variable to store loaded values
+        self.x = x
+        self.y = y
+        self.dx = dx
+        self.dy = dy
+        self.filename = None
+        
+    def set_filename(self,path=None):
+        """
+            Store path into a variable.If the user doesn't give a path as a parameter a pop-up
+            window appears to select the file.
+            @param path: the path given by the user
+        """
+        self.filename = path
+       
+
+    def get_filename(self):
+        """ return the file's path"""
+        return self.filename
+    
+    def set_values(self):
+        """ Store the values loaded from file in local variables """
+        if not self.filename == None:
+            input_f =  open(self.filename,'r')
+            buff = input_f.read()
+            lines = buff.split('\n')
+            self.x=[]
+            self.y=[]
+            self.dx = [] 
+            self.dy=[]
+            for line in lines:
+                try:
+                    toks = line.split()
+                    x = float(toks[0])
+                    y = float(toks[1])
+                    dy = float(toks[2])
+                    
+                    self.x.append(x)
+                    self.y.append(y)
+                    self.dy.append(dy)
+                    self.dx = numpy.zeros(len(self.x))
+                except:
+                    print "READ ERROR", line
+            
+            
+            # Sanity check
+            if not len(self.x) == len(self.dx):
+                raise ValueError, "x and dx have different length"
+            if not len(self.y) == len(self.dy):
+                raise ValueError, "y and dy have different length"
+            
+            
+    def get_values(self):
+        """ Return x, y, dx, dy """
+        return self.x,self.y,self.dx,self.dy
+    
+    def load_data(self,data):
+        """ Return plottable """
+        #load data
+        data.x = self.x
+        data.y = self.y
+        data.dx = self.dx
+        data.dy =self.dy
+        #Load its View class
+        #plottable.reset_view()
+       
+    
+if __name__ == "__main__": 
+    load= Load()
+    load.set_filename("testdata_line.txt")
+    print load.get_filename() 
+    load.set_values()
+    print load.get_values()
+    
+            
Index: rk_integration/testdata_generator.py
===================================================================
--- park_integration/testdata_generator.py	(revision 770530690a37496a90d89a41d399cc96206e8f8d)
+++ 	(revision )
@@ -1,67 +1,0 @@
-"""
-    Generate two correlated sets of data
-        1- A line: y = ax + b
-        2- A constant equal to a of set #1
-        
-"""
-
-class Generator:
-    ## Parameter A
-    constant_a = 2.5
-    ## Parameter B
-    constant_b = 4.0
-    ## Randomness factor
-    randomness = 0.15
-    
-    def __init__(self):
-        pass
-    
-    def create(self, filename, xmin=0.0, xmax=10.0, npts=50):
-        """
-            Create files with the generate data
-            The file names will be:
-                - Set #1: [filename]_line.txt
-                - Set #2: [filename]_cst.txt
-                
-            @param filename: string to prepend to the file name
-            @param xmin: minimum x-value
-            @param xmax: maximum x-value
-            @param npts: number of points to generate
-        """
-        import random, time
-        random.seed(time.time())
-        
-        # Write line data set
-        fd = open(filename+'_line.txt', 'w')
-        fd.write("#y=A*x+B\n#A=%g\n#B=%g\n" % (self.constant_a, self.constant_b))
-        
-        for i in range(npts):
-            x = xmin+(xmax-xmin)/(npts-1)*i
-            mu = self.constant_a*x+self.constant_b
-            err = self.randomness*mu
-            y = random.gauss(mu, err)
-            fd.write("%g  %g  %g\n" % (x,y,err))
-            
-        fd.close()
-        
-        # Write constant data set
-        fd = open(filename+'_cst.txt', 'w')
-        fd.write("#y=A\n#A=%g\n" % self.constant_a)
-        
-        for i in range(npts):
-            x = xmin+(xmax-xmin)/(npts-1)*i
-            err = self.randomness*self.constant_a
-            y = random.gauss(self.constant_a, err)
-            fd.write("%g  %g  %g\n" % (x,y,err))
-            
-        fd.close()
-        
-        
-
-if __name__ == "__main__": 
-    gen = Generator()
-    gen.create("testdata")
-    print "Files created"
-
-            
-            
