exovetter 0.0.5__tar.gz → 0.0.7__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.5 → exovetter-0.0.7}/PKG-INFO +1 -1
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/utils.py +170 -2
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/version.py +1 -1
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/vetters.py +180 -118
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter.egg-info/PKG-INFO +1 -1
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter.egg-info/SOURCES.txt +2 -6
- exovetter-0.0.7/tutorial_notebooks/100100827.pdf +0 -0
- exovetter-0.0.7/tutorial_notebooks/run_all.ipynb +372 -0
- exovetter-0.0.5/tutorial_notebooks/run_all.ipynb +0 -1513
- exovetter-0.0.5/tutorial_notebooks/run_all_plots/TOI_1000.01.pdf +0 -0
- exovetter-0.0.5/tutorial_notebooks/run_all_plots/TOI_1001.01.pdf +0 -0
- exovetter-0.0.5/tutorial_notebooks/run_all_plots/TOI_1004.01.pdf +0 -0
- exovetter-0.0.5/tutorial_notebooks/run_all_plots/TOI_1007.01.pdf +0 -0
- exovetter-0.0.5/tutorial_notebooks/run_all_plots/TOI_1011.01.pdf +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/.bandit.yaml +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/.github/workflows/ci_workflows.yml +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/.github/workflows/publish.yml +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/.gitignore +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/.readthedocs.yml +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/CHANGES.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/LICENSE.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/MANIFEST.in +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/README.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/Makefile +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/conf.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/index.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/install.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/make.bat +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/utils.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/vetters.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/docs/vetters_low_level.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/__init__.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/centroid/__init__.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/centroid/centroid.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/centroid/covar.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/centroid/disp.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/centroid/fastpsffit.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/const.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/leo.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/lightkurve_utils.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/lpp.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/model.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/modshift/__init__.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/modshift/modshift.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/modshift/plotmodshift.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/odd_even.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/sweet.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/tce.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/transit_coverage.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/trapezoid_fit.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter/viz_transits.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter.egg-info/dependency_links.txt +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter.egg-info/not-zip-safe +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter.egg-info/requires.txt +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/exovetter.egg-info/top_level.txt +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/licenses/DAVE_LICENSE +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/licenses/README.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/licenses/TEMPLATE_LICENCE.rst +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/pyproject.toml +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/requirements.txt +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/setup.cfg +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/setup.py +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/Centroid.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/LPP.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/LeoTransitEvents.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/OddEven.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/SWEET.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/TCEs.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/TransitPhaseCoverage.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/VizTransits.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/lightcurves.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/modshift.ipynb +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/wasp18b.fits +0 -0
- {exovetter-0.0.5 → exovetter-0.0.7}/tutorial_notebooks/wasp18b_tce +0 -0
|
@@ -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
|
+
|
|
@@ -6,10 +6,10 @@ from abc import ABC, abstractmethod
|
|
|
6
6
|
import astropy.units as u
|
|
7
7
|
import numpy as np
|
|
8
8
|
import pandas as pd
|
|
9
|
-
import time as py_time
|
|
9
|
+
# import time as py_time
|
|
10
10
|
import os
|
|
11
|
-
import matplotlib.pyplot as plt
|
|
12
|
-
from matplotlib.backends.backend_pdf import PdfPages
|
|
11
|
+
# import matplotlib.pyplot as plt
|
|
12
|
+
# from matplotlib.backends.backend_pdf import PdfPages
|
|
13
13
|
|
|
14
14
|
from exovetter.centroid import centroid as cent
|
|
15
15
|
from exovetter import transit_coverage
|
|
@@ -26,7 +26,7 @@ from exovetter import leo
|
|
|
26
26
|
|
|
27
27
|
__all__ = ['BaseVetter', 'ModShift', 'Lpp', 'OddEven',
|
|
28
28
|
'TransitPhaseCoverage', 'Sweet', 'Centroid',
|
|
29
|
-
'VizTransits', 'LeoTransitEvents'
|
|
29
|
+
'VizTransits', 'LeoTransitEvents']
|
|
30
30
|
|
|
31
31
|
class BaseVetter(ABC):
|
|
32
32
|
"""Base class for vetters.
|
|
@@ -585,13 +585,19 @@ class Sweet(BaseVetter):
|
|
|
585
585
|
class Centroid(BaseVetter):
|
|
586
586
|
"""Class to handle centroid vetting"""
|
|
587
587
|
|
|
588
|
-
def __init__(self, lc_name="flux"):
|
|
588
|
+
def __init__(self, lc_name="flux", diff_plots=False, centroid_plots=False):
|
|
589
589
|
"""
|
|
590
590
|
Parameters
|
|
591
591
|
----------
|
|
592
592
|
lc_name : str
|
|
593
593
|
Name of the flux array in the ``lightkurve`` object.
|
|
594
594
|
|
|
595
|
+
diff_plots : bool
|
|
596
|
+
Show centroid difference plots
|
|
597
|
+
|
|
598
|
+
centroid_plots : bool
|
|
599
|
+
Show centroid summary plot
|
|
600
|
+
|
|
595
601
|
Attributes
|
|
596
602
|
----------
|
|
597
603
|
tce : tce object
|
|
@@ -608,6 +614,8 @@ class Centroid(BaseVetter):
|
|
|
608
614
|
self.tce = None
|
|
609
615
|
self.tpf = None
|
|
610
616
|
self.metrics = None
|
|
617
|
+
self.diff_plots = diff_plots
|
|
618
|
+
self.centroid_plots = centroid_plots
|
|
611
619
|
|
|
612
620
|
def run(self, tce, lk_tpf, plot=False, remove_transits=None):
|
|
613
621
|
"""Runs cent.compute_diff_image_centroids and cent.measure_centroid_shift
|
|
@@ -642,6 +650,10 @@ class Centroid(BaseVetter):
|
|
|
642
650
|
self.tce = tce
|
|
643
651
|
self.tpf = lk_tpf
|
|
644
652
|
|
|
653
|
+
if plot:
|
|
654
|
+
self.diff_plots = True
|
|
655
|
+
self.centroid_plots = True
|
|
656
|
+
|
|
645
657
|
time, cube, time_offset_str = lightkurve_utils.unpack_tpf(
|
|
646
658
|
self.tpf, self.lc_name
|
|
647
659
|
) # noqa: E50
|
|
@@ -656,9 +668,9 @@ class Centroid(BaseVetter):
|
|
|
656
668
|
|
|
657
669
|
centroids, figs, kept_transits = cent.compute_diff_image_centroids(
|
|
658
670
|
time, cube, period_days, epoch, duration_days,
|
|
659
|
-
remove_transits, plot=
|
|
671
|
+
remove_transits, plot=self.diff_plots)
|
|
660
672
|
|
|
661
|
-
offset, signif, fig = cent.measure_centroid_shift(centroids, kept_transits,
|
|
673
|
+
offset, signif, fig = cent.measure_centroid_shift(centroids, kept_transits, self.centroid_plots)
|
|
662
674
|
figs.append(fig)
|
|
663
675
|
|
|
664
676
|
# TODO: If plot=True, figs is a list of figure handles.
|
|
@@ -901,17 +913,14 @@ class LeoTransitEvents(BaseVetter):
|
|
|
901
913
|
def plot(self):
|
|
902
914
|
pass
|
|
903
915
|
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
# TODO Add centroid, maybe rething plotting in general since plotting uses vetter.plot which essentially doubles runtime,
|
|
907
|
-
# probably should run initially with vet.run(plot=True) and not store them unless run_all plot=True
|
|
908
|
-
"""Runs vetters and packs results into a dataframe.
|
|
916
|
+
def run_all(tce, lc, vetters=[VizTransits(), ModShift(), Lpp(), OddEven(), TransitPhaseCoverage(), Sweet(), LeoTransitEvents()], remove_metrics = ['plot_data'], plot=False, plot_dir='', plot_name=None ,verbose=False):
|
|
917
|
+
"""Runs vetters on a tce and lc and packs results into a dictionary.
|
|
909
918
|
|
|
910
919
|
Parameters
|
|
911
920
|
----------
|
|
912
|
-
tces:
|
|
921
|
+
tces: tce object to vet on
|
|
913
922
|
|
|
914
|
-
lc:
|
|
923
|
+
lc: lightkurve object to vet on
|
|
915
924
|
|
|
916
925
|
vetters : list
|
|
917
926
|
List of vetter classes to run
|
|
@@ -919,127 +928,180 @@ def run_all(tces, lcs, vetters=[VizTransits(), ModShift(), Lpp(), OddEven(), Tra
|
|
|
919
928
|
plot : bool
|
|
920
929
|
Toggle diagnostic plots
|
|
921
930
|
|
|
922
|
-
plot_dir : str
|
|
923
|
-
path to store plots in, defaults to current working directory
|
|
924
|
-
|
|
925
931
|
verbose : bool
|
|
926
932
|
Toggle timing info and other print statements
|
|
927
933
|
|
|
928
934
|
Returns
|
|
929
935
|
------------
|
|
930
|
-
results :
|
|
931
|
-
|
|
936
|
+
results : dictionary
|
|
937
|
+
Dictionary of all the numerical results from the vetters
|
|
932
938
|
|
|
933
939
|
"""
|
|
934
940
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
941
|
+
results = run_vetters.run_all(tce, lc, vetters, remove_metrics, plot, plot_dir, plot_name, verbose)
|
|
942
|
+
|
|
943
|
+
return results
|
|
944
|
+
|
|
945
|
+
# results_list = []
|
|
946
|
+
|
|
947
|
+
# if plot == False:
|
|
948
|
+
# for vetter in vetters:
|
|
949
|
+
# vetter_results = vetter.run(tce, lc, plot=False) # dictionary returned from each vetter
|
|
950
|
+
# results_list.append(vetter_results)
|
|
951
|
+
|
|
952
|
+
# else:
|
|
953
|
+
#
|
|
954
|
+
# if plot_name is None:
|
|
955
|
+
# plot_name = tce['target']
|
|
956
|
+
# diagnostic_plot = PdfPages(plot_dir+plot_name+'.pdf') # initialize a pdf to save each figure into
|
|
957
|
+
# plot_figures = []
|
|
958
|
+
|
|
959
|
+
# for vetter in vetters:
|
|
960
|
+
# vetter_results = vetter.run(tce, lc, plot=True)
|
|
961
|
+
# plot_figures.append(plt.gcf())
|
|
962
|
+
# plt.close()
|
|
963
|
+
# results_list.append(vetter_results)
|
|
964
|
+
|
|
965
|
+
# # Save each diagnostic plot ran on that tce/lc
|
|
966
|
+
# for plot in plot_figures:
|
|
967
|
+
# diagnostic_plot.savefig(plot)
|
|
968
|
+
|
|
969
|
+
# diagnostic_plot.close()
|
|
970
|
+
|
|
971
|
+
# results_dict = {k: v for d in results_list for k, v in d.items()}
|
|
972
|
+
|
|
973
|
+
# # delete dictionary entries that are huge arrays to save space
|
|
974
|
+
# for key in remove_metrics:
|
|
975
|
+
# if results_dict.get(key):
|
|
976
|
+
# del results_dict[key]
|
|
977
|
+
|
|
978
|
+
# return results_dict
|
|
979
|
+
|
|
980
|
+
# OLDER CODE
|
|
981
|
+
# if plot:
|
|
982
|
+
# if vetter.__class__.__name__ != 'VizTransits' and vetter.__class__.__name__ != 'LeoTransitEvents':
|
|
983
|
+
# # viz_transits generates 2 figures so it's handled later, LeoTransitEvents just doesn't have a plot
|
|
984
|
+
# vetter.plot()
|
|
985
|
+
# vetter_plot = plt.gcf()
|
|
986
|
+
# vetter_plot.suptitle(tce['target']+' '+vetter.__class__.__name__)
|
|
987
|
+
# vetter_plot.tight_layout()
|
|
988
|
+
# plt.close()
|
|
989
|
+
# plot_figures.append(vetter_plot)
|
|
990
|
+
|
|
991
|
+
# if verbose:
|
|
992
|
+
# time_end = py_time.time()
|
|
993
|
+
# print(vetter.__class__.__name__, 'finished in', time_end - time_start, 's.')
|
|
994
|
+
|
|
995
|
+
# results_list.append(vetter_results)
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
# results_dicts = [] # initialize a list to pack results from each tce into
|
|
999
|
+
# tce_names = []
|
|
1000
|
+
# run_start = py_time.time()
|
|
938
1001
|
|
|
939
|
-
if plot_dir is None:
|
|
940
|
-
|
|
1002
|
+
# if plot_dir is None:
|
|
1003
|
+
# plot_dir = os.getcwd()
|
|
941
1004
|
|
|
942
|
-
if plot or verbose:
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
for tce, lc in zip(tces, lcs):
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1005
|
+
# if plot or verbose:
|
|
1006
|
+
# for tce in tces:
|
|
1007
|
+
# if 'target' not in tce.keys():
|
|
1008
|
+
# print("ERROR: Please supply a 'target' key to all input tces to use the plot or verbose parameters")
|
|
1009
|
+
# return
|
|
1010
|
+
|
|
1011
|
+
# for tce, lc in zip(tces, lcs):
|
|
1012
|
+
# if verbose:
|
|
1013
|
+
# print('Vetting', tce['target'], ':')
|
|
1014
|
+
|
|
1015
|
+
# tce_names.append(tce['target'])
|
|
1016
|
+
# results_list = [] # initialize a list to pack result dictionaries into
|
|
954
1017
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1018
|
+
# # run each vetter, if plotting is true fill the figures into a list to save later
|
|
1019
|
+
# plot_figures = []
|
|
1020
|
+
# for vetter in vetters:
|
|
1021
|
+
# time_start = py_time.time()
|
|
1022
|
+
# vetter_results = vetter.run(tce, lc)
|
|
960
1023
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1024
|
+
# if plot:
|
|
1025
|
+
# if vetter.__class__.__name__ != 'VizTransits' and vetter.__class__.__name__ != 'LeoTransitEvents':
|
|
1026
|
+
# # viz_transits generates 2 figures so it's handled later, LeoTransitEvents just doesn't have a plot
|
|
1027
|
+
# vetter.plot()
|
|
1028
|
+
# vetter_plot = plt.gcf()
|
|
1029
|
+
# vetter_plot.suptitle(tce['target']+' '+vetter.__class__.__name__)
|
|
1030
|
+
# vetter_plot.tight_layout()
|
|
1031
|
+
# plt.close()
|
|
1032
|
+
# plot_figures.append(vetter_plot)
|
|
1033
|
+
|
|
1034
|
+
# if verbose:
|
|
1035
|
+
# time_end = py_time.time()
|
|
1036
|
+
# print(vetter.__class__.__name__, 'finished in', time_end - time_start, 's.')
|
|
974
1037
|
|
|
975
|
-
|
|
1038
|
+
# results_list.append(vetter_results)
|
|
976
1039
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1040
|
+
# if verbose: # add some whitespace for readability
|
|
1041
|
+
# print()
|
|
1042
|
+
|
|
1043
|
+
# if plot: # save a pdf of each figure made for that vetter
|
|
1044
|
+
# diagnostic_plot = PdfPages(plot_dir+tce['target']+'.pdf') # initialize a pdf to save each figure into
|
|
1045
|
+
|
|
1046
|
+
# # plot the lightcurve with epochs oeverplotted
|
|
1047
|
+
# time, flux, time_offset_str = lightkurve_utils.unpack_lk_version(lc, "flux") # noqa: E50
|
|
1048
|
+
# period = tce["period"].to_value(u.day)
|
|
1049
|
+
# dur = tce["duration"].to_value(u.day)
|
|
1050
|
+
|
|
1051
|
+
# time_offset_q = getattr(exo_const, time_offset_str)
|
|
1052
|
+
# epoch = tce.get_epoch(time_offset_q).to_value(u.day)
|
|
1053
|
+
# intransit = utils.mark_transit_cadences(time, period, epoch, dur, num_durations=3, flags=None)
|
|
1054
|
+
|
|
1055
|
+
# fig, ax1 = plt.subplots(nrows=1, ncols=1, figsize=(9,5))
|
|
1056
|
+
# ax1.plot(time, flux, lw=0.4);
|
|
1057
|
+
# ax1.axvline(x=epoch, lw='0.6', color='r', label='epoch');
|
|
1058
|
+
# ax1.fill_between(time, 0,1, where=intransit, transform=ax1.get_xaxis_transform(), color='r', alpha=0.15, label='in transit')
|
|
1059
|
+
|
|
1060
|
+
# ax1.set_ylabel('Flux')
|
|
1061
|
+
# ax1.set_xlabel('Time '+time_offset_str)
|
|
1062
|
+
# if 'target' in tce:
|
|
1063
|
+
# ax1.set_title(tce['target']);
|
|
1064
|
+
|
|
1065
|
+
# ax1.legend();
|
|
1066
|
+
# lightcurve_plot = plt.gcf()
|
|
1067
|
+
# plt.close()
|
|
1068
|
+
# diagnostic_plot.savefig(lightcurve_plot)
|
|
1069
|
+
|
|
1070
|
+
# # run viz_transits plots
|
|
1071
|
+
# transit = VizTransits(transit_plot=True, folded_plot=False).run(tce, lc)
|
|
1072
|
+
# transit_plot = plt.gcf()
|
|
1073
|
+
# transit_plot.suptitle(tce['target']+' Transits')
|
|
1074
|
+
# transit_plot.tight_layout()
|
|
1075
|
+
# plt.close()
|
|
1076
|
+
# diagnostic_plot.savefig(transit_plot)
|
|
1077
|
+
|
|
1078
|
+
# folded = VizTransits(transit_plot=False, folded_plot=True).run(tce, lc)
|
|
1079
|
+
# folded_plot = plt.gcf()
|
|
1080
|
+
# folded_plot.suptitle(tce['target']+' Folded Transits')
|
|
1081
|
+
# folded_plot.tight_layout()
|
|
1082
|
+
# plt.close()
|
|
1083
|
+
# diagnostic_plot.savefig(folded_plot)
|
|
1084
|
+
|
|
1085
|
+
# # Save each diagnostic plot ran on that tce/lc
|
|
1086
|
+
# for plot in plot_figures:
|
|
1087
|
+
# diagnostic_plot.savefig(plot)
|
|
1088
|
+
|
|
1089
|
+
# diagnostic_plot.close()
|
|
1027
1090
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1091
|
+
# # put all values from each results dictionary into a single dictionary
|
|
1092
|
+
# results_dict = {k: v for d in results_list for k, v in d.items()}
|
|
1030
1093
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1094
|
+
# # delete dictionary entries that are huge arrays to save space
|
|
1095
|
+
# if results_dict.get('plot_data'):
|
|
1096
|
+
# del results_dict['plot_data']
|
|
1034
1097
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1098
|
+
# # add the dictionary to the final list
|
|
1099
|
+
# results_dicts.append(results_dict)
|
|
1037
1100
|
|
|
1038
|
-
results_df = pd.DataFrame(results_dicts) # Put the values from each result dictionary into a dataframe
|
|
1101
|
+
# results_df = pd.DataFrame(results_dicts) # Put the values from each result dictionary into a dataframe
|
|
1039
1102
|
|
|
1040
|
-
results_df.insert(loc=0, column='tce', value=tce_names)
|
|
1041
|
-
if verbose:
|
|
1042
|
-
|
|
1103
|
+
# results_df.insert(loc=0, column='tce', value=tce_names)
|
|
1104
|
+
# if verbose:
|
|
1105
|
+
# print('Execution time:', (py_time.time() - run_start), 's')
|
|
1043
1106
|
|
|
1044
|
-
return results_df
|
|
1045
|
-
|
|
1107
|
+
# return results_df
|
|
@@ -51,6 +51,7 @@ exovetter/modshift/plotmodshift.py
|
|
|
51
51
|
licenses/DAVE_LICENSE
|
|
52
52
|
licenses/README.rst
|
|
53
53
|
licenses/TEMPLATE_LICENCE.rst
|
|
54
|
+
tutorial_notebooks/100100827.pdf
|
|
54
55
|
tutorial_notebooks/Centroid.ipynb
|
|
55
56
|
tutorial_notebooks/LPP.ipynb
|
|
56
57
|
tutorial_notebooks/LeoTransitEvents.ipynb
|
|
@@ -63,9 +64,4 @@ tutorial_notebooks/lightcurves.ipynb
|
|
|
63
64
|
tutorial_notebooks/modshift.ipynb
|
|
64
65
|
tutorial_notebooks/run_all.ipynb
|
|
65
66
|
tutorial_notebooks/wasp18b.fits
|
|
66
|
-
tutorial_notebooks/wasp18b_tce
|
|
67
|
-
tutorial_notebooks/run_all_plots/TOI_1000.01.pdf
|
|
68
|
-
tutorial_notebooks/run_all_plots/TOI_1001.01.pdf
|
|
69
|
-
tutorial_notebooks/run_all_plots/TOI_1004.01.pdf
|
|
70
|
-
tutorial_notebooks/run_all_plots/TOI_1007.01.pdf
|
|
71
|
-
tutorial_notebooks/run_all_plots/TOI_1011.01.pdf
|
|
67
|
+
tutorial_notebooks/wasp18b_tce
|
|
Binary file
|