11from math import fabs , floor
2+
3+ from meepmeep .tsorbit import bounding_box
24from numba import njit , prange
35from 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 )
120126def 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 )
0 commit comments