def transit_prob(Rp, aR, e=0, w=90): """ Function to calculate period of rotation of a planet Parameters ----------- Rp: float; radius of the planet in unit f the stellar radius aR: float; Scaled semi-major axis i.e. a/R*. e: float; eccentricity of the orbit. w: float; longitude of periastron in degrees """ #eqn 5 - Kane & von Braun 2008, https://core.ac.uk/reader/216127860 prob = (1 + Rp)/aR * (1 + e*sin(radians(w))/(1-e**2) ) return prob
def inclination(b, a, e=0, w=90): """ Function to convert impact parameter b to inclination in degrees. Parameters: ---------- b: Impact parameter of the transit. a: Scaled semi-major axis i.e. a/R*. e: float; eccentricity of the orbit. w: float; longitude of periastron in degrees Returns -------- inc: The inclination of the planet orbit in degrees. """ ecc_factor = (1 - e**2) / (1 + e * sin(radians(w))) inc = degrees(acos(b / (a * ecc_factor))) return inc
def transit_duration(P, Rp, a, b=0, e=0, w=90, inc=None, total=True): """ Function to calculate the total (T14) or full (T23) transit duration Parameters: ---------- P: Period of planet orbit in days Rp: Radius of the planet in units of stellar radius b: Impact parameter of the planet transit [0, 1+Rp] a: scaled semi-major axis of the planet in units of solar radius inc: inclination of the orbit. Optional. If given b is not used. if None, b is used to calculate inc total: if True calculate the the total transit duration T14, else calculate duration of full transit T23 Returns ------- Tdur: duration of transit in same unit as P """ #eqn 30 and 31 of Kipping 2010 https://doi.org/10.1111/j.1365-2966.2010.16894.x factor = (1-e**2)/(1+e*sin(radians(w))) if inc == None: inc = inclination(b,a,e,w) if total is False: Rp = -Rp sini = sin(radians(inc)) cosi = cos(radians(inc)) denom = a*factor*sini tdur= (P/np.pi) * (factor**2/sqrt(1-e**2)) * (asin ( sqrt((1+Rp)**2 - (a*factor*cosi)**2)/ denom ) ) return tdur
def effective_ringed_planet_radius(rp, rin, rout, ir): """ Calculate effective radius of a ringed planet accounting for possible overlap between ring and planet. - eqn (2) from zuluaga+2015 http://dx.doi.org/10.1088/2041-8205/803/1/L14 Parameters: ----------- rp : float, ufloat; Radius of the planet hosting the ring rin, rout : float, ufloat; Inner and outer radii of the ring in units of rp. ir : float, ufloat; Inclination of the ring from the skyplane. 0 is face-on ring, 90 is edge on Returns: -------- eff_R : float, ufloat; effective radius of the ringed planet in same unit as rp """ cosir = cos(radians(ir)) sinir = sin(radians(ir)) y = lambda r: sqrt(r**2 - 1) / (r * sinir) def eff(r): if r * cosir > 1: eff_r = r**2 * cosir - 1 else: eff_r = (r**2 * cosir * 2 / np.pi * asin(y(r))) - (2 / np.pi * asin(y(r) * r * cosir)) return eff_r rout_eff2 = eff(rout) rin_eff2 = eff(rin) Arp = rp**2 + rp**2 * (rout_eff2 - rin_eff2) return sqrt(Arp)
def impact_parameter(inc, a, e=0, w=90, format='deg'): """ Function to convert inclination to impact parameter b. input format of angles as 'deg' or 'rad'. see eq. 1.19 in https://www.astro.ex.ac.uk/people/alapini/Publications/PhD_chap1.pdf also https://arxiv.org/pdf/1812.08549.pdf Parameters: ---------- inc: float; inclination of the planetary orbit a: float; scaled semi-major axis in units of solar radii e: float; eccentricity of the orbit. w: float; longitude of periastron format: str; - "deg" or "rad" unit of the `inc` and `w` Returns ------- b: impact parameter """ if format == 'deg': inc = radians(inc) w = radians(w) ecc_factor = (1 - e**2) / (1 + e * sin(w)) return a * cos(inc) * ecc_factor
def get_earth_observer_vector_fast(time): """Calculate the position vector of an observer on the earth in barcentric cartesian coordinates, approximately and hopefully abit faster. """ n = time-Time('2000-01-01T12:00:00', format='isot', scale='utc') # mean longitude of the sun L = (280.460 + 0.9856474*n.jd) % 360.0 # mean anomaly of the sun g = (357.528 + 0.9856003*n.jd) % 360.0 # ecliptic longitude of the sun l = L + 1.915*np.sin(np.radians(g)) + 0.020*np.sin(np.radians(2*g)) # axial tilt of the earth # Obliquity of the ecliptic epsilon = 23.439 - 0.0000004*n.jd return np.array([ np.cos(np.radians(l)), np.cos(np.radians(epsilon))*np.sin(np.radians(l)), np.sin(np.radians(epsilon))*np.sin(np.radians(l))]) * -1.0