Check whether time falls in transit window¶
- PyAstronomy.pyasl.isInTransit(time, T0, period, halfDuration, boolOutput=False, secin=False)¶
Check whether time is inclosed by transit interval.
This function uses the given ephemerides (T0, period, and halfDuration) to check whether the time point(s) specified by time are within a transit window or not. The edges of the window are counted as transit times.
- Parameters
- timefloat or array like
The time(s) which are to be checked.
- T0float
The time reference point (center of transit).
- periodfloat
The orbital period.
- halfDurationfloat
The half-duration of the event. Must have same units as time.
- boolOutputboolean, optional
If set True and time is an array, the function will return a bool array holding True for time points in- and False for time points out-of-transit.
- secinboolean, optional
If True, also points associated with the secondary transit (around phase 0.5) will be counted as falling into the transit window. Default is False.
- Returns
- inTransitboolean or array of int
If time was a float, the return value is a boolean, which is True if the give time falls into a transit interval and False otherwise. If time was given as an array, the return value is an array holding the indices of those time points, which fall into a transit window. The boolOutput option may be used to obtain a boolean array holding True for in-transit points.
Example: Check individual point in time¶
from __future__ import print_function, division
from PyAstronomy import pyasl
# Time of interest
time = 2476357.756234
# Define some (arbitrary) transit parameters
T0 = 2475123.01245
period = 3.4789112
duration = 2.2/24.0
# Check whether the time is in-transit
print("Time is within transit? ", end=' ')
if not pyasl.isInTransit(time, T0, period, duration/2.0):
print("No")
else:
print("Yes")
Example: Checking a series of times¶
from __future__ import print_function, division
from PyAstronomy import pyasl
import numpy as np
# Times of interest
times = 2476357.756234 + np.linspace(0.0, 5.0, 300)
# Define some (arbitrary) transit parameters
T0 = 2475123.01245
period = 3.4789112
duration = 2.2/24.0
# Check whether the time is in-transit
print("Indices if time points within transit: ", end=' ')
print(pyasl.isInTransit(times, T0, period, duration/2.0))
print()
print("For each time point, a flag indicating whether it")
print("is in- or off-transit:")
print(pyasl.isInTransit(times, T0, period, duration/2.0, boolOutput=True))