exovetter 0.0.6__py3-none-any.whl → 0.0.8__py3-none-any.whl

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.
@@ -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
- figs = []
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, fig = measure_centroids(
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
- fig.suptitle('Transit '+str(i))
96
+ plt.gcf().suptitle('Transit '+str(i))
92
97
 
93
98
  centroids.append(cents)
94
- figs.append(fig)
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, figs, kept_transits
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
- disp.plotCentroidLocation(res[0], res[1], marker="^", color=clr,
214
- label="diff")
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
- res = ootSoln.x
217
- disp.plotCentroidLocation(res[0], res[1], marker="o", color=clr,
218
- label="OOT")
275
+ res1 = ootSoln.x
276
+ disp.plotCentroidLocation(res1[0], res1[1], marker="o", color=clr,
277
+ label="OOT")
219
278
 
220
- res = intransSoln.x
221
- disp.plotCentroidLocation(res[0], res[1], marker="+", color=clr,
222
- label="InT")
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
 
exovetter/utils.py CHANGED
@@ -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
+
exovetter/version.py CHANGED
@@ -5,4 +5,4 @@ try:
5
5
  from setuptools_scm import get_version
6
6
  version = get_version(root='..', relative_to=__file__)
7
7
  except Exception:
8
- version = '0.0.6'
8
+ version = '0.0.8'
exovetter/vetters.py CHANGED
@@ -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', 'run_all']
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, starloc_pix=None):
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,9 @@ 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
619
+ self.starloc_pix = starloc_pix
611
620
 
612
621
  def run(self, tce, lk_tpf, plot=False, remove_transits=None):
613
622
  """Runs cent.compute_diff_image_centroids and cent.measure_centroid_shift
@@ -642,6 +651,10 @@ class Centroid(BaseVetter):
642
651
  self.tce = tce
643
652
  self.tpf = lk_tpf
644
653
 
654
+ if plot:
655
+ self.diff_plots = True
656
+ self.centroid_plots = True
657
+
645
658
  time, cube, time_offset_str = lightkurve_utils.unpack_tpf(
646
659
  self.tpf, self.lc_name
647
660
  ) # noqa: E50
@@ -653,12 +666,16 @@ class Centroid(BaseVetter):
653
666
 
654
667
  if remove_transits is None: # reformat to be a blank list
655
668
  remove_transits = []
656
-
669
+
657
670
  centroids, figs, kept_transits = cent.compute_diff_image_centroids(
658
671
  time, cube, period_days, epoch, duration_days,
659
- remove_transits, plot=plot)
672
+ remove_transits, starloc_pix=self.starloc_pix, plot=self.diff_plots)
660
673
 
661
- offset, signif, fig = cent.measure_centroid_shift(centroids, kept_transits, plot)
674
+ if (self.starloc_pix is not None) and (len(self.starloc_pix) == 2):
675
+ offset, signif, fig = cent.measure_centroid_shift_cat(centroids, kept_transits, self.starloc_pix, self.centroid_plots)
676
+ else:
677
+ offset, signif, fig = cent.measure_centroid_shift(centroids, kept_transits, self.centroid_plots)
678
+
662
679
  figs.append(fig)
663
680
 
664
681
  # TODO: If plot=True, figs is a list of figure handles.
@@ -901,16 +918,14 @@ class LeoTransitEvents(BaseVetter):
901
918
  def plot(self):
902
919
  pass
903
920
 
904
- def run_all(tces, lcs, vetters=[VizTransits(), ModShift(), Lpp(), OddEven(), TransitPhaseCoverage(), Sweet(), LeoTransitEvents()], plot=False, verbose=False, plot_dir=None):
905
- # TODO Add centroid, maybe rething plotting in general since plotting uses vetter.plot which essentially doubles runtime,
906
- # probably should run initially with vet.run(plot=True) and not store them unless run_all plot=True
907
- """Runs vetters and packs results into a dataframe.
921
+ 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):
922
+ """Runs vetters on a tce and lc and packs results into a dictionary.
908
923
 
909
924
  Parameters
910
925
  ----------
911
- tces: list of tce objects to vet on
926
+ tces: tce object to vet on
912
927
 
913
- lc: list of lightkurve objects to vet on
928
+ lc: lightkurve object to vet on
914
929
 
915
930
  vetters : list
916
931
  List of vetter classes to run
@@ -918,126 +933,180 @@ def run_all(tces, lcs, vetters=[VizTransits(), ModShift(), Lpp(), OddEven(), Tra
918
933
  plot : bool
919
934
  Toggle diagnostic plots
920
935
 
921
- plot_dir : str
922
- path to store plots in, defaults to current working directory
923
-
924
936
  verbose : bool
925
937
  Toggle timing info and other print statements
926
938
 
927
939
  Returns
928
940
  ------------
929
- results : dataframe
930
- Pandas dataframe of all the numerical results from the vetters
941
+ results : dictionary
942
+ Dictionary of all the numerical results from the vetters
931
943
 
932
944
  """
933
945
 
934
- results_dicts = [] # initialize a list to pack results from each tce into
935
- tce_names = []
936
- run_start = py_time.time()
946
+ results = run_vetters.run_all(tce, lc, vetters, remove_metrics, plot, plot_dir, plot_name, verbose)
947
+
948
+ return results
949
+
950
+ # results_list = []
951
+
952
+ # if plot == False:
953
+ # for vetter in vetters:
954
+ # vetter_results = vetter.run(tce, lc, plot=False) # dictionary returned from each vetter
955
+ # results_list.append(vetter_results)
956
+
957
+ # else:
958
+ #
959
+ # if plot_name is None:
960
+ # plot_name = tce['target']
961
+ # diagnostic_plot = PdfPages(plot_dir+plot_name+'.pdf') # initialize a pdf to save each figure into
962
+ # plot_figures = []
963
+
964
+ # for vetter in vetters:
965
+ # vetter_results = vetter.run(tce, lc, plot=True)
966
+ # plot_figures.append(plt.gcf())
967
+ # plt.close()
968
+ # results_list.append(vetter_results)
969
+
970
+ # # Save each diagnostic plot ran on that tce/lc
971
+ # for plot in plot_figures:
972
+ # diagnostic_plot.savefig(plot)
973
+
974
+ # diagnostic_plot.close()
975
+
976
+ # results_dict = {k: v for d in results_list for k, v in d.items()}
977
+
978
+ # # delete dictionary entries that are huge arrays to save space
979
+ # for key in remove_metrics:
980
+ # if results_dict.get(key):
981
+ # del results_dict[key]
982
+
983
+ # return results_dict
984
+
985
+ # OLDER CODE
986
+ # if plot:
987
+ # if vetter.__class__.__name__ != 'VizTransits' and vetter.__class__.__name__ != 'LeoTransitEvents':
988
+ # # viz_transits generates 2 figures so it's handled later, LeoTransitEvents just doesn't have a plot
989
+ # vetter.plot()
990
+ # vetter_plot = plt.gcf()
991
+ # vetter_plot.suptitle(tce['target']+' '+vetter.__class__.__name__)
992
+ # vetter_plot.tight_layout()
993
+ # plt.close()
994
+ # plot_figures.append(vetter_plot)
995
+
996
+ # if verbose:
997
+ # time_end = py_time.time()
998
+ # print(vetter.__class__.__name__, 'finished in', time_end - time_start, 's.')
999
+
1000
+ # results_list.append(vetter_results)
1001
+
1002
+
1003
+ # results_dicts = [] # initialize a list to pack results from each tce into
1004
+ # tce_names = []
1005
+ # run_start = py_time.time()
937
1006
 
938
- if plot_dir is None:
939
- plot_dir = os.getcwd()
1007
+ # if plot_dir is None:
1008
+ # plot_dir = os.getcwd()
940
1009
 
941
- if plot or verbose:
942
- for tce in tces:
943
- if 'target' not in tce.keys():
944
- print("ERROR: Please supply a 'target' key to all input tces to use the plot or verbose parameters")
945
- return
946
-
947
- for tce, lc in zip(tces, lcs):
948
- if verbose:
949
- print('Vetting', tce['target'], ':')
950
-
951
- tce_names.append(tce['target'])
952
- results_list = [] # initialize a list to pack result dictionaries into
1010
+ # if plot or verbose:
1011
+ # for tce in tces:
1012
+ # if 'target' not in tce.keys():
1013
+ # print("ERROR: Please supply a 'target' key to all input tces to use the plot or verbose parameters")
1014
+ # return
1015
+
1016
+ # for tce, lc in zip(tces, lcs):
1017
+ # if verbose:
1018
+ # print('Vetting', tce['target'], ':')
1019
+
1020
+ # tce_names.append(tce['target'])
1021
+ # results_list = [] # initialize a list to pack result dictionaries into
953
1022
 
954
- # run each vetter, if plotting is true fill the figures into a list to save later
955
- plot_figures = []
956
- for vetter in vetters:
957
- time_start = py_time.time()
958
- vetter_results = vetter.run(tce, lc)
1023
+ # # run each vetter, if plotting is true fill the figures into a list to save later
1024
+ # plot_figures = []
1025
+ # for vetter in vetters:
1026
+ # time_start = py_time.time()
1027
+ # vetter_results = vetter.run(tce, lc)
959
1028
 
960
- if plot:
961
- if vetter.__class__.__name__ != 'VizTransits' and vetter.__class__.__name__ != 'LeoTransitEvents':
962
- # viz_transits generates 2 figures so it's handled later, LeoTransitEvents just doesn't have a plot
963
- vetter.plot()
964
- vetter_plot = plt.gcf()
965
- vetter_plot.suptitle(tce['target']+' '+vetter.__class__.__name__)
966
- vetter_plot.tight_layout()
967
- plt.close()
968
- plot_figures.append(vetter_plot)
969
-
970
- if verbose:
971
- time_end = py_time.time()
972
- print(vetter.__class__.__name__, 'finished in', time_end - time_start, 's.')
1029
+ # if plot:
1030
+ # if vetter.__class__.__name__ != 'VizTransits' and vetter.__class__.__name__ != 'LeoTransitEvents':
1031
+ # # viz_transits generates 2 figures so it's handled later, LeoTransitEvents just doesn't have a plot
1032
+ # vetter.plot()
1033
+ # vetter_plot = plt.gcf()
1034
+ # vetter_plot.suptitle(tce['target']+' '+vetter.__class__.__name__)
1035
+ # vetter_plot.tight_layout()
1036
+ # plt.close()
1037
+ # plot_figures.append(vetter_plot)
1038
+
1039
+ # if verbose:
1040
+ # time_end = py_time.time()
1041
+ # print(vetter.__class__.__name__, 'finished in', time_end - time_start, 's.')
973
1042
 
974
- results_list.append(vetter_results)
1043
+ # results_list.append(vetter_results)
975
1044
 
976
- if verbose: # add some whitespace for readability
977
- print()
978
-
979
- if plot: # save a pdf of each figure made for that vetter
980
- diagnostic_plot = PdfPages(plot_dir+tce['target']+'.pdf') # initialize a pdf to save each figure into
981
-
982
- # plot the lightcurve with epochs oeverplotted
983
- time, flux, time_offset_str = lightkurve_utils.unpack_lk_version(lc, "flux") # noqa: E50
984
- period = tce["period"].to_value(u.day)
985
- dur = tce["duration"].to_value(u.day)
986
-
987
- time_offset_q = getattr(exo_const, time_offset_str)
988
- epoch = tce.get_epoch(time_offset_q).to_value(u.day)
989
- intransit = utils.mark_transit_cadences(time, period, epoch, dur, num_durations=3, flags=None)
990
-
991
- fig, ax1 = plt.subplots(nrows=1, ncols=1, figsize=(9,5))
992
- ax1.plot(time, flux, lw=0.4);
993
- ax1.axvline(x=epoch, lw='0.6', color='r', label='epoch');
994
- ax1.fill_between(time, 0,1, where=intransit, transform=ax1.get_xaxis_transform(), color='r', alpha=0.15, label='in transit')
995
-
996
- ax1.set_ylabel('Flux')
997
- ax1.set_xlabel('Time '+time_offset_str)
998
- if 'target' in tce:
999
- ax1.set_title(tce['target']);
1000
-
1001
- ax1.legend();
1002
- lightcurve_plot = plt.gcf()
1003
- plt.close()
1004
- diagnostic_plot.savefig(lightcurve_plot)
1005
-
1006
- # run viz_transits plots
1007
- transit = VizTransits(transit_plot=True, folded_plot=False).run(tce, lc)
1008
- transit_plot = plt.gcf()
1009
- transit_plot.suptitle(tce['target']+' Transits')
1010
- transit_plot.tight_layout()
1011
- plt.close()
1012
- diagnostic_plot.savefig(transit_plot)
1013
-
1014
- folded = VizTransits(transit_plot=False, folded_plot=True).run(tce, lc)
1015
- folded_plot = plt.gcf()
1016
- folded_plot.suptitle(tce['target']+' Folded Transits')
1017
- folded_plot.tight_layout()
1018
- plt.close()
1019
- diagnostic_plot.savefig(folded_plot)
1020
-
1021
- # Save each diagnostic plot ran on that tce/lc
1022
- for plot in plot_figures:
1023
- diagnostic_plot.savefig(plot)
1024
-
1025
- diagnostic_plot.close()
1045
+ # if verbose: # add some whitespace for readability
1046
+ # print()
1047
+
1048
+ # if plot: # save a pdf of each figure made for that vetter
1049
+ # diagnostic_plot = PdfPages(plot_dir+tce['target']+'.pdf') # initialize a pdf to save each figure into
1050
+
1051
+ # # plot the lightcurve with epochs oeverplotted
1052
+ # time, flux, time_offset_str = lightkurve_utils.unpack_lk_version(lc, "flux") # noqa: E50
1053
+ # period = tce["period"].to_value(u.day)
1054
+ # dur = tce["duration"].to_value(u.day)
1055
+
1056
+ # time_offset_q = getattr(exo_const, time_offset_str)
1057
+ # epoch = tce.get_epoch(time_offset_q).to_value(u.day)
1058
+ # intransit = utils.mark_transit_cadences(time, period, epoch, dur, num_durations=3, flags=None)
1059
+
1060
+ # fig, ax1 = plt.subplots(nrows=1, ncols=1, figsize=(9,5))
1061
+ # ax1.plot(time, flux, lw=0.4);
1062
+ # ax1.axvline(x=epoch, lw='0.6', color='r', label='epoch');
1063
+ # ax1.fill_between(time, 0,1, where=intransit, transform=ax1.get_xaxis_transform(), color='r', alpha=0.15, label='in transit')
1064
+
1065
+ # ax1.set_ylabel('Flux')
1066
+ # ax1.set_xlabel('Time '+time_offset_str)
1067
+ # if 'target' in tce:
1068
+ # ax1.set_title(tce['target']);
1069
+
1070
+ # ax1.legend();
1071
+ # lightcurve_plot = plt.gcf()
1072
+ # plt.close()
1073
+ # diagnostic_plot.savefig(lightcurve_plot)
1074
+
1075
+ # # run viz_transits plots
1076
+ # transit = VizTransits(transit_plot=True, folded_plot=False).run(tce, lc)
1077
+ # transit_plot = plt.gcf()
1078
+ # transit_plot.suptitle(tce['target']+' Transits')
1079
+ # transit_plot.tight_layout()
1080
+ # plt.close()
1081
+ # diagnostic_plot.savefig(transit_plot)
1082
+
1083
+ # folded = VizTransits(transit_plot=False, folded_plot=True).run(tce, lc)
1084
+ # folded_plot = plt.gcf()
1085
+ # folded_plot.suptitle(tce['target']+' Folded Transits')
1086
+ # folded_plot.tight_layout()
1087
+ # plt.close()
1088
+ # diagnostic_plot.savefig(folded_plot)
1089
+
1090
+ # # Save each diagnostic plot ran on that tce/lc
1091
+ # for plot in plot_figures:
1092
+ # diagnostic_plot.savefig(plot)
1093
+
1094
+ # diagnostic_plot.close()
1026
1095
 
1027
- # put all values from each results dictionary into a single dictionary
1028
- results_dict = {k: v for d in results_list for k, v in d.items()}
1096
+ # # put all values from each results dictionary into a single dictionary
1097
+ # results_dict = {k: v for d in results_list for k, v in d.items()}
1029
1098
 
1030
- # delete dictionary entries that are huge arrays to save space
1031
- if results_dict.get('plot_data'):
1032
- del results_dict['plot_data']
1099
+ # # delete dictionary entries that are huge arrays to save space
1100
+ # if results_dict.get('plot_data'):
1101
+ # del results_dict['plot_data']
1033
1102
 
1034
- # add the dictionary to the final list
1035
- results_dicts.append(results_dict)
1103
+ # # add the dictionary to the final list
1104
+ # results_dicts.append(results_dict)
1036
1105
 
1037
- results_df = pd.DataFrame(results_dicts) # Put the values from each result dictionary into a dataframe
1106
+ # results_df = pd.DataFrame(results_dicts) # Put the values from each result dictionary into a dataframe
1038
1107
 
1039
- results_df.insert(loc=0, column='tce', value=tce_names)
1040
- if verbose:
1041
- print('Execution time:', (py_time.time() - run_start), 's')
1108
+ # results_df.insert(loc=0, column='tce', value=tce_names)
1109
+ # if verbose:
1110
+ # print('Execution time:', (py_time.time() - run_start), 's')
1042
1111
 
1043
- return results_df
1112
+ # return results_df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: exovetter
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Exoplanet vetting package
5
5
  Home-page: https://github.com/spacetelescope/exovetter
6
6
  Author: Susan Mullally et al.
@@ -9,20 +9,20 @@ exovetter/sweet.py,sha256=prbuteEaahFWhAoCtQCVP47SbA6h4pYJn1Wn9JkEalc,3066
9
9
  exovetter/tce.py,sha256=5JFKkbKoKCtdhm5EuW6FMAvp0LiaHLuqpFUbY0joyLI,7302
10
10
  exovetter/transit_coverage.py,sha256=Wix6TaQmEgRxlEZKB6WF3OFQVXqtJN1tBkltFaMDrHM,2194
11
11
  exovetter/trapezoid_fit.py,sha256=Dok-H0zRsfigh4zfVO4R6Wi2TgK6hQXh4EIIYGouxiQ,31097
12
- exovetter/utils.py,sha256=4HNRJkzgHI9XlRYvPSLZqJIQMG8ihX0UujSSTpiRTvU,18430
13
- exovetter/version.py,sha256=EnOl1cJ7hjy3aYox8oAzHbnkOWXlNbTHGaVr_NVNfR0,337
14
- exovetter/vetters.py,sha256=MRQjRR-PDXuPfGk5Z0DuW4muOpTsp6ygp47lGpnChZ8,35132
12
+ exovetter/utils.py,sha256=1K34N6sQ7iomf4oFHyqGubcDhNwTa2lF_uKEOGJGrCk,24909
13
+ exovetter/version.py,sha256=CNeb6A0ENE0jLt2wd0GA-qc99gr3KYBjtMQVwKtJGN0,337
14
+ exovetter/vetters.py,sha256=muqjSzFRs5gCrOV1OAjnTd2y7y_dU9hWJfKpqUK_9RY,37732
15
15
  exovetter/viz_transits.py,sha256=FUc8DEedaQQ8YDoeVvR1QyGPmh2oPGmVg27W3WrVguQ,5648
16
16
  exovetter/centroid/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
17
- exovetter/centroid/centroid.py,sha256=LWqjn-Oerdw5j2wDCFYqB6omE4K9gckIwAA0-WZvgkY,8655
17
+ exovetter/centroid/centroid.py,sha256=tNT1ZEQqN1t1Sijn9hJYjGQYCnguVE9iJp2MlL-vWN8,10785
18
18
  exovetter/centroid/covar.py,sha256=suSgPjOVVEOclIi7rnhqc7wBbcSVsPOrdad91NXjX3Y,8973
19
- exovetter/centroid/disp.py,sha256=scVCRj16mNSqugHY28_uLt5bOkcdumIlJeFG3BXfldU,3674
19
+ exovetter/centroid/disp.py,sha256=Y7UeecpHuhzEyNb6F6_FoureXdIttongS_L4jbdNYgE,3692
20
20
  exovetter/centroid/fastpsffit.py,sha256=eRMxYUJ_4hsCxso4u1d1zQvFSJQlJ_gRzhNa2PXkKuE,4532
21
21
  exovetter/modshift/__init__.py,sha256=j5665q0RHVzbzdPBXv_jUozGB4sex8ANXtzB41EYzRQ,68
22
22
  exovetter/modshift/modshift.py,sha256=VEnj7ITvYRfqICyRiNeCZ9tqQ4d4fPOw8avB6TTbhIU,14773
23
23
  exovetter/modshift/plotmodshift.py,sha256=MMLkvxkOqBGIYGPN97_WtrHgTZsDzY_XRRNswhz5YQI,2452
24
- exovetter-0.0.6.dist-info/LICENSE.rst,sha256=uhiFz7eEG8WszLtRtYIT89FNMI3ijy1aACnvl5BOz2Y,1492
25
- exovetter-0.0.6.dist-info/METADATA,sha256=ionvGOGowwq37EvLogal4vsPZ46y5oKK4SxQOEvgTW0,3706
26
- exovetter-0.0.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
27
- exovetter-0.0.6.dist-info/top_level.txt,sha256=wh0_U5IPEspONX8zhGRaFUqfuovCGkgYjAmWuQe0w6Q,10
28
- exovetter-0.0.6.dist-info/RECORD,,
24
+ exovetter-0.0.8.dist-info/LICENSE.rst,sha256=uhiFz7eEG8WszLtRtYIT89FNMI3ijy1aACnvl5BOz2Y,1492
25
+ exovetter-0.0.8.dist-info/METADATA,sha256=rz9jh06oK8QeTWjgvsHYteiZRucjVbEsGnnQ7AUds7s,3706
26
+ exovetter-0.0.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
+ exovetter-0.0.8.dist-info/top_level.txt,sha256=wh0_U5IPEspONX8zhGRaFUqfuovCGkgYjAmWuQe0w6Q,10
28
+ exovetter-0.0.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5