Vectorization of methods for minor bodies propagation#520
Vectorization of methods for minor bodies propagation#520xmichaelx wants to merge 1 commit intoskyfielders:masterfrom xmichaelx:feature/vectorize-for-mpcorb
Conversation
|
Wow, thank you — I look forward to reading over this tomorrow! In case you're ever interested in plotting the orbits where they look flat rather than slanted, I think the most recent Skyfield now supports instead of: — a maneuver like: I only mention it because, when doing my own plots, it's always my first step so the Solar System doesn't look so lopsided. 🙂 |
|
Thanks, it looks better: from skyfield.api import load
from skyfield.data import mpc
from skyfield.data.mpc import _mpcorb_orbits
from skyfield.constants import GM_SUN_Pitjeva_2005_km3_s2 as GM_SUN
from numpy import arange, linspace, rollaxis
import matplotlib.pyplot as plt
from skyfield.framelib import ecliptic_frame
ts = load.timescale()
with load.open('MPCORB.DAT') as f:
rows = mpc.load_mpcorb_dataframe(f)
bad_orbits = rows.semimajor_axis_au.isnull()
rows = rows[~bad_orbits]
rows = rows.set_index('designation', drop=False)
comets = _mpcorb_orbits(rows.iloc[0:20], ts, GM_SUN)
t = ts.utc(linspace(2000, 2030, 100))
position = comets.at(t).frame_xyz(ecliptic_frame).au
plt.rcParams['legend.fontsize'] = 10
fig = plt.figure()
ax = fig.gca(projection='3d')
for i, (x, y, z) in enumerate(rollaxis(position, 1)):
ax.plot(x, y, z, label=rows.designation[i])
ax.legend()
plt.show()I'll compare results with non-vectorized version - but what would need to change in order to be able to use observe method on astrometric = earth.at(t).observe(sun + comets)Current exception stack: |
Good question. To take a single center and Or else improving the But either quick fix dodges a bigger issue that needs to be tackled: which is that this idea of a vector of comets or minor planets seems to be populating the 2nd dimension — so, the x,y,z of 20 comets has dimensions Currently Skyfield has well-founded ideas about 2 dimensions:
As the idea of “a vector of comets” expands us beyond this, we need to consider other uses of vectors, like: a vector of Earth observatories. Or a vector of other objects with which we are searching for conjunctions. A big, big question arises. Do we start prescribing for users what further dimensions always mean in Skyfield? Like:
Or, since Skyfield operations all seem pretty agnostic to everything but dimensions But a more immediate question concerns the ubiquity in current Skyfield code of the second slot always being time, except that the multi-comet and multi-asteroid code here instead uses it for n comets and asteroids. Do we add an intermediate dimension here so it comes out |
Yes, sorry for that. Right now I'm testing on 20 objects, 1 epoch. And this produces above stack. I figured it would be easier to debug that full-blown many epochs/many objects case. When 100 epochs are used stack looks like this: So it looks like position |
|
I don't yet have a strong preference either way - although I would suspect that case where we have |
This can be changed in |
|
Building on what both of you've said I believe that it would be a good idea to adopt following convention:
And leave out other proposed dimensions for now following YAGNI principle. Whenever single target is specified then last dimension can be skipped so it nicely reduces to what is available in skyfield now. At least that's my perception of it - I'd gladly help with that but I'd need some guidance and permission from both of you :) @JoshPaterson @brandon-rhodes So, what do you think? Is support for multiple observed objects worth a try? |
|
@xmichaelx — Thanks very much for your contributions here! I look forward to getting the pull request reviewed that you inspired. (Hopefully by the end of the weekend!) |
|
@brandon-rhodes I'll look closely to implementation provided by @JoshPaterson and probably try to follow the same convention in order to get multiple satellites propagation using sgp4. I see that there was a related opened PR #439 @JoshPaterson awesome trick with If you need help with test writing or anything, please let me know. |

This is basically copy-paste attempt of what @JoshPaterson did in #511
Following code shows it (MPCORB.DAT has header removed manually):
Produces following plot:
This still needs work but I'd like to use PR for discussion and to show some nice tricks for speeding up epoch_packed parsing in numpy. I also need to verify results with propagation done for each minor body separately to check if I converted everything properly.
Initial results of @JoshPaterson propagation are awesome - entire MPCORB.dat file (~ 1M orbits) propagates for one given epoch in around 30 seconds).