[ncl-talk] solution for drawing a polyline (trajectory) with different colors for each line segment (e.g., without using loop) to avoid very slow script?

Rick Brownrigg brownrig at ucar.edu
Mon Feb 8 13:42:10 MST 2021


Hi Andries,

I don't see anything that should cause the loop to run progressively
slower, and that puzzles me.  Are you able to send your data and actual
script (not the test script)?  You can send directly to me if you prefer.

Rick


On Mon, Feb 8, 2021 at 10:09 AM De Vries Andries via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear NCL team and NCL users,
>
>
> Currently I use NCL to plot air parcel trajectories using the function
> gsn_add_polyline on a latlon map. For these polylines I would like to
> assign different colors to each line segment, for example defined by
> pressure. I have a script that works, it is practically the same as the
> example 2 under the link https://www.ncl.ucar.edu/Applications/traj.shtml,
> whereby the script loops over each pair of points, retrieves the right
> color, and then plots each individual line segment. In my application I
> have a huge set of trajectories each consisting of many segments (~72 per
> trajectory). It takes extremely long for NCL to complete the plot; in the
> beginning the script will run fast, but it gets slower and slower as the
> script proceeds over the number trajectories.
>
>
> What solutions do I have to make the script faster?
>
>
> I tried a few things, for example, plotting the polylines using arrays in
> stead of loops, and retrieving colors as arrays. That works, but then
> plotting the lines using an array of different colors fails.
>
>
> In the attached script I send an example as well as the resulting plot and
> colorbar I used;
>
> 1) the working script with the loop over each line segment that works, but
> is in reality very slow (map1(0))
>
> 2) an attempt with retrieving the colors based on an array with Pressure,
> which works, but then using the 2-D color array assigned to the plotting
> resource (r2) fails (map1(1))
>
> 3) an attempt with named colors (in 1-D array), which also fails as only
> the first named color is used for all segments. (map1(2))
>
>
> Any solutions that avoid using the loop, or make the script faster, are
> most welcome!!
>
>
> Thank you so much!
>
>
> Best,
>
> Andries
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210208/63101107/attachment.html>


More information about the ncl-talk mailing list