The phasing module

Name

Type

Description

pykep.phasing.knn

class

Finds the nearest-neighbour in a large list of pykep.planet

pykep.phasing.dbscan

class

Detects clusters in a large list of pykep.planet

pykep.phasing.three_impulses_approx()

function

Computes the orbital transfer cost between two pykep.planet

Detailed Documentation

class pykep.phasing.knn(*args)

The class finds the k-nearest neighbours to a given planet from a list of planets. The problem of finding who is “close-by” can be efficiently solved using appropriate data structures. Here a kdtree is employed bringng complexity down to O(log N). The k-d-tree can then be queried efficiently for all asteroid within a given distance (‘ball’ query) or for all k closest asteroids (‘knn’ query).

The notion of distance used (metric) can be:

  • ‘euclidean’: the simple Euclidean distance over the asteroid’s (r,v). The position an velocity vectors are scaled w.r.t. some reference values.

  • ‘orbital’, the distance is computed with respect to (r/T + v, r/T), corresponding to the DV computed over a linear model of the orbital transfer. The distance returned will thus be in m/s.

__init__(*args)

USAGE: knn = knn(planet_list, t, metric=’orbital’, ref_r=AU, ref_v=EARTH_VELOCITY, T=365.25):

  • planet_list list of pykep planets (typically thousands)

  • t epoch

  • metric one of [‘euclidean’, ‘orbital’]

  • ref_r reference radius (used as a scaling factor for r if the metric is ‘euclidean’)

  • ref_v reference velocity (used as a scaling factor for v if the metric is ‘euclidean’)

  • T average transfer time (used in the definition of the ‘orbital’ metric)

Example:

from pykep import *
pl_list = [planet.gtoc7(i) for i in range(16257)]
knn = phasing.knn(pl_list, epoch(t0), metric='orbital', T=180)
neighb, ids, dists = knn.find_neighbours(pl_list[ast_0], query_type='knn', k=10000)
neighb, ids, _ = knn.find_neighbours(pl_list[ast_0], query_type='ball', r=5000)
find_neighbours(*args)

Finds the neighbours of a given planet at a given epoch. The user may query for the k-nearest neighbours or for all neighbours within a given distance

knn.find_neighbours(query_planet, query_type=’knn’, *args, **kwargs )

  • query_planet: the planet we want to find neighbours of. Can be an integer, in which case it refers to the idx in self.asteroid_list

  • query_type: one of ‘knn’ or ‘ball’.

  • *args, **args: according to the query type (read below)

Returns (neighb, neighb_ids, dists), where dist is only computed if ‘knn’ type query is made

The following kinds of spatial queries are currently implemented:

query_type = ‘knn’:

The kwarg ‘k’ determines how many k-nearest neighbours are returned For arguments, see: http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.cKDTree.query.html

query_type = ‘ball’:

The kwarg ‘r’ determines the distance within which all asteroids are returned. For arguments, see: http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.cKDTree.query_ball_point.html


class pykep.phasing.dbscan(*args)

This class can be used to locate areas of the interplanetsry space that are ‘dense’ at one epoch. Essentially, it locates planet clusters

__init__(*args)

USAGE: cl = dbscan(planet_list):

  • planet_list = list of pykep planets (typically thousands)

cluster(*args)

USAGE: cl.cluster(t, eps=0.125, min_samples=10, metric=’orbital’, T=180, ref_r=AU, ref_v=EARTH_VELOCITY):

  • t: epoch (in MJD2000)

  • eps: max distance between points in a cluster

  • min_samples: minimum number of samples per cluster

  • metric: one of ‘euclidean’, ‘euclidean_r’, orbital’

  • T: average transfer time (used in the definition of the ‘orbital’ metric)

  • ref_r reference radius (used as a scaling factor for r if the metric is ‘euclidean’ or ‘euclidean_r’)

  • ref_v reference velocity (used as a scaling factor for v if the metric is ‘euclidean’)

pretty(*args)

Prints the cluster lists.

plot(*args)

Plots the clusters.


pykep.phasing.three_impulses_approx(*args)

DV = pykep.phasing.three_impulses_approx(pl1, pl2, ep1=None, ep2=None)

  • pl1: departure planet

  • pl2: arrival planet

  • ep1: departure epoch (optional and only useful for non keplerian planets)

  • ep1: arrival epoch (default value is ep1).

  • [out] DV: estimated DV cost for the orbital trab=nsfer

Returns the DV in m/s necessary for an orbit transfer between pl1 and pl2 assuming a perfect phasing. The transfer will be made of three impulses. One to match apogees, one to match inclination and RAAN and one to match perigees. Two of the three impulses will be merged together at either departure or arrival. The argument of perigee is not matched, so that this approximation is only good for near-circular orbits.

Examples:

DV = three_impulses_approx(pl1, pl2)
DV = three_impulses_approx(pl1, pl2, ep1 = epoch(5500))
DV = three_impulses_approx(pl1, pl2, ep1 = epoch(5500), ep2 = epoch(5700))