Ticket #7776: ring_image.py

File ring_image.py, 1.3 KB (added by Gesner Passos, 7 years ago)
Line 
1
2import numpy as np
3import math
4npoints=100
5x_pos = np.linspace(-10,10, npoints)
6y_pos = np.linspace(-10,10, npoints)
7half_bin = (x_pos[1]-x_pos[0])/2.0
8x_bins = np.concatenate((x_pos - half_bin , [x_pos[-1]+half_bin]))
9print x_bins.shape
10y_values = np.zeros((npoints*npoints))
11
12for 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
22vUnit = 'dSpacing'
23ws = 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.
27min_r = 0.1
28max_r = 12
29num_steps = 20
30num_bins = 36
31startangle = -1
32y_values = list()
33delta = (max_r-min_r)/num_steps
34centre = [0,0]
35
36for 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
45all_rings = CreateWorkspace(aux.readX(0),numpy.concatenate(y_values),NSpec=num_steps)
46