-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMy Lightkurve Query.py
258 lines (170 loc) · 6.53 KB
/
My Lightkurve Query.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
################################## 001 #########################################
# %%
print("\nSection 001\n")
import matplotlib.pyplot as plt
%matplotlib inline
import astropy.units as u
# %%
################################## 001B #########################################
# %%
print("\nSection 001B\n")
from importlib.metadata import version
import lightkurve as lk
print(version('lightkurve'))
from lightkurve import search_targetpixelfile
from lightkurve import search_lightcurve
# %%
################################## 002 #########################################
# %%
print("\nSection 002\n")
def Pldtarget(target, i, targetstring):
pixelfile = lk.search_targetpixelfile(target)[i].download();
lc = pixelfile.to_lightcurve(method="pld").remove_outliers().flatten()
period = lc.to_periodogram("bls").period_at_max_power
lc.fold(period).scatter();
plt.title(str(target) + " (" + str(i) + ")" + str(targetstring));
# %%
################################## 003 #########################################
# %%
print("\nSection 003\n")
import ipywidgets as widgets
from IPython.display import display, clear_output
r1_select_variable = widgets.Dropdown(
options=[
'Kepler-1','Kepler-2','Kepler-3','Kepler-4','Kepler-5','Kepler-6','Kepler-7','Kepler-8','Kepler-9',
'Kepler-10','Kepler-11','Kepler-12','Kepler-13','Kepler-14','Kepler-15','Kepler-16','Kepler-17','Kepler-18','Kepler-19',
'Kepler-20','Kepler-21','Kepler-22','Kepler-23','Kepler-24','Kepler-25','Kepler-26','Kepler-27','Kepler-28','Kepler-29',
'Kepler-30','Kepler-31','Kepler-32','Kepler-33','Kepler-34','Kepler-35','Kepler-36','Kepler-37','Kepler-38','Kepler-39',
'Kepler-40','Kepler-41','Kepler-42','Kepler-43','Kepler-44','Kepler-45','Kepler-46','Kepler-47','Kepler-48','Kepler-49',
'Kepler-50','Kepler-51','Kepler-52','Kepler-53','Kepler-54','Kepler-55','Kepler-56','Kepler-57','Kepler-58','Kepler-59',
'Kepler-60','Kepler-61','Kepler-62','Kepler-63','Kepler-64','Kepler-65','Kepler-66','Kepler-67','Kepler-68','Kepler-69',
'Kepler-70','Kepler-71','Kepler-72','Kepler-73','Kepler-74','Kepler-75','Kepler-76','Kepler-77','Kepler-78','Kepler-79',
'Kepler-80','Kepler-81','Kepler-82','Kepler-83','Kepler-84','Kepler-85','Kepler-86','Kepler-87','Kepler-88','Kepler-89',
'Kepler-90','Kepler-91','Kepler-92','Kepler-93','Kepler-94','Kepler-95','Kepler-96','Kepler-97','Kepler-98','Kepler-99',
"KIC 3832474", "Kepler-30",
"KIC 4548011", "Kepler-1581",
"KIC 4852528", "Kepler-80",
"KIC 5972334", "Kepler-487",
'KIC 6922244', 'Kepler-8',
'KIC 8462852',
"KIC 8480285", "Kepler-647",
"KIC 10264202",
"KIC 10337517", "Kepler-783",
"KIC 11030475",
"KIC 11442793", "Kepler-90",
"KIC 11568987", "Kepler-534",
"Proxima Cen",
"Tau Ceti",
"Trappist-1",
"Wolf 359",
'Choose a target'],
value='Choose a target',
description='Target:',
disabled=False,
)
def get_variable(b):
clear_output
print(r1_select_variable.value)
display(r1_select_variable)
# %%
################################## 004 #########################################
# %%
print("\nSection 004\n")
# Print a list of all target entries
target1 = r1_select_variable.value
print("Target: " + str(target1))
search_result = lk.search_lightcurve(target1)
print(search_result)
print("\n")
Target_Name = " "
# %%
################################## 004B #########################################
# %%
print("\nSection 004B\n")
# Print the first entry
print("\nThe first entry\n")
Pldtarget(target1, 0, Target_Name)
# %%
################################## 004C #########################################
# %%
print("\nSection 004C\n")
# Print the graphs of the first 5 entries
print("\nGraphs of the first 5 entries\n")
for i in range(0, 5):
Pldtarget(target1, i, Target_Name)
# %%
################################# 004D #########################################
# %%
print("\nSection 004D\n")
# Print all the entries
print("\nGraphs of all the entries\n")
for i in range(0, int(len(search_result))):
Pldtarget(target1, i, Target_Name)
# %%
################################## 005 #########################################
# %%
print("\nSection 005\n")
# Print the graphs of the first half of the entries
print("\nGraphs of the first half of the entries\n")
for i in range(0, int(len(search_result)/2)):
Pldtarget(target1, i, Target_Name)
# %%
################################## 006 #########################################
# %%
print("\nSection 006\n")
# Print the graphs of the second half of the entries
print("\nGraphs of the second half of the entries\n")
for i in range(int(len(search_result)/2) -1, len(search_result)):
Pldtarget(target1, i, Target_Name)
# %%
################################## 007 #########################################
# %%
print("\nSection 007\n")
# Print the graphs of the first 10 entries
print("\nGraphs of the first 10 entries\n")
for i in range(0, 10):
Pldtarget(target1, i, Target_Name)
# %%
################################## 008 #########################################
# %%
print("\nSection 008\n")
# Print the 5th entry
print("\nGraphs of the f5th entry\n")
Pldtarget(target1, 5, Target_Name)
# %%
################################## 009 #########################################
# %%
print("\nSection 009\n")
# https://github.com/openexoplanetcatalogue/open_exoplanet_catalogue/
import xml.etree.ElementTree as ET, urllib.request, gzip, io
url = "https://github.com/OpenExoplanetCatalogue/oec_gzip/raw/master/systems.xml.gz"
oec = ET.parse(gzip.GzipFile(fileobj=io.BytesIO(urllib.request.urlopen(url).read())))
# %%
################################## 010 #########################################
# %%
print("\nSection 010\n")
# Output mass and radius of all planets
for planet in oec.findall(".//planet"):
print([planet.findtext("mass"), planet.findtext("radius")])
# %%
################################## 011 #########################################
# %%
print("\nSection 011\n")
# Find all circumbinary planets
for planet in oec.findall(".//binary/planet"):
print(planet.findtext("name"))
# %%
################################## 012 #########################################
# %%
print("\nSection 012\n")
# Output distance to planetary system (in pc, if known) and number of planets in system
for system in oec.findall(".//system"):
print(system.findtext("distance"), len(system.findall(".//planet")))
# %%
################################# 013 #########################################
# %%
print("\nSection 013\n")
# Find all circumbinary planets
for star in oec.findall(".//star"):
print(star.findtext("star"))
# %%