allWindows.append(window) (xmin, ymin, xmax, ymax) = determineFullFrameSize(allWindows) fullFramexsize = xmax - xmin fullFrameysize = ymax - ymin """ Set up the PGPLOT windows """ xyPositionPlot = {} xyPositionPlot['pgplotHandle'] = ppgplot.pgopen('/xs') xyPositionPlot['yLimit'] = 1.0 xyPositionPlot['numXYPanels'] = len(referenceApertures.sources) ppgplot.pgpap(6.18, 1.618) ppgplot.pgsubp(1, xyPositionPlot['numXYPanels']) ppgplot.pgsci(5) for panel in range(xyPositionPlot['numXYPanels']): currentSize = ppgplot.pgqch() ppgplot.pgsch(1) yLimit = xyPositionPlot['yLimit'] ppgplot.pgenv(startFrame, startFrame + frameRange, -yLimit, yLimit, 0, -2) ppgplot.pgbox('A', 0.0, 0, 'BCG', 0.0, 0) ppgplot.pglab("", "%d"%panel, "") ppgplot.pgsch(currentSize) ppgplot.pgask(False) ppgplot.pgsci(1) if (arg.preview):
def prepplot(rangex, rangey, title=None, labx=None, laby=None, \ rangex2=None, rangey2=None, labx2=None, laby2=None, \ logx=0, logy=0, logx2=0, logy2=0, font=ppgplot_font_, \ fontsize=ppgplot_font_size_, id=0, aspect=1, ticks='in', \ panels=[1,1], device=ppgplot_device_): """ prepplot(rangex, rangey, ...) Open a PGPLOT device for plotting. 'rangex' and 'rangey' are sequence objects giving min and max values for each axis. The optional entries are: title: graph title (default = None) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: ranges for 2nd x-axis (default = None) rangey2: ranges for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: Show ID line on plot (default = 0 (no)) aspect: Aspect ratio (default = 1 (square)) ticks: Ticks point in or out (default = 'in') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ global ppgplot_dev_open_, ppgplot_dev_prep_ # Check if we will use second X or Y axes # Note: if using a 2nd X axis, the range should correspond # to the minimum and maximum values of the 1st X axis. If # using a 2nd Y axis, the range should correspond to the # scalerange() values of the 1st Y axis. if rangex2 is None: rangex2=rangex otherxaxis=0 else: otherxaxis=1 if rangey2 is None: rangey2=rangey otheryaxis=0 else: otheryaxis=1 # Open the plot device if (not ppgplot_dev_open_): ppgplot.pgopen(device) # My little add-on to switch the background to white if device == '/XWIN': reset_colors() if device == '/AQT': ppgplot.pgsci(0) # Let the routines know that we already have a device open ppgplot_dev_open_ = 1 # Set the aspect ratio ppgplot.pgpap(0.0, aspect) if (panels != [1,1]): # Set the number of panels ppgplot.pgsubp(panels[0], panels[1]) ppgplot.pgpage() # Choose the font ppgplot.pgscf(font) # Choose the font size ppgplot.pgsch(fontsize) # Choose the font size ppgplot.pgslw(ppgplot_linewidth_) # Plot the 2nd axis if needed first if otherxaxis or otheryaxis: ppgplot.pgvstd() ppgplot.pgswin(rangex2[0], rangex2[1], rangey2[0], rangey2[1]) # Decide how the axes will be drawn if ticks=='in': env = "CMST" else: env = "CMSTI" if logx2: lxenv='L' else: lxenv='' if logy2: lyenv='L' else: lyenv='' if otherxaxis and otheryaxis: ppgplot.pgbox(env+lxenv, 0.0, 0, env+lyenv, 0.0, 0) elif otheryaxis: ppgplot.pgbox("", 0.0, 0, env+lyenv, 0.0, 0) else: ppgplot.pgbox(env+lxenv, 0.0, 0, "", 0.0, 0) # Now setup the primary axis ppgplot.pgvstd() ppgplot.pgswin(rangex[0], rangex[1], rangey[0], rangey[1]) # Decide how the axes will be drawn if ticks=='in': env = "ST" else: env = "STI" if logx: lxenv='L' else: lxenv='' if logy: lyenv='L' else: lyenv='' if otherxaxis and otheryaxis: ppgplot.pgbox("BN"+env+lxenv, 0.0, 0, "BN"+env+lyenv, 0.0, 0) elif otheryaxis: ppgplot.pgbox("BCN"+env+lxenv, 0.0, 0, "BN"+env+lyenv, 0.0, 0) elif otherxaxis: ppgplot.pgbox("BN"+env+lxenv, 0.0, 0, "BCN"+env+lyenv, 0.0, 0) else: ppgplot.pgbox("BCN"+env+lxenv, 0.0, 0, "BCN"+env+lyenv, 0.0, 0) # My little add-on to switch the background to white if device == '/AQT' or device == '/XWIN': reset_colors() # Add labels if not title is None: ppgplot.pgmtxt("T", 3.2, 0.5, 0.5, title) ppgplot.pgmtxt("B", 3.0, 0.5, 0.5, labx) ppgplot.pgmtxt("L", 2.6, 0.5, 0.5, laby) if otherxaxis: ppgplot.pgmtxt("T", 2.0, 0.5, 0.5, labx2) if otheryaxis: ppgplot.pgmtxt("R", 3.0, 0.5, 0.5, laby2) # Add ID line if required if (id==1): ppgplot.pgiden() # Let the routines know that we have already prepped the device ppgplot_dev_prep_ = 1
def prepplot(rangex, rangey, title=None, labx=None, laby=None, \ rangex2=None, rangey2=None, labx2=None, laby2=None, \ logx=0, logy=0, logx2=0, logy2=0, font=ppgplot_font_, \ fontsize=ppgplot_font_size_, id=0, aspect=1, ticks='in', \ panels=[1,1], device=ppgplot_device_): """ prepplot(rangex, rangey, ...) Open a PGPLOT device for plotting. 'rangex' and 'rangey' are sequence objects giving min and max values for each axis. The optional entries are: title: graph title (default = None) labx: label for the x-axis (default = None) laby: label for the y-axis (default = None) rangex2: ranges for 2nd x-axis (default = None) rangey2: ranges for 2nd y-axis (default = None) labx2: label for the 2nd x-axis (default = None) laby2: label for the 2nd y-axis (default = None) logx: make the 1st x-axis log (default = 0 (no)) logy: make the 1st y-axis log (default = 0 (no)) logx2: make the 2nd x-axis log (default = 0 (no)) logy2: make the 2nd y-axis log (default = 0 (no)) font: PGPLOT font to use (default = 1 (normal)) fontsize: PGPLOT font size to use (default = 1.0 (normal)) id: Show ID line on plot (default = 0 (no)) aspect: Aspect ratio (default = 1 (square)) ticks: Ticks point in or out (default = 'in') panels: Number of subpanels [r,c] (default = [1,1]) device: PGPLOT device to use (default = '/XWIN') Note: Many default values are defined in global variables with names like ppgplot_font_ or ppgplot_device_. """ global ppgplot_dev_open_, ppgplot_dev_prep_ # Check if we will use second X or Y axes # Note: if using a 2nd X axis, the range should correspond # to the minimum and maximum values of the 1st X axis. If # using a 2nd Y axis, the range should correspond to the # scalerange() values of the 1st Y axis. if rangex2 is None: rangex2 = rangex otherxaxis = 0 else: otherxaxis = 1 if rangey2 is None: rangey2 = rangey otheryaxis = 0 else: otheryaxis = 1 # Open the plot device if (not ppgplot_dev_open_): ppgplot.pgopen(device) # Let the routines know that we already have a device open ppgplot_dev_open_ = 1 # Set the aspect ratio ppgplot.pgpap(0.0, aspect) if (panels != [1, 1]): # Set the number of panels ppgplot.pgsubp(panels[0], panels[1]) ppgplot.pgpage() # Choose the font ppgplot.pgscf(font) # Choose the font size ppgplot.pgsch(fontsize) # Choose the font size ppgplot.pgslw(ppgplot_linewidth_) # Plot the 2nd axis if needed first if otherxaxis or otheryaxis: ppgplot.pgvstd() ppgplot.pgswin(rangex2[0], rangex2[1], rangey2[0], rangey2[1]) # Decide how the axes will be drawn if ticks == 'in': env = "CMST" else: env = "CMSTI" if logx2: lxenv = 'L' else: lxenv = '' if logy2: lyenv = 'L' else: lyenv = '' if otherxaxis and otheryaxis: ppgplot.pgbox(env + lxenv, 0.0, 0, env + lyenv, 0.0, 0) elif otheryaxis: ppgplot.pgbox("", 0.0, 0, env + lyenv, 0.0, 0) else: ppgplot.pgbox(env + lxenv, 0.0, 0, "", 0.0, 0) # Now setup the primary axis ppgplot.pgvstd() ppgplot.pgswin(rangex[0], rangex[1], rangey[0], rangey[1]) # Decide how the axes will be drawn if ticks == 'in': env = "ST" else: env = "STI" if logx: lxenv = 'L' else: lxenv = '' if logy: lyenv = 'L' else: lyenv = '' if otherxaxis and otheryaxis: ppgplot.pgbox("BN" + env + lxenv, 0.0, 0, "BN" + env + lyenv, 0.0, 0) elif otheryaxis: ppgplot.pgbox("BCN" + env + lxenv, 0.0, 0, "BN" + env + lyenv, 0.0, 0) elif otherxaxis: ppgplot.pgbox("BN" + env + lxenv, 0.0, 0, "BCN" + env + lyenv, 0.0, 0) else: ppgplot.pgbox("BCN" + env + lxenv, 0.0, 0, "BCN" + env + lyenv, 0.0, 0) # Add labels if not title is None: ppgplot.pgmtxt("T", 3.2, 0.5, 0.5, title) ppgplot.pgmtxt("B", 3.0, 0.5, 0.5, labx) ppgplot.pgmtxt("L", 2.6, 0.5, 0.5, laby) if otherxaxis: ppgplot.pgmtxt("T", 2.0, 0.5, 0.5, labx2) if otheryaxis: ppgplot.pgmtxt("R", 3.0, 0.5, 0.5, laby2) # Add ID line if required if (id == 1): ppgplot.pgiden() # Let the routines know that we have already prepped the device ppgplot_dev_prep_ = 1
def plot(self, vlo=2., vhi=98., nc=-1, method='p', mpl=False, cmap=CMDEF, \ close=True, x1=None, x2=None, y1=None, y2=None, sepmin=1.): """ Plots an MCCD using pgplot or matplotlib if preferred. :Parameters: vlo : float number specifying the lowest level to plot (default as a percentile) vhi : float number specifying the lowest level to plot (default as a percentile) nc : int CCD number (starting from 0, -1 for all) method : string how vlo and vhi are to be interpreted. 'p' = percentile, 'a' = automatic (min to max, vlo and vhi are irrelevant), 'd' = direct, i.e. just take the values given. mpl : bool True to prefer matplotlib over pgplot (which may not even be an option) cmap : matplotlib.cm.binary colour map if using matplotlib close : bool close (pgplot) or 'show' (matplotlib) the plot at the end (or not, to allow you to plot something else, use a cursor etc). In the case of pgplot, this also implies opening the plot at the start, i.e. a self-contained quick plot. x1 : float left-hand plot limit. Defaults to 0.5 x2 : float right-hand plot limit. Defaults to nxmax+0.5 y1 : float lower plot limit. Defaults to 0.5 y2 : float upper plot limit. Defaults to nymax+0.5 sepmin : float minimum separation between intensity limits (> 0 to stop PGPLOT complaining) :Returns: range(s) : tuple or list the plot range(s) used either as a single 2-element tuple, or a list of them, one per CCD plotted. """ if nc == -1: nc1 = 0 nc2 = len(self) else: nc1 = nc nc2 = nc+1 if not mpl: if close: pg.pgopen('/xs') if nc2-nc1 > 1: pg.pgsubp(nc2-nc1,1) prange = [] for nc, ccd in enumerate(self._data[nc1:nc2]): # Determine intensity range to display if method == 'p': vmin, vmax = ccd.centile((vlo,vhi)) elif method == 'a': vmin, vmax = ccd.min(), ccd.max() elif method == 'd': vmin, vmax = vlo, vhi else: raise UltracamError('MCCD.plot: method must be one of p, a or d.') if vmin == vmax: vmin -= sepmin/2. vmax += sepmin/2. prange.append((vmin, vmax)) # start nxmax, nymax = ccd.nxmax, ccd.nymax x1 = 0.5 if x1 is None else x1 x2 = nxmax+0.5 if x2 is None else x2 y1 = 0.5 if y1 is None else y1 y2 = nymax+0.5 if y2 is None else y2 if mpl: if nc2-nc1 > 1: plt.subplot(1,nc2-nc1,nc+1) plt.axis('equal') else: if nc2-nc1 > 1: pg.pgpanl(nc-nc1+1,1) pg.pgwnad(x1,x2,y1,y2) # plot CCD ccd.plot(vmin,vmax,mpl,cmap) # per-frame finishing-off if mpl: plt.xlim(x1,x2) plt.ylim(y1,y2) else: pg.pgbox('bcnst',0,0,'bcnst',0,0) pg.pglab('X','Y','') if close: if mpl: plt.show() else: pg.pgclos() # return intensity range(s) used if len(prange) == 1: return prange[0] else: return tuple(prange)
def plot(self, vlo=2., vhi=98., nc=-1, method='p', mpl=False, cmap=CMDEF, \ close=True, x1=None, x2=None, y1=None, y2=None, sepmin=1.): """ Plots an MCCD using pgplot or matplotlib if preferred. :Parameters: vlo : float number specifying the lowest level to plot (default as a percentile) vhi : float number specifying the lowest level to plot (default as a percentile) nc : int CCD number (starting from 0, -1 for all) method : string how vlo and vhi are to be interpreted. 'p' = percentile, 'a' = automatic (min to max, vlo and vhi are irrelevant), 'd' = direct, i.e. just take the values given. mpl : bool True to prefer matplotlib over pgplot (which may not even be an option) cmap : matplotlib.cm.binary colour map if using matplotlib close : bool close (pgplot) or 'show' (matplotlib) the plot at the end (or not, to allow you to plot something else, use a cursor etc). In the case of pgplot, this also implies opening the plot at the start, i.e. a self-contained quick plot. x1 : float left-hand plot limit. Defaults to 0.5 x2 : float right-hand plot limit. Defaults to nxmax+0.5 y1 : float lower plot limit. Defaults to 0.5 y2 : float upper plot limit. Defaults to nymax+0.5 sepmin : float minimum separation between intensity limits (> 0 to stop PGPLOT complaining) :Returns: range(s) : tuple or list the plot range(s) used either as a single 2-element tuple, or a list of them, one per CCD plotted. """ if nc == -1: nc1 = 0 nc2 = len(self) else: nc1 = nc nc2 = nc + 1 if not mpl: if close: pg.pgopen('/xs') if nc2 - nc1 > 1: pg.pgsubp(nc2 - nc1, 1) prange = [] for nc, ccd in enumerate(self._data[nc1:nc2]): # Determine intensity range to display if method == 'p': vmin, vmax = ccd.centile((vlo, vhi)) elif method == 'a': vmin, vmax = ccd.min(), ccd.max() elif method == 'd': vmin, vmax = vlo, vhi else: raise UltracamError( 'MCCD.plot: method must be one of p, a or d.') if vmin == vmax: vmin -= sepmin / 2. vmax += sepmin / 2. prange.append((vmin, vmax)) # start nxmax, nymax = ccd.nxmax, ccd.nymax x1 = 0.5 if x1 is None else x1 x2 = nxmax + 0.5 if x2 is None else x2 y1 = 0.5 if y1 is None else y1 y2 = nymax + 0.5 if y2 is None else y2 if mpl: if nc2 - nc1 > 1: plt.subplot(1, nc2 - nc1, nc + 1) plt.axis('equal') else: if nc2 - nc1 > 1: pg.pgpanl(nc - nc1 + 1, 1) pg.pgwnad(x1, x2, y1, y2) # plot CCD ccd.plot(vmin, vmax, mpl, cmap) # per-frame finishing-off if mpl: plt.xlim(x1, x2) plt.ylim(y1, y2) else: pg.pgbox('bcnst', 0, 0, 'bcnst', 0, 0) pg.pglab('X', 'Y', '') if close: if mpl: plt.show() else: pg.pgclos() # return intensity range(s) used if len(prange) == 1: return prange[0] else: return tuple(prange)
matplotlib.pyplot.draw() matplotlib.pyplot.show() ppgplot.pgclos() ########################################################################################################################## # Phase Plots ########################################################################################################################## if arg.ps: device = "phaseplots.ps/ps" else: device = "/xs" phasePlotWindow = ppgplot.pgopen(device) pgPlotTransform = [0, 1, 0, 0, 0, 1] ppgplot.pgslct(phasePlotWindow) ppgplot.pgsci(1) # ppgplot.pgpap(3, 0.618) if extraColumn: ppgplot.pgsubp(1, 2) ppgplot.pgask(True) rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']}) ## for Palatino and other serif fonts use: rc('font',**{'family':'serif','serif':['Palatino']}) rc('text', usetex=True) figSize = 10 labelSize = 20 tickSize = 18 matplotlib.pyplot.figure(figsize=(figSize, figSize / 1.618)) for o in objects: if o.hasEphemeris: