def plotHistogram( self, *name, **arg ): """ :param bins: number of bins (10) :type bins: int :param ynormalize: normalize histograms to area 1.0 (False) :type ynormalize: bool :param xnormalize: adapt bin range to min and max of all profiles (True) :type xnormalize: bool :param xrange: min and max of bin range (None) :type xrange: (float, float) :param steps: draw histogram steps (True) :type steps: bool """ if not biggles: raise ImportError('module biggles could not be imported') plot = biggles.FramedArray( len(name),1 ) if not 'size' in arg: arg['size'] = 1 bins = arg.get('bins', 10) hist = arg.get('ynormalize', False) steps= arg.get('steps', 1) histrange= arg.get('xrange', None) autorange= arg.get('xnormalize', histrange is None) xkey = arg.get('xkey', None) if xkey: plot.xlabel = xkey if autorange: v = [] for keys in name: if not type(keys) is tuple: keys = ( keys, ) for key in keys: v += list(self[key]) histrange = ( min( v ), max( v ) ) for i, keys in enumerate(name): if not type(keys) is tuple: keys = ( keys, ) for j, key in enumerate(keys): h = density( self[key], nBins=bins, steps=steps, hist=hist, range=histrange ) x = h[:,0] y = h[:,1] colors = [0] + T.colorSpectrum( len(keys) , '00FF00', 'FF00FF') plot[i,0].add( biggles.Curve( x, y, color=colors[j], **arg ) ) plot[i,0].add( biggles.PlotLabel( 0.7, 0.95-j*0.1, key, color=colors[j] ) ) return plot
def plotMemberProfiles( self, *name, **arg ): """ Plot profiles of all member trajectories seperately:: plotMemberProfiles( name1, [name2, .. ],[ arg1=x,..]) -> biggles.Table :param name: profile name(s) :type name: str :param arg: pairs for biggles.Curve() and/or xlabel=..,ylabel=.. :type arg: key=value :return: biggles plot object :rtype: biggles.FramedArray() """ if not biggles: raise ImportError('biggles module could not be imported.') rows = self.n_members // 2 + self.n_members % 2 page = biggles.FramedArray( rows , 2) biggles.configure('fontsize_min', 1) colors = T.colorSpectrum( len( name ) , '00FF00', 'FF00FF') ml = self.memberList() i = 0 minV = maxV = None for t in ml: for j in range( len(name)): p = t.profile( name[j] ) if minV is None or minV > min( p ): minV = min(p) if maxV is None or maxV < max( p ): maxV = max(p) page[i//2, i%2].add( biggles.Curve( list(range( len(p))), list(p), color=colors[j], **arg ) ) page[i//2, i%2].add( biggles.PlotLabel( 0.8, 0.8-j/8.0, name[j], color=colors[j]) ) page[i//2, i%2].add( biggles.PlotLabel( 0.1, 0.9, 'Traj %i' % i)) i += 1 if self.n_members % 2 != 0: line = biggles.Line( (0,minV), (len(p),maxV) ) page[ self.n_members//2, 1 ].add( line ) page.uniform_limits = 1 page.xlabel = arg.get('xlabel',None) page.ylabel = arg.get('ylabel',None) return page
def plotArray(self, *name, **arg): """ Plot several profiles as a panel of separate plots. :param *name: one or more profile names or tuples of profile names :type *name: str or (str, str,...) :param xkey: profile to be used as x-axis (default: None) :type xkey: str :param arg: key=value pairs for Biggles.Curve() function :type arg: :return: plot, view using plot.show() :rtype: biggles.FramedPlot :raise TypeError: if profile contains non-number items :raise ImportError: If biggles module could not be imported """ if not biggles: raise ImportError('module biggles could not be imported') plot = biggles.FramedArray(len(name), 1) if not 'size' in arg: arg['size'] = 1 xkey = arg.get('xkey', None) if xkey: plot.xlabel = xkey for i, keys in enumerate(name): if not type(keys) is tuple: keys = (keys, ) for j, key in enumerate(keys): x = self.get(xkey, list(range(self.profLength()))) y = self[key] colors = [0] + T.colorSpectrum(len(keys), '00FF00', 'FF00FF') plot[i, 0].add(biggles.Curve(x, y, color=colors[j], **arg)) plot[i, 0].add( biggles.PlotLabel(0.7, 0.95 - j * 0.1, key, color=colors[j])) return plot
def plotArray( self, *name, **arg ): """ Plot several profiles as a panel of separate plots. :param *name: one or more profile names or tuples of profile names :type *name: str or (str, str,...) :param xkey: profile to be used as x-axis (default: None) :type xkey: str :param arg: key=value pairs for Biggles.Curve() function :type arg: :return: plot, view using plot.show() :rtype: biggles.FramedPlot :raise TypeError: if profile contains non-number items :raise ImportError: If biggles module could not be imported """ if not biggles: raise ImportError('module biggles could not be imported') plot = biggles.FramedArray( len(name),1 ) if not 'size' in arg: arg['size'] = 1 xkey = arg.get('xkey', None) if xkey: plot.xlabel = xkey for i, keys in enumerate(name): if not type(keys) is tuple: keys = ( keys, ) for j, key in enumerate(keys): x = self.get( xkey, list(range(self.profLength())) ) y = self[key] colors = [0] + T.colorSpectrum( len(keys) , '00FF00', 'FF00FF') plot[i,0].add( biggles.Curve( x, y, color=colors[j], **arg ) ) plot[i,0].add( biggles.PlotLabel( 0.7, 0.95-j*0.1, key, color=colors[j] ) ) return plot
def plot(self, xkey, *ykey, **arg): """ Plot pairs of info values. The additional arg arguments are handed over to biggles.Points().:: plot( xkey, [ykey1, ykey2..],[arg1=x, arg2=y]) -> biggles.FramedPlot @param xkey: key specifying x-values @type xkey: str @param ykey: key specifying y-values @type ykey: str OR [str] @param arg: additional biggles arguments @type arg: key=value @return: biggles plot object @rtype: biggles.FramedPlot() """ if not biggles: raise ImportError('biggles module could not be imported.') plot = biggles.FramedPlot() plot.xlabel = xkey colors = t.colorSpectrum(len(ykey)) if not 'size' in arg: arg['size'] = 1 for i in range(len(ykey)): x = self.valuesOf(xkey) y = self.valuesOf(ykey[i]) x, y = self.__maskNone(x, y) plot.add(biggles.Points(x, y, color=colors[i], **arg)) plot.add( biggles.PlotLabel(0.2, 0.95 - i / 8.0, ykey[i], color=colors[i])) return plot
def plot(self, *name, **arg): """ Plot one or more profiles using Biggles:: plot( name1, [name2, ..],[arg1=x, arg2=y]) -> biggles.FramedPlot :param name: one or more profile names :type name: str :param arg: key=value pairs for Biggles.Curve() function :type arg: :raise TypeError: if profile contains non-number items :return: plot, view using plot.show() :rtype: biggles.FramedPlot :raise ImportError: If biggles module could not be imported """ if not biggles: raise ImportError('module biggles could not be imported') plot = biggles.FramedPlot() colors = T.colorSpectrum(len(name), '00FF00', 'FF00FF') for i in range(len(name)): p = N.array(self.get(name[i])) if p.dtype in ['O', 'c']: raise TypeError('Cannot plot values of profile %s.' % name[i]) # Biggles with its old Numeric cannot handle numpy arrays plot.add( biggles.Curve(list(range(len(p))), list(p), color=colors[i], **arg)) plot.add( biggles.PlotLabel(0.8, 0.8 - i / 8.0, name[i], color=colors[i])) return plot
def plot( self, xkey, *ykey, **arg ): """ Plot pairs of info values. The additional arg arguments are handed over to biggles.Points().:: plot( xkey, [ykey1, ykey2..],[arg1=x, arg2=y]) -> biggles.FramedPlot @param xkey: key specifying x-values @type xkey: str @param ykey: key specifying y-values @type ykey: str OR [str] @param arg: additional biggles arguments @type arg: key=value @return: biggles plot object @rtype: biggles.FramedPlot() """ if not biggles: raise ImportError('biggles module could not be imported.') plot = biggles.FramedPlot() plot.xlabel = xkey colors = t.colorSpectrum( len( ykey ) ) if not 'size' in arg: arg['size'] = 1 for i in range( len(ykey)): x = self.valuesOf( xkey ) y = self.valuesOf( ykey[i] ) x, y = self.__maskNone( x, y ) plot.add( biggles.Points( x, y, color=colors[i], **arg ) ) plot.add( biggles.PlotLabel( 0.2, 0.95-i/8.0, ykey[i], color=colors[i] ) ) return plot
def plot( self, *name, **arg ): """ Plot one or more profiles using Biggles:: plot( name1, [name2, ..],[arg1=x, arg2=y]) -> biggles.FramedPlot :param name: one or more profile names :type name: str :param arg: key=value pairs for Biggles.Curve() function :type arg: :raise TypeError: if profile contains non-number items :return: plot, view using plot.show() :rtype: biggles.FramedPlot :raise ImportError: If biggles module could not be imported """ if not biggles: raise ImportError('module biggles could not be imported') plot = biggles.FramedPlot() colors = T.colorSpectrum( len( name ) , '00FF00', 'FF00FF') for i in range( len(name)): p = N.array( self.get( name[i] ) ) if p.dtype in ['O','c']: raise TypeError('Cannot plot values of profile %s.' % name[i]) # Biggles with its old Numeric cannot handle numpy arrays plot.add( biggles.Curve( list(range( len(p))), list(p), color=colors[i], **arg ) ) plot.add( biggles.PlotLabel( 0.8, 0.8-i/8.0, name[i], color=colors[i]) ) return plot
def plotHistogram(self, *name, **arg): """ :param bins: number of bins (10) :type bins: int :param ynormalize: normalize histograms to area 1.0 (False) :type ynormalize: bool :param xnormalize: adapt bin range to min and max of all profiles (True) :type xnormalize: bool :param xrange: min and max of bin range (None) :type xrange: (float, float) :param steps: draw histogram steps (True) :type steps: bool """ if not biggles: raise ImportError('module biggles could not be imported') plot = biggles.FramedArray(len(name), 1) if not 'size' in arg: arg['size'] = 1 bins = arg.get('bins', 10) hist = arg.get('ynormalize', False) steps = arg.get('steps', 1) histrange = arg.get('xrange', None) autorange = arg.get('xnormalize', histrange is None) xkey = arg.get('xkey', None) if xkey: plot.xlabel = xkey if autorange: v = [] for keys in name: if not type(keys) is tuple: keys = (keys, ) for key in keys: v += list(self[key]) histrange = (min(v), max(v)) for i, keys in enumerate(name): if not type(keys) is tuple: keys = (keys, ) for j, key in enumerate(keys): h = density(self[key], nBins=bins, steps=steps, hist=hist, range=histrange) x = h[:, 0] y = h[:, 1] colors = [0] + T.colorSpectrum(len(keys), '00FF00', 'FF00FF') plot[i, 0].add(biggles.Curve(x, y, color=colors[j], **arg)) plot[i, 0].add( biggles.PlotLabel(0.7, 0.95 - j * 0.1, key, color=colors[j])) return plot