Commits
Ajay Vibhute authored db263f2cbb1 Merge
24 24 | # results[4].read()[0].rq_result[0].final[0].gaintable |
25 25 | |
26 26 | def plot(self): |
27 27 | plots = [self.get_plot_wrapper('syspower_box')] |
28 28 | return [p for p in plots if p is not None] |
29 29 | |
30 30 | def create_plot(self, prefix): |
31 31 | figfile = self.get_figfile(prefix) |
32 32 | |
33 33 | antenna_names = [a.name for a in self.ms.antennas] |
34 - | |
34 + | # Positions of the boxes; ticks and limits are automatically set to match. |
35 + | # Defaults to range(1, N+1), where N is the number of boxes to be drawn. |
36 + | # Reference: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html |
37 + | # Hence, adding 1 to antenna ids |
38 + | antenna_ids = [a.id+1 for a in self.ms.antennas] |
35 39 | # box plot of Pdiff template |
36 - | dat_common = self.dat_common # self.result.dat_common |
40 + | dat_common = self.dat_common # self.result.dat_common |
37 41 | clip_sp_template = self.result.clip_sp_template |
38 42 | |
39 43 | LOG.info("Creating syspower box chart for {!s}-band...".format(self.band)) |
40 44 | plt.clf() |
41 45 | dshape = dat_common.shape |
42 46 | ant_dat = np.reshape(dat_common, newshape=(dshape[0], np.prod(dshape[1:]))) |
43 47 | ant_dat = np.ma.array(ant_dat) |
44 48 | ant_dat.mask = np.ma.getmaskarray(ant_dat) |
45 49 | ant_dat = np.ma.masked_outside(ant_dat, clip_sp_template[0], clip_sp_template[1]) |
46 50 | ant_dat_filtered = [ant_dat[i][~ant_dat.mask[i]] for i in range(dshape[0])] |
47 51 | plt.boxplot(ant_dat_filtered, whis=10, sym='.') |
48 - | plt.xticks(rotation=45) |
52 + | plt.xticks(rotation=50) |
53 + | plt.xticks(antenna_ids, antenna_names) |
49 54 | plt.ylim(clip_sp_template[0], clip_sp_template[1]) |
50 55 | plt.ylabel('Template Pdiff {!s}-band'.format(self.band)) |
51 56 | plt.xlabel('Antenna') |
52 57 | plt.savefig(figfile) |
53 58 | |
54 59 | def get_figfile(self, prefix): |
55 60 | return os.path.join(self.context.report_dir, 'stage%s' % self.result.stage_number, |
56 61 | 'syspower-{!s}-'.format(self.band) + prefix + '-%s-box.png' % self.ms.basename) |
57 62 | |
58 63 | def get_plot_wrapper(self, prefix): |
104 109 | plt.clf() |
105 110 | dshape = dat_common.shape |
106 111 | ant_dat = np.reshape(dat_common, newshape=(dshape[0], np.prod(dshape[1:]))) |
107 112 | ant_dat = np.ma.array(ant_dat) |
108 113 | ant_dat.mask = np.ma.getmaskarray(ant_dat) |
109 114 | ant_dat = np.ma.masked_outside(ant_dat, clip_sp_template[0], clip_sp_template[1]) |
110 115 | |
111 116 | # fraction of flagged data in Pdiff template |
112 117 | percent_flagged_by_antenna = [100. * np.sum(ant_dat.mask[i]) / ant_dat.mask[i].size for i in range(dshape[0])] |
113 118 | plt.bar(list(range(dshape[0])), percent_flagged_by_antenna, color='red') |
114 - | plt.xticks(rotation=45) |
119 + | plt.xticks(rotation=50) |
120 + | plt.xticks(np.arange(0, len(antenna_names)), antenna_names) |
115 121 | plt.ylabel('Fraction of Flagged Solutions (%) {!s}-band'.format(self.band)) |
116 122 | plt.xlabel('Antenna') |
117 123 | |
118 124 | plt.savefig(figfile) |
119 125 | |
120 126 | def get_figfile(self, prefix): |
121 127 | return os.path.join(self.context.report_dir, 'stage%s' % self.result.stage_number, |
122 128 | 'syspower-{!s}-'.format(self.band) + prefix + '-%s-bar.png' % self.ms.basename) |
123 129 | |
124 130 | def get_plot_wrapper(self, prefix): |