source: sasview/src/sas/sascalc/simulation/pointsmodelpy/tests/testlores2d.py @ 7b4676a

magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 7b4676a was a1b8fee, checked in by andyfaff, 8 years ago

MAINT: from future import print_function

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