Skip to content

Commit 26c2832

Browse files
committed
Improved transit bounding box calculations for RoadRunnerModel to better handle eccentric orbits, updated dependency to meepmeep >= 0.8.0, and bumped version to 2.6.17.
1 parent c757101 commit 26c2832

File tree

5 files changed

+48
-30
lines changed

5 files changed

+48
-30
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [2.6.17] - 2025-11-27
4+
5+
### Changed
6+
7+
- Improved RoadRunnerModel transit bounding box calculation for eccentric orbits.
8+
39
## [2.6.16] - 2025-10-29
410

511
### Changed

pytransit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
4242
"""
4343

44-
__version__ = '2.6.16'
44+
__version__ = '2.6.17'
4545

4646
# Generic
4747
# -------

pytransit/models/roadrunner/model_full.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from math import fabs, floor
2+
3+
from meepmeep.tsorbit import bounding_box
24
from numba import njit, prange
35
from numpy import zeros, dot, ndarray, isnan, nan, ones, full
46

@@ -54,7 +56,7 @@ def rr_full_serial(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: ndarr
5456
pv_is_good = full(npv, True)
5557
ldm = zeros((npv, npb, ng)) # Limb darkening means
5658
xyc = zeros((npv, 2, 5)) # Taylor series coefficients for the (x, y) position
57-
hwws = zeros((npv, npb)) # Half-window widths [d]
59+
bbs = zeros((npv, nlc, 2))
5860

5961
for ipv in range(npv):
6062
if isnan(a[ipv]) or (a[ipv] <= 1.0) or (e[ipv] < 0.0) or (isnan(ldp[ipv, 0, 0])):
@@ -79,12 +81,15 @@ def rr_full_serial(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: ndarr
7981
# ------------------------------------------------------#
8082
xyc[ipv, :, :] = solve_xy_p5s(0.0, p[ipv], a[ipv], i[ipv], e[ipv], w[ipv])
8183

82-
# ---------------------------------#
83-
# Calculate the half-window widths #
84-
# ---------------------------------#
85-
hww = 0.5 * d_from_pkaiews(p[ipv], ks[ipv, 0], a[ipv], i[ipv], e[ipv], w[ipv], 1, 14)
84+
# -----------------------------#
85+
# Calculate the bounding boxes #
86+
# -----------------------------#
87+
bt1, bt4 = bounding_box(k, xyc)
88+
bbs[ipv, :, 0] = bt1
89+
bbs[ipv, :, 1] = bt4
8690
for ilc in range(nlc):
87-
hwws[ipv, ilc] = 0.0015 + _exptimes[ilc] + hww
91+
bbs[ipv, ilc, 0] -= 0.003 + _exptimes[ilc]
92+
bbs[ipv, ilc, 1] += 0.003 + _exptimes[ilc]
8893

8994
# ---------------------------#
9095
# Calculate the light curves #
@@ -104,8 +109,8 @@ def rr_full_serial(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: ndarr
104109

105110
epoch = floor((times[ipt] - t0[ipv, iep] + 0.5 * p[ipv]) / p[ipv])
106111
tc = times[ipt] - (t0[ipv, iep] + epoch * p[ipv])
107-
if fabs(tc) > hwws[ipv, ilc]:
108-
flux[ipv, ipt] = 1.0
112+
if not (bbs[ipv, ilc, 0] <= tc <= bbs[ipv, ilc, 1]):
113+
flux[ipt] = 1.0
109114
else:
110115
for isample in range(1, nsamples[ilc] + 1):
111116
time_offset = exptimes[ilc] * ((isample - 0.5) / nsamples[ilc] - 0.5)
@@ -116,6 +121,7 @@ def rr_full_serial(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: ndarr
116121
flux[ipv, ipt] /= nsamples[ilc]
117122
return flux
118123

124+
119125
@njit(parallel=True, fastmath=False)
120126
def rr_full_parallel(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: ndarray, i: ndarray, e: ndarray, w: ndarray,
121127
nlc: int, npb: int, nep: int,
@@ -146,6 +152,7 @@ def rr_full_parallel(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: nda
146152
ldm = zeros((npv, npb, ng)) # Limb darkening means
147153
xyc = zeros((npv, 2, 5)) # Taylor series coefficients for the (x, y) position
148154
hwws = zeros((npv, npb)) # Half-window widths [d]
155+
bbs = zeros((npv, nlc, 2))
149156

150157
for ipv in range(npv):
151158
if isnan(a[ipv]) or (a[ipv] <= 1.0) or (e[ipv] < 0.0) or (isnan(ldp[ipv, 0, 0])):
@@ -171,12 +178,15 @@ def rr_full_parallel(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: nda
171178
# ------------------------------------------------------#
172179
xyc[ipv, :, :] = solve_xy_p5s(0.0, p[ipv], a[ipv], i[ipv], e[ipv], w[ipv])
173180

174-
# ---------------------------------#
175-
# Calculate the half-window widths #
176-
# ---------------------------------#
177-
hww = 0.5 * d_from_pkaiews(p[ipv], ks[ipv, 0], a[ipv], i[ipv], e[ipv], w[ipv], 1, 14)
181+
# -----------------------------#
182+
# Calculate the bounding boxes #
183+
# -----------------------------#
184+
bt1, bt4 = bounding_box(k, xyc)
185+
bbs[ipv, :, 0] = bt1
186+
bbs[ipv, :, 1] = bt4
178187
for ilc in range(nlc):
179-
hwws[ipv, ilc] = 0.0015 + _exptimes[ilc] + hww
188+
bbs[ipv, ilc, 0] -= 0.003 + _exptimes[ilc]
189+
bbs[ipv, ilc, 1] += 0.003 + _exptimes[ilc]
180190

181191
# ---------------------------#
182192
# Calculate the light curves #
@@ -196,8 +206,8 @@ def rr_full_parallel(times: ndarray, k: ndarray, t0: ndarray, p: ndarray, a: nda
196206

197207
epoch = floor((times[ipt] - t0[ipv, iep] + 0.5 * p[ipv]) / p[ipv])
198208
tc = times[ipt] - (t0[ipv, iep] + epoch * p[ipv])
199-
if fabs(tc) > hwws[ipv, ilc]:
200-
flux[ipv, ipt] = 1.0
209+
if not (bbs[ipv, ilc, 0] <= tc <= bbs[ipv, ilc, 1]):
210+
flux[ipt] = 1.0
201211
else:
202212
for isample in range(1, nsamples[ilc] + 1):
203213
time_offset = exptimes[ilc] * ((isample - 0.5) / nsamples[ilc] - 0.5)

pytransit/models/roadrunner/model_simple.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from numba import njit, prange
33
from numpy import zeros, dot, ndarray, isnan, full, nan
44

5-
from meepmeep.xy.position import solve_xy_p5s, pd_t15sc
5+
from meepmeep.xy.position import solve_xy_p5s, pd_t15sc, bounding_box
66
from meepmeep.utils import d_from_pkaiews
77

88
from .common import calculate_weights_2d, interpolate_mean_limb_darkening_s
@@ -54,11 +54,12 @@ def rr_simple_serial(times: ndarray, k: float, t0: float, p: float, a: float, i:
5454
# -----------------------------------------------------#
5555
xyc[:, :] = solve_xy_p5s(0.0, p, a, i, e, w)
5656

57-
# --------------------------------#
58-
# Calculate the half-window width #
59-
# --------------------------------#
60-
hww = 0.5 * d_from_pkaiews(p, k, a, i, e, w, 1, 14)
61-
hww = 0.0015 + exptimes + hww
57+
# ---------------------------#
58+
# Calculate the bounding box #
59+
# ---------------------------#
60+
bt1, bt4 = bounding_box(k, xyc)
61+
bt1 -= 0.003 + exptimes
62+
bt4 += 0.003 + exptimes
6263

6364
# --------------------------#
6465
# Calculate the light curve #
@@ -67,7 +68,7 @@ def rr_simple_serial(times: ndarray, k: float, t0: float, p: float, a: float, i:
6768
for ipt in range(npt):
6869
epoch = floor((times[ipt] - t0 + 0.5 * p) / p)
6970
tc = times[ipt] - (t0 + epoch * p)
70-
if fabs(tc) > hww:
71+
if not (bt1 <= tc <= bt4):
7172
flux[ipt] = 1.0
7273
else:
7374
for isample in range(1, nsamples+ 1):
@@ -111,11 +112,12 @@ def rr_simple_parallel(times: ndarray, k: float, t0: float, p: float, a: float,
111112
# -----------------------------------------------------#
112113
xyc[:, :] = solve_xy_p5s(0.0, p, a, i, e, w)
113114

114-
# --------------------------------#
115-
# Calculate the half-window width #
116-
# --------------------------------#
117-
hww = 0.5 * d_from_pkaiews(p, k, a, i, e, w, 1, 14)
118-
hww = 0.0015 + exptimes + hww
115+
# ---------------------------#
116+
# Calculate the bounding box #
117+
# ---------------------------#
118+
bt1, bt4 = bounding_box(k, xyc)
119+
bt1 -= 0.003 + exptimes
120+
bt4 += 0.003 + exptimes
119121

120122
# --------------------------#
121123
# Calculate the light curve #
@@ -124,7 +126,7 @@ def rr_simple_parallel(times: ndarray, k: float, t0: float, p: float, a: float,
124126
for ipt in prange(npt):
125127
epoch = floor((times[ipt] - t0 + 0.5 * p) / p)
126128
tc = times[ipt] - (t0 + epoch * p)
127-
if fabs(tc) > hww:
129+
if not (bt1 <= tc <= bt4):
128130
flux[ipt] = 1.0
129131
else:
130132
for isample in range(1, nsamples+ 1):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ emcee
1717
pyopencl
1818
corner
1919
celerite
20-
meepmeep
20+
meepmeep >= 0.8.0

0 commit comments

Comments
 (0)