1 | |
---|
2 | import numpy as np |
---|
3 | import math |
---|
4 | npoints=100 |
---|
5 | x_pos = np.linspace(-10,10, npoints) |
---|
6 | y_pos = np.linspace(-10,10, npoints) |
---|
7 | half_bin = (x_pos[1]-x_pos[0])/2.0 |
---|
8 | x_bins = np.concatenate((x_pos - half_bin , [x_pos[-1]+half_bin])) |
---|
9 | print x_bins.shape |
---|
10 | y_values = np.zeros((npoints*npoints)) |
---|
11 | |
---|
12 | for iy in range(npoints): |
---|
13 | for ix in range(npoints): |
---|
14 | distance = math.sqrt(x_pos[ix]**2+y_pos[iy]**2) |
---|
15 | if math.sin(distance) < 0: |
---|
16 | y_values[iy*npoints+ix] = 0 |
---|
17 | else: |
---|
18 | y_values[iy*npoints+ix] = math.sin(distance) |
---|
19 | |
---|
20 | |
---|
21 | |
---|
22 | vUnit = 'dSpacing' |
---|
23 | ws = CreateWorkspace(x_bins, y_values, NSpec=npoints, VerticalAxisValues=y_pos, VerticalAxisUnit=vUnit) |
---|
24 | |
---|
25 | |
---|
26 | # execute the ring profile for all the image in different rings. |
---|
27 | min_r = 0.1 |
---|
28 | max_r = 12 |
---|
29 | num_steps = 20 |
---|
30 | num_bins = 36 |
---|
31 | startangle = -1 |
---|
32 | y_values = list() |
---|
33 | delta = (max_r-min_r)/num_steps |
---|
34 | centre = [0,0] |
---|
35 | |
---|
36 | for i in range(num_steps): |
---|
37 | aux = RingProfile(ws, centre, min_r, min_r+delta, num_bins, startangle) |
---|
38 | min_r += delta |
---|
39 | y_values.append(numpy.copy(aux.readY(0))) |
---|
40 | #if you want to compensate the fact that for small rings, the numbers of |
---|
41 | # detectors are smaller, uncoment this line |
---|
42 | #y_values.append(aux.readY(0)/((min_r+delta/2)**2)) |
---|
43 | |
---|
44 | # create the result output |
---|
45 | all_rings = CreateWorkspace(aux.readX(0),numpy.concatenate(y_values),NSpec=num_steps) |
---|
46 | |
---|