1 | from WrappedReduction import * |
---|
2 | |
---|
3 | ##################### M2-0167 T=5K |
---|
4 | #( _ ,r1q , _)= ref('8169+8171+8173+8175+8177+8179+8181',theta=0.4) #Test ref() |
---|
5 | #r1q= refl('8169+8171+8173+8175+8177+8179+8181',theta=0.4) # Test refl |
---|
6 | r1q= refq('8169+8171+8173+8175+8177+8179+8181',theta=0.4) # Test refq |
---|
7 | |
---|
8 | graph0=plotSpectrum(r1q,0); |
---|
9 | graph0.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph0.activeLayer().setAutoScale(); |
---|
10 | |
---|
11 | #(_ ,r2q, _)= ref('8197+8198+8199+8200', 0.615) |
---|
12 | #r2q= refl('8197+8198+8199+8200', 0.615) |
---|
13 | r2q= refq('8197+8198+8199+8200', 0.615) |
---|
14 | |
---|
15 | graph0=plotSpectrum(r2q,0); |
---|
16 | graph0.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph0.activeLayer().setAutoScale(); |
---|
17 | |
---|
18 | #( _ ,r3q , _)= ref('8170+8172+8174+8176+8178+8180', theta=1.52) |
---|
19 | #r3q= refl('8170+8172+8174+8176+8178+8180', theta=1.52) |
---|
20 | r3q= refq('8170+8172+8174+8176+8178+8180', theta=1.52) |
---|
21 | |
---|
22 | graph0=plotSpectrum(r3q,0); |
---|
23 | graph0.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph0.activeLayer().setAutoScale(); |
---|
24 | |
---|
25 | # Plot the data to check the results |
---|
26 | graph0=plotSpectrum([r1q,r2q,r3q],0); |
---|
27 | graph0.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph0.activeLayer().setAutoScale(); |
---|
28 | |
---|
29 | # Rebin prior to stitching |
---|
30 | rr1q=Rebin(r1q,'0.009,-0.02,0.048') |
---|
31 | rr2q=Rebin(r2q,'0.014,-0.02,0.066') |
---|
32 | rr3q=Rebin(r3q,'0.026,-0.02,0.18') |
---|
33 | |
---|
34 | # Plot the data to check the results |
---|
35 | graph1=plotSpectrum([rr1q,rr2q,rr3q],0); |
---|
36 | graph1.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph1.activeLayer().setAutoScale(); |
---|
37 | ### Test Matplotlib graphics |
---|
38 | plt.plot(centerbins(rr1q[0].readX(0)),rr1q[0].readY(0), 'r.-',centerbins(rr1q[1].readX(0)),rr1q[1].readY(0), 'k.-' ) |
---|
39 | plt.plot(centerbins(rr2q[0].readX(0)),rr2q[0].readY(0), 'b.-',centerbins(rr2q[1].readX(0)),rr2q[1].readY(0), 'g.-' ) |
---|
40 | plt.plot(centerbins(rr3q[0].readX(0)),rr3q[0].readY(0), 'c.-',centerbins(rr3q[1].readX(0)),rr3q[1].readY(0), 'm.-' ) |
---|
41 | #plt.show() # Causes a full mantid crash. |
---|
42 | |
---|
43 | """ |
---|
44 | # Stitch three data sets together |
---|
45 | r5k = Stitch1DMany([rr1q,rr2q,rr3q], [0.014,0.026],[0.048,0.066],-0.05) |
---|
46 | |
---|
47 | # Plot the stitched data |
---|
48 | graph2=plotSpectrum(r5k,0); |
---|
49 | graph2.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph2.activeLayer().setAutoScale(); |
---|
50 | # Normalize the area of total reflection to 1 |
---|
51 | y0=r5k[0].readY(0); y1=r5k[1].readY(0); |
---|
52 | avg=numpy.average( numpy.array( ( numpy.average(y0[0:10]), numpy.average(y1[0:10]) ) ) ) |
---|
53 | r5k=r5k/avg |
---|
54 | |
---|
55 | # Write out textfiles |
---|
56 | #SaveAscii(r5k[0],'M2-167T=5KH=0p9T.001.dat', ScientificFormat=True,ColumnHeader=False) |
---|
57 | #SaveAscii(r5k[1],'M2-167T=5KH=0p9T.002.dat', ScientificFormat=True,ColumnHeader=False) |
---|
58 | |
---|
59 | #calculate the spin asymmetry and flipping ratio. We rebin again to improve the error bar on the high q data |
---|
60 | rr=Rebin(r5k,'0.009,-0.05,0.02,0.07,0.2') |
---|
61 | asym=(rr[0]-rr[1])/(rr[0]+rr[1]) |
---|
62 | ratio=rr[0]/rr[1] |
---|
63 | |
---|
64 | # Plot the stitched data |
---|
65 | graph3=plotSpectrum(asym,0); graph3.activeLayer().setAxisTitle(0, "SA") |
---|
66 | graph4=plotSpectrum(Ratio,0); graph4.activeLayer().setAxisTitle(0, "Ratio") |
---|
67 | g=mergePlots(graph3,graph4) |
---|
68 | |
---|
69 | # Write out textfiles |
---|
70 | #SaveAscii(asym,'M2-167T=5KH=0p9T.asy.dat', ScientificFormat=True,ColumnHeader=False) |
---|
71 | #SaveAscii(ratio, 'M2-167T=5KH=0p9T.rat.dat', ScientificFormat=True,ColumnHeader=False) |
---|
72 | |
---|
73 | """ |
---|
74 | ''' |
---|
75 | ################################################################################################# |
---|
76 | ##################### M2-0167 T=50K |
---|
77 | ################################################################################################# |
---|
78 | r1q = refq('8187+8189+8191+8193', theta=0.401) |
---|
79 | r2q = refq('8196', theta=0.61) |
---|
80 | r3q = refq('8195', theta=0.9) |
---|
81 | r4q = refq('8188+8190+8192+8194', theta=1.501) |
---|
82 | # Rebin prior to stitching |
---|
83 | rr1q=Rebin(r1q,'0.009,-0.02,0.048') |
---|
84 | rr2q=Rebin(r2q,'0.0155,-0.02,0.06') |
---|
85 | rr3q=Rebin(r3q,'0.018,-0.02,0.1') |
---|
86 | rr4q=Rebin(r4q,'0.026,-0.02,0.2') |
---|
87 | |
---|
88 | # Plot the data to check the results |
---|
89 | graph1=plotSpectrum([rr1q,rr2q,rr3q,rr4q],0); |
---|
90 | graph1.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph1.activeLayer().setAutoScale(); |
---|
91 | |
---|
92 | # Stitch three data sets together |
---|
93 | r50k = Stitch1DMany([rr1q,rr2q,rr3q,rr4q], [0.0155,0.18,0.026],[0.048,0.06,0.1],'-0.05') |
---|
94 | |
---|
95 | # Plot the stitched data |
---|
96 | graph2=plotSpectrum(r50k,0); |
---|
97 | graph2.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph2.activeLayer().setAutoScale(); |
---|
98 | # Normalize the area of total reflection to 1 |
---|
99 | y0=r50k[0].readY(0); y1=r50k[1].readY(0); |
---|
100 | avg=numpy.average( numpy.array( ( numpy.average(y0[0:10]), numpy.average(y1[0:10]) ) ) ) |
---|
101 | r50k=r50k/avg |
---|
102 | |
---|
103 | # Write out textfiles |
---|
104 | #SaveAscii(r5k[0],'M2-167T=50KH=0p9T.001.dat', ScientificFormat=True,ColumnHeader=False) |
---|
105 | #SaveAscii(r5k[1],'M2-167T=50KH=0p9T.002.dat', ScientificFormat=True,ColumnHeader=False) |
---|
106 | |
---|
107 | #calculate the spin asymmetry and flipping ratio. We rebin again to improve the error bar on the high q data |
---|
108 | rr=Rebin(r50k,'0.009,-0.05,0.02,0.07,0.2') |
---|
109 | asym=(rr[0]-rr[1])/(rr[0]+rr[1]) |
---|
110 | ratio=rr[0]/rr[1] |
---|
111 | |
---|
112 | # Plot the stitched data |
---|
113 | graph3=plotSpectrum(asym,0); graph3.activeLayer().setAxisTitle(0, "SA") |
---|
114 | graph4=plotSpectrum(Ratio,0); graph4.activeLayer().setAxisTitle(0, "Ratio") |
---|
115 | g=mergePlots(graph3,graph4) |
---|
116 | |
---|
117 | # Write out textfiles |
---|
118 | #SaveAscii(asym,'M2-167T=50KH=0p9T.asy.dat', ScientificFormat=True,ColumnHeader=False) |
---|
119 | #SaveAscii(ratio, 'M2-167T=50KH=0p9T.rat.dat', ScientificFormat=True,ColumnHeader=False) |
---|
120 | |
---|
121 | ################################################################################################# |
---|
122 | ##################### M2-0167 T=300K |
---|
123 | ################################################################################################# |
---|
124 | r1q=refq('8209+8210+8211', theta=0.618) |
---|
125 | r2q=refq('8212+8213+8214+8215+8216+8217+8218+8219+8220+8221+8222+8223+8224', theta=0.93) |
---|
126 | # Rebin prior to stitching |
---|
127 | rr1q=Rebin(r1q,'0.01,-0.03,0.048') |
---|
128 | rr2q=Rebin(r2q,'0.018,-0.03,0.15') |
---|
129 | |
---|
130 | # Plot the data to check the results |
---|
131 | graph1=plotSpectrum([rr1q,rr2q],0); graph1.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph1.activeLayer().setAutoScale(); |
---|
132 | |
---|
133 | # Stitch three data sets together |
---|
134 | r300k = Stitch1DMany([rr1q,rr2q], [0.018],[0.048],'-0.05') |
---|
135 | |
---|
136 | # Plot the stitched data |
---|
137 | graph2=plotSpectrum(r300k,0); graph2.activeLayer().setAxisScale(Layer.Left,1e-7,1,Layer.Log10); graph2.activeLayer().setAutoScale(); |
---|
138 | |
---|
139 | # Normalize the area of total reflection to 1 |
---|
140 | y0=r300k[0].readY(0); y1=r300k[1].readY(0); |
---|
141 | avg=numpy.average( numpy.array( ( numpy.average(y0[0:10]), numpy.average(y1[0:10]) ) ) ) |
---|
142 | r300k=r300k/avg |
---|
143 | |
---|
144 | # Write out textfiles |
---|
145 | #SaveAscii(r300k[0],'M2-167T=300KH=0p9T.001.dat', ScientificFormat=True,ColumnHeader=False) |
---|
146 | #SaveAscii(r300k[1],'M2-167T=300KH=0p9T.002.dat', ScientificFormat=True,ColumnHeader=False) |
---|
147 | |
---|
148 | #calculate the spin asymmetry and flipping ratio. We rebin again to improve the error bar on the high q data |
---|
149 | rr=Rebin(r300k,'0.009,-0.05,0.02,0.07,0.2') |
---|
150 | asym=(rr[0]-rr[1])/(rr[0]+rr[1]) |
---|
151 | ratio=rr[0]/rr[1] |
---|
152 | |
---|
153 | # Plot the stitched data |
---|
154 | graph3=plotSpectrum(asym,0); graph3.activeLayer().setAxisTitle(0, "SA") |
---|
155 | graph4=plotSpectrum(Ratio,0); graph4.activeLayer().setAxisTitle(0, "Ratio") |
---|
156 | g=mergePlots(graph3,graph4) |
---|
157 | |
---|
158 | # Write out textfiles |
---|
159 | #SaveAscii(asym,'M2-167T=300KH=0p9T.asy.dat', ScientificFormat=True,ColumnHeader=False) |
---|
160 | #SaveAscii(ratio, 'M2-167T=300KH=0p9T.rat.dat', ScientificFormat=True,ColumnHeader=False) |
---|
161 | |
---|
162 | ''' |
---|