Skip to content

Commit 03d5e78

Browse files
Create My Lightkurve Query.py
Updates
1 parent 8e7a956 commit 03d5e78

File tree

1 file changed

+258
-0
lines changed

1 file changed

+258
-0
lines changed

My Lightkurve Query.py

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

0 commit comments

Comments
 (0)