sp=yrsplit.search(m).groups(0) models['age'][m]=(int(sp[0])+(float(sp[1])/10000.))*10**int(sp[2]) maxage= float(max(models['age'].values)) minage= float(min(models['age'].values)) diffage=float(maxage-minage) ###print models['age'] modelcolors=['#%02x%02x%02x' % (int(255*(1-(i-minage)/diffage)),0,int(255 * ((i-minage)/diffage))) for i in models['age'].values] models['col']=modelcolors models['a']=0 match_df['x']=match_df['J']-match_df['K'] match_df['ex']=np.sqrt(match_df['e_J']**2+match_df['e_K']**2) #plt.errorbar(match_df['x'],match_df['J']-6.2,fmt=None,ecolor='k',xerr=match_df['ex'],yerr=match_df['e_J']) alphaarray=['']*len(models.index.values) for j in range(len(alphaarray)): i=models.index.values[j] ff=it.testfitiso(match_df,d[i],6.2) alphaarray[j]=1-2*ff models['a']=alphaarray #print 1-2*ff #print models['a'][i] print models['a'] for i in models.index.values: plt.plot(d[i]['J']-d[i]['K'],d[i]['J'],color=models['col'][i],alpha=models['a'][i]) outfile.write('{0}\t{1}\ta={2}\n'.format(models['age'][i],ff,models['a'][i])) plt.scatter(match_df['x'],match_df['J']-6.2,color=match_df['col'],marker='o') xmin=float('inf') xmax=-float('inf') ymin=float('inf') ymax=-float('inf') for i in models.index.values: color_of_model=d[i]['J']-d[i]['K']
import pandas as pd import psycopg2 as p2 import matplotlib.pyplot as plt import isotools as iso df = pd.DataFrame con = p2.connect("dbname='stars' host='localhost' user='******'") cur = con.cursor() cur.execute("select jmag, e_jmag, hmag, e_hmag, kmag, e_kmag from alphaperprevmembers where jmag-kmag<0.6") ap = df(cur.fetchall(), columns=["J", "e_J", "H", "e_H", "K", "e_K"]) cur.close() con.close() con = p2.connect("dbname='parsec' host='localhost' user='******'") cur = con.cursor() cur.execute("select names from years_z021") N = cur.fetchall() d = {} for n in N: cur.execute("select j, h, k from {0}_z021;".format(n[0])) d[n] = df(cur.fetchall(), columns=["J", "H", "K"]) d[n]["fit"] = iso.testfitiso(ap, d[n], 6.2) outfile = open("bestiso.txt", "w") for k in d.keys(): outfile.write("{0}\t{1}\n".format(k, d[k]["fit"][0])) cur.close() con.close() outfile.close()