PlotInterface package

Submodules

PlotInterface.AutoPlotHazard module

AutoPlotHazard – Plot hazard maps and curves

Automatically plots hazard maps for each return period and hazard return curves for each locality within the domain. Adapted from compareGrids.py code and plotHazardCurves.py developed by Craig Arthur.

class AutoPlotHazard(configFile, progressbar=None)

Bases: object

getLocations()

Extract locations from the localities database

Returns

Names, ID, latitude and longitude of all locations within the model domain, plus the locations rec array

loadFile(inputFile, varname)

Load a variable from a netcdf file and return data as a masked array

Parameters
  • inputFile (str) – path to a netcdf file containing hazard data.

  • varname (str) – name of the netcdf variable to plot.

Returns

lon, lat, years and data (as a masked array)

plotCurves()

Plot hazard curves for speified locations

plotHazardCurves(inputFile, plotPath)

Plot the hazard values stored in hazardFile, at the stns stored in stnFile.

plotMap()

Plot return period wind speed maps

class PlotUnits(units)

Bases: object

PlotInterface.curves module

curves – plot curve figures

The routines here make use of the themes from seaborn to define the line styles and annotations (font sizes, etc.).

class CurveFigure

Bases: matplotlib.figure.Figure

Base class for plotting line figures.

add(xdata, ydata, xlabel='x', ylabel='y', title='x')

Add a new subplot to the list of subplots to be created.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • ydata (numpy.ndarray) – y values of the data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

addGrid(axes)

Add a graticule to the subplot axes. The x-axis is autoscaled, the grid is a dotted black line, linewidth 0.2.

Parameters

axesaxes instance.

addRange(axes, xdata, ymin, ymax)

Add a shaded range of values to the plot.

Parameters
  • axesmatplotlib.axes instance.

  • xdata (numpy.ndarray) – x-data values.

  • ymin (numpy.ndarray) – Lower range of y values.

  • ymax (numpy.ndarray) – Upper range of y values.

plot()

Plot the subfigures.

For a number of subplots, they are organised into an approximately square arrangement.

subplot(axes, subfigure)

Draw a line plot on an matplotlib.axes instance. The data and labels are contained in a tuple. The basic plot is a black line plot, with the x-ticks presented as integer values. A grid is added with a call to RangeFigure.addGrid().

Parameters
  • axesmatplotlib.axes instance.

  • subfigure (tuple) – Holds the data and labels to be added to the subplot.

class DistributionCurve

Bases: PlotInterface.curves.RangeCompareCurve

plot(x, y1, y2, y2max, y2min, xlabel, ylabel, title)

Plot a distribution curve, which compares two curves, plus an upper/lower confidence range.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • y1 (numpy.ndarray) – y values of the primary data points.

  • y2 (numpy.ndarray) – y values of the secondary data points.

  • ymax (numpy.ndarray) – y values of the upper range data points.

  • ymin (numpy.ndarray) – y values of the lower range data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

class HazardCurve

Bases: PlotInterface.curves.SemilogRangeCurve

plot(years, wspd, wspdupper, wspdlower, xlabel, ylabel, title)

Plot a hazard curve, including upper and lower conffidence range estimates. This uses the SemilogRangeCurve() method for plotting the curve on a semilog x-axis. :param years: Return period years to plot. :param wspd: Return period wind speed values. :param wspdupper: Upper confidence range wind speed values. :param wspdlower: Lower confidence range wind speed values. :type years: numpy.ndarray :type wspd: numpy.ndarray :type wspdupper: numpy.ndarray :type wspdlower: numpy.ndarray :param str xlabel: x-axis label. :param str ylabel: y-axis label. :param str title: Plot title.

class HazardScatterCurve

Bases: PlotInterface.curves.SemilogRangeScatterCurve

plot(years, events, wspd, wspdupper, wspdlower, xlabel, ylabel, title, fit)

Plot a hazard curve, including upper and lower conffidence range estimates. This uses the SemilogRangeCurve() method for plotting the curve on a semilog x-axis.

Parameters
  • years (numpy.ndarray) – Return period years to plot.

  • eventsnumpy.ndarray

  • wspd (numpy.ndarray) – Return period wind speed values.

  • wspdupper (numpy.ndarray) – Upper confidence range wind speed values.

  • wspdlower (numpy.ndarray) – Lower confidence range wind speed values.

  • xlabel (str) – x-axis label.

  • ylabel (str) – y-axis label.

  • title (str) – Plot title.

  • fit (str) – Label for the legend containing the EVD fit type

class RangeCompareCurve

Bases: PlotInterface.curves.CurveFigure

A line plot, with additional range (e.g. confidence interval) and a second line for comparison. e.g. if you have model output (with an upper and lower estimate) and an observed value to compare against.

add(xdata, y1, y2, y2max, y2min, xlabel='x', ylabel='y', title='x')

Add a new subplot to the list of subplots to be created.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • y1 (numpy.ndarray) – y values of the primary data points.

  • y2 (numpy.ndarray) – y values of the secondary data points.

  • ymax (numpy.ndarray) – y values of the upper range data points.

  • ymin (numpy.ndarray) – y values of the lower range data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

subplot(axes, subfigure)

Draw a line plot on an matplotlib.axes instance. The data and labels are contained in a tuple. This will plot two lines and a grey range (for displaying uncertainty). A grid is added with a call to RangeFigure.addGrid().

Parameters
  • axesmatplotlib.axes instance.

  • subfigure (tuple) – Holds the data and labels to be added to the subplot.

class RangeCurve

Bases: PlotInterface.curves.CurveFigure

A line plot, with additional range (e.g. confidence interval)

add(xdata, ymean, ymax, ymin, xlabel='x', ylabel='y', title='x')

Add a new subplot to the list of subplots to be created.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • ymean (numpy.ndarray) – y values of the data points.

  • ymax (numpy.ndarray) – y values of the upper range data points.

  • ymin (numpy.ndarray) – y values of the lower range data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

subplot(axes, subfigure)

Draw a line plot on an matplotlib.axes instance. The data and labels are contained in a tuple. This will plot a line plot and a grey range (for displaying uncertainty). A grid is added with a call to RangeFigure.addGrid().

Parameters
  • axesmatplotlib.axes instance.

  • subfigure (tuple) – Holds the data and labels to be added to the subplot.

class SemilogCurve

Bases: PlotInterface.curves.CurveFigure

Extend the basic CurveFigure to use a logarithmic scale on the x-axis.

addGrid(axes)

Add a logarithmic graticule to the subplot axes.

Parameters

axesaxes instance.

subplot(axes, subfigure)

Draw a line plot on an matplotlib.axes instance, with a logarithmic scale on the x-axis. Data and labels are contained in a tuple. x-ticks presented as integer values. A grid is added with a call to RangeFigure.addGrid().

Parameters
  • axesmatplotlib.axes instance.

  • subfigure (tuple) – Holds the data and labels to be added to the subplot.

class SemilogRangeCompareCurve

Bases: PlotInterface.curves.SemilogCurve

A line plot on a semilog-x plot with additional range (e.g. confidence interval) and a second line for comparison. e.g. if you have model output (with an upper and lower estimate) and an observed value to compare against.

add(xdata, y1, y2, y2max, y2min, xlabel='x', ylabel='y', title='x')

Add a new subplot to the list of subplots to be created.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • y1 (numpy.ndarray) – y values of the primary data points.

  • y2 (numpy.ndarray) – y values of the secondary data points.

  • ymax (numpy.ndarray) – y values of the upper range data points.

  • ymin (numpy.ndarray) – y values of the lower range data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

subplot(axes, subfigure)

Draw a range-compare plot on an matplotlib.axes instance, with a logarithmic scale on the x-axis. Data and labels are contained in a tuple. x-ticks presented as integer values. A grid is added with a call to RangeFigure.addGrid().

Parameters
  • axesmatplotlib.axes instance.

  • subfigure (tuple) – Holds the data and labels to be added to the subplot.

class SemilogRangeCurve

Bases: PlotInterface.curves.SemilogCurve

A line plot on a semilog-x plot with additional range (e.g. confidence interval).

add(xdata, ymean, ymax, ymin, xlabel, ylabel, title)

Add a new subplot to the list of subplots to be created.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • ymean (numpy.ndarray) – y values of the data points.

  • ymax (numpy.ndarray) – y values of the upper range data points.

  • ymin (numpy.ndarray) – y values of the lower range data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

subplot(axes, subfigure)

Draw a line and range plot on an matplotlib.axes instance, with a logarithmic scale on the x-axis. Data and labels are contained in a tuple. x-ticks presented as integer values. A grid is added with a call to SemilogCurve.addGrid().

Parameters
  • axesmatplotlib.axes instance.

  • subfigure (tuple) – Holds the data and labels to be added to the subplot.

class SemilogRangeScatterCurve

Bases: PlotInterface.curves.SemilogCurve

A line plot on a semilog-x plot with additional range (e.g. confidence interval).

add(xdata, events, ymean, ymax, ymin, xlabel, ylabel, title, fit)

Add a new subplot to the list of subplots to be created.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • ymean (numpy.ndarray) – y values of the data points.

  • ymax (numpy.ndarray) – y values of the upper range data points.

  • ymin (numpy.ndarray) – y values of the lower range data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

empReturnPeriod(data, npyr=365.25)

Returns the empirically-based recurrence interval (in years) for a set of observations. It is assumed the data are daily observations. If the observations are not daily, there are two options: set the npyr variable, or backfill the data variable with zero values to match the assumed length of the record. The highest return period should be (approximately) len(data)/npyr. :param data: numpy.ndarray containing the observed values (with

missing values removed).

Parameters

npy (float) – Number of observations per year (default=365.25)

Returns

Recurrence intervals for the observed data.

Return type

numpy.ndarray

subplot(axes, subfigure)

Draw a line and range plot on an matplotlib.axes instance, with a logarithmic scale on the x-axis. Data and labels are contained in a tuple. x-ticks presented as integer values. A grid is added with a call to SemilogCurve.addGrid().

Parameters
  • axesmatplotlib.axes instance.

  • subfigure (tuple) – Holds the data and labels to be added to the subplot.

saveDistributionCurve(x, y1, y2, y2max, y2min, xlabel, ylabel, title, filename)

Plot and save a distribution curve, which compares two curves, plus an upper/lower confidence range.

Parameters
  • xdata (numpy.ndarray) – x values of the data points.

  • y1 (numpy.ndarray) – y values of the primary data points.

  • y2 (numpy.ndarray) – y values of the secondary data points.

  • ymax (numpy.ndarray) – y values of the upper range data points.

  • ymin (numpy.ndarray) – y values of the lower range data points.

  • xlabel (str) – Label for the x-axis

  • ylabel (str) – Label for the y-axis

  • title (str) – Plot title

  • filename (str) – Path to save the figure to

saveFigure(figure, filename)

Save a figure canvas to file.

Parameters
  • figureFigure instance.

  • filename (str) – Path to the location to store the image.

saveHazardCurve(years, events, wspd, wspdupper, wspdlower, xlabel, ylabel, title, filename, fit)

Plot a hazard curve, including upper and lower conffidence range estimates. This uses the SemilogRangeCurve() method for plotting the curve on a semilog x-axis.

Parameters
  • years (numpy.ndarray) – Return period years to plot.

  • eventsnumpy.ndarray

  • wspd (numpy.ndarray) – Return period wind speed values.

  • wspdupper (numpy.ndarray) – Upper confidence range wind speed values.

  • wspdlower (numpy.ndarray) – Lower confidence range wind speed values.

  • xlabel (str) – x-axis label.

  • ylabel (str) – y-axis label.

  • title (str) – Plot title.

  • filename (str) – Path to save teh figure to.

  • fit (str) – Label for the legend containing the EVD fit type

PlotInterface.figures module

figures – basic figure elements

class BearingFigure

Bases: PlotInterface.figures.LaggedRegressionFigure

Plot TC bearing data.

plot(bearings, bearingRates)
class FrequencyFigure

Bases: PlotInterface.figures.LineRegressionFigure

Plot TC frequency data

plot(years, frequency)
class LaggedRegressionFigure

Bases: PlotInterface.figures.RegressionFigure

Generate a regression figure, where the data is regressed using a lag-1 regression (i.e. data at time _t_ compared to data at time _t-1_).

add(data, label='x', title='x', transform=<function LaggedRegressionFigure.<lambda>>)
subplot(axes, subfigure)
class LineRegressionFigure

Bases: PlotInterface.figures.RegressionFigure

Generate a regression plot that includes a fitted regression line.

add(x, y, xlabel='x', ylabel='y', title='x')
subplot(axes, subfigure)
class PressureFigure

Bases: PlotInterface.figures.LaggedRegressionFigure

Plot central pressure/rate data

plot(pressures, pressureRates)
class QuantileFigure

Bases: matplotlib.figure.Figure

Create a quantile-quantile plot that includes estimated confidence intervals for the simulated (or second) dataset.

add(xdata, ydata, axisrange, xlabel='x', ylabel='y', title='Q-Q plot')

Add a subplot to the collection

addGrid(axes)

Add a grid to the subplot axes.

Parameters

axesmatplotlib.axes instance

formatAxes(axes, limits)

Format the axes to have the same limits

percentilerange(data)

Calculate a range of percentile values

percentiles(data)

Calculate percentile values from 1 to 100

plot()
subplot(axes, subfigure)
class RegressionFigure

Bases: matplotlib.figure.Figure

Basic regression figure

add(xdata, ydata, xlabel='x', ylabel='y', title='x', transform=<function RegressionFigure.<lambda>>)
formatAxes(axes, xdata, ydata)
plot()
prepareData(xdata, ydata, transform)
subplot(axes, subfigure)
class ScatterHistogramFigure

Bases: matplotlib.figure.Figure

Generate a scatter plot with histograms on the top/right margins for the two components (see seaborn.jointplot).

plot(xdata, ydata, **kwargs)

Generate a plot using the given data arrays. Additional kwargs are passed directly to seaborn.jointplot

Parameters
  • xdatanumpy.ndarray of data for x values.

  • ydatanumpy.ndarray of data for y values.

  • **kwargs

    Additional keyword args.

class SpeedFigure

Bases: PlotInterface.figures.LaggedRegressionFigure

Plot TC speed data.

plot(speeds, speedRates)
class WindProfileFigure(lat, lon, eP, cP, rMax, beta, beta1=1.5, beta2=1.4)

Bases: matplotlib.figure.Figure, object

Generate a plot of all available wind profiles.

plot(profileType=None)

Execute the plot.

Parameters

profileType (str) – Name of the radial profile to plot. If None, all available profiles are plotted.

main()
saveBearingFigure(bearings, bearingRates)

Generate and save a plot of TC bearing and bearing rates with lag-1 autoregression.

Parameters
  • bearingsnumpy.ndarray of bearing values.

  • bearingRatesnumpy.ndarray of bearing rate values.

  • filename (str) – Path to save the figure to.

saveFigure(figure, filename)

Save a matplotlib.figure instance to file.

Parameters
  • figurematplotlib.figure instance.

  • filename (str) – Path to save the figure to.

saveFrequencyFigure(years, frequency, filename='docs/freq_corr.png')

Plot and save annual frequency figure.

Parameters
  • yearsnumpy.ndarray of the years of data.

  • frequencynumpy.ndarray of the annual frequency of TCs.

  • filename (str) – Path to save the figure to.

savePressureFigure(pressures, pressureRates, filename='docs/prs_corr.png')

Generate and save a plot of pressure and pressure rates with lag-1 autoregression.

Parameters
  • pressuresnumpy.ndarray of pressure values.

  • pressureRatesnumpy.ndarray of pressure rate values.

  • filename (str) – Path to save the figure to.

saveSpeedFigures(speeds, speedRates)

Generate and save a plot of TC speed and speed rates with lag-1 autoregression.

Parameters
  • speedsnumpy.ndarray of speed values.

  • speedRatesnumpy.ndarray of speed rate values.

  • filename (str) – Path to save the figure to.

saveWindProfilesFigure(lat, lon, eP, cP, rMax, beta, filename='docs/windprofiles.png')

Generate a plot of the available wind profiles and save to file.

Parameters
  • lat (float) – Sample latitude for the example profiles.

  • lon (float) – Sample longitude for the example profiles.

  • eP (float) – Environmental pressure for the example profiles (Pa).

  • cP (float) – Central pressure for the example profiles (Pa).

  • rMax (float) – Radius to maximum wind for the example profiles (km).

  • beta (float) – Holland beta parameter for the example profiles.

  • filename (str) – Path to save the figure to.

PlotInterface.maps module

maps – base class for generating maps

Note: Many of the defaults (e.g. coastline colours, font sizes for

the graticule) are set up for GA’s style. These can be overridden in this base class if users want a different style for their output.

class ArrayMap

Bases: PlotInterface.maps.ArrayMapFigure

Plot a gridded array of values over a map

plot(data, xgrid, ygrid, title, datarange, cbarlab, map_kwargs)

Plot all subfigures onto a figure in a (roughly) square arrangement.

class ArrayMapFigure

Bases: PlotInterface.maps.MapFigure

Array plot

add(data, xgrid, ygrid, title, datarange, cbarlab, map_kwargs)

Add a new subfigure to the collection of subfigures to be plotted.

Parameters
  • datanumpy.ndarray of the data to be plotted.

  • xgridnumpy.ndarray representing the points on the x-axis. For gridded arrays of data, xgrid must have the same shape as data.

  • ygridnumpy.ndarray representing the points on the y-axis. For gridded arrays of data, ygrid must have the same shape as data.

  • title (str) – Subfigure title

  • lvlsnumpy.ndarray of levels used for plotting contours.

  • cbarlabel (str) – Label for the colorbar (if one is to be added).

  • map_kwargs (dict) – dict of keyword arguments used for setting up the GeoAxes instance.

subplot(axes, subfigure)

Generate the subplot on the figure.

Parameters
  • axesmatplotlib.axes instance where the plot will be added.

  • subfigure (tuple) – A tuple that holds all the required elements of the plot, including the data, x- and y-grids, title, data range, colorbar label and map keyword arguments.

class FilledContourMapFigure

Bases: PlotInterface.maps.MapFigure

A filled contour map figure.

Useful for plotting continuous values across a spatial domain.

add(data, xgrid, ygrid, title, lvls, cbarlab, map_kwargs)

Add a filled contour subfigure to the list of subfigures to be plotted.

Parameters
  • datanumpy.ndarray of (continuous) values to be plotted.

  • xgridnumpy.ndarray of x-coordinates of the data points.

  • ygridnumpy.ndarray of y-coordinates of the data points.

  • title (str) – Title to put on the subfigure.

  • lvlsnumpy.ndarra or list of values that define the contour levels to use.

  • cbarlab (str) – Label for the color bar.

  • map_kwargs (dict) – A dict containing keyword arguments for setting up the GeoAxes instance.

subplot(axes, subfigure)

Generate the subplot on the figure.

Parameters
  • axesmatplotlib.axes instance where the plot will be added.

  • subfigure (tuple) – A tuple that holds all the required elements of the plot, including the data, x- and y-grids, title, contour levels, colorbar label and map keyword arguments.

class HazardMap

Bases: PlotInterface.maps.FilledContourMapFigure

A map for presenting return level data.

plot(data, xgrid, ygrid, title, lvls, cbarlab, map_kwargs)

Plot all subfigures onto a figure in a (roughly) square arrangement.

class MapFigure

Bases: matplotlib.figure.Figure

A base class for all map figures. Implements methods to annotate maps in a consistent fashion.

add(data, xgrid, ygrid, title, lvls, cbarlab, map_kwargs)

Add a new subfigure to the collection of subfigures to be plotted.

Parameters
  • datanumpy.ndarray of the data to be plotted.

  • xgridnumpy.ndarray representing the points on the x-axis. For gridded arrays of data, xgrid must have the same shape as data.

  • ygridnumpy.ndarray representing the points on the y-axis. For gridded arrays of data, ygrid must have the same shape as data.

  • title (str) – Subfigure title

  • lvlsnumpy.ndarray of levels used for plotting contours.

  • cbarlabel (str) – Label for the colorbar (if one is to be added).

  • map_kwargs (dict) – dict of keyword arguments used for setting up the GeoAxes instance.

addCoastline(mapobj)

Draw coastlines and a map background to the current GeoAxes instance.

Parameters

mapobj – Current GeoAxes instance to add coastlines to.

addGraticule(axes, mapobj)

Add a graticule to the map instance (tick marks and lines for parallels and meridians). Grid spacing is automatically determined from the maximum span of either longitude or latitude.

Parameters
  • axes – Current matplotlib.Axes instance being worked on.

  • mapobj – Current GeoAxes instance to annotate.

addMapScale(mapobj)

Add a map scale to the curent Basemap instance. This automatically determines a ‘nice’ length forthe scale bar - chosen to be approximately 20% of the map width at the centre of the map.

Parameters

mapobj – Current Basemap instance to add the scale bar to.

createMap(axes, xgrid, ygrid, map_kwargs)

Configure the map extent

fillContinents(mapobj, fillcolor='#FFDAB5')

Fill continents with a base color in the current GeoAxes instance.

Parameters

mapobj – Current GeoAxes instance to color fill the

continents on.

labelAxes(axes, xlabel='Longitude', ylabel='Latitude')

Add labels to the x- and y-axis on the current matplotlib.Axes instance.

Parameters
  • axes – Current matplotlib.Axes instance to annotate.

  • xlabel (str) – Label for the x-axis. Defaults to ‘Longitude’.

  • ylabel (str) – Label for the y-axis. Defaults to ‘Latitude’.

maskOceans(mapobj, fillcolor='#66ccff')

Mask oceans with a blue background in the current GeoAxes instance.

Parameters
  • mapobj – Current GeoAxes instance to colour fill the oceans

  • fillcolor – Optional colour to use (default #66CCFF)

plot()

Plot all subfigures onto a figure in a (roughly) square arrangement.

save(filename)

Save the figure to file.

Parameters

filename (str) – Full path (incl. extension) to save the figure to.

subplot(axes, subfigure)

Add a new subplot to the current figure.

Parameters
  • axesmatplotlib.Axes instance that will be used for the subplot. Usually created by a call to self.add_subplot()

  • subfigure (tuple) – A tuple containing the data, x- and y-grid, title, levels, colorbar label and a map_kwargs dict.

class MaskedArrayMapFigure

Bases: PlotInterface.maps.ArrayMapFigure

Array plot with ocean areas masked

subplot(axes, subfigure)

Generate the subplot on the figure.

Parameters
  • axesmatplotlib.axes instance where the plot will be added.

  • subfigure (tuple) – A tuple that holds all the required elements of the plot, including the data, x- and y-grids, title, data range, colorbar label and map keyword arguments.

class MaskedContourMapFigure

Bases: PlotInterface.maps.FilledContourMapFigure

Create a filled contour plot with ocean areas masked.

subplot(axes, subfigure)

Generate the subplot on the figure.

Parameters
  • axesmatplotlib.axes instance where the plot will be added.

  • subfigure (tuple) – A tuple that holds all the required elements of the plot, including the data, x- and y-grids, title, contour levels, colorbar label and map keyword arguments.

class WindfieldMap

Bases: PlotInterface.maps.FilledContourMapFigure

Plot a wind field using filled contours. Only presents the magnitude of the wind field, not the direction.

plot(data, xgrid, ygrid, title, lvls, cbarlab, map_kwargs)

Plot all subfigures onto a figure in a (roughly) square arrangement.

demo()

Perform a basic demonstration of the plotting routines.

levels(maxval, minval=0)

Calculate a nice number of levels between minval and maxval for plotting contour intervals.

Parameters
  • maxval (float) – Maximum value in the field to be plotted.

  • minval (float) – Minimum value in the field to be plotted.

Returns

Array of levels and the exponential by which the values are scaled

Return type

tuple

Raises

ValueError if the minimum and maximum values are equal.

saveFigure(figure, filename)

Save a MapFigure instance to file.

Parameters
  • figureMapFigure instance.

  • filename (str) – Path (including extension) to save the figure to.

saveHazardMap(data, xgrid, ygrid, title, lvls, cbarlab, map_kwargs, filename)

Plot and save a hazard map.

saveWindfieldMap(data, xgrid, ygrid, title, lvls, cbarlab, map_kwargs, filename)

Plot and save a map of wind speeds as a filled contour map.

selectColormap(data_range, percent=0.1)

Determine whether to use a sequential or diverging color map, based on the defined data range to be used for the plot. Note the diverging color map only works when the data range spans zero (and it won’t automatically put the neutral colour at zero).

Red to green colour palette using recommendations from ISO22324 (2015). Unsaturated colour palette: [(0.486, 0.722, 0.573), (0.447, 0.843, 0.714), (0.875, 0.882, 0.443), (0.969, 0.906, 0.514), (0.933, 0.729, 0.416), (0.906, 0.522, 0.373), (0.937, 0.522, 0.616)]

Parameters
  • data_range – array-like containing either the minimum and maximum levels of the data range, or the array of levels (e.g. for contour maps).

  • percent (float) – Threshold for switching from diverging to sequential colormap

Returns

A matplotlib.colors.LinearSegmentedColormap instance used for setting the Figure.cmap attribute.

Raises

TypeError for non-numeric input, or if the data_range is not array-like.

PlotInterface.plotStats module

plotStats – statistical plotting routines

class PlotBearing(output_path, output_format, context='poster')

Bases: PlotInterface.plotStats.PlotData

plotBearing(data)
plotBearingRate(data)
class PlotData(output_path, output_format, context='poster')

Bases: object

Base class for plotting summaries of input data.

barPlot(xdata, ydata, name, labels)

Bar plot, with added trend line or mean line

Parameters
  • xnumpy.ndarray of x-values.

  • ynumpy.ndarray of y-values.

  • name (str) – Name of the parameter, which will be used in the filename.

  • labels (list) – A list of the x- and y-axis labels to apply.

figurenum()

Increment the figure number and return the new value

minPressureHist(index, pAllData)

Plot a histogram of the minimum central pressures from the input dataset.

plotRegression(xdata, name, labels, transform=<function PlotData.<lambda>>)

A generic function to plot a lag-1 autoregression of the variable, with a joint probability plot including marginal distribution plots.

Parameters
  • xnumpy.ndarray of the data variable to plot.

  • name (str) – Name of the variable. Used for saving the resulting image.

  • labels (list) – A list of the x- and y-axis labels to apply.

  • transform (func) – A transform function to apply to the data. Default is to leave the data unchanged.

plotSpeedBear(sAllData, bAllData)

Plot speed and bearing against each other

quantile(data, parameterName, dist='norm')

Generate a probability plot of the given data; data should be an array of anomalies

savefig(filename, **kwargs)

Provide a shortcut to plt.savefig() that adds the output path to the filename. All keyword args are passed without alteration

scatterHistogram(xdata, ydata, labels, name, transform=<function PlotData.<lambda>>, **kwargs)

Create a scatter plot with marginal distributions

Parameters
  • xnumpy.ndarray of x values.

  • ynumpy.ndarray of y values.

  • labels (list) – A length-2 list with the x and y labels as strings.

  • name (str) – Name to use in the file name for saving the figure.

  • transform (func) – A function to transform the data.

  • kwargs – Additional keyword arguments passed to seaborn.jointplot.

class PlotDays(output_path, output_format, context='poster')

Bases: PlotInterface.plotStats.PlotData

plotJulianDays(julianDayObs, julianDayGenesis)

Plot bar graphs of the number of TC observations per day of year and genesis events per day of year.

TODO: Format the tick marks to represent monthly intervals.

Add a KDE over both bar plots, remembering this is cyclic data (so KDE[-1] ~ KDE[0]).

class PlotFrequency(output_path, output_format, context='poster')

Bases: PlotInterface.plotStats.PlotData

plotFrequency(years, frequency)

Plot annual count of events within the domain.

TODO: Automatically adjust the x-tickmarks to be spaced

nicely (i.e. no overlap of labels). Offer option of drawing the mean value (using axes.axhline) or a linear trend line.

class PlotLonLat(output_path, output_format, context='poster')

Bases: PlotInterface.plotStats.PlotData

plotLonLat(lonData, latData, indicator)
class PlotPressure(output_path, output_format, context='poster')

Bases: PlotInterface.plotStats.PlotData

plotMinPressure(index, pAllData)

Plot the distribution of minimum central pressure, and include a fitted distribution (presently uses the scipy.stats.frechet_l distribution).

Parameters
  • indexnumpy.ndarray of 1/0 that indicates the start of separate TC tracks.

  • pAllDatanumpy.ndarray of pressure observations from TC events.

plotPressure(data)
plotPressureRate(data)
class PlotSpeed(output_path, output_format, context='poster')

Bases: PlotInterface.plotStats.PlotData

plotSpeed(data)
plotSpeedRate(data)
linreg(data)

Calculate the linear regression of the data against itself (lag-1) Returns the slope, intercept, correlation, two-tailed probability and standard error of the estimate.

PlotInterface.plotTimeseries module

plotTimeseries – plot timeseries data generated by TCRM

Load timeseries data generated by TCRM and plot the wind speed, component wind speeds and bearing.

loadTimeseriesData(datafile)
plotTimeseries(inputPath, outputPath, locID=None)

Load the data and pass it to the TimeSeriesFigure.plot() method.

Parameters
  • inputPath (str) – Path to the raw timeseries data.

  • outputPath (str) – Path to the location that images should be stored in.

  • locID (str) – Unique identifier for a chosen location. If not given, all files in the input path will be processed.

Example: plotTimeseries(‘/tcrm/output/timeseries’,’/tcrm/output/plots’)

PlotInterface.plotTracks module

PlotInterface.plotWindfield module

PlotInterface.timeseries module

class TimeSeriesFigure

Bases: matplotlib.figure.Figure

Base class for plotting time series data

add(dt, ydata, yrange, ylabel, title)
addGrid(axes)
addLegend(axes)
addTitle(title)
formatXticks(axes)
make_patch_spines_invisible(axes)
ooplot()
plot()
subplot(axes, subfigure, color)
subplot_twinx(axes, subfigure, color, position)
saveFigure(figure, filename)

Module contents