1
2 """
3 Plot the data associated with the polarization efficiency correction.
4
5 This is a pair of plots locked together, one plot showing the intensity
6 scans for the individual cross-sections, and the estimated 2*beta, the
7 other showing the efficiencies of the front/back polarizers and flippers.
8 """
9
10 import numpy
11 import wx
12 import matplotlib as mpl
13 mpl.interactive(False)
14 mpl.use('WXAgg')
15 import matplotlib.pyplot
16
17 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
18
19
21 - def __init__(self, parent, id = -1, dpi = None, **kwargs):
22 wx.Panel.__init__(self, parent, id=id, **kwargs)
23 self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2,2))
24 self.canvas = Canvas(self, -1, self.figure)
25 sizer = wx.BoxSizer(wx.VERTICAL)
26 sizer.Add(self.canvas,1,wx.EXPAND)
27 self.SetSizer(sizer)
28
29 self.intensity = self.figure.add_subplot(211)
30 mpl.pyplot.setp(self.intensity.get_xticklabels(), visible=False)
31 self.efficiency = self.figure.add_subplot(212, sharex=self.intensity)
32
33 self.raw = None
34 self.smooth = None
35
37 ax = self.intensity
38 ax.clear()
39 ax.set_ylabel("Counts")
40 if self.raw is not None:
41 eff = self.raw
42 for data,label,color in zip([eff.beam.pp, eff.beam.pm,
43 eff.beam.mp, eff.beam.mm],
44 ['$I++$','$I+-$','$I-+$','$I--$'],
45 ['r','g','b','m']):
46 self.intensity.errorbar(data.x,data.v,yerr=data.dv,
47 fmt='x'+color,label=label)
48 self.intensity.plot(eff.beam.pp.x,eff.Ic,'xc',label='$I_c$')
49 if self.smooth is not None:
50 eff = self.smooth
51 for data,color in zip([eff.beam.pp, eff.beam.pm,
52 eff.beam.mp, eff.beam.mm],
53 ['r','g','b','m']):
54 self.intensity.errorbar(data.x,data.v,data.dv,fmt='-'+color)
55 self.intensity.semilogy(eff.beam.pp.x,eff.Ic,'-c')
56 ax.legend()
57 ax.set_yscale('log')
58 self.canvas.draw_idle()
59
61 ax = self.efficiency
62 ax.clear()
63 ax.set_ylabel("Efficiency (%)")
64
65 if self.raw is not None:
66 eff = self.raw
67 ax.set_xlabel("%s (%s)"%(eff.beam.xlabel, eff.beam.xunits))
68 for y,lab,color in zip([eff.fp, eff.ff, eff.rf, eff.rp],
69 ['F pol','F flip','R pol','R flip'],
70 ['r','g','b','m']):
71 self.efficiency.plot(eff.beam.pp.x, 100*y,'x'+color,label=lab)
72 if self.smooth is not None:
73 eff = self.smooth
74 ax.set_xlabel("%s (%s)"%(eff.beam.xlabel, eff.beam.xunits))
75 for y,color in zip([eff.fp, eff.ff, eff.rf, eff.rp],
76 ['r','g','b','m']):
77 self.efficiency.plot(eff.beam.pp.x, 100*y,'-'+color)
78 ax.set_ylim(ymax=105)
79 ax.axhspan(100,1000,facecolor='0.8',alpha=0.5)
80 ax.legend()
81 self.canvas.draw_idle()
82
83 - def plot(self, raw=None, smooth=None):
88
112
113 if __name__ == "__main__": demo()
114