question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot sample orbits around the Moon

See original GitHub issue

Code to reproduce:

In [1]: from poliastro.bodies import Moon                                                                                               

In [2]: from poliastro.twobody import Orbit                                                                                             

In [3]: from astropy import units as u                                                                                                  

In [4]: o1 = Orbit.circular(Moon, 100 * u.km)                                                                                           

In [5]: o1.sample()                                                                                                                     
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/Development/poliastro/poliastro-library/src/poliastro/frames.py in get_frame(attractor, plane, obstime)
    254     try:
--> 255         frames = _FRAME_MAPPING[attractor]
    256     except KeyError:

KeyError: Moon (☾)

During handling of the above exception, another exception occurred:

NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-5515a447cc0b> in <module>
----> 1 o1.sample()

~/Development/poliastro/poliastro-library/src/poliastro/twobody/orbit.py in sample(self, values, min_anomaly, max_anomaly, method)
   1042 
   1043         time_values = self._generate_time_values(nu_values)
-> 1044         return propagate(self, time.TimeDelta(time_values), method=method)
   1045 
   1046     def _generate_time_values(self, nu_vals):

~/Development/poliastro/poliastro-library/src/poliastro/twobody/propagation.py in propagate(orbit, time_of_flight, method, rtol, **kwargs)
    225     # If the frame supports obstime, set the time values
    226     kwargs = {}
--> 227     if "obstime" in orbit.frame.frame_attributes:
    228         kwargs["obstime"] = orbit.epoch + time_of_flight
    229     else:

~/Development/poliastro/poliastro-library/src/poliastro/twobody/orbit.py in frame(self)
     99         """
    100         if self._frame is None:
--> 101             self._frame = get_frame(self.attractor, self._plane, self.epoch)
    102 
    103         return self._frame

~/Development/poliastro/poliastro-library/src/poliastro/frames.py in get_frame(attractor, plane, obstime)
    256     except KeyError:
    257         raise NotImplementedError(
--> 258             "Frames for orbits around custom bodies are not yet supported"
    259         )
    260 

NotImplementedError: Frames for orbits around custom bodies are not yet supported

Perhaps instead of being so strict, we could raise a warning and “just” return the CartesianCoordinates. And in that case, perhaps poliastro.twobody.propagation.propagate should ignore the frame, and just produce coordinates:

https://github.com/poliastro/poliastro/blob/1d366845e13d7bac59cdd11a3178fe2126d46827/src/poliastro/twobody/propagation.py#L225-L240

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dragonlostcommented, Jul 10, 2019

nice is fixe !

0reactions
astrojuanlucommented, Dec 21, 2019

(See #797)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bizarre Lunar Orbits | Science Mission Directorate
"If the Moon were a uniform sphere, you could have an orbit that was perfect ellipse or circle," Konopliv explained. "The Moon has...
Read more >
Orbit of the Moon - Wikipedia
The Moon orbits Earth in the prograde direction and completes one revolution relative to the Vernal Equinox and the stars in about 27.32...
Read more >
Can moons have moons? (Intermediate) - Ask an Astronomer
The only problem is that the sub-satellite cannot stay in orbit around the Moon indefinitely because of tides.
Read more >
Orbit - TuHS Physics
New Quantities; Formulae; General Problem Solving Strategy; Example ... and a mass of 7.36(10 22 )kg, how high above the Moon's surface is...
Read more >
Why Doesn't the Moon Fall Down? - PBS LearningMedia
Astronomer Doris Daou explains how the forces of speed and gravity keep the Moon in a constant orbit around Earth in this animated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found