def format(fname, age, feh, nG, nK, nM, mvG, mvK, mvM, e_bv, use_IMF=False): ntot = nG + nK + nM # create arrays of temperature and logg, G : K : M tf = lambda n, Xmin, Xmax: np.random.uniform(Xmin, Xmax, n) teffs = np.concatenate((tf(nG, Gmin, Gmax), tf(nK, Kmin, Kmax), tf(nM, Mmin, Mmax))) lg = lambda n, logg: np.ones(n) * logg loggs = np.concatenate((lg(nG, Glogg), lg(nK, Klogg), lg(nM, Mlogg))) # create arrays of feh, b-v, log(age) and log(teff) fehs = np.ones(ntot) * feh bvs = teff2bv_orig(teffs, fehs, loggs) - e_bv bv_func = lambda n, Xmin, Xmax: np.random.uniform(Xmin, Xmax, n) bvs = np.concatenate((bv_func(nG, .5, .8), bv_func(nK, .8, 1.1), tf(nM, 1.1, 1.4))) logAges = np.ones(ntot) * np.log10(age) logTeff = np.log10(teffs) rmag = np.concatenate((V2r(mvG, bvs[:nG]), V2r(mvK, bvs[nG:nG+nK]), V2r(mvM, bvs[nG+nK:]))) data = np.vstack((logAges, bvs, logTeff, rmag)) np.savetxt("{0}.dat".format(fname), data.T) return logAges, bvs, logTeff, rmag
def format(fname, age, feh, nG, nK, nM, mvG, mvK, mvM, e_bv, use_IMF=False): ntot = nG + nK + nM # create arrays of temperature and logg, G : K : M tf = lambda n, Xmin, Xmax: np.random.uniform(Xmin, Xmax, n) teffs = np.concatenate((tf(nG, Gmin, Gmax), tf(nK, Kmin, Kmax), tf(nM, Mmin, Mmax))) lg = lambda n, logg: np.ones(n) * logg loggs = np.concatenate((lg(nG, Glogg), lg(nK, Klogg), lg(nM, Mlogg))) # create arrays of feh, b-v, log(age) and log(teff) fehs = np.ones(ntot) * feh bvs = teff2bv_orig(teffs, fehs, loggs) - e_bv bv_func = lambda n, Xmin, Xmax: np.random.uniform(Xmin, Xmax, n) bvs = np.concatenate((bv_func(nG, .5, .8), bv_func(nK, .8, 1.1), tf(nM, 1.1, 1.4))) logAges = np.ones(ntot) * np.log10(age) logTeff = np.log10(teffs) rmag = np.concatenate( (V2r(mvG, bvs[:nG]), V2r(mvK, bvs[nG:nG + nK]), V2r(mvM, bvs[nG + nK:]))) data = np.vstack((logAges, bvs, logTeff, rmag)) np.savetxt("{0}.dat".format(fname), data.T) return logAges, bvs, logTeff, rmag
a_surf = np.linspace(.65, 15, 100)*1000 c_surf = np.linspace(.4, 1.4, 100) a_surf, c_surf = np.meshgrid(a_surf, c_surf) p_surf = a_surf**n * a * (c_surf - c)**b a_surf /= 1000. # load my data # data = np.genfromtxt("/Users/angusr/Python/Gyro/data/garcia_all_astero.txt") # data = np.genfromtxt("/Users/angusr/Python/Gyro/data/garcia_all_astero_no_precise.txt") data = np.genfromtxt("/Users/angusr/Python/Gyro/data/all_astero_plusgarcia.txt") t = data[1] a = data[3] p = data[6] logg = data[8] feh = data[11] bv = teff2bv_orig(t, logg, feh) # load precise data data = np.genfromtxt("/Users/angusr/Python/Gyro/data/vandt.txt", skip_header=1).T pt = data[1] pa = data[3] pp = data[6] plogg = data[8] pfeh = data[11] pbv = teff2bv_orig(pt, plogg, pfeh) # load cluster and field stars data data = np.genfromtxt("/Users/angusr/Python/Gyro/data/clusters.txt").T cbv = data[0] cp = data[2] ca = data[4]
# plot plt.clf() plt.plot((JK), teff[a], 'k.') plt.plot(xs, teff_fit, 'b-') # find teffs newteff = np.polyval(p, j_k) plt.plot(j_k, newteff, 'ro') plt.savefig("JK2teff") feh = np.zeros_like(newteff) newlogg = np.zeros_like(newteff) # find loggs def find_nearest(array,value): idx = (np.abs(array-value)).argmin() return array[idx] for i, t in enumerate(newteff): l = teff==find_nearest(teff, t) newlogg[i] = logg[l][0] bv = teff2bv_orig(newteff, newlogg, feh) data = np.zeros((2, len(newteff))) data[0:] = period data[1:] = bv np.savetxt('/Users/angusr/Python/Gyro/data/ComaBer_bv.txt', data.T)
# load Coma Ber data = np.genfromtxt("/Users/angusr/Python/Gyro/data/ComaBer.txt", skip_header=1).T j_k = data[2] # dereddened J-K j_k = j_k - deltaJK JK = J-K # fit a polynomial a = (.47 < age) * (age < .53) * teff > 3000 JK = J[a] - K[a] p = np.polyfit(JK, teff[a], 3) xs = np.linspace(min(JK), max(JK), 1000) teff_fit = np.polyval(p, xs) # plot plt.clf() plt.plot((JK), teff[a], 'k.') plt.plot(xs, teff_fit, 'b-') # find teffs teff = np.polyval(p, j_k) print teff plt.plot(j_k, teff, 'ro') plt.savefig("JK2teff") feh = np.zeros_like(teff) bv = teff2bv_orig(teff, logg, feh)
pl.ylabel("$P_{rot}~\mathrm{(days)}$") pl.xlabel("$\mathrm{Age~(Gyr)}$") pl.xlim(0.1, 15) pl.ylim(0, 70) pl.savefig('cool_stars5') # add Amy data = np.genfromtxt('/Users/angusr/Python/Gyro/data/extra_amy_matched.txt').T period = np.concatenate((period, data[1])) period_err = np.concatenate((period_err, data[2])) teff = np.concatenate((teff, data[3])) teff_err = np.concatenate((teff_err, data[4])) age = np.concatenate((age, data[13])) age_err = np.concatenate((age_err, data[14])) logg = np.concatenate((logg, data[10])) bv = teff2bv_orig(teff, logg, np.ones_like(teff)*-.2) bv_err = np.ones_like(bv)*.01 a_errp = age_err a_errm = age_err p_err = period_err pl.clf() pl.errorbar(age, period, xerr = (a_errp, a_errm), yerr = p_err, \ color = ocols[1], fmt = 'o', mec = ocols[1], capsize = 0, \ markersize = ms, ecolor = '0.8') print len(age) pl.ylabel("$P_{rot}~\mathrm{(days)}$") pl.xlabel("$\mathrm{Age~(Gyr)}$") pl.xlim(0.1, 15) pl.ylim(0, 70)