source: sasview/sansmodels/test/prototypes/test_cyl_iq.py @ 0abf7bf

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 0abf7bf was 18e250c, checked in by Gervaise Alina <gervyh@…>, 13 years ago

move test to sansmodels top level

  • Property mode set to 100644
File size: 1.9 KB
Line 
1try:
2    from sans.models.prototypes.TestSphere2 import TestSphere2
3    from sans.models.prototypes.SimCylinderF import SimCylinderF
4    from sans.models.prototypes.SimCylinder import SimCylinder
5except:
6    print "This test uses the prototypes module."
7from sans.models.SphereModel import SphereModel
8from sans.models.CylinderModel import CylinderModel
9import math, time
10
11
12def test_lores():
13
14    lores = open('lores.iq', 'r')
15    f = open('lores_check.txt', 'w')
16    content = lores.read()
17    lines = content.split('\n')
18    inum = 0
19    norma = 0.
20    for line in lines:
21        toks = line.split()
22        if len(toks)==2:
23            inum += 1
24            q = float(toks[0])
25            ana = sph.run(q)
26            if inum==1:
27                continue
28            elif inum==2:
29                norma = ana/float(toks[1])
30            lor = float(toks[1])*norma
31            f.write("%g %g %g\n" % (q, ana, lor))
32    f.close()
33           
34
35#sim = TestSphere2()
36#sph = SphereModel()
37sim = SimCylinderF()
38sph = CylinderModel()
39
40sim.setParam('radius', 20)
41sim.setParam('length', 200)
42sim.setParam('phi', 1)
43sim.setParam('theta', 1)
44sim.setParam('npoints',2500)
45#print sph.params
46
47sph.setParam('radius', 20)
48sph.setParam('scale', 1)
49sph.setParam('contrast',1)
50sph.setParam('length', 200)
51sph.setParam('cyl_phi', 1)
52sph.setParam('cyl_theta', 1)
53
54#print "ANA", sph.run(0.1)
55#print "SIM", sim.run(0.1)
56
57f = open('sim_iq.txt', 'w')
58f.write("<q>  <ana>  <sim>\n")
59
60t_0 = time.time()
61
62for i in range(60):
63    q = 0.01 * (i+1) /3.0
64    #ana_value = sph.run([q,0])
65    #sim_value = sim.run([q,0])
66    ana_value = sph.run(q)
67    sim_value = sim.run(q)
68    ratio = 0
69    if sim_value>0:
70        ratio = sim_value/ana_value
71    print q, ana_value, sim_value, ratio
72    f.write("%10g %10g %10g\n" % (q, ana_value, sim_value))
73
74t_f = time.time()
75print "Time = ", t_f-t_0
76f.close()
77
Note: See TracBrowser for help on using the repository browser.