exovetter 0.0.6__tar.gz → 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {exovetter-0.0.6 → exovetter-0.0.8}/PKG-INFO +1 -1
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/centroid/centroid.py +82 -15
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/centroid/disp.py +3 -3
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/utils.py +170 -2
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/version.py +1 -1
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/vetters.py +186 -117
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter.egg-info/PKG-INFO +1 -1
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter.egg-info/SOURCES.txt +2 -6
- exovetter-0.0.8/tutorial_notebooks/100100827.pdf +0 -0
- exovetter-0.0.8/tutorial_notebooks/Centroid.ipynb +342 -0
- exovetter-0.0.8/tutorial_notebooks/run_all.ipynb +372 -0
- exovetter-0.0.6/tutorial_notebooks/Centroid.ipynb +0 -231
- exovetter-0.0.6/tutorial_notebooks/run_all.ipynb +0 -1511
- exovetter-0.0.6/tutorial_notebooks/run_all_plots/TOI_1000.01.pdf +0 -0
- exovetter-0.0.6/tutorial_notebooks/run_all_plots/TOI_1001.01.pdf +0 -0
- exovetter-0.0.6/tutorial_notebooks/run_all_plots/TOI_1004.01.pdf +0 -0
- exovetter-0.0.6/tutorial_notebooks/run_all_plots/TOI_1007.01.pdf +0 -0
- exovetter-0.0.6/tutorial_notebooks/run_all_plots/TOI_1011.01.pdf +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/.bandit.yaml +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/.github/workflows/ci_workflows.yml +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/.github/workflows/publish.yml +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/.gitignore +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/.readthedocs.yml +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/CHANGES.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/LICENSE.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/MANIFEST.in +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/README.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/Makefile +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/conf.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/index.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/install.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/make.bat +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/utils.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/vetters.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/docs/vetters_low_level.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/__init__.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/centroid/__init__.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/centroid/covar.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/centroid/fastpsffit.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/const.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/leo.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/lightkurve_utils.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/lpp.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/model.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/modshift/__init__.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/modshift/modshift.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/modshift/plotmodshift.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/odd_even.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/sweet.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/tce.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/transit_coverage.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/trapezoid_fit.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter/viz_transits.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter.egg-info/dependency_links.txt +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter.egg-info/not-zip-safe +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter.egg-info/requires.txt +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/exovetter.egg-info/top_level.txt +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/licenses/DAVE_LICENSE +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/licenses/README.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/licenses/TEMPLATE_LICENCE.rst +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/pyproject.toml +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/requirements.txt +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/setup.cfg +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/setup.py +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/LPP.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/LeoTransitEvents.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/OddEven.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/SWEET.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/TCEs.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/TransitPhaseCoverage.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/VizTransits.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/lightcurves.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/modshift.ipynb +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/wasp18b.fits +0 -0
- {exovetter-0.0.6 → exovetter-0.0.8}/tutorial_notebooks/wasp18b_tce +0 -0
|
@@ -14,6 +14,7 @@ def compute_diff_image_centroids(
|
|
|
14
14
|
duration_days,
|
|
15
15
|
remove_transits,
|
|
16
16
|
max_oot_shift_pix=1.5,
|
|
17
|
+
starloc_pix = None,
|
|
17
18
|
plot=False
|
|
18
19
|
):
|
|
19
20
|
"""Compute difference image centroid shifts for every transit in a dataset.
|
|
@@ -42,6 +43,9 @@ def compute_diff_image_centroids(
|
|
|
42
43
|
(float) Duration of transit.
|
|
43
44
|
remove_transits
|
|
44
45
|
(list) List of 0 indexed transit integers to not calculate on.
|
|
46
|
+
starloc_pix
|
|
47
|
+
(2d array) catalog location of target star for plotting.
|
|
48
|
+
Default is None.
|
|
45
49
|
max_oot_shift_pix
|
|
46
50
|
(float) Passed to `fastpsffit.fastGaussianPrfFit()
|
|
47
51
|
|
|
@@ -74,29 +78,30 @@ def compute_diff_image_centroids(
|
|
|
74
78
|
transits = getIngressEgressCadences(
|
|
75
79
|
time, period_days, epoch, duration_days)
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
axs = []
|
|
78
82
|
centroids = []
|
|
79
83
|
|
|
80
84
|
for i in range(len(transits)):
|
|
81
85
|
if i not in remove_transits:
|
|
82
86
|
cin = transits[i]
|
|
83
|
-
cents,
|
|
87
|
+
cents, ax = measure_centroids(
|
|
84
88
|
cube,
|
|
85
89
|
cin,
|
|
86
90
|
max_oot_shift_pix=max_oot_shift_pix,
|
|
91
|
+
starloc_pix = starloc_pix,
|
|
87
92
|
plot=plot
|
|
88
93
|
)
|
|
89
94
|
|
|
90
95
|
if plot == True:
|
|
91
|
-
|
|
96
|
+
plt.gcf().suptitle('Transit '+str(i))
|
|
92
97
|
|
|
93
98
|
centroids.append(cents)
|
|
94
|
-
|
|
99
|
+
axs.append(ax)
|
|
95
100
|
|
|
96
101
|
centroids = np.array(centroids)
|
|
97
102
|
all_transits = list(np.arange(len(transits)))
|
|
98
103
|
kept_transits = [x for x in all_transits if x not in remove_transits]
|
|
99
|
-
return centroids,
|
|
104
|
+
return centroids, axs, kept_transits
|
|
100
105
|
|
|
101
106
|
|
|
102
107
|
def measure_centroid_shift(centroids, kept_transits, plot=False):
|
|
@@ -140,6 +145,51 @@ def measure_centroid_shift(centroids, kept_transits, plot=False):
|
|
|
140
145
|
fig = covar.diagnostic_plot(dcol, drow, kept_transits, flags)
|
|
141
146
|
return offset_pix, signif, fig
|
|
142
147
|
|
|
148
|
+
def measure_centroid_shift_cat(centroids, kept_transits, starloc_pix, plot=False):
|
|
149
|
+
"""Measure the average offset of the DIC centroids from the catalog position.
|
|
150
|
+
|
|
151
|
+
Inputs
|
|
152
|
+
----------
|
|
153
|
+
centroids
|
|
154
|
+
(2d np array) Output of :func:`compute_diff_image_centroids`
|
|
155
|
+
|
|
156
|
+
kept_transits
|
|
157
|
+
(list) List of 0 indexed transit integers to calculate on.
|
|
158
|
+
|
|
159
|
+
starloc_pix
|
|
160
|
+
(2d np array) col,row expected location of target star
|
|
161
|
+
|
|
162
|
+
Returns
|
|
163
|
+
-----------
|
|
164
|
+
offset
|
|
165
|
+
(float) Size of offset in pixels (or whatever unit `centroids`
|
|
166
|
+
is in)
|
|
167
|
+
signif
|
|
168
|
+
(float) The statistical significance of the transit. Values
|
|
169
|
+
close to 1 mean the transit is likely on the target star.
|
|
170
|
+
Values less than ~1e-3 suggest the target is not the
|
|
171
|
+
source of the transit.
|
|
172
|
+
fig
|
|
173
|
+
A figure handle. Is **None** if plot is **False**
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
# DIC - catalog
|
|
177
|
+
# dcol = centroids[:, 5] - centroids[:, 0]
|
|
178
|
+
# drow = centroids[:, 4] - centroids[:, 1]
|
|
179
|
+
dcol = centroids[:, 4] - starloc_pix[0]
|
|
180
|
+
drow = centroids[:, 5] - starloc_pix[1]
|
|
181
|
+
|
|
182
|
+
flags = centroids[:, -1].astype(bool)
|
|
183
|
+
|
|
184
|
+
offset_pix, signif = covar.compute_offset_and_signif(
|
|
185
|
+
dcol[~flags], drow[~flags])
|
|
186
|
+
|
|
187
|
+
fig = None
|
|
188
|
+
if plot:
|
|
189
|
+
fig = covar.diagnostic_plot(dcol, drow, kept_transits, flags)
|
|
190
|
+
|
|
191
|
+
return offset_pix, signif, fig
|
|
192
|
+
|
|
143
193
|
|
|
144
194
|
def getIngressEgressCadences(time, period_days, epoch_btjd, duration_days):
|
|
145
195
|
assert np.all(np.isfinite(time))
|
|
@@ -151,7 +201,7 @@ def getIngressEgressCadences(time, period_days, epoch_btjd, duration_days):
|
|
|
151
201
|
return transits
|
|
152
202
|
|
|
153
203
|
|
|
154
|
-
def measure_centroids(cube, cin, max_oot_shift_pix=0.5, plot=False):
|
|
204
|
+
def measure_centroids(cube, cin, max_oot_shift_pix=0.5, starloc_pix = None, plot=False):
|
|
155
205
|
"""Private function of :func:`compute_diff_image_centroids`
|
|
156
206
|
|
|
157
207
|
Computes OOT, ITR and diff images for a single transit event,
|
|
@@ -209,17 +259,31 @@ def measure_centroids(cube, cin, max_oot_shift_pix=0.5, plot=False):
|
|
|
209
259
|
if diffSoln.success:
|
|
210
260
|
clr = "green"
|
|
211
261
|
|
|
262
|
+
fig = plt.gcf()
|
|
263
|
+
axlist = fig.axes
|
|
264
|
+
#assert len(axlist) == 3, axlist
|
|
265
|
+
|
|
212
266
|
res = diffSoln.x
|
|
213
|
-
|
|
214
|
-
|
|
267
|
+
for ax in axlist:
|
|
268
|
+
if ax.get_label() == '<colorbar>':
|
|
269
|
+
continue
|
|
270
|
+
|
|
271
|
+
plt.sca(ax)
|
|
272
|
+
disp.plotCentroidLocation(res[0], res[1], marker="^", color=clr,
|
|
273
|
+
label="diff")
|
|
215
274
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
275
|
+
res1 = ootSoln.x
|
|
276
|
+
disp.plotCentroidLocation(res1[0], res1[1], marker="o", color=clr,
|
|
277
|
+
label="OOT")
|
|
219
278
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
279
|
+
res2 = intransSoln.x
|
|
280
|
+
disp.plotCentroidLocation(res2[0], res2[1], marker="+", color=clr,
|
|
281
|
+
label="InT")
|
|
282
|
+
|
|
283
|
+
if starloc_pix is not None:
|
|
284
|
+
disp.plotCentroidLocation(starloc_pix[0], starloc_pix[1], marker="*",
|
|
285
|
+
color='red', label="Cat", ms=10)
|
|
286
|
+
|
|
223
287
|
plt.legend(fontsize=12, framealpha=0.7, facecolor='silver')
|
|
224
288
|
|
|
225
289
|
out = []
|
|
@@ -236,7 +300,7 @@ def measure_centroids(cube, cin, max_oot_shift_pix=0.5, plot=False):
|
|
|
236
300
|
return out, ax
|
|
237
301
|
|
|
238
302
|
|
|
239
|
-
def generateDiffImg(cube, transits, plot=False):
|
|
303
|
+
def generateDiffImg(cube, transits, starloc_pix = None, plot=False):
|
|
240
304
|
"""Generate a difference image.
|
|
241
305
|
|
|
242
306
|
Also generates an image for each the $n$ cadedences before
|
|
@@ -249,6 +313,8 @@ def generateDiffImg(cube, transits, plot=False):
|
|
|
249
313
|
(np 3 array) Datacube of postage stamps
|
|
250
314
|
transits
|
|
251
315
|
(2-tuples) Indices of the first and last cadence
|
|
316
|
+
starloc_pix
|
|
317
|
+
(np 2 element array) col, row position of star
|
|
252
318
|
|
|
253
319
|
Optional Inputs
|
|
254
320
|
-----------------
|
|
@@ -286,6 +352,7 @@ def generateDiffImg(cube, transits, plot=False):
|
|
|
286
352
|
fig = plt.figure()
|
|
287
353
|
fig.set_size_inches(16, 4)
|
|
288
354
|
disp.plotTransit(fig, oot, during, diff)
|
|
355
|
+
|
|
289
356
|
else:
|
|
290
357
|
fig = None
|
|
291
358
|
|
|
@@ -8,15 +8,15 @@ import numpy as np
|
|
|
8
8
|
|
|
9
9
|
def plotTransit(fig, oot, during, diff, **kwargs):
|
|
10
10
|
|
|
11
|
-
fig.add_subplot(131)
|
|
11
|
+
ax1 = fig.add_subplot(131)
|
|
12
12
|
plotImage(oot, **kwargs)
|
|
13
13
|
plt.title("OOT")
|
|
14
14
|
|
|
15
|
-
fig.add_subplot(132)
|
|
15
|
+
ax2 = fig.add_subplot(132)
|
|
16
16
|
plotImage(during, **kwargs)
|
|
17
17
|
plt.title("In-transit")
|
|
18
18
|
|
|
19
|
-
fig.add_subplot(133)
|
|
19
|
+
ax3 = fig.add_subplot(133)
|
|
20
20
|
plotDiffImage(diff, **kwargs)
|
|
21
21
|
plt.title("Difference")
|
|
22
22
|
|
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
4
|
import warnings
|
|
5
|
-
|
|
5
|
+
from exovetter import lightkurve_utils
|
|
6
|
+
from exovetter import utils
|
|
7
|
+
from exovetter import const as exo_const
|
|
8
|
+
import astropy.units as u
|
|
9
|
+
from exovetter import vetters as vet
|
|
10
|
+
from matplotlib.backends.backend_pdf import PdfPages
|
|
11
|
+
import matplotlib.pyplot as plt
|
|
6
12
|
import numpy as np
|
|
13
|
+
import os
|
|
7
14
|
|
|
8
15
|
__all__ = ['sine', 'estimate_scatter', 'mark_transit_cadences', 'median_detrend',
|
|
9
16
|
'plateau', 'set_median_flux_to_zero', 'set_median_flux_to_one', 'sigmaClip',
|
|
10
|
-
'get_mast_tce', 'WqedLSF', 'compute_phases', 'first_epoch']
|
|
17
|
+
'get_mast_tce', 'WqedLSF', 'compute_phases', 'first_epoch', 'run_all']
|
|
11
18
|
|
|
12
19
|
def sine(x, order, period=1):
|
|
13
20
|
"""Sine function for SWEET vetter."""
|
|
@@ -653,3 +660,164 @@ def first_epoch(epoch, period, lc):
|
|
|
653
660
|
first_epoch = epoch + N*period
|
|
654
661
|
|
|
655
662
|
return first_epoch
|
|
663
|
+
|
|
664
|
+
def run_all(tce, lc, tpf=None, vetters=None, remove_metrics=None, plot=False, plot_dir=None):
|
|
665
|
+
"""Run a set of vetters on a tce and lc, returning a dictionary of all metrics collected
|
|
666
|
+
|
|
667
|
+
Parameters
|
|
668
|
+
----------
|
|
669
|
+
tce : tce object
|
|
670
|
+
tce object is a dictionary that contains information about the tce
|
|
671
|
+
to vet, like period, epoch, duration, depth
|
|
672
|
+
|
|
673
|
+
lc : lightkurve object
|
|
674
|
+
lightkurve object with the time and flux to use for vetting.
|
|
675
|
+
|
|
676
|
+
tpf : obj
|
|
677
|
+
``lightkurve`` target pixel file object with pixels in column lc_name
|
|
678
|
+
|
|
679
|
+
vetters : list
|
|
680
|
+
list of vetter objects to run on, ie [vet.ModShift(), vet.OddEven(dur_frac=0.75)]
|
|
681
|
+
Defaults to all vetters
|
|
682
|
+
|
|
683
|
+
remove_metrics : list
|
|
684
|
+
metrics to not store, defaults to removing plotting values
|
|
685
|
+
|
|
686
|
+
plot : bool
|
|
687
|
+
Option to return a pdf of the vetting diagnostic plots, defaults to False
|
|
688
|
+
|
|
689
|
+
plot_dir : str
|
|
690
|
+
Path to store diagnostic pdfs in, defaults to current working directory
|
|
691
|
+
|
|
692
|
+
Returns
|
|
693
|
+
-------
|
|
694
|
+
results_dict : dictionary
|
|
695
|
+
Dictionary of the kept vetting metrics
|
|
696
|
+
"""
|
|
697
|
+
|
|
698
|
+
# Set initial parameters
|
|
699
|
+
if not vetters:
|
|
700
|
+
vetters = [vet.VizTransits(), vet.ModShift(), vet.Lpp(), vet.OddEven(), vet.TransitPhaseCoverage(), vet.Sweet(), vet.LeoTransitEvents(), vet.Centroid()]
|
|
701
|
+
|
|
702
|
+
if not remove_metrics:
|
|
703
|
+
remove_metrics = ['plot_data']
|
|
704
|
+
|
|
705
|
+
if not plot_dir:
|
|
706
|
+
plot_dir = os.getcwd()+'/'
|
|
707
|
+
|
|
708
|
+
if not tpf:
|
|
709
|
+
if any(vetter.__class__.__name__ == 'Centroid' for vetter in vetters):
|
|
710
|
+
raise Exception("TPF file required while running centroid")
|
|
711
|
+
|
|
712
|
+
# Run all listed vetters
|
|
713
|
+
results_list = []
|
|
714
|
+
|
|
715
|
+
if not plot:
|
|
716
|
+
for vetter in vetters:
|
|
717
|
+
if vetter.__class__.__name__ != 'Centroid':
|
|
718
|
+
vetter_results = vetter.run(tce, lc, plot=False) # dictionary returned from each vetter
|
|
719
|
+
results_list.append(vetter_results)
|
|
720
|
+
else:
|
|
721
|
+
vetter_results = vetter.run(tce, tpf, plot=False) # centroid uses tpf rather than lc
|
|
722
|
+
results_list.append(vetter_results)
|
|
723
|
+
|
|
724
|
+
else:
|
|
725
|
+
plot_name = lc.LABEL
|
|
726
|
+
|
|
727
|
+
diagnostic_plot = PdfPages(plot_dir+plot_name+'.pdf') # initialize a pdf to save each figure into
|
|
728
|
+
plot_figures = []
|
|
729
|
+
|
|
730
|
+
# Manually run viz transits with an extra mark cadences plot
|
|
731
|
+
cadences_plot = mark_cadences_plot(lc, tce)
|
|
732
|
+
diagnostic_plot.savefig(cadences_plot)
|
|
733
|
+
|
|
734
|
+
for vetter in vetters:
|
|
735
|
+
if vetter.__class__.__name__ not in ['VizTransits', 'Centroid', 'LeoTransitEvents']: # viz_transits and Centroid generate more than one figures so handle later
|
|
736
|
+
vetter_results = vetter.run(tce, lc, plot=True) # dictionary returned from each vetter
|
|
737
|
+
plot_figures.append(plt.gcf())
|
|
738
|
+
plt.close() # Make them not show up if running in a notebook
|
|
739
|
+
results_list.append(vetter_results)
|
|
740
|
+
|
|
741
|
+
if vetter.__class__.__name__ == 'Centroid': # centroid produces 2 plots, the second of which is the most useful so just collect that one
|
|
742
|
+
vetter_results = vet.Centroid(lc_name=vetter.lc_name, diff_plots=False, centroid_plots=True).run(tce, tpf)
|
|
743
|
+
plot_figures.append(plt.gcf())
|
|
744
|
+
plt.close()
|
|
745
|
+
results_list.append(vetter_results)
|
|
746
|
+
|
|
747
|
+
# run viz_transits plots
|
|
748
|
+
transit = vet.VizTransits(transit_plot=True, folded_plot=False).run(tce, lc)
|
|
749
|
+
transit_plot = plt.gcf()
|
|
750
|
+
transit_plot.suptitle(plot_name+' Transits')
|
|
751
|
+
transit_plot.tight_layout()
|
|
752
|
+
plt.close()
|
|
753
|
+
diagnostic_plot.savefig(transit_plot)
|
|
754
|
+
|
|
755
|
+
folded = vet.VizTransits(transit_plot=False, folded_plot=True).run(tce, lc)
|
|
756
|
+
folded_plot = plt.gcf()
|
|
757
|
+
folded_plot.suptitle(plot_name+' Folded Transits')
|
|
758
|
+
folded_plot.tight_layout()
|
|
759
|
+
plt.close()
|
|
760
|
+
diagnostic_plot.savefig(folded_plot)
|
|
761
|
+
|
|
762
|
+
# Save each diagnostic plot stored in plot_figures to diagnostic_plot pdf file
|
|
763
|
+
for plot in plot_figures:
|
|
764
|
+
diagnostic_plot.savefig(plot)
|
|
765
|
+
|
|
766
|
+
diagnostic_plot.close()
|
|
767
|
+
|
|
768
|
+
# Convert to a single dictionary output
|
|
769
|
+
results_dict = {k: v for d in results_list for k, v in d.items()} # Combine all dictionaries returned from vetters
|
|
770
|
+
|
|
771
|
+
# delete specified metrics
|
|
772
|
+
for key in remove_metrics:
|
|
773
|
+
if results_dict.get(key):
|
|
774
|
+
del results_dict[key]
|
|
775
|
+
|
|
776
|
+
return results_dict
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
def mark_cadences_plot(lc, tce):
|
|
780
|
+
"""return figure object of the lightcurve with epochs oeverplotted"""
|
|
781
|
+
|
|
782
|
+
fig, ax1 = plt.subplots(nrows=1, ncols=1, figsize=(9,5))
|
|
783
|
+
|
|
784
|
+
# Get lightcurve data
|
|
785
|
+
time, flux, time_offset_str = lightkurve_utils.unpack_lk_version(lc, "flux") # noqa: E50
|
|
786
|
+
time_offset_q = getattr(exo_const, time_offset_str)
|
|
787
|
+
epoch = tce.get_epoch(time_offset_q).to_value(u.day)
|
|
788
|
+
|
|
789
|
+
# Get points of lightcurve found to be in transit
|
|
790
|
+
period = tce["period"].to_value(u.day)
|
|
791
|
+
dur = tce["duration"].to_value(u.day)
|
|
792
|
+
intransit = mark_transit_cadences(time, period, epoch, dur)
|
|
793
|
+
|
|
794
|
+
# Plot epoch
|
|
795
|
+
ax1.axvline(x=epoch, lw='0.6', color='r', label='epoch', alpha=0.5)
|
|
796
|
+
|
|
797
|
+
# Plot transit train
|
|
798
|
+
ax1.plot(time, flux, lw=0.72, alpha=0.9)
|
|
799
|
+
ax1.scatter(time, flux, color='k', s=3, label='cadences', alpha=0.5)
|
|
800
|
+
|
|
801
|
+
# TODO This only plots forward in time from the epoch, works fine assuming tce epoch is first in light curve but not robust
|
|
802
|
+
transit_epochs = epoch-dur/2
|
|
803
|
+
while transit_epochs <= time[-1]:
|
|
804
|
+
ax1.axvline(x=transit_epochs, lw='0.6', color='r', alpha=0.3, ls='--')
|
|
805
|
+
transit_epochs = transit_epochs+dur
|
|
806
|
+
ax1.axvline(x=transit_epochs, lw='0.6', color='r', alpha=0.3, ls='--')
|
|
807
|
+
transit_epochs = transit_epochs-dur + period
|
|
808
|
+
|
|
809
|
+
# Plot cadences in transit
|
|
810
|
+
ax1.scatter(time[intransit], flux[intransit], color='r', s=4, label='cadences in transit');
|
|
811
|
+
|
|
812
|
+
# Plotting params
|
|
813
|
+
ax1.set_ylabel('Flux')
|
|
814
|
+
ax1.set_xlabel('Time '+time_offset_str)
|
|
815
|
+
ax1.set_title(lc.label+' period='+'{0:.2f}'.format(period)+'d, dur='+'{0:.2f}'.format(dur)+'d')
|
|
816
|
+
ax1.legend();
|
|
817
|
+
|
|
818
|
+
cadences_plot = plt.gcf()
|
|
819
|
+
plt.close()
|
|
820
|
+
|
|
821
|
+
return cadences_plot
|
|
822
|
+
|
|
823
|
+
|