Closed skgrunblatt closed 4 years ago
import ktransit
def validate_ktransit(self, ticid=None, lc=None, rprs=0.02): from ktransit import FitTransit fitT = FitTransit()
if ticid is not None: lc = self.from_eleanor(ticid)[1] lc = self._clean_data(lc) elif lc is None: lc = self.lc lc.flux = lc.flux / np.mean(lc.flux) model = BoxLeastSquares(lc.time, lc.flux) results = model.autopower(0.16) #periods = np.linspace(3,15,400) #results = model.power(periods, 0.16) period = results.period[np.argmax(results.power)] t0 = results.transit_time[np.argmax(results.power)] if rprs is None: depth = results.depth[np.argmax(results.power)] rprs = depth ** 2 fitT.add_guess_star(rho=0.022, zpt=0, ld1=0.6505,ld2=0.1041) #come up with better way to estimate this using AS fitT.add_guess_planet(T0=t0, period=period, impact=0.5, rprs=rprs) ferr=np.ones_like(lc.time) * 0.00001 fitT.add_data(time=lc.time,flux=lc.flux,ferr=ferr)#*1e-3) vary_star = ['zpt'] # free stellar parameters vary_planet = (['period', 'impact', # free planetary parameters 'T0', #'esinw', 'ecosw', 'rprs']) #'impact', # free planet parameters are the same for every planet you model fitT.free_parameters(vary_star, vary_planet) fitT.do_fit() # run the fitting fitT.print_results() # print some results res=fitT.fitresultplanets res2=fitT.fitresultstellar fig = ktransit.plot_results(lc.time,lc.flux,fitT.transitmodel) fig.show()
import ktransit
def validate_ktransit(self, ticid=None, lc=None, rprs=0.02): from ktransit import FitTransit fitT = FitTransit()