Changeset bda194e3 in sasview for sansmodels/src/sans/models/test


Ignore:
Timestamp:
Aug 21, 2009 8:06:40 AM (15 years ago)
Author:
Jae Cho <jhjcho@…>
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:
c1c29b6
Parents:
861a2d3
Message:

This should be the final code for testing 2D 3-axes shape model; comparing 1d to the 2d avg.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/test/validate_2D_3axes_shape_model.py

    r8e36cdd rbda194e3  
    2525        Averaging the 3-axes 2D scattering intensity give a slightly 
    2626        different output than the 1D function   
    27         at hight Q (Q>~0.2). This is due(?) to the way the IGOR library  
    28         averages, taking only 76 points in alpha, the angle between 
     27        at hight Q (Q>~0.2). This is due to the way the IGOR library  
     28        averages(?), taking only 76 points in alpha, the angle between 
    2929        the axis of the ellipsoid and the q vector. 
    3030         
     
    5959         
    6060        npts =points 
     61        #The average values are very sensitive to npts of phi so npts_alpha should be large enough. 
     62        npts_alpha =180 #npts of phi 
    6163        model = model_class() 
    6264        #model.setParam('scale', 1.0) 
     
    8486        output_f.write("<q_average> <2d_average> <1d_average>\n") 
    8587             
    86         for i_q in range(1, 40): 
     88        for i_q in range(1, 23): 
    8789            q = 0.01*i_q 
    8890            sum = 0.0 
     91            weight = 0.0 
    8992            for i_theta in range(npts): 
    9093                theta = math.pi/npts*(i_theta+1) 
     
    9295                model.setParam(theta_label, theta) 
    9396                 
    94                 for j in range(npts): 
    95                     model.setParam(phi_label, math.pi * 2.0 / npts * j) 
     97                for j in range(npts_alpha): 
     98                    model.setParam(phi_label, math.pi * 2.0 / npts_alpha * j) 
    9699                    for k in range(npts): 
    97100                        model.setParam(psi_label, math.pi * 2.0 / npts * k) 
    98101                        if str(model.run([q, 0])).count("INF")>0:                         
    99102                            print "ERROR", q, theta, math.pi * 2.0 / npts * k 
     103                             
     104                        # sin() is due to having not uniform bin number density wrt the q plane. 
    100105                        sum += model.run([q, 0])*math.sin(theta) 
    101                         #sum += model.run([q, 0]) 
    102             value = sum/npts/(npts)/npts*math.pi/2.0 
     106                        weight += math.sin(theta)  
     107 
     108            value = sum/weight #*math.pi/2.0 
    103109            ana = model.run(q) 
    104             if q<0.2 and (value-ana)/ana>0.05: 
     110            if q<0.3 and (value-ana)/ana>0.05: 
    105111                passed = False 
    106112            output_f.write("%10g %10g %10g\n" % (q, value, ana)) 
     
    115121    validator = Validate2D() 
    116122     
    117     #te was not passed. 
     123    #Note: Test one model by one model, otherwise it could crash depending on the memory. 
     124     
    118125    te_passed =validator(TriaxialEllipsoidModel, points=76) 
    119     pp_passed = validator(ParallelepipedModel, points=76) 
    120     ell_passed = validator(EllipticalCylinderModel, points=76) 
     126    #pp_passed = validator(ParallelepipedModel, points=76) 
     127    #ell_passed = validator(EllipticalCylinderModel, points=76) 
    121128         
    122129    print "" 
    123130    print "Model             Passed" 
    124131    print "TriaxialEllipsoid         %s" % te_passed 
    125     print "ParallelepipedModel    %s" % pp_passed 
    126     print "EllipticalCylinder        %s" % ell_passed 
     132    #print "ParallelepipedModel    %s" % pp_passed 
     133    #print "EllipticalCylinder        %s" % ell_passed 
    127134  
    128135         
Note: See TracChangeset for help on using the changeset viewer.