tropy.plotting_tools package¶
Submodules¶
tropy.plotting_tools.bmaps module¶
tropy.plotting_tools.colormaps module¶
-
tropy.plotting_tools.colormaps.
colorname_based_cmap
(colname, start_col=None, final_col=None, reverse=False)¶ A matplotlib colormap is constructed based on one color’
- cmap = colorname_based_cmap(colname,
- start_col = None, final_col = None, reverse = False)
colname : supported colorname as basis for colormap start_col : color at one end of the colormap final_col : color at the other end of the colormap reverse: option if order is reversed
cmap: resulting colormap
-
tropy.plotting_tools.colormaps.
dwd_sfmap
()¶
-
tropy.plotting_tools.colormaps.
enhanced_colormap
(vmin=200.0, vmed=240.0, vmax=300.0)¶
-
tropy.plotting_tools.colormaps.
enhanced_wv62_cmap
(vmin=200.0, vmed1=230.0, vmed2=240.0, vmax=260.0)¶
-
tropy.plotting_tools.colormaps.
nice_cmaps
(cmap_name)¶
tropy.plotting_tools.compare module¶
-
tropy.plotting_tools.compare.
compare
(*args, **kwargs)¶ The function compare can be used to fastly compare several 2d fields.
The coordinates of the x and y axis are needed. An arbitrary number of fields is plotted using the function shaded. Corresponding option keywords can be used.
-
tropy.plotting_tools.compare.
compare_shaded
(x, y, *args, **kwargs)¶ The function compare can be used to fastly compare several 2d fields.
The coordinates of the x and y axis are needed. An arbitrary number of fields is plotted using the function shaded. Corresponding option keywords can be used.
tropy.plotting_tools.histograms module¶
Module for histogram calculations and plotting.
Histogram calculations include * partial normalization to get marginal distributions * conditional averages, standard deviations and percentiles
Histogram plotting is for * conditioned histograms with averages or percentiles
-
tropy.plotting_tools.histograms.
ave_sig_from_hist
(xe, ye, h)¶ Use output from the numpy 2d histogram routine to calculate y-mean and standard deviations along y direction.
Parameters: - xe (np.array) – x-part of histogram grid (edge values)
- ye (np.array) – y-part of histogram grid (edge values)
- h (np.array) – frequency of occurence
Returns: - yave (np.array) – mean of y weigthed by h along y-direction
- ysig (np.array) – standard deviation of y weigthed by h along y-direction
-
tropy.plotting_tools.histograms.
axis_average_from_hist3d
(bins3d, h, axis=0)¶ Calculates the average of a 3-dim histogram along a selected axis.
Parameters: - bins3d (list of 3dim np.array) – mesh of bin edges
- h (np.array) – absolute histogram counts
- axis ({0, 1}, optional) – axis along which the calculations are peformed
Returns: ave – conditional average field
Return type: np.array
-
tropy.plotting_tools.histograms.
conditioned_hist
(h, axis=0)¶ Make conditioned histogram.
Prob per bin (not PDF!!!).
Parameters: h (np.array) – absolute frequency of occurence Returns: “normalized” frequency Return type: np.array
-
tropy.plotting_tools.histograms.
hist2d_scatter
(x, y, bins=200, **kwargs)¶ A 2d histogram is constructed and displayed as scatter plot.
Parameters: - x (np.array) – 1st data vector
- y (np.array) – 2nd data vector
Returns: - hxy (np.array) – frequency of occurence
- xs (np.array) – x-part of histogram grid (edge values)
- ys (np.array) – y-part of histogram grid (edge values)
-
tropy.plotting_tools.histograms.
hist3d
(v1, v2, v3, bins)¶ A wrapper for 3d histogram binning.
It additionally generates the average bin values with the same 3d shape as histogram itself.
Parameters: - v1 (np.array) – 1st data vector
- v2 (np.array) – 2nd data vector
- v3 (np.array) – 3rd data vector
- bins (list of 3 np.arrays) – bins argument passed to the np.histogramdd function
Returns: - bins3d (list of 3dim np.array) – mesh of bin edges
- h (np.array) – absolute histogram counts
-
tropy.plotting_tools.histograms.
max_from_hist
(xe, ye, h)¶ Use output from the numpy 2d histogram routine to calculate y-positions where maximum occurences are located.
Parameters: - xe (np.array) – x-part of histogram grid (edge values)
- ye (np.array) – y-part of histogram grid (edge values)
- h (np.array) – frequency of occurence
Returns: ymax – y-position where h is maximal along y-direction
Return type: np.array
-
tropy.plotting_tools.histograms.
percentiles_from_hist
(xe, ye, h, p=[25, 50, 75], axis=0, sig=0)¶ Use output from the numpy 2d histogram routine to calculate percentiles of the y variable based on relative occurence rates.
Parameters: - xe (np.array) – x-part of histogram grid (edge values)
- ye (np.array) – y-part of histogram grid (edge values)
- h (np.array) – frequency of occurence
- p (list, optional, default = [25, 50, 75]) – list of percentile values to be calculated (in 100th)
- axis ({0, 1}, optional) – axis along which the calculations are peformed
- sig (float, optional, default = 0) –
signa of a Gaussian filter apllied to the histogram in advance
Should be non-negative.
Returns: yperc – list of arrays containing the percentiles
Return type: np.array
-
tropy.plotting_tools.histograms.
plot_cond_hist
(xe, ye, h, ax, axis=0, logscale=True, **kwargs)¶ Plot conditioned histogram (marginal distribution).
Parameters: - xe (np.array) – x-part of histogram grid (edge values)
- ye (np.array) – y-part of histogram grid (edge values)
- h (np.array) – frequency of occurence
- ax (plt.axes instance) – a current axes where the plot is placed in
- axis ({0, 1}, optional) – axis along which the calculations are peformed
- logscale ({True, False}, optional) – if histogram is plotted with logarithmic colorscale
- **kwargs (dict) – further optional keywords passed to plt.pcolormesh
Returns: pcm
Return type: plt.pcolormesh instance
-
tropy.plotting_tools.histograms.
plot_hist_median_and_intervals
(xe, ye, h, ax)¶ Plot histogram with median and IQR. (axis = 1, fixed).
Parameters: - xe (np.array) – x-part of histogram grid (edge values)
- ye (np.array) – y-part of histogram grid (edge values)
- h (np.array) – frequency of occurence
- ax (plt.axes instance) – a current axes where the plot is placed in
Returns: ax – a current axes where the plot is placed in
Return type: plt.axes instance
tropy.plotting_tools.meta2png module¶
Module designed to write an Author Name and the Source Filename into the Meta-Data of an PNG file saved with matplotlib.
-
tropy.plotting_tools.meta2png.
meta2png
(fname, meta)¶ Saves meta data into image file.
Parameters:
tropy.plotting_tools.shaded module¶
A module to make shaded plots.
It contains a function for non-linear colormaps.
-
class
tropy.plotting_tools.shaded.
nlcmap
(cmap, levels)¶ Bases:
matplotlib.colors.LinearSegmentedColormap
A nonlinear colormap class.
Parameters: - cmap (matplotlib.cmap) – a matplotlib colormap, e.g. matplotlib.cm.jet
- levels (list or np.array) – list of values where different colors should appear
Notes
Derived from the matplotlib.colors.LinearSegmentedColormap
Copyright (c) 2006-2007, Robert Hetland <hetland@tamu.edu> Release under MIT license.
-
name
= 'nlcmap'¶
-
tropy.plotting_tools.shaded.
set_levs
(nmax, depth, largest=5, sym=True, sign=True, zmax='None')¶ Makes a non-linear level set based on pre-defined numbers.
Parameters: - nmax (int) – exponent of maximum number
- depth (int) – number of iterations used down to scales of 10**(nmax - depth)
- largest ({5, 8}, optional) – set the largest number in the base array either to 5 or 8
- sym ({True, False}, optional) – switch if levels are symmetric around origin
- sign ({True, False}, optional) – switches sign if negative
- zmax (float, optional, default = 'none') – limiter for levels, |levs| > zmax are not allowed
Returns: levs – set of non-linear levels
Return type: np.array
-
tropy.plotting_tools.shaded.
shaded
(x, y, z, *args, **kwargs)¶ The function shaded is a wrapper for the pylab function contourf.
In addition to contourf, shaded can plot filled contours for which a non-linear colormap is used.
Parameters: - x (np.array) – x-values passed to plt.contourf
- y (np.array) – y-values passed to plt.contourf
- z (np.array) – z-values passed to plt.contourf (color value)
- *args (list) – other positional arguments passed to plt.contourf
- **kwargs (dict) –
other optional arguments passed to plt.contourf
special keywords:
- ’levels’ : numpy array of color / contour levels
- ’lev_depth’ : gives the depth of an automatically generated level set
i.e. an initial base (e.g. [1,2,3,5] ) that contains
the maximum value of the field (e.g. 4.3) is downscaled
by 10**-1, …, 10**-lev_depth.
Example: Given lev_depth = 2, for a positive field with maximum 4.3 a level set [0.01, 0.02, 0.03, 0.05, 0.1, 0.2, 0.3, 0.5, 1, 2, 3, 5] is generated.
Returns: Return type: pl.contourf instance