Ignore:
Timestamp:
Oct 27, 2008 11:43:52 AM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
4d3acb6
Parents:
922b0d1
Message:

code for description modified

Location:
sansmodels/src/sans/models/c_extensions
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_extensions/WrapperGenerator.py

    rae3ce4e r96672c0  
    44 
    55import os, sys 
     6import re 
    67 
    78class WrapperGenerator: 
     
    7576        ## List of default parameters (text) 
    7677        self.default_list = "" 
     78        ##description 
     79        self.description='' 
    7780        ## Dictionary of units 
    7881        self.details = "" 
     
    8487        rep += "  struc name: %s\n" % self.structName 
    8588        rep += "  params:     %s\n" % self.params 
     89        rep += "  description: %s\n"% self.description 
    8690        return rep 
    8791         
     
    96100        f = open(self.file,'r') 
    97101        buf = f.read() 
    98          
     102        
    99103        self.default_list = "List of default parameters:\n" 
    100104        #lines = string.split(buf,'\n') 
     
    102106        self.details  = "## Parameter details [units, min, max]\n" 
    103107        self.details += "        self.details = {}\n" 
     108        # Catch Description 
     109        key = "[DESCRIPTION]" 
     110        find_description= 0 
     111        temp="" 
     112        for line in lines: 
     113            if line.count(key)>0 : 
     114                 
     115                try: 
     116                    find_description= 1 
     117                    index = line.index(key) 
     118                    toks = line[index:].split("=",1 ) 
     119                    temp=toks[1].lstrip().rstrip() 
     120                    text='text' 
     121                    key2="<%s>"%text.lower() 
     122                    if re.match(key2,temp)!=None: 
     123                        #index2 = line.index(key2) 
     124                        #temp = temp[index2:] 
     125                        toks2=temp.split(key2,1) 
     126                        self.description=toks2[1] 
     127                        text='text' 
     128                        key2="</%s>"%text.lower() 
     129                        if re.search(key2,toks2[1])!=None: 
     130                            temp=toks2[1].split(key2,1) 
     131                            self.description=temp[0] 
     132                            break 
     133                        print self.description 
     134                    else: 
     135                        self.description=temp 
     136                        break 
     137                except: 
     138                     raise ValueError, "Could not parse file %s" % self.file 
     139            elif find_description==1: 
     140                text='text' 
     141                key2="</%s>"%text.lower() 
     142                #print "second line",line,key2,re.search(key2,line) 
     143                if re.search(key2,line)!=None: 
     144                    tok=line.split(key2,1) 
     145                    temp=tok[0].split("//",1) 
     146                    self.description+=tok[1].lstrip().rstrip() 
     147                    break 
     148                else: 
     149                    print re.search("//",line) 
     150                    if re.search("//",line)!=None: 
     151                        temp=line.split("//",1) 
     152                        self.description+='\n'+temp[1].lstrip().rstrip() 
     153                         
     154                    else: 
     155                        self.description+=line 
     156                     
     157                 
    104158        for line in lines: 
    105159             
     
    132186                toks2 = toks[0].split(',') 
    133187                self.structName = toks2[0].lstrip().rstrip() 
    134                  
     188           
    135189            # Catch struct content 
    136190            key = "[DEFAULT]" 
     
    274328            newline = self.replaceToken(newline,  
    275329                                        "[DEFAULT_LIST]", self.default_list) 
    276  
     330            # Model Description 
     331            newline = self.replaceToken(newline,  
     332                                        "[DESCRIPTION]", self.description) 
    277333            # Parameter details 
    278334            newline = self.replaceToken(newline,  
  • sansmodels/src/sans/models/c_extensions/core_shell.h

    r0f5bc9f r96672c0  
    77 //[PYTHONCLASS] = CoreShellModel 
    88 //[DISP_PARAMS] = radius, thickness 
     9 //[DESCRIPTION] ="" 
    910typedef struct { 
    1011    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/core_shell_cylinder.h

    r4e2f6ef8 r96672c0  
    77 //[PYTHONCLASS] = CoreShellCylinderModel 
    88 //[DISP_PARAMS] = radius, thickness, length, axis_theta, axis_phi 
    9  //[DESCRIPTION] = '' 
     9 //[DESCRIPTION] = <text>"P(q,alpha)= scale/Vs*f(q)^(2) + bkg  Where:\n\ 
     10                                                 f(q)= 2(core_sld- solvant_sld)* Vc*sin[qLcos(alpha/2)]/\n\ 
     11                                                [qLcos(alpha/2)]*J1(qRsin(alpha))/[qRsin(alpha)] +\n 2(shell_sld-solvent_sld)*Vs\n\ 
     12                                                *sin[q(L+T)cos(alpha/2)]/[[q(L+T)cos(alpha/2)]\n\ 
     13                                                *J1(q(R+T)sin(alpha))/q(R+T)sin(alpha)]\n\ 
     14                                                alpha:is the angle between the axis of the cylinder and the q-vector\n\ 
     15                                                Vs: the volume of the outer shell\n\ 
     16                                                Vc: the volume of the core\n\ 
     17                                                L: the length of the core\n\ 
     18                                        shell_sld: the scattering length density of the shell\n\ 
     19                                                solvent_sld: the scattering length density of the solvent\n\ 
     20                                                bkg: the background\n\ 
     21                                                T: the thickness\n\ 
     22                                        R+T: is the outer radius\n\ 
     23                                                L+2T: The total length of the outershell\n\ 
     24                                                J1: the first order Bessel function\n\ 
     25                                                theta: axis_theta of the cylinder\n\ 
     26                                                phi: the axis_phi of the cylinder"\ 
     27                                        </text> 
     28 
    1029typedef struct { 
    1130    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/cylinder.h

    r4e2f6ef8 r96672c0  
    55 * [PYTHONCLASS] = CylinderModel 
    66 * [DISP_PARAMS] = radius, length, cyl_theta, cyl_phi 
    7    [DESCRIPTION] = '' 
     7   [DESCRIPTION] = <text>"P(q,alpha)= scale/V*f(q)^(2)+bkg\n\ 
     8                                                f(q)= 2*(scatter_sld - solvent_sld)*V*sin(qLcos(alpha/2))/[qLcos(alpha/2)]*\n\ 
     9                                                J1(qRsin(alpha/2))/[qRsin(alpha)]\n\ 
     10                                                V: Volume of the cylinder\n\ 
     11                                                R: Radius of the cylinder\n\ 
     12                                                L: Length of the cylinder\n\ 
     13                                                J1: The bessel function\n\ 
     14                                                alpha: angle betweenthe axis of the cylinder and the q-vector\n\ 
     15                                                for 1D:the ouput is P(q)=scale/V*integral from pi/2 to zero of f(q)^(2)*\n\ 
     16                                                sin(alpha)*dalpha+ bkg" 
     17                                        </text> 
    818         
    919 * */ 
  • sansmodels/src/sans/models/c_extensions/ellipsoid.h

    r0f5bc9f r96672c0  
    99 //[PYTHONCLASS] = EllipsoidModel 
    1010 //[DISP_PARAMS] = radius_a, radius_b, axis_theta, axis_phi 
     11 //[DESCRIPTION] = <text>"P(q.alpha)= scale*f(q)^(2)+ bkg\n\ 
     12                                                f(q)= 3*(scatter_sld- scatter_solvent)*V*[sin(q*r(Ra,Rb,alpha)) - q*r*cos(qr(Ra,Rb,alpha))]\n\ 
     13                                                        /[qr(Ra,Rb,alpha)]^(3)"\ 
     14                                                r(Ra,Rb,alpha)= [Rb^(2)*(sin(alpha))^(2) + Ra^(2)*(cos(alpha))^(2)]^(1/2)\ 
     15                                                scatter_sld: scattering length density of the scatter\n\ 
     16                                                solvent_sld: scattering length density of the solvent\n\ 
     17                                                V: volune of the Eliipsoid\n\ 
     18                                                Ra: radius along the rotation axis of the Ellipsoid\n\ 
     19                                                Rb: radius perpendicular to the rotation axis of the ellipsoid\n\ 
     20                                                </text> 
    1121typedef struct { 
    1222    /// Scale factor 
  • sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h

    r0f5bc9f r96672c0  
    55 * [PYTHONCLASS] = EllipticalCylinderModel 
    66 * [DISP_PARAMS] = r_minor, r_ratio, length, cyl_theta, cyl_phi, cyl_psi 
    7  * 
     7 * [DESCRIPTION] = "" 
    88 * */ 
    99typedef struct { 
  • sansmodels/src/sans/models/c_extensions/gaussian.h

    rae3ce4e r96672c0  
    88 *  
    99 * [PYTHONCLASS] = Gaussian 
     10 * [DESCRIPTION] = <text>f(x)=scale * 1/(sigma^2*2pi)e^(-(x-mu)^2/2sigma^2)</text> 
    1011 */ 
    1112typedef struct { 
  • sansmodels/src/sans/models/c_extensions/lorentzian.h

    rae3ce4e r96672c0  
    88 *  
    99 * [PYTHONCLASS] = Lorentzian 
     10 * [DESCRIPTION] = <text>f(x)=scale * 1/pi 0.5gamma / [ (x-x_0)^2 + (0.5gamma)^2 ]</text> 
    1011 */ 
    1112typedef struct { 
  • sansmodels/src/sans/models/c_extensions/sphere.h

    r0f5bc9f r96672c0  
    77 //[PYTHONCLASS] = SphereModel 
    88 //[DISP_PARAMS] = radius 
     9 //[DESCRIPTION] =<text>P(q)=(scale/V)*[3V(scatter_sld-solvent_sld)*(sin(qR)-qRcos(qR))/(qR)^3]^(2) 
     10 //                                             +bkg 
     11 //                                             bkg: background level 
     12 //                                             R: radius of the sphere 
     13 //                                             V:The volume of the scatter 
     14 //                                             scatter_sld: the scattering length density of the scatter 
     15 //                                             solvent_sld: the scattering length density of the solvent 
     16 //                             </text> 
     17  
    918typedef struct { 
    1019    /// Scale factor 
Note: See TracChangeset for help on using the changeset viewer.