def transitcalcloop(): plandataarray = np.load( 'plandataarray.npy') #load the planetary data array stellardataarray = np.load( 'Stellardataarray.npy' ) #load the stellar data array (No longer need to run LDCcalc beforehand for line in plandataarray: #now loop through the planetary data array, in which line represents a single planet print 'For Kepler {}, planet {}:'.format(line['KeplerID'], line['planetnumber']) if os.path.exists( 'kepler-{0}-planet-{1}-analyticaltransitlc.npy'.format( line['KeplerID'], line['planetnumber'])) == False: Teff, Logg, Metalicity, Rheader = stellarextractor( line['KeplerID'], stellardataarray) #extract the gamma values Keplerlc = np.load('kepler-{0}-planet-{1}-trandata.npy'.format( line['KeplerID'], line['planetnumber'])) #extract the kepler transit data tvalues = np.sort( Keplerlc['Foldtime'] ) #create an array of times associated with each data point and sort them Keplertransit = np.sort( Keplerlc, order='Foldtime') #sort the kepler data in the same way sigma = sigmacalc(Keplertransit) impactpar, T_dur, R_plan, Teff_fit, Logg_fit, Metalicity_fit, bestfitarray, errors, covar = zandtfit( line, Keplerlc, Teff, Logg, Metalicity, sigma) #calculate the t and z values gamma1, gamma2, = gammainterpolator(Teff_fit, Logg_fit, np.log10(Metalicity_fit)) zvalues = zandtcalculator(tvalues, impactpar, T_dur, R_plan) f = transit.occultquad( zvalues, R_plan, [gamma1, gamma2 ]) #calculate/find the analytical transit lightcurve #transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve comtransitplot( tvalues, f, Keplertransit['Foldtime'], Keplertransit['Flux'], line['KeplerID'], line['planetnumber'], line['KOI'] ) #plot both the kepler and anaytical transit data on the same graph analyticaltransitlc = np.vstack((tvalues, f)) chi, chireduced = chicalc(Keplertransit, analyticaltransitlc, sigma, T_dur) #print analyticaltransitlc print 'The new impactparameter is {}+-{}, the new duration is {}+-{} and the new radius is {}+-{}'.format( impactpar, errors[0], T_dur, errors[1], R_plan, errors[2]) np.save('kepler-{0}-planet-{1}-analyticaltransitlc'.format( line['KeplerID'], line['planetnumber']), analyticaltransitlc) #save the analytical transit np.save('kepler-{0}-planet-{1}-covariance'.format( line['KeplerID'], line['planetnumber']), covar) #save the covariance array saveplandata(line, impactpar, T_dur, R_plan, line['planetnumber'], line['KeplerID'], errors) savefittedstellardata(line['KeplerID'], Teff, Teff_fit, errors[3], Logg, Logg_fit, errors[4], Metalicity, Metalicity_fit, errors[5], Rheader, gamma1, gamma2, line['planetnumber']) else: print 'Already Done' return
def minimisefunction(x, Keplerlc=None, fjac = None, sigma = None, Orbitalperiod_SI = None, KeplerID = None, Planetnumberer = None): #DONE Inclination = math.acos(x[0]) #extract the impact parameter Planetaryradius = x[1] * 6.3675E6 #extract the transit duration Teff = x[2] #Extract the effective surface temperature Logg = x[3] #Extract the log of the surface gravity Metalicity = x[4] #Extract the metalicity (logged) gamma1, gamma2 = gammainterpolator(Teff, Logg, Metalicity) #calculate the gamma values tvalues = np.sort(Keplerlc['Foldtime']) #create an array of times associated with each data point and sort them Keplertransit = np.sort(Keplerlc, order = 'Foldtime') #sort the kepler data in the same way Stellarmass_SI, StellarRadius_SI, Stellardensity_SI = RMrhocalc(Teff, Logg, (10**Metalicity)) Planetaryradiusratio = Planetaryradius / StellarRadius_SI #Planetary radius in terms of the stellar radius #print Teff, Logg, Metalicity, Planetaryradius, StellarRadius_SI, Planetaryradiusratio zvalues = zandtcalculator(tvalues, Stellardensity_SI, Inclination, Orbitalperiod_SI) #calculate the t and z values #print np.min(zvalues) f = transit.occultquad(zvalues, Planetaryradiusratio, [gamma1, gamma2]) #calculate/find the analytical transit lightcurve #transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve #tempkeplervalues = np.copy(Keplertransit) #create a copy of the kepler data which will be used to calculate the standard deviation for i in range(0, len(Keplertransit['Flux']), 1): #loop over the kepler data array, normalising it to the analytical lightcurve if not 'returnval' in locals(): returnval = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the first value to return else: temparray = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the other values to return returnval = np.append(returnval, temparray) #and add them to the return array #sigma = np.std(tempkeplervalues['Flux']) #calculate the standard deviation of the normalised lightcurve status = 0 #this will not error, so it exists purely as a formality if np.min(zvalues) > (1+Planetaryradiusratio): return [status, returnval*100] return [status, returnval] #return a list, which is apparently what is required
def transitcalcloop(): plandataarray = np.load('plandataarray.npy') #load the planetary data array stellardataarray = np.load('Stellardataarray.npy') #load the stellar data array (No longer need to run LDCcalc beforehand for line in plandataarray: #now loop through the planetary data array, in which line represents a single planet print 'For Kepler {}, planet {}:'.format(line['KeplerID'], line['planetnumber']) if os.path.exists('kepler-{0}-planet-{1}-analyticaltransitlc.npy'.format(line['KeplerID'], line['planetnumber'])) == False: Teff, Logg, Metalicity, Rheader = stellarextractor(line['KeplerID'], stellardataarray) #extract the gamma values Keplerlc = np.load('kepler-{0}-planet-{1}-trandata.npy'.format(line['KeplerID'], line['planetnumber'])) #extract the kepler transit data tvalues = np.sort(Keplerlc['Foldtime']) #create an array of times associated with each data point and sort them Keplertransit = np.sort(Keplerlc, order = 'Foldtime') #sort the kepler data in the same way sigma = sigmacalc(Keplertransit) impactpar, T_dur, R_plan, Teff_fit, Logg_fit, Metalicity_fit, bestfitarray, errors, covar = zandtfit(line, Keplerlc, Teff, Logg, Metalicity, sigma) #calculate the t and z values gamma1, gamma2, = gammainterpolator(Teff_fit, Logg_fit, np.log10(Metalicity_fit)) zvalues = zandtcalculator(tvalues, impactpar, T_dur, R_plan) f = transit.occultquad(zvalues, R_plan, [gamma1, gamma2]) #calculate/find the analytical transit lightcurve #transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve comtransitplot(tvalues, f, Keplertransit['Foldtime'], Keplertransit['Flux'], line['KeplerID'], line['planetnumber'], line['KOI']) #plot both the kepler and anaytical transit data on the same graph analyticaltransitlc = np.vstack((tvalues, f)) chi, chireduced = chicalc(Keplertransit, analyticaltransitlc, sigma, T_dur) #print analyticaltransitlc print 'The new impactparameter is {}+-{}, the new duration is {}+-{} and the new radius is {}+-{}'. format(impactpar, errors[0], T_dur, errors[1], R_plan, errors[2]) np.save('kepler-{0}-planet-{1}-analyticaltransitlc'.format(line['KeplerID'], line['planetnumber']), analyticaltransitlc) #save the analytical transit np.save('kepler-{0}-planet-{1}-covariance'.format(line['KeplerID'], line['planetnumber']), covar) #save the covariance array saveplandata(line, impactpar, T_dur, R_plan, line['planetnumber'], line['KeplerID'], errors) savefittedstellardata(line['KeplerID'], Teff, Teff_fit, errors[3], Logg, Logg_fit, errors[4], Metalicity, Metalicity_fit, errors[5], Rheader, gamma1, gamma2, line['planetnumber']) else: print 'Already Done' return
def transittest(): # was used to test the analytical transit generator - now not used z = np.linspace(0,1.4,200) gammaslist = [[0., 0.], [1., 0.], [2., -1.]] plt.figure() for gammas in gammaslist: f = transit.occultquad(z, 0.1, gammas) plt.plot(z, f) plt.savefig('Test.pdf') return
def unbound_transit_calc(Impactpar, Transitduration_days, R_plan_over_R_star, gamma1, gamma2, Time_datapoints): zvalues = zandtcalculator_unbound( Time_datapoints, Impactpar, Transitduration_days, R_plan_over_R_star) #calculate the zvalues f = transit.occultquad( zvalues, R_plan_over_R_star, [gamma1, gamma2 ]) #and then use these to calculate the analytical transit return f
def makeModel(self, tt, period, incl, t, dor, ror, ldm_coeff1, ldm_coeff2): """ -t2z I have modified this function so that the midpoint of every transit is 0 find lmdk from the star """ # use t2z to make z z = t2z(tt, period, incl, t, dor) return occultquad(z, ror, [ldm_coeff1, ldm_coeff2])
def transittest( ): # was used to test the analytical transit generator - now not used z = np.linspace(0, 1.4, 200) gammaslist = [[0., 0.], [1., 0.], [2., -1.]] plt.figure() for gammas in gammaslist: f = transit.occultquad(z, 0.1, gammas) plt.plot(z, f) plt.savefig('Test.pdf') return
def bound_transit_calc(Inclination_rad, Planetaryradius_SI, Orbtialperiod_days, Rstar_SI, RHOstar_SI, gamma1, gamma2, Time_datapoints): Orbitalperiod_SI = Orbtialperiod_days * 86400 #convert the orbital period to SI units zvalues = zandtcalculator_bound(Time_datapoints, RHOstar_SI, Inclination_rad, Orbitalperiod_SI) #calculate the zvalues Planetaryradiusratio = Planetaryradius_SI / Rstar_SI #calculate the ratio of R_plan/R_star f = transit.occultquad( zvalues, Planetaryradiusratio, [gamma1, gamma2]) #and then calculate the analytical transit return f
def minimisefunction(x, Keplerlc=None, fjac=None, sigma=None, Orbitalperiod_SI=None, KeplerID=None, Planetnumberer=None): #DONE Inclination = math.acos(x[0]) #extract the impact parameter Planetaryradius = x[1] * 6.3675E6 #extract the transit duration Teff = x[2] #Extract the effective surface temperature Logg = x[3] #Extract the log of the surface gravity Metalicity = x[4] #Extract the metalicity (logged) gamma1, gamma2 = gammainterpolator(Teff, Logg, Metalicity) #calculate the gamma values tvalues = np.sort( Keplerlc['Foldtime'] ) #create an array of times associated with each data point and sort them Keplertransit = np.sort( Keplerlc, order='Foldtime') #sort the kepler data in the same way Stellarmass_SI, StellarRadius_SI, Stellardensity_SI = RMrhocalc( Teff, Logg, (10**Metalicity)) Planetaryradiusratio = Planetaryradius / StellarRadius_SI #Planetary radius in terms of the stellar radius #print Teff, Logg, Metalicity, Planetaryradius, StellarRadius_SI, Planetaryradiusratio zvalues = zandtcalculator(tvalues, Stellardensity_SI, Inclination, Orbitalperiod_SI) #calculate the t and z values #print np.min(zvalues) f = transit.occultquad( zvalues, Planetaryradiusratio, [gamma1, gamma2]) #calculate/find the analytical transit lightcurve #transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve #tempkeplervalues = np.copy(Keplertransit) #create a copy of the kepler data which will be used to calculate the standard deviation for i in range( 0, len(Keplertransit['Flux']), 1 ): #loop over the kepler data array, normalising it to the analytical lightcurve if not 'returnval' in locals(): returnval = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the first value to return else: temparray = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the other values to return returnval = np.append(returnval, temparray) #and add them to the return array #sigma = np.std(tempkeplervalues['Flux']) #calculate the standard deviation of the normalised lightcurve status = 0 #this will not error, so it exists purely as a formality if np.min(zvalues) > (1 + Planetaryradiusratio): return [status, returnval * 100] return [status, returnval] #return a list, which is apparently what is required
def transitcalcloop(): #Just need to add the save functions plandataarray = np.load('plandataarray.npy') #load the planetary data array stellardataarray = np.load('Stellardataarray.npy') #load the stellar data array (No longer need to run LDCcalc beforehand flats = np.loadtxt('flats.txt') for line in plandataarray: #now loop through the planetary data array, in which line represents a single planet print 'For Kepler {}, planet {}:'.format(line['KeplerID'], line['planetnumber']) if line['KeplerID'] in flats and os.path.exists('kepler-{0}-planet-{1}-analyticaltransitlc.npy'.format(line['KeplerID'], line['planetnumber'])) == False: Teff, Logg, Metalicity, Rheader = stellarextractor(line['KeplerID'], stellardataarray) #extract the gamma values Inclination = math.acos(line['Impactpar'] / line['a/R_star']) #calculate the inclination from the normalised impactpar #print Inclination Planetaryradius = line['R_planet'] #extract the planetary radius Planetaryradius_SI = Planetaryradius * 6.3675E6 #and convert it from earth radii to meters Orbitalperiod = line['Orbitalperiod'] #Extract the orbital period Orbitalperiod_SI = Orbitalperiod * 86400 #and convert it from days to seconds Keplerlc = np.load('kepler-{0}-planet-{1}-trandata.npy'.format(line['KeplerID'], line['planetnumber'])) #extract the kepler transit data tvalues = np.sort(Keplerlc['Foldtime']) #create an array of times associated with each data point and sort them Keplertransit = np.sort(Keplerlc, order = 'Foldtime') #sort the kepler data in the same way sigma = sigmacalc(Keplertransit) #Calculate the standard deviation of the surrounding data points Inclination_fit, Planetaryradius_SI_fit, Teff_fit, Logg_fit, Metalicity_fit, Mstar_SI, Rstar_SI, Stellardensity_SI, semimajoraxis_SI, T_dur_SI, errors, covar = \ zandtfit(Inclination, Planetaryradius_SI, Keplerlc, Teff, Logg, Metalicity, sigma, Orbitalperiod_SI, line['KeplerID'], line['planetnumber']) #calculate the t and z values gamma1, gamma2, = gammainterpolator(Teff_fit, Logg_fit, np.log10(Metalicity_fit)) #calculate the LDC zvalues = zandtcalculator(tvalues, Stellardensity_SI, Inclination_fit, Orbitalperiod_SI) #calculate the zvalues #print zvalues #testing #print tvalues #print 'The minimum zvalue is:' #print np.min(zvalues) norm_impactparameter = (semimajoraxis_SI * math.cos(Inclination_fit) / Rstar_SI) print 'The transit duration is:' print T_dur_SI / 86400 Rplanratio = Planetaryradius_SI_fit / Rstar_SI #Calculate the ratio of planetary radius to stellar radius #print 'The Planetary Ratio is' print Logg, Logg_fit f = transit.occultquad(zvalues, Rplanratio, [gamma1, gamma2]) #calculate/find the analytical transit lightcurve ##transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve comtransitplot(tvalues, f, Keplertransit['Foldtime'], Keplertransit['Flux'], line['KeplerID'], line['planetnumber'], line['KOI']) #plot both the kepler and analytical transit data on the same graph analyticaltransitlc = np.vstack((tvalues, f)) #make a single array to contain the analytical transit lightcurve chi, chireduced, DOF, chifull, chireducedfull, DOFfull = chicalc(Keplertransit, analyticaltransitlc, sigma, T_dur_SI) #calculate the chisquared values #print analyticaltransitlc #print 'The new impactparameter is {}+-{}, the new duration is {}+-{} and the new radius is {}+-{}'. format(impactpar, errors[0], T_dur, errors[1], R_plan, errors[2]) print 'Saving' np.save('kepler-{0}-planet-{1}-analyticaltransitlc'.format(line['KeplerID'], line['planetnumber']), analyticaltransitlc) #save the analytical transit np.save('kepler-{0}-planet-{1}-covariance'.format(line['KeplerID'], line['planetnumber']), covar) #save the covariance array saveplandata(line, Inclination_fit, T_dur_SI, Planetaryradius_SI_fit, semimajoraxis_SI, line['planetnumber'], line['KeplerID'], errors, chireduced, norm_impactparameter, DOF, chireducedfull, DOFfull) savefittedstellardata(line['KeplerID'], line['planetnumber'], Mstar_SI, Rstar_SI, Stellardensity_SI, Teff, Teff_fit, errors[2], Logg, Logg_fit, errors[3], Metalicity, Metalicity_fit, errors[4], Rheader, gamma1, gamma2, chireduced, DOF, chireducedfull, DOFfull) else: print 'Already Done' return
def minimisefunction(x, Keplerlc=None, fjac=None, sigma=None): impactparameter = x[0] #extract the impact parameter Transitduration = x[1] #extract the transit duration R_plan = x[2] #extract the planetary radius Teff = x[3] Logg = x[4] Metalicity = x[5] gamma1, gamma2 = gammainterpolator(Teff, Logg, Metalicity) tvalues = np.sort( Keplerlc['Foldtime'] ) #create an array of times associated with each data point and sort them Keplertransit = np.sort( Keplerlc, order='Foldtime') #sort the kepler data in the same way zvalues = zandtcalculator(tvalues, impactparameter, Transitduration, R_plan) #calculate the t and z values f = transit.occultquad( zvalues, R_plan, [gamma1, gamma2]) #calculate/find the analytical transit lightcurve #transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve tempkeplervalues = np.copy( Keplertransit ) #create a copy of the kepler data which will be used to caculate the standard deviation for i in range( 0, len(Keplertransit['Flux']), 1 ): #loop over the kepler data array, normalising it to the analytical lightcuve if not 'returnval' in locals(): returnval = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the first value to return else: temparray = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the other values to return returnval = np.append(returnval, temparray) #and add them to the return array sigma = np.std( tempkeplervalues['Flux'] ) #calculate the standard deivation of the normalised lightcurve status = 0 #this will not error, so it exists purely as a formality return [status, returnval] #return a list, which is apparently what is required
def minimisefunction(x, Keplerlc=None, fjac = None, sigma = None): impactparameter = x[0] #extract the impact parameter Transitduration = x[1] #extract the transit duration R_plan = x[2] #extract the planetary radius Teff = x[3] Logg = x[4] Metalicity = x[5] gamma1, gamma2 = gammainterpolator(Teff, Logg, Metalicity) tvalues = np.sort(Keplerlc['Foldtime']) #create an array of times associated with each data point and sort them Keplertransit = np.sort(Keplerlc, order = 'Foldtime') #sort the kepler data in the same way zvalues = zandtcalculator(tvalues, impactparameter, Transitduration, R_plan) #calculate the t and z values f = transit.occultquad(zvalues, R_plan, [gamma1, gamma2]) #calculate/find the analytical transit lightcurve #transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve tempkeplervalues = np.copy(Keplertransit) #create a copy of the kepler data which will be used to caculate the standard deviation for i in range(0, len(Keplertransit['Flux']), 1): #loop over the kepler data array, normalising it to the analytical lightcuve if not 'returnval' in locals(): returnval = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the first value to return else: temparray = np.array((Keplertransit['Flux'][i] - f[i]) / sigma) #calculate the other values to return returnval = np.append(returnval, temparray) #and add them to the return array sigma = np.std(tempkeplervalues['Flux']) #calculate the standard deivation of the normalised lightcurve status = 0 #this will not error, so it exists purely as a formality return [status, returnval] #return a list, which is apparently what is required
def transitcalcloop(): #Just need to add the save functions plandataarray = np.load( 'plandataarray.npy') #load the planetary data array stellardataarray = np.load( 'Stellardataarray.npy' ) #load the stellar data array (No longer need to run LDCcalc beforehand for line in plandataarray: #now loop through the planetary data array, in which line represents a single planet print 'For Kepler {}, planet {}:'.format(line['KeplerID'], line['planetnumber']) if os.path.exists( 'kepler-{0}-planet-{1}-analyticaltransitlc.npy'.format( line['KeplerID'], line['planetnumber'])) == False: Teff, Logg, Metalicity, Rheader = stellarextractor( line['KeplerID'], stellardataarray) #extract the gamma values Inclination = math.acos( line['Impactpar'] / line['a/R_star'] ) #calculate the inclination from the normalised impact-parameter #print Inclination Planetaryradius = line['R_planet'] #extract the planetary radius Planetaryradius_SI = Planetaryradius * 6.3675E6 #and convert it from earth radii to meters Orbitalperiod = line['Orbitalperiod'] #Extract the orbital period Orbitalperiod_SI = Orbitalperiod * 86400 #and convert it from days to seconds Keplerlc = np.load('kepler-{0}-planet-{1}-trandata.npy'.format( line['KeplerID'], line['planetnumber'])) #extract the kepler transit data tvalues = np.sort( Keplerlc['Foldtime'] ) #create an array of times associated with each data point and sort them Keplertransit = np.sort( Keplerlc, order='Foldtime') #sort the kepler data in the same way sigma = sigmacalc( Keplertransit ) #Calculate the standard deviation of the surrounding data points Inclination_fit, Planetaryradius_SI_fit, Teff_fit, Logg_fit, Metalicity_fit, Mstar_SI, Rstar_SI, Stellardensity_SI, semimajoraxis_SI, T_dur_SI, errors, covar = \ zandtfit(Inclination, Planetaryradius_SI, Keplerlc, Teff, Logg, Metalicity, sigma, Orbitalperiod_SI, line['KeplerID'], line['planetnumber']) #calculate the t and z values gamma1, gamma2 = gammainterpolator( Teff_fit, Logg_fit, np.log10(Metalicity_fit)) #calculate the LDC zvalues = zandtcalculator(tvalues, Stellardensity_SI, Inclination_fit, Orbitalperiod_SI) #calculate the zvalues #print zvalues #testing #print tvalues #print 'The minimum zvalue is:' #print np.min(zvalues) norm_impactparameter = (semimajoraxis_SI * math.cos(Inclination_fit) / Rstar_SI) print 'The transit duration is:' print T_dur_SI / 86400 Rplanratio = Planetaryradius_SI_fit / Rstar_SI #Calculate the ratio of planetary radius to stellar radius #print 'The Planetary Ratio is' print Logg, Logg_fit f = transit.occultquad( zvalues, Rplanratio, [gamma1, gamma2 ]) #calculate/find the analytical transit lightcurve ##transitplot(tvalues, f, line['KeplerID'], line['planetnumber']) #plot the analytical transit lightcurve comtransitplot( tvalues, f, Keplertransit['Foldtime'], Keplertransit['Flux'], line['KeplerID'], line['planetnumber'], line['KOI'] ) #plot both the kepler and analytical transit data on the same graph analyticaltransitlc = np.vstack( (tvalues, f) ) #make a single array to contain the analytical transit lightcurve chi, chireduced, DOF, chifull, chireducedfull, DOFfull = chicalc( Keplertransit, analyticaltransitlc, sigma, T_dur_SI) #calculate the chi-squared values #print analyticaltransitlc #print 'The new impact-parameter is {}+-{}, the new duration is {}+-{} and the new radius is {}+-{}'. format(impactpar, errors[0], T_dur, errors[1], R_plan, errors[2]) print 'Saving' np.save('kepler-{0}-planet-{1}-analyticaltransitlc'.format( line['KeplerID'], line['planetnumber']), analyticaltransitlc) #save the analytical transit np.save('kepler-{0}-planet-{1}-covariance'.format( line['KeplerID'], line['planetnumber']), covar) #save the covariance array saveplandata(line, Inclination_fit, T_dur_SI, Planetaryradius_SI_fit, semimajoraxis_SI, line['planetnumber'], line['KeplerID'], errors, chireduced, norm_impactparameter, DOF, chireducedfull, DOFfull) savefittedstellardata(line['KeplerID'], line['planetnumber'], Mstar_SI, Rstar_SI, Stellardensity_SI, Teff, Teff_fit, errors[2], Logg, Logg_fit, errors[3], Metalicity, Metalicity_fit, errors[4], Rheader, gamma1, gamma2, chireduced, DOF, chireducedfull, DOFfull) else: print 'Already Done' return
def transit_model(x,hjd,airmass,fix=[]): p0 = abs(x[0]) gamma = x[5:7] if len(fix) > 0: x = fix tt = x[1] per = x[2] inc = x[3] ars = x[4] airmass_2 = x[7] norm_1 = x[8] norm_2 = x[9] t_10 = x[10] t_11 = x[11] t_20 = x[12] t_21 = x[13] poly_p = x[14:] poly_p_1 = x[14:14+len(poly_p)/2] poly_p_2 = x[14+len(poly_p)/2:] #poly_p_2[1] = poly_p_1[1] #poly_p_2[2] = poly_p_1[2] per = 1.7497798 inc = 85.35 ars = 7.38 # gamma = [0,0] tt = -1.25135820e-04 tt += 2456892.54327 gamma[0] = abs(gamma[0]) gamma[1] = abs(gamma[1]) if gamma[1] > gamma[0]: gamma[1] = gamma[0] #print airmass_2 #print norm_1, norm_2 #print t_1, t_2 z = transit.t2z(tt, per, inc, hjd, ars) divider = 2456895 poly_m_1 = poly_model(poly_p_1,hjd[hjd < divider] - min(hjd[hjd < divider])) poly_m_2 = poly_model(poly_p_2,hjd[hjd > divider] - min(hjd[hjd > divider])) poly_t_1 = poly_model([t_10,t_11],hjd[hjd < divider] - min(hjd[hjd < divider])) poly_t_2 = poly_model([t_20,t_21],hjd[hjd > divider] - min(hjd[hjd > divider])) t_dep = array(list(poly_t_1) + list(poly_t_2)) extinction = array(list(poly_m_1) + list(poly_m_2)) poly_m = 1.0 + 10.0**(0.4*(airmass + airmass_2*airmass**2.0)*extinction) print x model = transit.occultquad(z, p0, gamma) detrended = t_dep*model / poly_m for i in range(0,len(hjd)): if hjd[i] < divider: detrended[i] = detrended[i]*norm_1 else: detrended[i] = detrended[i]*norm_2 # detrended = detrended*sum(model)/sum(detrended) return detrended, z
def bound_transit_calc(Inclination_rad, Planetaryradius_SI, Orbtialperiod_days, Rstar_SI, RHOstar_SI, gamma1, gamma2, Time_datapoints): Orbitalperiod_SI = Orbtialperiod_days * 86400 #convert the orbital period to SI units zvalues = zandtcalculator_bound(Time_datapoints, RHOstar_SI, Inclination_rad, Orbitalperiod_SI) #calculate the zvalues Planetaryradiusratio = Planetaryradius_SI / Rstar_SI #calculate the ratio of R_plan/R_star f = transit.occultquad(zvalues, Planetaryradiusratio, [gamma1, gamma2]) #and then calculate the analytical transit return f
def unbound_transit_calc(Impactpar, Transitduration_days, R_plan_over_R_star, gamma1, gamma2, Time_datapoints): zvalues = zandtcalculator_unbound(Time_datapoints, Impactpar, Transitduration_days, R_plan_over_R_star) #calculate the zvalues f = transit.occultquad(zvalues, R_plan_over_R_star, [gamma1, gamma2]) #and then use these to calculate the analytical transit return f
def transit_model(x, hjd, airmass, fix=[], SPOT_DATA=False): spotlong = x[6] spotlat = x[7] spotsize = abs(x[8]) spotflux = abs(x[9]) if spotsize > 20: spotsize = 20 if spotflux > 1.0: spotflux = 1.0 print SPOT_DATA print x p0 = x[0] #p0 = abs(x[0]) #if p0 > 0.25: #p0 = 0.25 gamma = x[10:12] if len(fix) > 0: x = fix #if abs(gamma[0]) > 1.0: #gamma[0] = 2.0*(gamma[0]/abs(gamma[0])) #if abs(gamma[0] + gamma[1]) >= 1.0: #gamma[1] = 1.0 - gamma[0] airmass_2 = x[1] norm_1 = x[2] norm_2 = x[3] t_11 = x[4] t_21 = x[5] poly_p = x[12:] poly_p_1 = x[12:12 + len(poly_p) / 2] poly_p_2 = x[12 + len(poly_p) / 2:] #poly_p_2[1] = poly_p_1[1] #poly_p_2[2] = poly_p_1[2] per = 1.7497798 inc = 85.35 ars = 7.38 # gamma = [0,0] tt = -1.25135820e-04 tt += 2456892.54327 t_10 = 1.0 t_20 = 1.0 #print airmass_2 #print norm_1, norm_2 #print t_1, t_2 print gamma divider = 2456895 poly_m_1 = poly_model(poly_p_1, hjd[hjd < divider] - min(hjd[hjd < divider])) poly_m_2 = poly_model(poly_p_2, hjd[hjd > divider] - min(hjd[hjd > divider])) poly_t_1 = poly_model([t_10, t_11], hjd[hjd < divider] - min(hjd[hjd < divider])) poly_t_2 = poly_model([t_20, t_21], hjd[hjd > divider] - min(hjd[hjd > divider])) t_dep = array(list(poly_t_1) + list(poly_t_2)) extinction = array(list(poly_m_1) + list(poly_m_2)) poly_m = 1.0 + 10.0**(0.4 * (airmass + airmass_2 * airmass**2.0) * extinction) z = transit.t2z(tt, per, inc, hjd, ars) #model = transit.occultquad(z, p0, gamma) # model = transit.occultnonlin(z, p0, gamma) radiustotal = (1.0 + p0) / ars phase_offset = 0 INPUT = [ p0, radiustotal, gamma[0], gamma[1], inc, phase_offset, spotlong, spotlat, spotsize, spotflux ] if SPOT_DATA == True: plotting = False model = fprism((hjd - tt) / (per), INPUT, SPOT_DATA, plotting=plotting) if plotting == True: quit() else: model = transit.occultquad(z, p0, gamma) #plot(hjd,model2,'b-') #plot(hjd,model,'ro') #show() detrended = t_dep * model / poly_m for i in range(0, len(hjd)): if hjd[i] < divider: detrended[i] = detrended[i] * norm_1 else: detrended[i] = detrended[i] * norm_2 # detrended = detrended*sum(model)/sum(detrended) return detrended, z
def transit_model(x,hjd,airmass,fix=[],SPOT_DATA=False): spotlong = x[6] spotlat = x[7] spotsize = abs(x[8]) spotflux = abs(x[9]) if spotsize > 20: spotsize = 20 if spotflux > 1.0: spotflux = 1.0 print SPOT_DATA print x p0 = x[0] #p0 = abs(x[0]) #if p0 > 0.25: #p0 = 0.25 gamma = x[10:12] if len(fix) > 0: x = fix #if abs(gamma[0]) > 1.0: #gamma[0] = 2.0*(gamma[0]/abs(gamma[0])) #if abs(gamma[0] + gamma[1]) >= 1.0: #gamma[1] = 1.0 - gamma[0] airmass_2 = x[1] norm_1 = x[2] norm_2 = x[3] t_11 = x[4] t_21 = x[5] poly_p = x[12:] poly_p_1 = x[12:12+len(poly_p)/2] poly_p_2 = x[12+len(poly_p)/2:] #poly_p_2[1] = poly_p_1[1] #poly_p_2[2] = poly_p_1[2] per = 1.7497798 inc = 85.35 ars = 7.38 # gamma = [0,0] tt = -1.25135820e-04 tt += 2456892.54327 t_10 = 1.0 t_20 = 1.0 #print airmass_2 #print norm_1, norm_2 #print t_1, t_2 print gamma divider = 2456895 poly_m_1 = poly_model(poly_p_1,hjd[hjd < divider] - min(hjd[hjd < divider])) poly_m_2 = poly_model(poly_p_2,hjd[hjd > divider] - min(hjd[hjd > divider])) poly_t_1 = poly_model([t_10,t_11],hjd[hjd < divider] - min(hjd[hjd < divider])) poly_t_2 = poly_model([t_20,t_21],hjd[hjd > divider] - min(hjd[hjd > divider])) t_dep = array(list(poly_t_1) + list(poly_t_2)) extinction = array(list(poly_m_1) + list(poly_m_2)) poly_m = 1.0 + 10.0**(0.4*(airmass + airmass_2*airmass**2.0)*extinction) z = transit.t2z(tt, per, inc, hjd, ars) #model = transit.occultquad(z, p0, gamma) # model = transit.occultnonlin(z, p0, gamma) radiustotal = (1.0 + p0)/ars phase_offset = 0 INPUT = [p0,radiustotal,gamma[0],gamma[1],inc,phase_offset,spotlong,spotlat,spotsize,spotflux] if SPOT_DATA == True: plotting = False model = fprism((hjd-tt)/(per),INPUT,SPOT_DATA,plotting=plotting) if plotting == True: quit() else: model = transit.occultquad(z, p0, gamma) #plot(hjd,model2,'b-') #plot(hjd,model,'ro') #show() detrended = t_dep*model / poly_m for i in range(0,len(hjd)): if hjd[i] < divider: detrended[i] = detrended[i]*norm_1 else: detrended[i] = detrended[i]*norm_2 # detrended = detrended*sum(model)/sum(detrended) return detrended, z