def chi2_1(individual): """ Fitness function for 1 planet model """ P, K, ecc, omega, T0, gam = individual get_rvn(system.time, P, K, ecc, omega, T0, gam, vel) chi2 = sum(((system.vrad - vel)/system.error)**2) #print chi2 return chi2,
def chi2_n(params): """ Fitness function for N planet model """ # print params P, K, ecc, omega, T0, gam = [params[i::6] for i in range(6)] #print ecc if any(e>1 or e<0 for e in ecc): return 1e99 get_rvn(system.time, P, K, ecc, omega, T0, gam[0], vel) #print 'out of get_rvn' return system.vrad - vel
def chi2_n(individual): """ Fitness function for N planet model """ P, K, ecc, omega, T0, gam = [individual[i::6] for i in range(6)] #print ecc get_rvn(system.time, P, K, ecc, omega, T0, gam[0], vel) #print 'out of get_rvn' chi2 = sum(((system.vrad - vel)/system.error)**2) #print chi2 return chi2,
def chi2_2(params): P, K, ecc, omega, T0, gam = params get_rvn(system.time, P, K, ecc, omega, T0, gam, vel) return system.vrad - vel
def do_plot_fit(self): """ Plot the observed radial velocities together with the current best fit curve as well as phased RV curves for each planet considered in the fit. Data from each file are color coded and labeled. """ if self.fit is None: return # there is no fit yet colors = 'rgbmk' # possible colors t, rv, err = self.time, self.vrad, self.error # temporaries tt = numpy.linspace(self.time.min()-200, self.time.max()+300, 400) final = numpy.zeros_like(tt) par = self.fit['params'] keplerians = int(len(par)/6) P, K, ecc, omega, T0, gam = [par[j::6] for j in range(6)] gam = gam[0] get_rvn(tt, P, K, ecc, omega, T0, gam, final) ### observations + fitted curve + residuals plt.figure() gs = gridspec.GridSpec(2, 1, height_ratios=[2,1]) ax1 = plt.subplot(gs[0]) # plot each file's values for i, (fname, [n, nout]) in enumerate(sorted(self.provenance.iteritems())): m = n-nout # how many values are there after restriction ax1.errorbar(t[:m], rv[:m], yerr=err[:m], \ fmt='o'+colors[i], label=fname) t, rv, err = t[m:], rv[m:], err[m:] ax1.plot(tt, final, 'k-') # redo this... t, rv, err = self.time, self.vrad, self.error # temporaries final = numpy.zeros_like(t) get_rvn(t, P, K, ecc, omega, T0, gam, final) ax2 = plt.subplot(gs[1], sharex=ax1) # plot residuals for i, (fname, [n, nout]) in enumerate(sorted(self.provenance.iteritems())): m = n-nout # how many values are there after restriction ax2.errorbar(t[:m], rv[:m]-final[:m], yerr=err[:m], \ fmt='o'+colors[i], label=fname) t, rv, err, final = t[m:], rv[m:], err[m:], final[m:] ax2.axhline(y=0, xmin=0, xmax=1, ls='--', color='k') # # redo this... # t, rv, err = self.time-self.time.min(), self.vrad, self.error # temporaries # final = numpy.zeros_like(tt) # ### phased RV curves # plt.figure() # gs = gridspec.GridSpec(keplerians, 1) # for i in range(keplerians): # get_rvn(tt, P[i], K[i], ecc[i], omega[i], T0[i], gam, final) # ax = plt.subplot(gs[i]) # # plot each file's values # for i, (fname, [n, nout]) in enumerate(sorted(self.provenance.iteritems())): # m = n-nout # how many values are there after restriction # ax.errorbar(t[:m]/P[i], rv[:m], yerr=err[:m], \ # fmt='o'+colors[i], label=fname) # t, rv, err = t[m:], rv[m:], err[m:] # ax.plot((tt-min(tt))/P[i], final, 'k-') plt.show()