1 | |
---|
2 | import numpy |
---|
3 | import math |
---|
4 | # get an instrument |
---|
5 | ws = Load('LOQ48098', SpectrumMin=2, SpectrumMax=16000) |
---|
6 | |
---|
7 | # process the workspace in order to get an image with circles around the |
---|
8 | # defined origin (look at the resulting workspace at instrument view) |
---|
9 | origin = V3D(0.006,0,15.15) |
---|
10 | n = ws.blocksize() |
---|
11 | x_pos = numpy.zeros(ws.getNumberHistograms()) |
---|
12 | y_pos = numpy.zeros(ws.getNumberHistograms()) |
---|
13 | for i in range(ws.getNumberHistograms()): |
---|
14 | try: |
---|
15 | if ws.getDetector(i).isMonitor() : |
---|
16 | ws.setY(i,numpy.zeros(n)) |
---|
17 | continue |
---|
18 | x_pos[i] = ws.getDetector(i).getPos().getX() |
---|
19 | y_pos[i] = ws.getDetector(i).getPos().getY() |
---|
20 | dist = ws.getDetector(i).getPos().distance(origin) |
---|
21 | if (math.sin(dist*30)<0): |
---|
22 | ws.setY(i,numpy.zeros(n)) |
---|
23 | else: |
---|
24 | ws.setY(i, numpy.zeros(n) + math.sin(dist*30)) |
---|
25 | except : |
---|
26 | print 'ex' |
---|
27 | pass |
---|
28 | |
---|
29 | |
---|
30 | # execute the ring profile for all the image in different rings. |
---|
31 | min_r = 0.001 |
---|
32 | max_r = 0.33 |
---|
33 | num_steps = 20 |
---|
34 | num_bins = 36 |
---|
35 | startangle = -1 |
---|
36 | y_values = list() |
---|
37 | delta = (max_r-min_r)/num_steps |
---|
38 | centre = [0.006,0,15.15] |
---|
39 | |
---|
40 | for i in range(num_steps): |
---|
41 | aux = RingProfile(ws, centre, min_r, min_r+delta, num_bins, startangle) |
---|
42 | min_r += delta |
---|
43 | y_values.append(numpy.copy(aux.readY(0))) |
---|
44 | #if you want to compensate the fact that for small rings, the numbers of |
---|
45 | # detectors are smaller, uncoment this line |
---|
46 | #y_values.append(aux.readY(0)/((min_r+delta/2)**2)) |
---|
47 | |
---|
48 | # create the result output |
---|
49 | all_rings = CreateWorkspace(aux.readX(0),numpy.concatenate(y_values),NSpec=num_steps) |
---|
50 | |
---|