def fit_eclipse_bottom(time, data, params, zero_eclipse_method="mean"): """Calculates the eclipse bottom to set the zero-point in the data Args: time: observational time (same units at orbital period) data: observational data params: dict of floats/numpy arrays, including params.per - orbital period, same units as time params.T0 - mid-transit time params.p - ratio of the planet to the star's radius params.b - impact parameter in units of stellar radius params.a - semi-major axis in units of stellar radius zero_eclipse_method (str): Which method used to set zero-point - "mean" - Use in-eclipse average value "median" - Use in-eclipse median value Returns: eclipse bottom value """ if(zero_eclipse_method == "mean"): calc_method = np.nanmean elif(zero_eclipse_method == "median"): calc_method = np.nanmedian else: raise ValueError("which_method should be mean or median!") eclipse_bottom = 0. period = params.per TE = calc_eclipse_time(params) # In some cases, the planet is never totally occulted. # For those cases, fit eclipse with quadratic and return min value. if((1. - params.p)**2 - params.b**2. < 0.): # Find in-eclipse points dur = transit_duration(params, which_duration='full') ind = isInTransit(time, TE, period, 0.5*dur, boolOutput=True) # Fit quadratic to eclipse to estimate minimum coeffs = np.polyfit(time[ind], data[ind], 2) eclipse_bottom = np.polyval(coeffs, -coeffs[1]/2./coeffs[0]) else: # Find in-eclipse points dur = transit_duration(params, which_duration='short') ind = isInTransit(time, TE, period, 0.5*dur, boolOutput=True) eclipse_bottom = calc_method(data[ind]) return eclipse_bottom
def sanity_inTransitExample_2(self): """ inTransit---Series of points in time """ 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: ", 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)
def sanity_inTransitExample_1(self): """ inTransit---individual point in time """ 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? ", if not pyasl.isInTransit(time, T0, period, duration/2.0): print "No" else: print "Yes"