pySAXS.models.PearsonVII — pySAXS 77.September2012 documentation

### Navigation

- index
- modules |
- pySAXS 77.September2012 documentation »
- Module code »

# Source code for pySAXS.models.PearsonVII

    from pySAXS.models.model import Model
    import numpy

    class PearsonVII(Model):
        '''
        PearsonVII model
        by OT : 5/7/2012
        '''

        def PearsonVIIFunction(self,q,par):
            """
            PearsonVII model
            par[0] : Amplitute of peak
            par[1] : q at maximum of peak
            par[2] : width of peak
            par[3] : shape of peak
            par[4] : background
            """
            return par[0]/(1+((q-par[1])/par[2])**2)**par[3]+par[4]

        '''
        parameters definition
        '''
        IntensityFunc=PearsonVIIFunction #function
        N=0
        q=numpy.arange(0,100,1.0)      #q range(x scale)
        Arg=[100.,0.1,0.5,2,0]            #list of parameters
        Format=["%f","%f","%f","%f","%f"]      #list of c format
        istofit=[True,True,True,True,True]    #list of boolean for fitting
        name="PearsonVII"          #name of the model
        Doc=["Amplitute of peak"\
                 ,"q at maximum of peak"\
                 ,"width of peak"\
                 ,"shape of peak"\
                 ,"background"] #list of description for parameters
        Description="PearsonVII"  # description of model
        Author="Olivier Tache'"       #name of Author

    if __name__=="__main__":
        '''
        test code
        '''
        g=PearsonVII()
        g.Arg=[100,10,50,0]
        import Gnuplot
        gp=Gnuplot.Gnuplot()
        c=Gnuplot.Data(g.q,g.getIntensity(),with_='points')
        gp.plot(c)

        yn=g.getNoisy()
        cn=Gnuplot.Data(g.q,yn,with_='points')
        gp.plot(c,cn)
        res=g.fit(yn)

        cf=Gnuplot.Data(g.q,g.IntensityFunc(g.q,res),with_='lines')
        gp.plot(c,cn,cf)
        raw_input("enter")

        bounds=[(0,200),(2,12),(30.0,55.0),(-1,2)]
        res2=g.fitBounds(yn,bounds)
        print res2
        raw_input("enter")

### Navigation

- index
- modules |
- pySAXS 77.September2012 documentation »
- Module code »