pyts.plot package¶
Submodules¶
pyts.plot.api module¶
pyts.plot.axform module¶
-
class
pyts.plot.axform.
FigAxForm
(fignum, axforms=[], comp=['u', 'v', 'w'], axsize=2, frame=[0.6, 0.3, 1, 0.3], gap=[0.2, 1], tightgap=0.2, **kwargs)[source]¶ Bases:
pyts.plot.superaxes.sfig
The ‘figure’ class that uses and handles
axesForm
.Parameters: fignum : integer,string
The figure number, or string, into which the data will be plotted.
axforms : list of axForms (e.g.
velprof
,tkeprof
)These are the axes formats that will be plotted.
comp : list of velocity components (0,1,2 or ‘u’,’v’,’w’)
axsize : float, tuple, list (2)
The size of the axes. If 2 parameters are specified this sets they set the horizontal and vertical size of the axes.
frame : tuple(4) ,list(4)
This specifies the border around the axes (left, right, bottom, top)
gap : tuple(2), list(2)
This specifies the gap between axes in the horizontal and vertical directions.
tightgap : float
This specifies the horizontal spacing between axes that have the same type of y-axis (specified in the formats ‘yax’ attribute).
Other inputs are passed directly to :meth:`superaxes.sfig.__init__`.
Notes
This will create an NxM axes-grid, where N=len(comp), and M=len(axforms).
The width of each axes is scaled by the ‘hrel’ attribute of each axform.
-
class
pyts.plot.axform.
Tiprof
(xlim=[None, None], ylim=[None, None], xscale='linear', yscale='linear')[source]¶ Bases:
pyts.plot.axform.prof
A Turbulence intensity axesForm
-
xax
= 'Ti'¶
-
-
class
pyts.plot.axform.
axesForm
(xlim=[None, None], ylim=[None, None], xscale='linear', yscale='linear')[source]¶ Bases:
object
A base ‘axesForm’ class for for quickly plotting TurbSim data.
Parameters: xlim : iterable(2) (default: [None, None])
Specify the xlims of the axes of these plots. The default will simply select the limits automatically.
ylim : iterable(2) (default: [None, None])
Specify the ylims of the axes of these plots. The default will simply select the limits automatically.
xscale : (‘log’ or ‘linear’)
specify whether the x-scale should be logarithmic or linear.
yscale : (‘log’ or ‘linear’)
specify whether the y-scale should be logarithmic or linear.
-
finalize
(axes)[source]¶ This function ‘finishes’ the axes according to the specifications in this axesForm.
Parameters: axes : A superaxes.axgroup
instance.
-
hide_ylabels
= False¶
-
method_map
= {<class 'pyts.main.tsrun'>: '_calc_tsrun', <class 'pyts.main.tsdata'>: '_calc_tsdata'}¶
-
-
class
pyts.plot.axform.
cohere
(window_time_sec=600, igrid0=None, igrid1=None, xscale='log', ylim=[0, 1], **kwargs)[source]¶ Bases:
pyts.plot.axform.axesForm
A ‘coherence’ plotting format for showing coherence between two points.
Parameters: window_time_sec : float
the length of the fft window (seconds).
igrid0 : tuple,list (2), optional (default: i_hub)
The first spatial-index from which to estimate+plot coherence.
igrid1 : tuple,list (2), optional (default: (0,0))
The second spatial-index from which to estimate+plot coherence.
See also
Notes
This axesForm defaults to have a ‘log’ x-scale, and to have a linear y-axis with ylim=[0, 1].
-
hrel
= 1¶
-
xax
= 'freq'¶
-
yax
= 'coh'¶
-
-
class
pyts.plot.axform.
prof
(xlim=[None, None], ylim=[None, None], xscale='linear', yscale='linear')[source]¶ Bases:
pyts.plot.axform.axesForm
A base axesForm for plotting vertical profiles.
-
hrel
= 0.6¶
-
xtick_n
= 3¶
-
yax
= 'z'¶
-
-
class
pyts.plot.axform.
spec
(window_time_sec=600, igrid=None, xscale='log', yscale='log', **kwargs)[source]¶ Bases:
pyts.plot.axform.axesForm
A ‘spectral’ axesForm.
Parameters: window_time_sec : float
the length of the fft window (seconds).
igrid : tuple,list (2), optional (default: i_hub)
The spatial-index of the grid-point that should be plotted.
See also
Notes
This axesForm defaults to have ‘log’ x- and y-scales.
-
hrel
= 1¶
-
xax
= 'freq'¶
-
yax
= 'spec'¶
-
-
class
pyts.plot.axform.
stressprof
(xlim=[None, None], ylim=[None, None], xscale='linear', yscale='linear')[source]¶ Bases:
pyts.plot.axform.tkeprof
A ‘Reynold’s stress profile’ axesForm.
-
xax
= 'tke'¶
-
-
pyts.plot.axform.
summfig
(fignum=400, axforms=[<pyts.plot.axform.velprof object>, <pyts.plot.axform.spec object>], **kwargs)[source]¶
-
class
pyts.plot.axform.
tkeprof
(xlim=[None, None], ylim=[None, None], xscale='linear', yscale='linear')[source]¶ Bases:
pyts.plot.axform.prof
A ‘tke profile’ axesForm.
-
xax
= 'tke'¶
-
-
class
pyts.plot.axform.
velprof
(xlim=[None, None], ylim=[None, None], xscale='linear', yscale='linear')[source]¶ Bases:
pyts.plot.axform.prof
A ‘mean velocity profile’ axesForm format.
-
xax
= 'vel'¶
-
pyts.plot.base module¶
pyts.plot.psd module¶
-
pyts.plot.psd.
coh
(u1, u2, sr, nfft)[source]¶ Helper function to compute the coherence between two signals.
Parameters: u1 : array_like
Signal 1.
u2 : array_like
Signal 2.
sr : float
The sample rate of u.
nfft : The number of points to use in computing the fft.
Returns: p : array_like
The coherence between the two signal (no units) as a function of frequency.
f : array_like
Frequency (same units as sr).
-
pyts.plot.psd.
psd
(u, sr, nfft)[source]¶ Helper function to compute the power spectral density (PSD) of a signal.
Parameters: u : array_like
The signal to compute the PSD of.
sr : float
The sample rate of u.
nfft : The number of points to use in computing the fft.
Returns: p : array_like
The power in the signal u as a function of frequency (units of u squared/units of sr)
f : array_like
Frequency (same units as sr).
pyts.plot.superaxes module¶
-
class
pyts.plot.superaxes.
axPlacer
(vSpacer, hSpacer)[source]¶ Bases:
object
Axes placers contain the information on where axes objects should be placed in a figure object.
Parameters: vSpacer :
axSpacer
The vertical axes spacer object.
hSpacer :
axSpacer
The horizontal axes spacer object.
-
axes_positions
¶ Returns a list of location tuples (left, bottom, width, height) for axes objects.
-
figSize
¶ Width x Height in inches.
-
n
¶
-
Bases:
object
Returns the ‘prime’ axes to be shared for the axes at grid-point (iv,ih).
Parameters: (iv,ih) : The index of the axgrid for which you want the shareax.
Returns: shareax :
axes
, orNone
.None if the axis does not share an axes, or one has not yet been created that it matches.
-
class
pyts.plot.superaxes.
axSpacer
(axsize=[1, 1], gap=[0.7, 0.2, 0.2], vertical=False)[source]¶ Bases:
object
Defines the position and size of axes in either the horizontal or vertical direction.
Parameters: axsize : array_like(n,float)
An array specifying the size of each axes in inches.
gap : array_like(n+1,float)
An array specifying the spacing in inches between axes. The first element is the distance from the left/bottom of the figure to the first axes, the last element is the distrance from the right/top of the figure to the last axes.
vertical : bool (default: False)
A flag specifying that this is a ‘vertical’ axSpacer (flips ordering of axes positions so that the first axes is at the top of the figure).
-
axsize
¶ The axes size, in inches.
-
axsize_
¶ The figure-units axes sizes, array_like.
-
frame
¶ The bounding ‘frame’ around the axes, in inches.
-
gap
¶ The gap between axes, in inches.
-
gap_
¶ The figure-units gap between axes, array_like.
-
n
¶ The number of axes described by this axSpacer.
-
pos
¶
-
pos_
¶ The figure-units position of the axes, array_like.
-
totsize
¶
-
-
pyts.plot.superaxes.
axes
(*args, **kwargs)[source]¶ Add an axes at position rect specified by:
axes()
by itself creates a default fullsubplot(111)
window axis.axes(rect, axisbg='w')
where rect = [left, bottom, width, height] in normalized (0, 1) units. axisbg is the background color for the axis, default white.axes(h)
where h is an axes instance makes h the current axis. AnAxes
instance is returned.
kwarg Accepts Desctiption axisbg color the axes background color frameon [True|False] display the frame? sharex otherax current axes shares xaxis attribute with otherax sharey otherax current axes shares yaxis attribute with otherax polar [True|False] use a polar axes? Examples:
examples/pylab_examples/axes_demo.py
places custom axes.examples/pylab_examples/shared_axis_demo.py
uses sharex and sharey.
This was copied from the pyplot axes function. Several methods have been added to the axes.
-
class
pyts.plot.superaxes.
axgroup
(axes)[source]¶ Bases:
object
-
alphNumAxes
(axs, vals='abcdefghijklmnopqrstuvwxyz', prefix='', suffix=')', **kwargs)¶ Label the axes with alphanumeric characters.
Parameters: axs : iterable of axes objects
The axes over which to add labels.
vals : iterable of strings to annotate axes (default: ‘abcdefg…’)
prefix : string (default ‘’)
The string to prefix to the label.
suffix : string (default ‘)’)
The string to add to the end of the label.
See also
annoteCorner()
-
ax
¶ A shortcut to ‘self.axes’
-
fill_between
(*args, **kwargs)[source]¶ Iterates a fill_between call over all axes in the group. See fill_between
-
fill_betweenx
(*args, **kwargs)[source]¶ Iterates a fill_betweenx call over all axes in the group. See fill_betweenx
-
hide
(objs='xticklabels', ax=None)[source]¶ Hide objs on all axes of this group except for those specified in ax.
Parameters: objs : str {‘xticklabels’, ‘yticklabels’, ‘minorxticks’, ‘minoryticks’}
or a list of these.
ax : axes, optional (default: hide all)
The axes (or list of axes) on which these items should not be hidden.
See also
Examples
- Hide the xticklabels on all axes except ax0::
- hide(‘xticklabels’,self.ax0)
- To hide all xticklabels, simply do:
- hide(‘xticklabels’)
-
size
¶
-
-
pyts.plot.superaxes.
axvec2axSpacer
(n, vec, vertflag, rel=False)[source]¶ Returns an
axSpacer
corresponding to the n axes based on the axes vector vec.Parameters: n : int
The number of axes.
vec : iterable(3)
The (left/bottom,right/top,gap) surrounding and between the axes.
vertflag : bool, optional (default: False)
Specifies this is for vertical (True) or horizontal spacing.
rel : iterable(n), optional
This specifies the relative width of each of the axes. By default all axes are the same width.
Returns: axSpacer :
axSpacer
The axes spacer object corresponding to the specified inputs.
Notes
The units of the returned axSpacer match that of the input vec.
-
class
pyts.plot.superaxes.
fig_meta
[source]¶ Bases:
object
-
description
= None¶
-
keywords
= None¶
-
producer
= u'matplotlib 2.1.1, http://matplotlib.sf.net'¶
-
script
= None¶
-
title
= None¶
-
-
class
pyts.plot.superaxes.
figobj
(fignum, nax=None, axsize=None, frame=[0.6, 0.3, 1, 0.3], gap=0.4, **kwargs)[source]¶ Bases:
pyts.plot.superaxes.axgroup
A base class for axes-grid figures.
Parameters: fignum : int
Figure number
nax : tuple(2 ints)
Shape of the axes grid.
saxparams : dict
input arguments to saxes.
axsize : tuple(2 floats)
specifies the size of the axes [vertical,horizontal] in inches.
frame : iterable(4)
specifies the frame around the axes [bottom,top,left,right], in inches (default: [.6,.3,1,.3]).
gap : tuple(2 floats) or float
specifies the gap between axes [vertical,horizontal], in inches (default: [.2,.2]).
hrel : iterable
specifies the relative horizontal size of each axes.
vrel : iterable
specifies the relative vertical size of each axes.
-
nax
= (1, 1)¶
-
-
class
pyts.plot.superaxes.
myaxes
(fig=None, rect=None, **kwargs)[source]¶ Bases:
matplotlib.axes._axes.Axes
My own axes class.
-
annoteCorner
(ax, s, pos='ll', offset=10, **kwargs)¶ annotate a corner of an axes with a string.
Parameters: *ax* : axes
is the axes into which to place the annotation.
*s* : str
is the text to place in the corner.
*pos* : str {‘ll’,’ul’,’lr’,’ur’}, tuple(2)
The tuple form specifies the text locaiton in axes coordinates.
*offset* : tuple(1 or 2)
Specifies the offset from the selected pos (in points).
Returns: t : text artist.
Also, it creates a ‘corner_label’ attribute in the axes, with this text artist.
Notes
If the string form of pos is used then the sign of offset is always such that it shifts the string toward the center.If it is a two element tuple or string, it specifies a different offset in the x and y directions.
-
cpcolor
(x, y, c)¶ makes a pseudocolor plot of the data in c
Optional keyword arguments: fixgaps=True threshx=inf threshy=inf
-
errorshadex
(peer, x, y, xerr, ecolor=None, ealpha=0.5, color='b', zorder=0, **kwargs)¶ Plot a line with a shaded region for error.
-
labelax
(peer, str, place='right', **kwargs)¶
-
offset_text
(ax, x, y, s, offset=(0, 0), transform=None, **kwargs)¶ Add text to an axes offset from a location.
offset specifies the offset (in points) from the selected pos. If offset is a two element list or tuple, it specifies a different offset in the x and y directions.
Returns the text object.
By default the x,*y* positions are in data coordinates. Specify a different ‘transform’ to change this.
-
setaxesframe
(ax, str)¶
-
skip_ticklabels
(ax, rep=2, offset=0, axis='x', force=True)¶ hide the ticklabels on ticks except for every rep’th tick. offset specifies an offset, of tick to start on. axis specifies the x (default) or y axis. when force is True (default) this function turns on every rep’th tick.
-
transAxesXDataY
¶
-
transDataXAxesY
¶
-
-
class
pyts.plot.superaxes.
saxes
(n=(1, 1), h=[0.1, 0.9, 0.05], v=[0.1, 0.9, 0.05], **kwargs)[source]¶ Bases:
pyts.plot.superaxes.saxes_szr
Create an axes object using S(uper)AXES.
Use keyword argument fig=<figure object> to specify the figure in which to create the axes.
Notes
n=(3,4) to set up a 3x4 array of axes.
n=(3,[1,1,1,.5]) to set up a 3x4 array of axes with the last column half the width of the others.
n=([1,1,1.5],[1,1,1,.5]) to set up a 3x4 array of axes with the last row 1.5 times as tall and the last column half as wide.
h=(.1,.9,.05) to create the horizontal frame box at .1 and .9, with gaps of .05 between each axes.
v=(.1,.9,.05) similarly for the vertical frame/gap.
drawax=L, where L is a logical array of the axes you actually want to draw (default is all of them).
sharex=True, chooses whether the axes share an xaxis. sharey=True, chooses whether the axes share a yaxis.
-
n
= None¶
-
-
class
pyts.plot.superaxes.
saxes_szr
(axPlacer, **kwargs)[source]¶ Bases:
pyts.plot.superaxes.axgroup
-
n
¶
-
-
class
pyts.plot.superaxes.
sfig
(fignum, axPlacer, **kwargs)[source]¶ Bases:
pyts.plot.superaxes.axgroup
-
ax
¶
-
axes
¶
-
-
pyts.plot.superaxes.
simpleAxSpacer
(n, axsize, gap, frm=array([0.5, 0.5]), vertical=False)[source]¶ calculates the width (or height) of a figure with n subplots. Specify the width (height) of each subplot with ax[0], the space between subplots with ax[1], and the left/right (bottom/top) spacing with frame[0]/frame[1].
See also: saxes, axes, calcAxesSize
-
pyts.plot.superaxes.
skip_ticklabels
(ax, rep=2, offset=0, axis='x', force=True)[source]¶ hide the ticklabels on ticks except for every rep’th tick. offset specifies an offset, of tick to start on. axis specifies the x (default) or y axis. when force is True (default) this function turns on every rep’th tick.
Module contents¶
This is the PyTurbSim plotting package. It contains various functions and tools for plotting data that is created by PyTurbSim (and, by extension, TurbSim).
For more information and to use this package import the api module, e.g.
>>> import pyts.plot.api as pt