StationPlotLayout

class metpy.plots.StationPlotLayout[source]

make a layout to encapsulate plotting using StationPlot.

This class keeps a collection of offsets, plot formats, etc. for a parameter based on its name. This then allows a dictionary of data (or any object that allows looking up of arrays based on a name) to be passed to plot() to plot the data all at once.

See also

StationPlot

Methods Summary

add_barb(u_name, v_name[, units]) Add a wind barb to the center of the station layout.
add_symbol(location, name, symbol_mapper, …) Add a symbol to the station layout.
add_text(location, name, **kwargs) Add a text field to the station layout.
add_value(location, name[, fmt, units]) Add a numeric value to the station layout.
clear()
copy()
fromkeys Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
names() Get the list of names used by the layout.
plot(plotter, data_dict) Plot a collection of data using this layout for a station plot.
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
values()

Methods Documentation

add_barb(u_name, v_name, units=None, **kwargs)[source]

Add a wind barb to the center of the station layout.

This specifies that u- and v-component data should be pulled from the data container using the keys u_name and v_name, respectively, and plotted as a wind barb at the center of the station plot. If units are given, both components will be converted to these units.

Additional keyword arguments given will be passed onto the actual plotting code; this is useful for specifying things like color or line width.

Parameters:
  • u_name (str) – The name of the parameter for the u-component for barbs, which is used as a key to pull data out of the data container passed to plot().
  • v_name (str) – The name of the parameter for the v-component for barbs, which is used as a key to pull data out of the data container passed to plot().
  • units (pint-compatible unit, optional) – The units to use for plotting. Data will be converted to this unit before conversion to a string. If not specified, no conversion is done.
  • kwargs – Additional keyword arguments to use for matplotlib’s barbs() function.
add_symbol(location, name, symbol_mapper, **kwargs)[source]

Add a symbol to the station layout.

This specifies that at the offset location, data should be pulled from the data container using the key name and plotted. Data values will converted to glyphs appropriate for MetPy’s symbol font using the callable symbol_mapper.

Additional keyword arguments given will be passed onto the actual plotting code; this is useful for specifying things like color or font properties.

Parameters:
  • location (str or tuple[float, float]) – The offset (relative to center) to plot this value. If str, should be one of ‘C’, ‘N’, ‘NE’, ‘E’, ‘SE’, ‘S’, ‘SW’, ‘W’, or ‘NW’. Otherwise, should be a tuple specifying the number of increments in the x and y directions.
  • name (str) – The name of the parameter, which is used as a key to pull data out of the data container passed to plot().
  • symbol_mapper (callable) – Controls converting data values to unicode code points for the wx_symbol_font font. This should take a value and return a single unicode character. See metpy.plots.wx_symbols for included mappers.
  • kwargs – Additional keyword arguments to use for matplotlib’s plotting functions.
add_text(location, name, **kwargs)[source]

Add a text field to the station layout.

This specifies that at the offset location, data should be pulled from the data container using the key name and plotted directly as text with no conversion applied.

Additional keyword arguments given will be passed onto the actual plotting code; this is useful for specifying things like color or font properties.

Parameters:
  • location (str or tuple(float, float)) – The offset (relative to center) to plot this value. If str, should be one of ‘C’, ‘N’, ‘NE’, ‘E’, ‘SE’, ‘S’, ‘SW’, ‘W’, or ‘NW’. Otherwise, should be a tuple specifying the number of increments in the x and y directions.
  • name (str) – The name of the parameter, which is used as a key to pull data out of the data container passed to plot().
  • kwargs – Additional keyword arguments to use for matplotlib’s plotting functions.
add_value(location, name, fmt='.0f', units=None, **kwargs)[source]

Add a numeric value to the station layout.

This specifies that at the offset location, data should be pulled from the data container using the key name and plotted. The conversion of the data values to a string is controlled by fmt. The units required for plotting can also be passed in using units, which will cause the data to be converted before plotting.

Additional keyword arguments given will be passed onto the actual plotting code; this is useful for specifying things like color or font properties.

Parameters:
  • location (str or tuple[float, float]) – The offset (relative to center) to plot this value. If str, should be one of ‘C’, ‘N’, ‘NE’, ‘E’, ‘SE’, ‘S’, ‘SW’, ‘W’, or ‘NW’. Otherwise, should be a tuple specifying the number of increments in the x and y directions.
  • name (str) – The name of the parameter, which is used as a key to pull data out of the data container passed to plot().
  • fmt (str or callable, optional) – How to format the data as a string for plotting. If a string, it should be compatible with the format() builtin. If a callable, this should take a value and return a string. Defaults to ‘0.f’.
  • units (pint-compatible unit, optional) – The units to use for plotting. Data will be converted to this unit before conversion to a string. If not specified, no conversion is done.
  • kwargs – Additional keyword arguments to use for matplotlib’s plotting functions.
clear() → None. Remove all items from D.
copy() → a shallow copy of D
fromkeys()

Returns a new dict with keys from iterable and values equal to value.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
names()[source]

Get the list of names used by the layout.

Returns:list[str] – the list of names of variables used by the layout
plot(plotter, data_dict)[source]

Plot a collection of data using this layout for a station plot.

This function iterates through the entire specified layout, pulling the fields named in the layout from data_dict and plotting them using plotter as specified in the layout. Fields present in the layout, but not in data_dict, are ignored.

Parameters:
  • plotter (StationPlot) – StationPlot to use to plot the data. This controls the axes, spacing, station locations, etc.
  • data_dict (dict[str, array-like]) – Data container that maps a name to an array of data. Data from this object will be used to fill out the station plot.
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D's values

Examples using metpy.plots.StationPlotLayout