Skip to content

Raise error instead of attempting absurd BarbPlot #2785

@sgdecker

Description

@sgdecker

What should we add?

The following code is a great way to eat through all of your system's memory and then some as Matplotlib attempts to draw trillions of triangles:

import xarray as xr
from metpy.cbook import get_test_data
from metpy.plots import BarbPlot, MapPanel, PanelContainer

data = xr.open_dataset(get_test_data('narr_example.nc')).squeeze()

bp = BarbPlot()
bp.data = data
bp.field = ['u_wind', 'v_wind']
bp.level = 500
bp.scale = 1e14

mp = MapPanel()
mp.layout = (1, 1, 1)
mp.layers = ['coastline', 'borders', 'states']
mp.plots = [bp]

pc = PanelContainer()
pc.size = (10, 8)
pc.panels = [mp]
pc.show()

(This report is inspired by true events.)

My feature request is that the declarative interface raise an error when the magnitudes are so high that the number of pennants drawn would exceed some reasonable threshold, rather than attempt to create the plot and hang the computer.

Reference

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: PlotsPertains to producing plotsType: EnhancementEnhancement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions