Changeset 2605 for trunk/python
- Timestamp:
- 07/20/12 17:49:33 (12 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/customgui_base.py
r2324 r2605 1167 1167 1168 1168 self.plotter._plotter.hold() 1169 self.plotter._plotter.legend(1)1169 #self.plotter._plotter.legend(1) 1170 1170 self._set_plot_counter(pagemode) 1171 1171 self.plotter._plot(self.plotter._data) -
trunk/python/flagplotter.py
r2453 r2605 32 32 self.set_stacking('scan') 33 33 self._ismodified = False 34 self._showflag = True #False 35 self.set_colors("blue gray",False) 34 36 35 37 def _new_custombar(self): … … 49 51 asaplog.post("ERROR") 50 52 53 def set_showflag(self, show): 54 """ Whether or not plotting flagged data""" 55 if type(show) == bool: 56 self._showflag = show 57 51 58 @asaplog_post_dec 52 59 def _invalid_func(self, name): … … 61 68 return 62 69 msg = "Pannel setting is fixed to row mode in 'flagplotter'" 70 asaplog.push(msg) 71 asaplog.post('ERROR') 72 self._panelling = 'r' 73 74 def set_range(self,xstart=None,xend=None,ystart=None,yend=None,refresh=False, offset=None): 75 """ This function is not available for the class flagplotter """ 76 msg = "Plot range setting is not allowed in 'flagplotter'" 63 77 asaplog.push(msg) 64 78 asaplog.post('ERROR') … … 116 130 if self._is_new_scan(scan): 117 131 self._ismodified = False 132 if not self._showflag: 133 self.set_legend(mode=None,refresh=False) 134 elif not self._legendloc: 135 self.set_legend(mode=1,refresh=False) 118 136 asapplotter.plot(self,scan) 119 137 plot.__doc__ = asapplotter.plot.__doc__ … … 121 139 @asaplog_post_dec 122 140 def _plot(self, scan): 123 asapplotter._plot(self,scan)141 self._plot_with_flag(scan,self._showflag) 124 142 # rescale x-range of subplots 5% margins 125 143 ganged = (self._plotter.axes._sharex != None) … … 136 154 _plot.__doc__ = asapplotter._plot.__doc__ 137 155 156 157 @asaplog_post_dec 158 def _plot_with_flag(self, scan, showflag=True): 159 # total number of panles to plot as a whole 160 nptot = scan.nrow() 161 # remaining panels to plot 162 n = nptot - self._ipanel - 1 163 ganged = False 164 maxpanel = 25 165 166 if n > 1: 167 ganged = rcParams['plotter.ganged'] 168 if self._rows and self._cols: 169 n = min(n,self._rows*self._cols) 170 self._plotter.set_panels(rows=self._rows,cols=self._cols, 171 nplots=n,margin=self._margins,ganged=ganged) 172 else: 173 n = min(n,maxpanel) 174 self._plotter.set_panels(rows=n,cols=0,nplots=n,margin=self._margins,ganged=ganged) 175 else: 176 self._plotter.set_panels(margin=self._margins) 177 #r = 0 178 r = self._startrow 179 # total row number of scantable 180 nr = scan.nrow() 181 panelcount = 0 182 183 while r < nr: 184 # always plot to new panel 185 self._plotter.subplot(panelcount) 186 self._plotter.palette(0) 187 # title and axes labels 188 xlab = self._abcissa and self._abcissa[panelcount] \ 189 or scan._getabcissalabel() 190 if self._offset and not self._abcissa: 191 xlab += " (relative)" 192 ylab = self._ordinate and self._ordinate[panelcount] \ 193 or scan._get_ordinate_label() 194 self._plotter.set_axes('xlabel', xlab) 195 self._plotter.set_axes('ylabel', ylab) 196 lbl = self._get_label(scan, r, mode='title', userlabel=self._title) 197 if type(lbl) in (list, tuple): 198 if 0 <= panelcount < len(lbl): 199 lbl = lbl[panelcount] 200 else: 201 # get default label 202 lbl = self._get_label(scan, r, 'title') 203 self._plotter.set_axes('title',lbl) 204 panelcount += 1 205 # Now get data to plot 206 y = scan._getspectrum(r) 207 #flag row 208 mr = scan._getflagrow(r) 209 from numpy import ma, array 210 if mr: 211 ys = ma.masked_array(y,mask=mr) 212 if showflag: 213 yf = ma.masked_array(y, mask=(not mr)) 214 else: 215 m = scan._getmask(r) 216 from numpy import logical_not, logical_and 217 if self._maskselection and len(self._usermask) == len(m): 218 if d[self._stacking](r) in self._maskselection[self._stacking]: 219 m = logical_and(m, self._usermask) 220 ys = ma.masked_array(y,mask=logical_not(array(m,copy=False))) 221 if showflag: 222 yf = ma.masked_array(y,mask=m) 223 224 x = array(scan._getabcissa(r)) 225 if self._offset: 226 x += self._offset 227 llbl = self._get_label(scan, r, mode='legend', userlabel=self._lmap) 228 if type(llbl) in (list, tuple): 229 llbl = llbl[0] 230 self._plotter.set_line(label=llbl) 231 plotit = self._plotter.plot 232 if self._hist: plotit = self._plotter.hist 233 plotit(x,ys) 234 if showflag: 235 self._plotter.set_line(label="flagged") 236 plotit(x,yf) 237 if (panelcount == n) or (r == nr-1): 238 break 239 r+=1 # next row 240 241 242 # save the current counter for multi-page plotting 243 self._startrow = r+1 244 self._ipanel += panelcount 245 if self.casabar_exists(): 246 if self._ipanel >= nptot-1: 247 self._plotter.figmgr.casabar.disable_next() 248 else: 249 self._plotter.figmgr.casabar.enable_next() 250 if self._ipanel + 1 - panelcount > 0: 251 self._plotter.figmgr.casabar.enable_prev() 252 else: 253 self._plotter.figmgr.casabar.disable_prev() 254 255 256 257 def _get_label(self, scan, row, mode='title', userlabel=None): 258 if isinstance(userlabel, list) and len(userlabel) == 0: 259 userlabel = " " 260 elif not mode.upper().startswith('T'): 261 pms = dict(zip(self._selection.get_pols(), \ 262 self._selection.get_poltypes())) 263 if len(pms): 264 poleval = scan._getpollabel(scan.getpol(row), \ 265 pms[scan.getpol(row)]) 266 else: 267 poleval = scan._getpollabel(scan.getpol(row),scan.poltype()) 268 label = "IF%d, POL %s, Scan%d" % \ 269 (scan.getif(row),poleval,scan.getscan(row)) 270 else: 271 label = "row %d" % (row) 272 273 return userlabel or label 274 275 138 276 def _is_new_scan(self,scan): 139 277 if isinstance(scan, scantable):
Note:
See TracChangeset
for help on using the changeset viewer.