exovetter 0.0.2__tar.gz → 0.0.4__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.
Files changed (76) hide show
  1. {exovetter-0.0.2 → exovetter-0.0.4}/.github/workflows/ci_workflows.yml +12 -19
  2. exovetter-0.0.4/.readthedocs.yml +30 -0
  3. {exovetter-0.0.2 → exovetter-0.0.4}/PKG-INFO +16 -3
  4. {exovetter-0.0.2 → exovetter-0.0.4}/docs/utils.rst +0 -3
  5. exovetter-0.0.4/exovetter/centroid/__init__.py +1 -0
  6. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/centroid/centroid.py +29 -14
  7. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/centroid/covar.py +5 -3
  8. exovetter-0.0.4/exovetter/leo.py +227 -0
  9. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/lightkurve_utils.py +1 -1
  10. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/lpp.py +2 -1
  11. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/sweet.py +6 -3
  12. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/tce.py +6 -0
  13. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/trapezoid_fit.py +2 -1
  14. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/utils.py +58 -18
  15. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/version.py +1 -1
  16. exovetter-0.0.4/exovetter/vetters.py +955 -0
  17. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/viz_transits.py +17 -9
  18. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter.egg-info/PKG-INFO +16 -3
  19. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter.egg-info/SOURCES.txt +15 -8
  20. exovetter-0.0.4/pyproject.toml +5 -0
  21. exovetter-0.0.4/tutorial_notebooks/Centroid.ipynb +231 -0
  22. exovetter-0.0.4/tutorial_notebooks/LEO.ipynb +230 -0
  23. exovetter-0.0.4/tutorial_notebooks/LPP.ipynb +337 -0
  24. exovetter-0.0.4/tutorial_notebooks/OddEven.ipynb +248 -0
  25. exovetter-0.0.4/tutorial_notebooks/SWEET.ipynb +256 -0
  26. exovetter-0.0.4/tutorial_notebooks/TCEs.ipynb +356 -0
  27. exovetter-0.0.4/tutorial_notebooks/TransitPhaseCoverage.ipynb +246 -0
  28. exovetter-0.0.4/tutorial_notebooks/VizTransits.ipynb +225 -0
  29. exovetter-0.0.4/tutorial_notebooks/lightcurves.ipynb +446 -0
  30. exovetter-0.0.4/tutorial_notebooks/modshift.ipynb +289 -0
  31. exovetter-0.0.4/tutorial_notebooks/wasp18b.fits +0 -0
  32. exovetter-0.0.4/tutorial_notebooks/wasp18b_tce +1 -0
  33. exovetter-0.0.2/.readthedocs.yml +0 -21
  34. exovetter-0.0.2/example_notebooks/Centroid_Vetting_Example.ipynb +0 -789
  35. exovetter-0.0.2/example_notebooks/TCE_example.ipynb +0 -346
  36. exovetter-0.0.2/example_notebooks/Untitled.ipynb +0 -33
  37. exovetter-0.0.2/example_notebooks/trapezoid_fit_simple.ipynb +0 -351
  38. exovetter-0.0.2/exovetter/__init__.py.mine +0 -11
  39. exovetter-0.0.2/exovetter/centroid/untitled0.py +0 -24
  40. exovetter-0.0.2/exovetter/junk +0 -89
  41. exovetter-0.0.2/exovetter/vetters.py +0 -550
  42. exovetter-0.0.2/pyproject.toml +0 -14
  43. {exovetter-0.0.2 → exovetter-0.0.4}/.bandit.yaml +0 -0
  44. {exovetter-0.0.2 → exovetter-0.0.4}/.github/workflows/publish.yml +0 -0
  45. {exovetter-0.0.2 → exovetter-0.0.4}/.gitignore +0 -0
  46. {exovetter-0.0.2 → exovetter-0.0.4}/CHANGES.rst +0 -0
  47. {exovetter-0.0.2 → exovetter-0.0.4}/LICENSE.rst +0 -0
  48. {exovetter-0.0.2 → exovetter-0.0.4}/MANIFEST.in +0 -0
  49. {exovetter-0.0.2 → exovetter-0.0.4}/README.rst +0 -0
  50. {exovetter-0.0.2 → exovetter-0.0.4}/docs/Makefile +0 -0
  51. {exovetter-0.0.2 → exovetter-0.0.4}/docs/conf.py +0 -0
  52. {exovetter-0.0.2 → exovetter-0.0.4}/docs/index.rst +0 -0
  53. {exovetter-0.0.2 → exovetter-0.0.4}/docs/install.rst +0 -0
  54. {exovetter-0.0.2 → exovetter-0.0.4}/docs/make.bat +0 -0
  55. {exovetter-0.0.2 → exovetter-0.0.4}/docs/vetters.rst +0 -0
  56. {exovetter-0.0.2 → exovetter-0.0.4}/docs/vetters_low_level.rst +0 -0
  57. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/__init__.py +0 -0
  58. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/centroid/disp.py +0 -0
  59. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/centroid/fastpsffit.py +0 -0
  60. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/const.py +0 -0
  61. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/model.py +0 -0
  62. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/modshift/__init__.py +0 -0
  63. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/modshift/modshift.py +0 -0
  64. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/modshift/plotmodshift.py +0 -0
  65. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/odd_even.py +0 -0
  66. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter/transit_coverage.py +0 -0
  67. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter.egg-info/dependency_links.txt +0 -0
  68. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter.egg-info/not-zip-safe +0 -0
  69. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter.egg-info/requires.txt +0 -0
  70. {exovetter-0.0.2 → exovetter-0.0.4}/exovetter.egg-info/top_level.txt +0 -0
  71. {exovetter-0.0.2 → exovetter-0.0.4}/licenses/DAVE_LICENSE +0 -0
  72. {exovetter-0.0.2 → exovetter-0.0.4}/licenses/README.rst +0 -0
  73. {exovetter-0.0.2 → exovetter-0.0.4}/licenses/TEMPLATE_LICENCE.rst +0 -0
  74. {exovetter-0.0.2 → exovetter-0.0.4}/requirements.txt +0 -0
  75. {exovetter-0.0.2 → exovetter-0.0.4}/setup.cfg +0 -0
  76. {exovetter-0.0.2 → exovetter-0.0.4}/setup.py +0 -0
@@ -10,14 +10,12 @@ on:
10
10
 
11
11
  jobs:
12
12
  pep_and_audit:
13
- runs-on: ubuntu-16.04
13
+ runs-on: ubuntu-latest
14
14
  steps:
15
15
  - name: Checkout code
16
- uses: actions/checkout@v2
17
- - name: Fetch tags
18
- run: git fetch --prune --unshallow --tags
16
+ uses: actions/checkout@v4
19
17
  - name: Set up Python
20
- uses: actions/setup-python@v2
18
+ uses: actions/setup-python@v4
21
19
  with:
22
20
  python-version: '3.x'
23
21
  - name: Lint with pyflakes
@@ -36,38 +34,33 @@ jobs:
36
34
  # python -m pip install --upgrade bandit
37
35
  # bandit -r . -c .bandit.yaml
38
36
 
39
- # Python 3.7 + Numpy 1.19 resulted in NaN results, so we downgrade Numpy.
40
37
  initial_tests:
41
- runs-on: ubuntu-16.04
38
+ runs-on: ubuntu-latest
42
39
  steps:
43
40
  - name: Checkout code
44
- uses: actions/checkout@v2
45
- - name: Fetch tags
46
- run: git fetch --prune --unshallow --tags
41
+ uses: actions/checkout@v4
47
42
  - name: Set up Python
48
- uses: actions/setup-python@v2
43
+ uses: actions/setup-python@v4
49
44
  with:
50
- python-version: '3.7'
45
+ python-version: '3.11'
51
46
  - name: Install and build
52
47
  run: |
53
48
  sudo apt-get install libxml2-utils
54
49
  python -m pip install --upgrade pip setuptools
55
- python -m pip install 'numpy<1.19'
56
50
  python -m pip install -e .[test,all]
57
51
  - name: Test with stable deps and coverage
58
- run: pytest --cov=./ --cov-report=xml --remote-data
52
+ run: pytest --remote-data
53
+ # run: pytest --cov=./ --cov-report=xml --remote-data
59
54
  # - name: Coverage report
60
- # uses: codecov/codecov-action@v2
55
+ # uses: codecov/codecov-action@v3
61
56
 
62
57
  # dev_deps_tests:
63
58
  # runs-on: ubuntu-latest
64
59
  # steps:
65
60
  # - name: Checkout code
66
- # uses: actions/checkout@v2
67
- # - name: Fetch tags
68
- # run: git fetch --prune --unshallow --tags
61
+ # uses: actions/checkout@v4
69
62
  # - name: Set up Python
70
- # uses: actions/setup-python@v2
63
+ # uses: actions/setup-python@v4
71
64
  # with:
72
65
  # python-version: '3.x'
73
66
  # - name: Install and build
@@ -0,0 +1,30 @@
1
+ # Read the Docs configuration file for Sphinx projects
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version and other tools you might need
8
+ build:
9
+ os: ubuntu-22.04
10
+ apt_packages:
11
+ - graphviz
12
+ tools:
13
+ python: "3.11"
14
+
15
+ # Build documentation in the "docs/" directory with Sphinx
16
+ sphinx:
17
+ builder: html
18
+ configuration: docs/conf.py
19
+ fail_on_warning: true
20
+
21
+ python:
22
+ install:
23
+ - method: pip
24
+ path: .
25
+ extra_requirements:
26
+ - docs
27
+ - all
28
+
29
+ # Don't build any extra formats
30
+ formats: []
@@ -1,16 +1,29 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: exovetter
3
- Version: 0.0.2
4
- Summary: Transiting Exoplanet Vetting Package for TESS and Kepler
3
+ Version: 0.0.4
4
+ Summary: Exoplanet vetting package
5
5
  Home-page: https://github.com/spacetelescope/exovetter
6
6
  Author: Susan Mullally et al.
7
7
  Author-email: smullally@stsci.edu
8
+ License: BSD 3-Clause
8
9
  Requires-Python: >=3.7
9
10
  Description-Content-Type: text/x-rst
11
+ License-File: LICENSE.rst
12
+ Requires-Dist: numpy
13
+ Requires-Dist: astropy>=3
14
+ Requires-Dist: scipy
10
15
  Provides-Extra: all
16
+ Requires-Dist: matplotlib; extra == "all"
17
+ Requires-Dist: scikit-learn; extra == "all"
18
+ Requires-Dist: lightkurve>=2; extra == "all"
19
+ Requires-Dist: lpproj; extra == "all"
11
20
  Provides-Extra: test
21
+ Requires-Dist: pytest-cov; extra == "test"
22
+ Requires-Dist: pytest-remotedata; extra == "test"
23
+ Requires-Dist: pytest-doctestplus; extra == "test"
12
24
  Provides-Extra: docs
13
- License-File: LICENSE.rst
25
+ Requires-Dist: sphinx-astropy; extra == "docs"
26
+ Requires-Dist: sphinx_rtd_theme; extra == "docs"
14
27
 
15
28
  exovetter: Exoplanet Vetting
16
29
  ============================
@@ -13,9 +13,6 @@ These provide low-level functionality for ``exovetter``.
13
13
  .. automodapi:: exovetter.model
14
14
  :no-inheritance-diagram:
15
15
 
16
- .. automodapi:: exovetter.lcutils
17
- :no-inheritance-diagram:
18
-
19
16
  .. automodapi:: exovetter.lightkurve_utils
20
17
  :no-inheritance-diagram:
21
18
 
@@ -11,7 +11,8 @@ def compute_diff_image_centroids(
11
11
  cube,
12
12
  period_days,
13
13
  epoch,
14
- duration_days,
14
+ duration_days,
15
+ remove_transits,
15
16
  max_oot_shift_pix=1.5,
16
17
  plot=False
17
18
  ):
@@ -38,7 +39,9 @@ def compute_diff_image_centroids(
38
39
  epoch
39
40
  (float) Epoch of transit centre in the same time system as `time`.
40
41
  duration_days
41
- (float) Duration of transit.
42
+ (float) Duration of transit.
43
+ remove_transits
44
+ (list) List of 0 indexed transit integers to not calculate on.
42
45
  max_oot_shift_pix
43
46
  (float) Passed to `fastpsffit.fastGaussianPrfFit()
44
47
 
@@ -73,21 +76,30 @@ def compute_diff_image_centroids(
73
76
 
74
77
  figs = []
75
78
  centroids = []
79
+
76
80
  for i in range(len(transits)):
77
- cin = transits[i]
78
- cents, fig = measure_centroids(
79
- cube,
80
- cin,
81
- max_oot_shift_pix=max_oot_shift_pix,
82
- plot=plot
83
- )
84
- centroids.append(cents)
85
- figs.append(fig)
81
+ if i not in remove_transits:
82
+ cin = transits[i]
83
+ cents, fig = measure_centroids(
84
+ cube,
85
+ cin,
86
+ max_oot_shift_pix=max_oot_shift_pix,
87
+ plot=plot
88
+ )
89
+
90
+ if plot == True:
91
+ fig.suptitle('Transit '+str(i))
92
+
93
+ centroids.append(cents)
94
+ figs.append(fig)
95
+
86
96
  centroids = np.array(centroids)
87
- return centroids, figs
97
+ all_transits = list(np.arange(len(transits)))
98
+ kept_transits = [x for x in all_transits if x not in remove_transits]
99
+ return centroids, figs, kept_transits
88
100
 
89
101
 
90
- def measure_centroid_shift(centroids, plot=False):
102
+ def measure_centroid_shift(centroids, kept_transits, plot=False):
91
103
  """Measure the average offset of the DIC centroids from the OOT centroids.
92
104
 
93
105
  Inputs
@@ -95,6 +107,9 @@ def measure_centroid_shift(centroids, plot=False):
95
107
  centroids
96
108
  (2d np array) Output of :func:`compute_diff_image_centroids`
97
109
 
110
+ kept_transits
111
+ (list) List of 0 indexed transit integers to calculate on.
112
+
98
113
  Returns
99
114
  -----------
100
115
  offset
@@ -122,7 +137,7 @@ def measure_centroid_shift(centroids, plot=False):
122
137
 
123
138
  fig = None
124
139
  if plot:
125
- fig = covar.diagnostic_plot(dcol, drow, flags)
140
+ fig = covar.diagnostic_plot(dcol, drow, kept_transits, flags)
126
141
  return offset_pix, signif, fig
127
142
 
128
143
 
@@ -45,7 +45,7 @@ import numpy as np
45
45
  """
46
46
 
47
47
 
48
- def diagnostic_plot(x, y, flag=None):
48
+ def diagnostic_plot(x, y, kept_transits, flag=None):
49
49
 
50
50
  if flag is None:
51
51
  flag = np.zeros(len(x))
@@ -57,7 +57,8 @@ def diagnostic_plot(x, y, flag=None):
57
57
  mu_y = np.mean(y[~idx])
58
58
  sma, smi = compute_eigen_vectors(x[~idx], y[~idx])
59
59
 
60
- plt.clf()
60
+ # plt.clf()
61
+ plt.figure()
61
62
  plt.gcf().set_size_inches((10, 8))
62
63
  plt.plot(x, y, "ko", mec="w", label="Centroids", zorder=+5)
63
64
  if np.any(idx):
@@ -71,7 +72,8 @@ def diagnostic_plot(x, y, flag=None):
71
72
 
72
73
  # prob = compute_prob_of_points(x, y, sma, smi)
73
74
  for i in range(len(x)):
74
- plt.text(x[i], y[i], " %i" % (i), zorder=+5)
75
+
76
+ plt.text(x[i], y[i], " %i" % (kept_transits[i]), zorder=+5)
75
77
 
76
78
  sigma_a = np.linalg.norm(sma)
77
79
  sigma_b = np.linalg.norm(smi)
@@ -0,0 +1,227 @@
1
+ import numpy as np
2
+
3
+ def phasefold(t, per, epo):
4
+ # Phase will span -0.5 to 0.5, with transit centred at phase 0
5
+ phase = np.mod(t - epo, per) / per
6
+ phase[phase > 0.5] -= 1
7
+ return phase
8
+
9
+ def weighted_mean(y, dy):
10
+ w = 1 / dy**2
11
+ mean = np.sum(w * y) / np.sum(w)
12
+ return mean
13
+
14
+ def weighted_std(y, dy):
15
+ w = 1 / dy**2
16
+ N = len(w)
17
+ mean = np.sum(w * y) / np.sum(w)
18
+ std = np.sqrt(np.sum(w * (y - mean) ** 2) / ((N - 1) * np.sum(w) / N))
19
+ return std
20
+
21
+ def weighted_err(y, dy):
22
+ w = 1 / dy**2
23
+ err = 1 / np.sqrt(np.sum(w))
24
+ return err
25
+
26
+ class Leo:
27
+ def __init__(self, time, per, epo, dur, flux, flux_err, frac, max_chases_phase):
28
+ '''
29
+ Parameters
30
+ -----------
31
+ time : array
32
+ Array of times from lc
33
+
34
+ per : float
35
+ Orbital period in days
36
+
37
+ epo : float
38
+ Time of first transit in TESS BJD
39
+
40
+ dur : float
41
+ Transit duration in days
42
+
43
+ flux : array
44
+ Array of flux values from lc
45
+
46
+ flux_err : array
47
+ Array of flux error values from lc
48
+
49
+ frac : float
50
+ fraction of SES for a transit which triggers the chases false alarm statistic (default 0.7)
51
+
52
+ max_chases_phase : float
53
+ maximum to allow the chases search to run on (default 0.1)
54
+
55
+ Attributes
56
+ ------------
57
+ qtran : Transit duration divided by the period of the transit
58
+ phase : Array of phases for the time series spanning -0.5 to 0.5 with transit at 0
59
+ in_tran : Phases in transit
60
+ near_tran : Boolean of cadences within 1 transit duration
61
+ epochs : Number of transits accounting for gaps
62
+ tran_epochs : Epochs of the transits
63
+ N_transit : Length of tran_epochs
64
+ fit_tran : Cadences within 2 transit durations
65
+ zpt : Out-of-transit wieghted mean of the fluxes
66
+ dep : Depth of the transit based on the weighted mean of the in transit points
67
+ '''
68
+ self.time = time
69
+ self.per = per
70
+ self.epo = epo
71
+ self.dur = dur
72
+ self.flux = flux
73
+ self.flux_err = flux_err
74
+ self.qtran = dur / per
75
+
76
+ # Phase spans -0.5 to 0.5 with transit at 0
77
+ self.phase = phasefold(time, per, epo)
78
+ # Cadences in-transit
79
+ self.in_tran = abs(self.phase) < 0.5 * self.qtran
80
+ # Cadences within 1 transit duration
81
+ self.near_tran = abs(self.phase) < self.qtran
82
+ # Actual number of transits accounting for gaps
83
+ self.epochs = np.round((time - epo) / per)
84
+
85
+ self.tran_epochs = np.unique(self.epochs[self.in_tran])
86
+ self.N_transit = len(self.tran_epochs)
87
+ # Cadences within 2 transit durations
88
+ self.fit_tran = abs(self.phase) < 2 * self.qtran # can change to a variable other than 2
89
+ # Number of transit datapoints
90
+ self.n_in = np.sum(self.in_tran)
91
+
92
+ # Out-of-transit flux and transit depth
93
+ self.zpt = weighted_mean(self.flux[~self.near_tran], self.flux_err[~self.near_tran])
94
+ self.dep = self.zpt - weighted_mean(self.flux[self.in_tran], self.flux_err[self.in_tran])
95
+
96
+ self.frac = frac
97
+ self.max_chases_phase = max_chases_phase
98
+
99
+
100
+ def get_SES_MES(self):
101
+ N = len(self.time)
102
+ dep_SES = np.zeros(N)
103
+ n_SES = np.zeros(N)
104
+ dep_MES = np.zeros(N)
105
+ n_MES = np.zeros(N)
106
+ N_transit_MES = np.zeros(N)
107
+ bin_flux = np.zeros(N)
108
+ bin_flux_err = np.zeros(N)
109
+ phase = phasefold(self.time, self.per, self.epo)
110
+ phase[phase < 0] += 1
111
+ for i in np.arange(N):
112
+ # Get individual transit depth at this cadence, i.e. only use datapoints close in time
113
+ in_tran = abs(self.time - self.time[i]) < 0.5 * self.dur
114
+ n_SES[i] = np.sum(in_tran)
115
+ dep_SES[i] = self.zpt - weighted_mean(
116
+ self.flux[in_tran], self.flux_err[in_tran]
117
+ )
118
+ # Get overall transit depth at this cadence, i.e. use all datapoints close in phase
119
+ all_tran = (abs(phase - phase[i]) < 0.5 * self.qtran) | (
120
+ abs(phase - phase[i]) > 1 - 0.5 * self.qtran
121
+ )
122
+ n_MES[i] = np.sum(all_tran)
123
+ dep_MES[i] = self.zpt - weighted_mean(
124
+ self.flux[all_tran], self.flux_err[all_tran]
125
+ )
126
+ epochs = np.round((self.time - self.time[i]) / self.per)
127
+ tran_epochs = np.unique(epochs[all_tran])
128
+ N_transit_MES[i] = len(tran_epochs)
129
+ # Get running mean and uncertainty of out-of-transit fluxes, binned over transit timescale
130
+ in_bin = in_tran & ~self.near_tran
131
+ bin_flux[i] = weighted_mean(self.flux[in_bin], self.flux_err[in_bin])
132
+ bin_flux_err[i] = weighted_err(self.flux[in_bin], self.flux_err[in_bin]).value
133
+ # Estimate white and red noise following Hartman & Bakos (2016)
134
+ mask = ~np.isnan(bin_flux) & ~self.near_tran
135
+ std = weighted_std(self.flux[mask], self.flux_err[mask])
136
+ bin_std = weighted_std(bin_flux[mask], bin_flux_err[mask])
137
+ expected_bin_std = (
138
+ std
139
+ * np.sqrt(np.nanmean(bin_flux_err[mask] ** 2))
140
+ / np.sqrt(np.nanmean(self.flux_err[mask] ** 2))
141
+ ).value
142
+ self.sig_w = std
143
+ sig_r2 = bin_std**2 - expected_bin_std**2
144
+ self.sig_r = np.sqrt(sig_r2) if sig_r2 > 0 else 0
145
+ # Estimate signal-to-pink-noise following Pont et al. (2006)
146
+ self.err = np.sqrt(
147
+ (self.sig_w**2 / self.n_in) + (self.sig_r**2 / self.N_transit)
148
+ )
149
+ err_SES = np.sqrt((self.sig_w**2 / n_SES) + self.sig_r**2)
150
+ err_MES = np.sqrt((self.sig_w**2 / n_MES) + (self.sig_r**2 / N_transit_MES))
151
+ self.SES_series = dep_SES / err_SES
152
+ self.dep_series = dep_MES
153
+ self.err_series = err_MES
154
+ self.MES_series = dep_MES / err_MES
155
+ self.MES = self.dep / self.err
156
+ Fmin = np.nanmin(-self.dep_series)
157
+ Fmax = np.nanmax(-self.dep_series)
158
+ self.SHP = Fmax / (Fmax - Fmin)
159
+
160
+ def get_chases(self):
161
+ deps = np.zeros(self.N_transit)
162
+ errs = np.zeros(self.N_transit)
163
+ self.SES = np.zeros(self.N_transit)
164
+ self.rubble = np.zeros(self.N_transit)
165
+ self.chases = np.zeros(self.N_transit)
166
+ # self.redchi2 = np.zeros(self.N_transit)
167
+ # Search range for chases metric is between 1.5 durations and n times the period away
168
+ chases_tran = (abs(self.phase) > 1.5 * self.qtran) & (abs(self.phase) < self.max_chases_phase)
169
+
170
+ # Get metrics for each transit event
171
+ for i in range(self.N_transit):
172
+ epoch = self.tran_epochs[i]
173
+ in_epoch = self.in_tran & (self.epochs == epoch)
174
+ # Compute the transit time, depth, and SES for this transit
175
+ transit_time = self.epo + self.per * epoch
176
+ n_in = np.sum(in_epoch)
177
+ dep = self.zpt - weighted_mean(self.flux[in_epoch], self.flux_err[in_epoch])
178
+ err = np.sqrt((self.sig_w**2 / n_in) + self.sig_r**2)
179
+ deps[i], errs[i] = dep, err
180
+ self.SES[i] = dep / err
181
+ # Find the most significant nearby event
182
+ chases_epoch = (chases_tran & (self.epochs == epoch) & (np.abs(self.SES_series) > self.frac * self.SES[i]))
183
+
184
+ if np.any(chases_epoch):
185
+ self.chases[i] = np.min(np.abs(self.time[chases_epoch] - transit_time)) / (
186
+ self.max_chases_phase * self.per
187
+ )
188
+ else:
189
+ self.chases[i] = 1
190
+ # Find how much of the transit falls in gaps
191
+ fit_epoch = self.fit_tran & (self.epochs == epoch)
192
+ n_obs = np.sum(fit_epoch)
193
+ cadence = np.nanmedian(np.diff(self.time[fit_epoch]))
194
+ n_exp = 4 * self.dur / cadence # 4 is used because of the 2 transit duration on either side above in fit_tran
195
+ self.rubble[i] = n_obs / n_exp
196
+ # if ("transit_aic" in tlc.metrics) and ~np.isnan(tlc.metrics["transit_aic"]):
197
+ # tm = TransitModel(
198
+ # tlc.metrics["transit_per"],
199
+ # tlc.metrics["transit_epo"],
200
+ # tlc.metrics["transit_RpRs"],
201
+ # tlc.metrics["transit_aRs"],
202
+ # tlc.metrics["transit_b"],
203
+ # tlc.metrics["transit_u1"],
204
+ # tlc.metrics["transit_u2"],
205
+ # tlc.metrics["transit_zpt"],
206
+ # )
207
+ # resid = tm.residual(
208
+ # tm.params,
209
+ # tlc.time[fit_epoch],
210
+ # tlc.flux[fit_epoch],
211
+ # tlc.flux_err[fit_epoch],
212
+ # )
213
+ # chi2 = np.sum(resid**2)
214
+ # tlc.redchi2[i] = chi2 / (np.sum(fit_epoch) - 6)
215
+ # else:
216
+ # tlc.redchi2[i] = np.nan
217
+ O = self.SES
218
+ E = self.dep / errs
219
+ chi2 = np.sum((O - E) ** 2 / E)
220
+ self.CHI = self.MES / np.sqrt(chi2 / (self.N_transit - 1))
221
+ self.med_chases = np.nanmedian(self.chases)
222
+ self.mean_chases = np.nanmean(self.chases)
223
+ self.max_SES = np.nanmax(self.SES)
224
+ self.DMM = np.nanmean(deps) / np.nanmedian(deps)
225
+
226
+ def plot (self):
227
+ print('Plotting not yet implemented')
@@ -2,7 +2,7 @@
2
2
 
3
3
  import astropy
4
4
 
5
- __all__ = ['unpack_lk_version']
5
+ __all__ = ['unpack_lk_version', 'unpack_tpf']
6
6
 
7
7
 
8
8
  def unpack_lk_version(lightcurve, flux_name):
@@ -325,7 +325,8 @@ def plot_lpp_diagnostic(data, target, norm_lpp):
325
325
  ax2.plot(flux, 'k.', ms=5, label=f"LPP Norm = {norm_lpp:5.3f}")
326
326
  ax2.set_xlabel('Bin Number')
327
327
  ax2.legend()
328
-
328
+
329
+ fig.tight_layout()
329
330
  plt.draw()
330
331
 
331
332
  return fig
@@ -1,4 +1,4 @@
1
- """Module ot handle SWEET vetter."""
1
+ """Module to handle SWEET vetter."""
2
2
 
3
3
  import os
4
4
 
@@ -63,7 +63,8 @@ def sweet(time, flux, period, epoch, duration, plot=False):
63
63
 
64
64
  if plot:
65
65
  import matplotlib.pyplot as plt
66
- plt.clf()
66
+ #plt.clf() # swapped with a plt.figure below MD 2023
67
+ plt.figure(figsize=(7,7))
67
68
 
68
69
  out = []
69
70
  for i, per in enumerate([period * 0.5, period, 2 * period]):
@@ -77,9 +78,11 @@ def sweet(time, flux, period, epoch, duration, plot=False):
77
78
  if plot:
78
79
  srt = np.argsort(phase)
79
80
  plt.subplot(3, 1, i + 1)
80
- plt.plot(phase, flux, 'ko')
81
+ plt.plot(phase, flux, 'ko', ms=2.5)
81
82
  plt.plot(phase[srt], f_obj.get_best_fit_model(phase[srt]), '-')
82
83
  plt.ylabel("P=%g" % (per))
84
+ if i==0:
85
+ plt.title('SWEET: Folded at 1/2, 1, and 2 times the period')
83
86
 
84
87
  result = np.array(out)
85
88
 
@@ -130,9 +130,15 @@ class Tce(dict):
130
130
  """
131
131
  if 'epoch' not in self or 'epoch_offset' not in self:
132
132
  raise KeyError('epoch and epoch_offset must be defined first')
133
+
134
+ # Puts into bjd
133
135
  epoch = self["epoch"] - self["epoch_offset"]
136
+
134
137
  if offset is not None:
138
+ # Transforms from bjd into desired time system
135
139
  epoch = epoch + offset
140
+
141
+
136
142
  return epoch
137
143
 
138
144
  def validate(self):
@@ -742,7 +742,8 @@ class TrapezoidFit:
742
742
 
743
743
  """
744
744
  import scipy.optimize as opt
745
- from astropy.utils.compat.context import nullcontext
745
+ # from astropy.utils.compat.context import nullcontext # removed as depricated MD 2023
746
+ from contextlib import nullcontext # added instead of astropy's nullcontext ^
746
747
  from astropy.utils.misc import NumpyRNGContext
747
748
 
748
749
  if options is None: