source: sasview/realSpaceModeling/pointsmodelpy/tests/testlores2d.py @ eba0cb5f

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 eba0cb5f was f2d6445, checked in by Mathieu Doucet <doucetm@…>, 17 years ago

moving realSpaceModeling to trunk

  • Property mode set to 100644
File size: 3.1 KB
Line 
1def test_lores2d(phi):
2  from sansModeling.pointsmodelpy import pointsmodelpy
3  from sansModeling.iqPy import iqPy
4  from sansModeling.geoshapespy import geoshapespy
5
6  #lores model is to hold several geometric objects
7  lm = pointsmodelpy.new_loresmodel(0.1)
8
9  #generate single geometry shape
10  c = geoshapespy.new_cylinder(10,40)
11  geoshapespy.set_center(c,1,1,1)
12  geoshapespy.set_orientation(c,0,0,0)
13
14  #add single geometry shape to lores model
15  pointsmodelpy.lores_add(lm,c,3.0)
16
17  #retrieve the points from lores model for sans calculation
18  vp = pointsmodelpy.new_point3dvec()
19  pointsmodelpy.get_lorespoints(lm,vp)
20
21  #Calculate I(Q) and P(r) 2D
22  pointsmodelpy.distdistribution_xy(lm,vp)
23  pointsmodelpy.outputPR_xy(lm,"out_xy.pr")
24  iq = iqPy.new_iq(100,0.001, 0.3)
25  pointsmodelpy.calculateIQ_2D(lm,iq,phi)
26  iqPy.OutputIQ(iq, "out_xy.iq")
27
28def get2d():
29  from math import pi
30  from Numeric import arange,zeros
31  from enthought.util.numerix import Float,zeros
32  from sansModeling.file2array import readfile2array
33  from sansModeling.pointsmodelpy import pointsmodelpy
34  from sansModeling.geoshapespy import geoshapespy
35
36  lm = pointsmodelpy.new_loresmodel(0.1)
37  sph = geoshapespy.new_sphere(20)
38  pointsmodelpy.lores_add(lm,sph,1.0)
39
40  vp = pointsmodelpy.new_point3dvec()
41  pointsmodelpy.get_lorespoints(lm,vp)
42
43  pointsmodelpy.distdistribution_xy(lm,vp)
44
45  value_grid = zeros((100,100),Float)
46  width, height = value_grid.shape
47  print width,height
48
49  I = pointsmodelpy.calculateI_Qxy(lm,0.00001,0.000002)
50  print I
51
52  Imax = 0
53  for i in range(width):
54    for j in range(height):
55      qx = float(i-50)/200.0
56      qy = float(j-50)/200.0
57      value_grid[i,j] = pointsmodelpy.calculateI_Qxy(lm,qx,qy)
58      if value_grid[i][j] > Imax:
59        Imax = value_grid[i][j]
60
61  for i in range(width):
62    for j in range(height):
63      value_grid[i][j] = value_grid[i][j]/Imax
64
65  value_grid[50,50] = 1
66  return value_grid
67
68def get2d_2():
69  from math import pi
70  from Numeric import arange,zeros
71  from enthought.util.numerix import Float,zeros
72  from sansModeling.file2array import readfile2array
73  from sansModeling.pointsmodelpy import pointsmodelpy
74  from sansModeling.geoshapespy import geoshapespy
75
76  lm = pointsmodelpy.new_loresmodel(0.1)
77  cyn = geoshapespy.new_cylinder(5,20)
78  geoshapespy.set_orientation(cyn,0,0,90)
79  pointsmodelpy.lores_add(lm,cyn,1.0)
80
81  vp = pointsmodelpy.new_point3dvec()
82  pointsmodelpy.get_lorespoints(lm,vp)
83
84  pointsmodelpy.distdistribution_xy(lm,vp)
85
86  value_grid = zeros((100,100),Float)
87  width, height = value_grid.shape
88  print width,height
89
90  I = pointsmodelpy.calculateI_Qxy(lm,0.00001,0.000002)
91  print I
92
93  Imax = 0
94  for i in range(width):
95    for j in range(height):
96      qx = float(i-50)/200.0
97      qy = float(j-50)/200.0
98      value_grid[i,j] = pointsmodelpy.calculateI_Qxy(lm,qx,qy)
99      if value_grid[i][j] > Imax:
100        Imax = value_grid[i][j]
101
102  for i in range(width):
103    for j in range(height):
104      value_grid[i][j] = value_grid[i][j]/Imax
105
106  value_grid[50,50] = 1
107  return value_grid
108 
109if __name__ == "__main__":
110
111  print "start to test lores 2D"
112#  test_lores2d(10)
113  value_grid = get2d_2()
114  print value_grid
115  print "pass"
Note: See TracBrowser for help on using the repository browser.