I am measuring the mass of Jupiter based on Kepler's Third Law. I have taken 147 images of Jupiter and its moon, specifically Io. I have written code to take the position vectors from the image file so I can calculate the magnitude of the distance between Io and Jupiter (distance). This will allow me to plot distance over time. ie: plot(t,d)
The code below while not elegant maybe, achieves this wonderfully. Yet I am trying to convert my array of datetimes into a plot-able value. I have several nights worth of data. The plot will be sinusoidal and the period of Io's orbit will be derived by interpreting the plot. I have included the code, followed by the CSV file in .txt format: python3
import numpy as np
import matplotlib.pyplot as plt
import datetime
import matplotlib.dates as mdates
import math
# Declare arrays (lists) for (x,y) pixel position vectors from .fits
# image files.
jup_x = []
jup_y = []
io_x = []
io_y = []
cal_x = []
cal_y = []
gan_x = []
gan_y = []
eur_x = []
eur_y = []
date_and_time = []
readFile = open('raw_data1.txt','r')
sepFile = readFile.read().split('\n')
readFile.close()
for j_pos_pair in sepFile:
j_xandy = j_pos_pair.split(',')
jup_x.append(int(j_xandy[1]))
jup_y.append(int(j_xandy[2]))
print(jup_x)
print(jup_y)
for io_pos_pair in sepFile:
io_xandy = io_pos_pair.split(',')
io_x.append(int(io_xandy[3]))
io_y.append(int(io_xandy[4]))
print(io_x)
print(io_y)
for cal_pos_pair in sepFile:
cal_xandy = cal_pos_pair.split(',')
cal_x.append(int(cal_xandy[5]))
cal_y.append(int(cal_xandy[6]))
print(cal_x)
print(cal_y)
for gan_pos_pair in sepFile:
gan_xandy = gan_pos_pair.split(',')
gan_x.append(int(gan_xandy[7]))
gan_y.append(int(gan_xandy[8]))
print(gan_x)
print(gan_y)
for eur_pos_pair in sepFile:
eur_xandy = eur_pos_pair.split(',')
eur_x.append(int(eur_xandy[9]))
eur_y.append(int(eur_xandy[10]))
print(eur_x)
print(eur_y)
for date_time in sepFile:
d_and_t = date_time.split(',')
date_and_time.append(str(d_and_t[0]))
print(date_and_time)
# make into arrays for vector operations
# date_and_time = np.array(date_and_time)
datetime = np.array(date_and_time)
Jup_x = np.array(jup_x)
Jup_y = np.array(jup_y)
Io_x = np.array(io_x)
Io_y = np.array(io_y)
print(Jup_x)
print(Jup_y)
print(Io_x)
print(Io_y)
# vector subtraction (Position vector between Jupiter and Io)
J_Io_s_x = Jup_x - Io_x # reads: separation between Io and Jupiter x values
J_Io_s_y = Jup_y - Io_x # reads: separation between Io and Jupiter y values
print(J_Io_s_x)
print(J_Io_s_y)
M_s_J_Io = ((J_Io_s_x)**2 + (J_Io_s_y)**2)**0.5 # The magnitude of the separation
# between Jupiter and Io in pixels
print(M_s_J_Io)
from datetime import datetime
datetime.strptime("2015-feb-05 19:00", "%Y-%b-%d %H:%M")
x = np.array([datetime.datetime(2015, 2, 5, i, 0) for i in range(24)])
plot_M_s_J_Io = np.array(M_s_J_Io)
plt.plot(x,plot_M_s_J_Io)
plt.show()
The CSV file: (This is the test run copy, the actual list is waaaay larger)
2015-feb-05 20:11,1150,735,1335,647,307,1123,0000,000,965,818
This CSV file above includes info on all the moons as well. For my testing i restricted it to just info on Jupiter and Io. That is only the first five fields in the CSV file. Its indexed from 0-10.
Any suggestions, I know I am close, I just don't understand the time conversion aspect of it. Full disclosure: this IS for a LAB at NMT, however I am already going above and beyond in this report as I am using python instead of doing this by hand. All help is of course greatly appreciated.
Jesse