Message Boards Message Boards

1
|
11971 Views
|
3 Replies
|
7 Total Likes
View groups...
Share
Share this post:

How do I improve the rendering speed of this ListPlot?

Posted 11 years ago
Hello,

I have a workbook calculating angles between satellites.  Its pretty simple; some functions, some linear algebra.  It should be perfect for Mathematica.

The entire set of calculations executes really fast.  But, when I try to pull the data out of an array to try to plot it, the computer spends ~18 hours to plot 2500 points, without finishing.  I aborted the execution and came here.

Its not a memory problem, the memory usage stays fine.  And again, the calculation cells complete quickly.  Its just the indexing and assembling data for the ListPlot function that is insanely slow.  Somehow, I must be asking Mathematica to run though a LinkedList type structure, and I'm getting some huge O(N!) behavior, or something.  But, it doesn't make sense!  Indexing should simple!

Please tell me how to get Mathematcia to ListPlot the xPlot and yPlot variables in the linked workbook, [1].  I really like the way I am able to describe the operations to Mathematica.  I am in fact using Mathematica to check some MATLAB I wrote.  MATLAB runs fast, and has no problems with indexing, but the MATLAB code isn't as easy to look at  and I think there may be a mistake in it.  Mathematica is beautiful, and has no loops, preallocation, or 'programming' structure to trip over (just a unique syntax), but seems very ill suited to even a moderate amount of data.

Regards,

Andrew

[1] - https://docs.google.com/file/d/0B8DYPdWIOdpyRjBDcmdCakE1aDA/edit?usp=sharing
POSTED BY: A. K.
3 Replies
Posted 11 years ago
The azimuth angle calculation had a bug in it.  I was not normalizing the projected vector.  With that consideration, the 'teardrop' shape that was so suspicious goes away.








This looks so much more beleivable.  Problem(s) solved. 

Thanks again, Craig.

Andrew
POSTED BY: A. K.
Hello Andrew,
I believe it is because you are using a set-delayed (i.e., :=) where you don't need it.  ListPlot is calling a function each time (and that function calls another function).

For your posted code:


try this:
xp = Subscript[x, Plot];
yp = Subscript[y, Plot];
(n.b., this is also much slower that it needs to be, because of the set-delayed in phi and theta).

Then this:
ListPlot[Transpose[{xp, yp}]]
produces this:

almost immediately.

However, this shows the real power of mathematica (the cut and pastes are not working quite right with your subscripts, but you should be able to see what is intended from your code):
xP[t_] := Cos[ Subscript[\[Phi], LeoToGeo][t] Degree]
yP[t_] := Sin[ Subscript[\[Phi], LeoToGeo][t] Degree]
plot = ParametricPlot[ Subscript[\[Theta], LeoToGeo][t] {xP[t], yP[t]}, {t, 0, Subscript[T, G]}, ColorFunction -> Function[{x, y, t}, ColorData["Temperature"][t]]]
Manipulate[ Show[plot, Graphics[Disk[Subscript[\[Theta], LeoToGeo][t] {xP[t], yP[t]}, 5]]], {t, 0, Subscript[T, G]}]
Sateliites are so much fun!
POSTED BY: W. Craig Carter
Posted 11 years ago
AHA! Wow. I thought I was just supressing input with

:=


I see now that I must have been asking Mathematica to calculate everything, index a single point, and then start over. I think what I want is just an equals sign, and termination with a semi colon.

That animation is really awesome too. As I mentioned, I was checking MATLAB, because I didn't trust the results. That 'teardrop' shape is really interesting. Assuming that my linear algebra to do the coordinate transformations is good, then it seems like if you want to point from a Low Earth Satellite to a Geostationary Satellite, there are some angles you never need to point to. My MATLAB uses Two Line Elements with Vallado's SGP4 code for the ISS and the Tracking and Data Relay Satellite, and the qualitative effect is the same. Fascinating. With MATLAB I just have the blue dots. Seeing the evolution with time is nice. Satellites are fun indeed!

Thanks so much. I should have known better than to assume I was doing things right and Mathematica wasn't.

Regards,

Andrew
POSTED BY: A. K.
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