Domanda

I have created a program to take position and velocity state vectors and calculate all of the Keplerian orbital elements. The next step I want to do is plot the orbit! Any advice on how to approach this using Python 3? Also, any advice about where to migrate this question (if this spot is not appropriate) would be much appreciated. enter image description here

È stato utile?

Soluzione

The best plotting package is, by far, pyplot. It is essentialy a port of the matlab plotting system to python, but it works better than the original. Install numpy & matplotlib and look at the simple plotting tutorials. Plotting would be something like:

import matplotlib.pyplot as plt;
plt.plot(X, Y, color);
plt.show();

where X and Y are 1D arrays of the corresponding x, y values. The answer can't be more specific, since you don't give details about how the variables are stored.

Altri suggerimenti

I recommend OpenCV. Here I used CV2 for Python.

import numpy as np
import cv2

cv2.namedWindow("Orbit",cv2.WINDOW_AUTOSIZE)

im_old = np.zeros((100,100))

for i in range(360*4):
    xc = 50
    yc = 50
    im = im_old.copy()
    x = 25*np.cos(i*np.pi/180.0)+xc
    y = 25*np.sin(i*np.pi/180.0)+yc
    im[(x-2):(x+3),(y-2):(y+3)] = 255
    im_old[x,y] = 128
    cv2.imshow("Orbit",im)
    cv2.waitKey(10);

This is for Python 2.7, but I think it should still work.

EDIT: This is for visualizing the actual motion, if that's what you're looking for.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top