-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_kepler.py
62 lines (48 loc) · 1.7 KB
/
get_kepler.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import utils
import time
def read_csv(kic):
periods = []
df_list = []
filenames = utils.get_filenames(utils.BASE_PATH + str(kic), "csv")
if len(filenames) <= 5:
return {"df_list": df_list, "period": 0.0}
for idx, filename in enumerate(filenames):
if idx > 2:
data = utils.pd.read_csv(utils.BASE_PATH + str(kic) + "/" + filename)
try:
res = utils.get_signal_parameters(
data.dropna().TIME, data.dropna().PDC_NORM_FILT
)
periods.append(res["period"])
except Exception as e:
print(e)
print(idx)
print(kic)
df_list.append(data)
df = utils.pd.DataFrame()
for _df in df_list:
df = df.append(_df)
period = utils.get_period(df.TIME, df.PDC_NORM_FILT, df.EFPDC, periods)
return {"df_list": df_list, "period": period}
def get(kic):
try:
folder_path = utils.download_files(kic)
utils.process_data(folder_path)
data = read_csv(kic)
return data
except Exception as e:
print(e)
return e
def get_all():
return utils.pd.read_csv("datasets/keplerstellar.csv",low_memory=False)
def get_kois():
return utils.pd.read_csv("datasets/kepler-objects-of-interest.csv")
def get_binaries():
return utils.pd.read_csv("datasets/kepler-eclipsing-binary-catalog.csv")
def get_all_without_transit():
kepids = list(get_all().kepid)
kepids_koi = list(get_kois())
kepids_binary_stars = list(get_binaries().KIC)
kepids = [x for x in kepids if x not in kepids_koi]
kepids = [x for x in kepids if x not in kepids_binary_stars]
return kepids