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

__init__(*args, **kwargs)

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()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

Return a set-like object providing a view on the dict's items.

keys()

Return a set-like object providing a view on the dict's 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 the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E.keys(): 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()

Return an object providing a view on the dict's values.

Methods Documentation

__init__(*args, **kwargs)#
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.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 be 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 metpy.plots.wx_symbols.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.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()#

Remove all items from the dict.

copy()#

Return a shallow copy of the dict.

fromkeys(value=None, /)#

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)#

Return the value for key if key is in the dictionary, else default.

items()#

Return a set-like object providing a view on the dict’s items.

keys()#

Return a set-like object providing a view on the dict’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 the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()#

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)#

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from mapping/iterable E and F.#

If E is present and has a .keys() method, then does: for k in E.keys(): 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()#

Return an object providing a view on the dict’s values.

Examples using metpy.plots.StationPlotLayout#

Station Plot with Layout

Station Plot with Layout