Message Boards Message Boards

Calling ListVectorPlot causes kernel to crash, Mathematica 10.3

Posted 9 years ago

Hi all,

I am attempting to make a simple vector plot of wind speed and direction in the Illinois area using the following code:

data = {WeatherData[#, "Coordinates"],
     First[
       WeatherData[#, 
        "WindSpeed"]]*{-Sin[WeatherData[#, "WindDirection"]], -Cos[
         WeatherData[#, "WindDirection"]]}} & /@ {"KSPI", "KORD", 
    "KMDW", "KCMI", "KBMI"};

ListVectorPlot[data]

Approximately every other time I execute the ListVectorPlot command, the kernel will crash for no apparent reason. This even occurs when I put the data=... and ListVectorPlot commands in separate input cells, and re-run only the ListVectorPlot command (i.e., the data was not changed between successful and crashing calls of ListVectorPlot. Has anyone else seen this behavior, and/or is there a way to modify my code so that it does not happen? I am running Mathematica version 10.3 on Windows 10.

POSTED BY: Mark Lanari

I'm not sure if there's a simple way to prevent the issue. I would do this by basically reconstructing the ListVectorPlot Function from VectorPlot. To make it easy, I'll just make an Interpolation of the x and y values for the vectors separately:

(* Munging the data into a form acceptable by Interpolation *)
xvals = ReplaceAll[data, {position_, {xval_, yval_}} :> {position, xval}];
yvals = ReplaceAll[ data, {position_, {xval_, yval_}} :> {position, yval}];

(* Create Interpolations of the data *)
xfunc = Interpolation[xvals, InterpolationOrder -> 1];
yfunc = Interpolation[yvals, InterpolationOrder -> 1];

(* These interpolations can be used with VectorPlot *)
VectorPlot[{xfunc[x, y], yfunc[x, y]}, {x, 39, 42}, {y, -89, -87}]

You have to specify the range over which you want VectorPlot to plot. In this case, the range is a bit out of the bounds of the Interpolation, so there are some error messages. We can also get the actual Min/Max values in the dataset and use these.

{xmin, xmax} = MinMax@data[[All, 1, 1]];
{ymin, ymax} = MinMax@data[[All, 1, 2]];

VectorPlot[{xfunc[x, y], yfunc[x, y]}, {x, xmin, xmax}, {y, ymin, ymax}]

Thank you for taking the time to report this issue. I've forwarded the example to the developers so that they can take a closer look at the issue.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract