Mean-Motion Resonances
  • Home

Getting Started

  • Quick Start
  • Installation and updates
  • Examples
    • AstDyS Catalog
    • Configuring the integrator
    • Find only two-body MMRs near the semimajor axis
    • Find asteroids in a given resonance

Features

  • Simulations, Bodies, MMRs
  • Libration module
  • Resonance Matrices
  • Config

About

  • Copyright, license, references
Mean-Motion Resonances
  • »
  • Getting Started »
  • Examples
  • Edit on GitHub

Examples¶

Below are some examples of how the package could be used in astronomical studies. While there are more use cases, the most common are outlined below.

AstDyS Catalog¶

By default, the application uses NASA Horizon database for the initial data. However, there is another option for numbered asteroids — AstDyS catalog. The app will download the latest version, convert it, and start using it in simulation.

This is especially useful if you need to run some statistical experiments, such as finding all asteroids trapped in a specific resonance.

In [ ]:
Copied!
import resonances

sim = resonances.Simulation(name='test_astdys', source='astdys')
sim.create_solar_system()

sim.add_body(463, '4J-2S-1', '463 Lola')
import resonances sim = resonances.Simulation(name='test_astdys', source='astdys') sim.create_solar_system() sim.add_body(463, '4J-2S-1', '463 Lola')
In [3]:
Copied!
import warnings
warnings.filterwarnings("ignore")
import warnings warnings.filterwarnings("ignore")

Now, let's run the simulation with AstDyS data. Note that we did not specify the date of the simulation — when using AstDyS, the app will take the date of the AstDyS catalog. It is possible to change this but it is not recommended.

In [3]:
Copied!
sim.run()
sim.run()

Configuring the integrator¶

By default, the package uses ias15 and adaptive timestamp. However, sometimes, one might want to perform a quick integration using another integrator, i.e., whfast. The default functions does not support such a customization. However, it is easy to create a custom simulation and proceed with it.

In [2]:
Copied!
import resonances

sim = resonances.Simulation(name='test_whfast', date='2025-01-01 00:00', integrator='whfast', dt=0.1)
sim.create_solar_system()
sim.add_body(463, '4J-2S-1', '463 Lola')
import resonances sim = resonances.Simulation(name='test_whfast', date='2025-01-01 00:00', integrator='whfast', dt=0.1) sim.create_solar_system() sim.add_body(463, '4J-2S-1', '463 Lola')
Searching NASA Horizons for 'Sun'... 
Found: Sun (10) 
Searching NASA Horizons for 'Mercury'... 
Found: Mercury Barycenter (199) (chosen from query 'Mercury')
Searching NASA Horizons for 'Venus'... 
Found: Venus Barycenter (299) (chosen from query 'Venus')
Searching NASA Horizons for 'Earth'... 
Found: Earth-Moon Barycenter (3) (chosen from query 'Earth')
Searching NASA Horizons for 'Mars'... 
Found: Mars Barycenter (4) (chosen from query 'Mars')
Searching NASA Horizons for 'Jupiter'... 
Found: Jupiter Barycenter (5) (chosen from query 'Jupiter')
Searching NASA Horizons for 'Saturn'... 
Found: Saturn Barycenter (6) (chosen from query 'Saturn')
Searching NASA Horizons for 'Uranus'... 
Found: Uranus Barycenter (7) (chosen from query 'Uranus')
Searching NASA Horizons for 'Neptune'... 
Found: Neptune Barycenter (8) (chosen from query 'Neptune')
Searching NASA Horizons for 'Pluto'... 
Found: Pluto Barycenter (9) (chosen from query 'Pluto')
Searching NASA Horizons for '463;'... 
Found: 463 Lola (A900 UK) 
In [6]:
Copied!
sim.run()
sim.run()

Find only two-body MMRs near the semimajor axis¶

In Quick Start, we have seen how to find all MMRs (two-body and three-body) for a given value of semi-major axis through the function resonances.find_resonances. However, one might want to find only two-body or three-body resonances. To perform this, there are special classes ThreeBodyMatrix and TwoBodyMatrix that can be used to find only three-body and two-body resonances, respectively.

In [3]:
Copied!
from resonances import ThreeBodyMatrix, TwoBodyMatrix

mmrs = TwoBodyMatrix.find_resonances(2.35, sigma=0.1, planets=['Mars', 'Jupiter'])
for mmr in mmrs:
    print(mmr.to_short())

mmrs = ThreeBodyMatrix.find_resonances(2.35, sigma=0.05, planets=['Mars', 'Jupiter', 'Saturn'])
for mmr in mmrs:
    print(mmr.to_short())
from resonances import ThreeBodyMatrix, TwoBodyMatrix mmrs = TwoBodyMatrix.find_resonances(2.35, sigma=0.1, planets=['Mars', 'Jupiter']) for mmr in mmrs: print(mmr.to_short()) mmrs = ThreeBodyMatrix.find_resonances(2.35, sigma=0.05, planets=['Mars', 'Jupiter', 'Saturn']) for mmr in mmrs: print(mmr.to_short())
1M-2
1M+2
5M-9
6M-11
7J-2
7J+2
10J-3
1M-3J-1
2M-3J-3
2M+4J-5
3M-2J-5
3M+1J-6
3M+4J-7
4M-2J-7
1M+1S-2
2M+1S-4
3M+1S-6
3M+2S-6
2J+3S-1
4J-2S-1
5J-4S-1
6J+1S-2
7J-1S-2

The code above performs the following:

  1. The first find_resonances finds two-body MMRs resonances within the range $2.35\pm 0.1 = [2.25, 2.45]$.
  2. The second find_resonances finds three-body MMRs resonances within the range $2.35\pm 0.05 = [2.3, 2.4]$.

Find asteroids in a given resonance¶

One might want to find all asteroids in a given resonance. This can be done by the function find_asteroids_in_resonance. It has the following inputs:

  • mmr (Union[MMR, str]): The mean motion resonance to search for. Can be either an MMR object or a string representation (e.g., "4J-2S-1")
  • sigma (float, default=0.1): Width parameter for resonance search around the resonant axis
  • per_iteration (int, default=500): Number of asteroids to process in each batch/chunk for memory efficiency

The function returns a list of DataFrames containing simulation results for asteroids found in the specified resonance.

This function is time-consuming because it integrates the orbits of all relevant asteroids. One might want to get a list of candidates first based on the closeness of the resonant axis. To do this, we can use astdys package.

In [5]:
Copied!
import astdys, resonances

mmr = resonances.create_mmr('4J-2S-1')
df_asteroids = astdys.search_by_axis(mmr.resonant_axis, sigma=0.01)
print('Number of objects found: {}'.format(len(df_asteroids)))
df_asteroids.head(5)
import astdys, resonances mmr = resonances.create_mmr('4J-2S-1') df_asteroids = astdys.search_by_axis(mmr.resonant_axis, sigma=0.01) print('Number of objects found: {}'.format(len(df_asteroids))) df_asteroids.head(5)
Number of objects found: 3619
Out[5]:
a e inc Omega omega M epoch
num
20 2.407925 0.143731 0.012380 3.595020 4.493478 4.962143 60600.0
25 2.400450 0.254243 0.377134 3.736615 1.574323 5.989823 60600.0
60 2.392187 0.184544 0.062843 3.342778 4.725915 0.377345 60600.0
63 2.394722 0.128203 0.100759 5.893842 5.161197 5.439140 60600.0
192 2.402742 0.245596 0.118624 5.988033 0.533790 2.924088 60600.0

The function search_by_axis is powerful and can be used to find asteroids by a given value of the semi-major axis for other purposes as well (i.e., to plot some of them).

If one still wants to classify whether any of the asteroids found are really resonant, one can use the function find_asteroids_in_mmr described above.

In [35]:
Copied!
data = resonances.find_asteroids_in_mmr('6J-3S-2', sigma=0.01)
data = resonances.find_asteroids_in_mmr('6J-3S-2', sigma=0.01)

By default, this method also saves output data to cache/%current_datetime% subdirectory. You can access the results either through the variable data or by reading summary.csv file in the proper directory.

Previous Next

Built with MkDocs using a theme provided by Read the Docs.
GitHub « Previous Next »