In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
import flare_prob
import toymodel
import LSSToy
matplotlib.rcParams.update({'font.size':18})
matplotlib.rcParams.update({'font.family':'serif'})
In [2]:
files= np.loadtxt('trilegal_models/cluster_index.txt', comments='#', unpack=True,
usecols=(0,), dtype='str')
In [3]:
# compute the densities of GKM stars
l, b, r2, mvG2, mvK0, mvM0, nG, nK, nM, dist = np.loadtxt('trilegal_models/cluster_index.txt', comments='#',
unpack=True, dtype='float', usecols=(1,2,3,4,5,6,7,8,9,10))
fov = 0.1 # sq deg
Teff_bins = np.log10(np.arange(3000,8000,1000))
clrs = ['crimson','darkorange','cornflowerblue']
ddist = 250.
In [14]:
nG_f = np.zeros_like(nG)
nK_f = np.zeros_like(nK)
nM_f = np.zeros_like(nM)
plt.figure(figsize=(9,7))
for j in range(len(files)):
file = 'trilegal_models/' + files[j]
df = pd.read_table(file, sep=r"\s*", engine='python')
# get densities of GKM stars in each field, compute total # of GKM field stars within r2 radius
for k in range(len(Teff_bins)-2):
x = np.where((df['logg'] >= 4) & (df['logTe'] >= Teff_bins[k]) & (df['logTe'] < Teff_bins[k+1]))
_ = plt.hist(df['g'].values[x], bins=50, color=clrs[k], histtype='step', lw=4,
weights=np.ones(len(x[0])) / fov)
dist_c = 10.**(df['m-M0'].values/5. + 1.)
# within each temp bin for this cluster, count # of stars inside magnitude range of cluster (distance)
x = np.where((df['logg'] >= 4) & (df['logTe'] >= Teff_bins[2]) & (df['logTe'] < Teff_bins[2+1]) &
(dist_c >= dist[j]-ddist) & (dist_c <= dist[j]+ddist))
nG_f[j] = len(x[0]) / fov * np.pi * r2[j]**2.
x = np.where((df['logg'] >= 4) & (df['logTe'] >= Teff_bins[1]) & (df['logTe'] < Teff_bins[1+1]) &
(dist_c >= dist[j]-ddist) & (dist_c <= dist[j]+ddist))
nK_f[j] = len(x[0]) / fov * np.pi * r2[j]**2.
x = np.where((df['logg'] >= 4) & (df['logTe'] >= Teff_bins[0]) & (df['logTe'] < Teff_bins[0+1]) &
(dist_c >= dist[j]-ddist) & (dist_c <= dist[j]+ddist))
nM_f[j] = len(x[0]) / fov * np.pi * r2[j]**2.
plt.yscale('log')
plt.xlabel('g-band (mag)')
plt.ylabel('# Stars per Sq Deg')
plt.xlim(15,28)
Out[14]:
In [17]:
for k in range(len(files)):
print(files[k], nG[k],nG_f[k], nK[k],nK_f[k], nM[k],nM_f[k] )
In [16]:
for k in range(len(files)):
print(files[k], nG[k]/nG_f[k], nK[k]/nK_f[k], nM[k]/nM_f[k] )
In [13]:
x = np.where((df['logg'] >= 4) & (df['logTe'] >= Teff_bins[0]) & (df['logTe'] < Teff_bins[4]))
plt.hexbin(df['g'].values[x] - df['i'].values[x], df['g'].values[x])
plt.ylim(28,15)
Out[13]:
In [ ]: