Changeset c6a48c27 in sasview for DataLoader


Ignore:
Timestamp:
May 27, 2010 11:12:20 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:
06c7fcc
Parents:
35b556d
Message:

added one more test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/smearing_2d.py

    r6c2d1a1 rc6a48c27  
    103103        """ 
    104104            Over sampling of r_nbins times phi_nbins, calculate Gaussian weights, then find smeared intensity 
    105             # For the default values, this is equivalent (but speed optimized by a factor of ten)to the following: 
     105            # For the default values, this is equivalent (but by using numpy array  
     106            # the speed optimized by a factor of ten)to the following: 
    106107            ===================================================================================== 
    107108            ## Remove the singular points if exists 
     
    177178        return value 
    178179     
    179      
    180180if __name__ == '__main__': 
    181     ## Test 
     181    ## Test w/ 2D linear function 
     182    x = 0.001*numpy.arange(1,11) 
     183    dx = numpy.ones(len(x))*0.001 
     184    y = 0.001*numpy.arange(1,11) 
     185    dy = numpy.ones(len(x))*0.001 
     186    z = numpy.ones(10) 
     187    dz = numpy.sqrt(z) 
     188     
     189    from DataLoader import Data2D 
     190    #for i in range(10): print i, 0.001 + i*0.008/9.0  
     191    #for i in range(100): print i, int(math.floor( (i/ (100/9.0)) ))  
     192    out = Data2D() 
     193    out.data = z 
     194    out.qx_data = x 
     195    out.qy_data = y 
     196    out.dqx_data = dx 
     197    out.dqy_data = dy 
     198    index = numpy.ones(len(x), dtype = bool) 
     199    out.mask = index 
     200    from sans.models.LineModel import LineModel 
     201    model = LineModel() 
     202    model.setParam("A", 0) 
     203 
     204    smear = Smearer2D(out,model,index) 
     205    #smear.set_accuracy('Xhigh') 
     206    value = smear.get_value() 
     207    ## All data are ones, so the smeared should also be ones. 
     208    print "Data length =",len(value) 
     209    print " 2D linear function, I = 0 + 1*qx*qy" 
     210    print " Gaussian weighted averaging on a 2D linear function will provides the results same as without the averaging." 
     211    print "qx_data", "qy_data", "I_nonsmear", "I_smeared" 
     212    for ind in range(len(value)): 
     213        print x[ind],y[ind],model.evalDistribution([x,y])[ind], value[ind] 
     214   
     215"""     
     216if __name__ == '__main__': 
     217    ## Another Test w/ constant function 
    182218    x = 0.001*numpy.arange(1,11) 
    183219    dx = numpy.ones(len(x))*0.001 
     
    202238 
    203239    value = Smearer2D(out,model,index).get_value() 
    204     ## All data are ones, so the smeared should also be ones. 
     240    ## All data are ones, so the smeared values should also be ones. 
    205241    print "Data length =",len(value), ", Data=",value 
    206      
     242"""     
Note: See TracChangeset for help on using the changeset viewer.