Open dstansby opened 3 years ago
The HeliographicCarrington
->HeliocentricInertial
transformation can certainly be sped up. For historical reasons, that transformation goes through HeliographicStonyhurst
(HGS), which is detrimental to performance because the orientation of the HGS axes depends on the location of Earth. At least half of the runtime is wasted on figuring out the location of Earth, which has no bearing on the final result.
However, the reason that this is even noticeable is because your test script is highly inefficient and amplifies the above waste by three orders of magnitude. You perform 1000 independent SkyCoord
transformations, but all 1000 are actually the same rotation. Thus, ~80% of the runtime is wasted on redundantly calculating the same rotation matrices. Assuming that your test code is representative of the real situation, can you instead re-jigger sunkit-pyvista
to combine everything into a single SkyCoord
before performing the transformation?
Yes, there's probably a way to do that. I realised that I could also set the coordinate frame in sunkit-pyvista
to be HeliographicCarrington
, which would avoid the transformation altogether... probably still worth leaving the issue open though if you think there's a way to speed the transformation up.
In
pfsspy
field lines are often traced in a Heliographic Carrington frame of reference. Insunkit-pyvsita
, the plotting is all done in a Heliocentric Inertial frame, necessitating a transformation between lots (sometimes 180 x 360 ~ 65k) ofSkyCoord
objects that range in length (but are typically around 50 points long). This transformation is relatively slow - the example below with 1000 dummy field lines takes 40 seconds to run on my laptop.It would be good to speed this transformation up. The profile is: