def ma_with_oversmpling(Time, per, Tmid, p, a, i, linLimb, quadLimb, orbit="circular", ld="quad", b=0, ReBin_N=1, ReBin_dt=0, ToPlot=False): # Added ReBin_N, ReBin_dt to allow for finite integration time calculation by re-binning. These are the PyAstronomy parameters for the number of subsamples and the duration of the original samples if ReBin_N > 1 and ReBin_dt > 0: MA_Rebin = fuf.turnIntoRebin(ft.MandelAgolLC) ma = MA_Rebin() ma.setRebinArray_Ndt(Time, ReBin_N, ReBin_dt) else: ma = ft.MandelAgolLC() ma.pars._Params__params = { "orbit": orbit, "ld": ld, "per": per, "i": i, "a": a, "p": p, "linLimb": linLimb, "quadLimb": quadLimb, "b": b, "T0": Tmid } model = ma.evaluate(Time) if ToPlot: plt.plot((Time - Tmid + per / 2) % per - per / 2, model, '.') plt.xlabel("Time since T_mid [d]") #plt.show() return model
The analytical light curve is stored in the property `lightcurve`. """ # Translate the given parameters into an orbit and, finally, # into a projected, normalized distance (z-parameter) if self._orbit == "circular": self._calcZList(time - self["T0"]) else: # The orbit is keplerian self._calcZList(time) # Use occultquad Fortran library to compute flux decrease df = numpy.zeros(len(time)) if len(self._intrans) > 0: if self._ld == "quad": # Use occultquad Fortran library to compute flux decrease result = occultquad.occultquad(self._zlist[self._intrans], self["linLimb"], self["quadLimb"], self["p"], len(self._intrans)) else: result = occultnl.occultnl(self["p"], self["a1"], self["a2"], self["a3"], self["a4"], self._zlist[self._intrans]) df[self._intrans] = (1.0 - result[0]) self.lightcurve = (1. - df) * 1. / \ (1. + self["b"]) + self["b"] / (1.0 + self["b"]) return self.lightcurve MandelAgolLC_Rebin = fuf.turnIntoRebin(MandelAgolLC)
# 'W' parameters corresponding to notation in Pal '08 w = 6. - 2. * self["linLimb"] - self["quadLimb"] w0 = (6. - 6. * self["linLimb"] - 12. * self["quadLimb"]) / w w1 = (6. * self["linLimb"] + 12. * self["quadLimb"]) / w w2 = 6. * self["quadLimb"] / w # Initialize flux decrease array df = numpy.zeros(len(time)) # Get a list of 'cases' (according to Pal '08). Depends on radius ratio and 'z'-parameter along the orbit ca = self._selectCases() # Loop through in-transit points in z-list, # and calculate the light curve at each point in z (->time) for i in self._intrans: # Calculate the coefficients to be substituted into the Pal '08 equation c = self._returnCoeff(ca[i].step, self._zlist[i]) # Substitute the coefficients and get 'flux decrease' if ca[i].step != 12: # Calculate flux decrease only if there is an occultation if not self.useBoost: df[i] = w0 * c[0] + w2 * c[5] + w1 * (c[1] + c[2] * mpmath.ellipk( c[6]**2) + c[3] * mpmath.ellipe(c[6]**2) + c[4] * mpmath.ellippi(c[7], c[6]**2)) else: df[i] = w0 * c[0] + w2 * c[5] + w1 * (c[1] + c[2] * self.ell.ell1( c[6]) + c[3] * self.ell.ell2(c[6]) + c[4] * self.ell.ell3(c[7], c[6])) self.lightcurve = (1. - df) * 1. / \ (1. + self["b"]) + self["b"] / (1.0 + self["b"]) return self.lightcurve PalLC_Rebin = fuf.turnIntoRebin(PalLC)
(1.0 - self["gamma"]**2 - self["epsilon"]*(1./3. - self["gamma"]**2*(1.0-self.W1(rho[indi])))) indi = numpy.where(numpy.logical_and( \ numpy.logical_and(rho >= 1.-self["gamma"], rho < 1.0+self["gamma"]), dphase < 0.25))[0] z0 = self.z0(etap, indi) y[indi] = (Xp[indi]*self["Omega"]*sin(self["Is"])*( \ (1.0-self["epsilon"]) * (-z0[indi]*zeta[indi] + self["gamma"]**2*acos(zeta[indi]/self["gamma"])) + \ (self["epsilon"]/(1.0+etap[indi]))*self.W4(x0[indi], zeta[indi], xc[indi], etap[indi]))) / \ (pi*(1.-1.0/3.0*self["epsilon"]) - (1.0-self["epsilon"]) * (asin(z0[indi])-(1.+etap[indi])*z0[indi] + \ self["gamma"]**2*acos(zeta[indi]/self["gamma"])) - self["epsilon"]*self.W3(x0[indi], zeta[indi], xc[indi], etap[indi])) return y RmcL_Rebin = turnIntoRebin(RmcL) class RmcL_Hirano(OneDFit): def __init__(self): """ This class implements analytical expressions for the Rossiter-McLaughlin \ effect for the case when the anomalous radial velocity is obtained by \ cross-correlation with a stellar spectrum, according to *Hirano et. al 2010*. .. note:: The intrinsic line profile and the rotation kernel are both \ approximated by Gaussians, while the planet is assumed to be \ 'sufficiently small enough'.
def sanity_Overbinning(self): # Import numpy and matplotlib from numpy import arange, sqrt, exp, pi, random, ones import matplotlib.pylab as plt # ... and now the funcFit package from PyAstronomy import funcFit as fuf # Creating a Gaussian with some noise # Choose some parameters... gPar = {"A":-5.0, "sig":10.0, "mu":10.0, "off":1.0, "lin":0.0} # Calculate profile x = arange(20)/20.0 * 100.0 - 50.0 y = gPar["off"] + gPar["A"] / sqrt(2*pi*gPar["sig"]**2) \ * exp(-(x-gPar["mu"])**2/(2*gPar["sig"]**2)) # Add some noise y += random.normal(0.0, 0.01, x.size) # Let us see what we have done... plt.plot(x, y, 'bp') # First, we create a "GaussFit1d_Rebin" class object (note that the # class object has still to be instantiated, the name is arbitrary). GaussFit1d_Rebin = fuf.turnIntoRebin(fuf.GaussFit1d) # Do the instantiation and specify how the overbinning should be # carried out. gf = GaussFit1d_Rebin() gf.setRebinArray_Ndt(x, 10, x[1]-x[0]) # See what parameters are available print "List of available parameters: ", gf.availableParameters() # Set guess values for the parameters gf["A"] = -10.0 gf["sig"] = 15.77 gf["off"] = 0.87 gf["mu"] = 7.5 # Let us see whether the assignment worked print "Parameters and guess values: " print " A : ", gf["A"] print " sig : ", gf["sig"] print " off : ", gf["off"] print " mu : ", gf["mu"] print "" # Now some of the strengths of funcFit are demonstrated; namely, the # ability to consider some parameters as free and others as fixed. # By default, all parameters of the GaussFit1d are frozen. # Show values and names of frozen parameters print "Names and values if FROZEN parameters: ", gf.frozenParameters() # Which parameters shall be variable during the fit? # 'Thaw' those (the order is irrelevant) gf.thaw(["A", "sig", "off", "mu"]) # Let us assume that we know that the amplitude is negative, i.e., # no lower boundary (None) and 0.0 as upper limit. gf.setRestriction({"A":[None,0.0]}) # Now start the fit gf.fit(x, y, yerr=ones(x.size)*0.01) # Write the result to the screen and plot the best fit model gf.parameterSummary() # Plot the final best-fit model plt.plot(x, gf.model, 'rp--') # Show the overbinned (=unbinned) model, indicate by color # which point are averaged to obtain a point in the binned # model. for k, v in gf.rebinIdent.iteritems(): c = "y" if k % 2 == 0: c = "k" plt.plot(gf.rebinTimes[v], gf.unbinnedModel[v], c+'.')
w1 = (6. * self["linLimb"] + 12. * self["quadLimb"]) / w w2 = 6. * self["quadLimb"] / w # Initialize flux decrease array df = numpy.zeros(len(time)) # Get a list of 'cases' (according to Pal '08). Depends on radius ratio and 'z'-parameter along the orbit ca = self._selectCases() # Loop through in-transit points in z-list, # and calculate the light curve at each point in z (->time) for i in self._intrans: # Calculate the coefficients to be substituted into the Pal '08 equation c = self._returnCoeff(ca[i].step, self._zlist[i]) # Substitute the coefficients and get 'flux decrease' if ca[i].step != 12: # Calculate flux decrease only if there is an occultation if not self.useBoost: df[i] = w0 * c[0] + w2 * c[5] + w1 * ( c[1] + c[2] * mpmath.ellipk(c[6]**2) + c[3] * mpmath.ellipe(c[6]**2) + c[4] * mpmath.ellippi(c[7], c[6]**2)) else: df[i] = w0 * c[0] + w2 * c[5] + w1 * ( c[1] + c[2] * self.ell.ell1(c[6]) + c[3] * self.ell.ell2(c[6]) + c[4] * self.ell.ell3(c[7], c[6])) self.lightcurve = (1. - df) * 1. / \ (1. + self["b"]) + self["b"] / (1.0 + self["b"]) return self.lightcurve PalLC_Rebin = fuf.turnIntoRebin(PalLC)
time : array An array of time points at which the light curve shall be calculated. .. note:: time = 0 -> Planet is exactly in the line of sight (phase = 0). Returns ------- Model : array The analytical light curve is stored in the property `lightcurve`. """ # Translate the given parameters into an orbit and, finally, # into a projected, normalized distance (z-parameter) self._calcZList(time - self["T0"]) # Use occultquad Fortran library to compute flux decrease result = occultnl.occultnl(self["p"],self["a1"],self["a2"],self["a3"], \ self["a4"],self._zlist[self._intrans]) df = numpy.zeros(len(time)) df[self._intrans] = (1.0 - result[0]) self.lightcurve = (1. - df) * 1. / (1. + self["b"]) + self["b"] / ( 1.0 + self["b"]) return self.lightcurve MandelAgolNLLC_Rebin = fuf.turnIntoRebin(MandelAgolNLLC)