-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrvdatareader.py
45 lines (40 loc) · 1.34 KB
/
rvdatareader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import math
import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate
import csv
# Returns an array containing the data points of radial velocity vs time
def read_doppler_shift_data(filename):
time, doppler_shift = [], []
with open(filename) as file:
reader = csv.reader(file, delimiter=',')
line_count = 0
for row in reader:
if line_count > 0:
time.append(float(row[0]))
doppler_shift.append(float(row[1]))
line_count += 1
return time, doppler_shift
# This will take in CSV's with data for guess bounds for the guess and check algorithm
def read_guessandcheck_data(filename):
pass
"""
Structure:
will do later
"""
# 1D array of star masses denoted by indices
# NOTE: units are Solar masses
def read_star_mass_data(filename):
masses = []
with open(filename) as file:
reader = csv.reader(file, delimiter=',')
line_count = 0
for row in reader:
if line_count > 0:
masses.append(float(row[1])) # We only need to take in the second column
line_count += 1
return masses
if __name__ == "__main__":
star_masses = read_star_mass_data('star-masses.csv')
for m in star_masses:
print(m)