<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Using sample from paper
Step1:  Using sample from the paper, with B/T cut
Step2:  Using GSWLC, cut in redshift only
But we have already excluded a large part of the passive sequence because we have removed AGN.  What if we repeat the same procedure, but we use the full GSWLC, just limiting to the redshift range of the LCS.
Step3:  how to pick the mass where we define the offset relative to MS.  could use a percentile of LCS mass
Step4:  Using full GSWLC
Step5:  Summary of fits
<ASSISTANT_TASK:>
Python Code:
separate_sf(b.gsw.cat['logMstar'],b.gsw.cat['logSFR'],m1=9.,m2=11,ms_slope=0.592,ms_intercept=-6.05,dm=.2)
logmass = 10.8
yms = -.1968999*logmass**2+4.4186588*logmass-24.607396
print("offset b/w MS and sSFR=-11.5 = {:.3f} ".format(yms- (logmass-11.5)))
print("offset relative to MS sigma = {:.3f}".format((yms- (logmass-11.5))/.3))
Explanation: Using sample from paper
End of explanation
flag = b.gsw.cat['__B_T_r'] < 0.3
gswBTcut = b.gsw.cat[flag]
separate_sf(gswBTcut['logMstar'],gswBTcut['logSFR'],m1=9.,m2=11,ms_slope=0.754,ms_intercept=-7.56,dm=.3)
Explanation: Using sample from the paper, with B/T cut
End of explanation
gswlcs = Table.read(homedir+'/research/GSWLC/GSWLC-X2-LCS-Zoverlap.dat')
separate_sf(gswlcs['logMstar'],gswlcs['logSFR'],m1=9.,m2=11,ms_slope=.553,ms_intercept=-5.71,dm=.2)
logmass = 10.7
yms = -.121886*logmass**2+2.912528*logmass-17.1120
print("offset b/w MS and sSFR=-11.5 = {:.3f} ".format(yms- (logmass-11.5)))
print("offset relative to MS sigma = {:.3f}".format((yms- (logmass-11.5))/.3))
10.**.827
.827-.45
Explanation: Using GSWLC, cut in redshift only
But we have already excluded a large part of the passive sequence because we have removed AGN.  What if we repeat the same procedure, but we use the full GSWLC, just limiting to the redshift range of the LCS.
End of explanation
lcsflag = (b.lcs.membflag | b.lcs.infallflag) & (b.lcs.cat['logMstar'] > 9.7) & (b.lcs.cat['logSFR']-b.lcs.cat['logMstar'] > -11.5)
logmstar = b.lcs.cat['logMstar'][lcsflag]
from scipy.stats import scoreatpercentile
print("percentile mass of LCS sample = {:.3f}".format(scoreatpercentile(logmstar,90)))
flag =   (b.gsw.cat['logMstar'] > 9.7) & (b.gsw.cat['logSFR']-b.gsw.cat['logMstar'] > -11.5)
logmstar = b.gsw.cat['logMstar'][flag]
from scipy.stats import scoreatpercentile
print("percentile mass of field sample = {:.3f}".format(scoreatpercentile(logmstar,90)))
.834-.45
Explanation: how to pick the mass where we define the offset relative to MS.  could use a percentile of LCS mass
End of explanation
gsw = Table.read(homedir+'/research/GSWLC/GSWLC-X2.dat',format='ascii')
separate_sf(gsw['logMstar'],gsw['logSFR'],m1=9,m2=11,ms_slope=.799,ms_intercept=-7.93,dm=.2)
Explanation: Using full GSWLC
End of explanation
mycolors = plt.rcParams['axes.prop_cycle'].by_key()['color']
plt.figure()
plt.hexbin(gswlcs['logMstar'],gswlcs['logSFR'],cmap='gray_r',gridsize=75,bins='log')
xline = np.linspace(8,11.5,100)
# from GSWLC with LCS z cut
yline = .556*xline-5.74
STD = 0.32
offset = -0.62
plt.plot(xline,yline,lw=2,c=mycolors[0],label='GSWLC, Zcut only')
plt.plot(xline,yline-1.5*STD,ls='--',lw=2,c=mycolors[0])
plt.plot(xline,yline+offset,ls=':',lw=2,c=mycolors[0])
plt.fill_between(xline,yline-1.5*STD,yline+offset,color=mycolors[0],alpha=.5)
# from GSWLC, cut according to AGC, Simard, etc
STD = 0.29
offset = -0.7
yline = 0.592*xline -6.18
plt.plot(xline,yline,lw=2,c=mycolors[1],label='GSWLC, all cuts')
plt.plot(xline,yline-1.5*STD,ls='--',lw=2,c=mycolors[1])
plt.plot(xline,yline+offset,ls=':',lw=2,c=mycolors[1])
plt.fill_between(xline,yline-1.5*STD,yline+offset,color=mycolors[1],alpha=.5)
plt.legend()
# from full GSWLC
STD = 0.3
offset = -0.82
yline = 0.799*xline -7.92
#plt.plot(xline,yline,lw=2,c=mycolors[2],label='GSWLC')
#plt.plot(xline,yline-1.5*STD,ls='--',lw=2,c=mycolors[2])
#plt.plot(xline,yline+offset,ls=':',lw=2,c=mycolors[2])
#plt.fill_between(xline,yline-1.5*STD,yline+offset,color=mycolors[2],alpha=.5)
plt.legend()
plt.axis([8,12,-4,2])
plt.xlabel('logMstar')
plt.ylabel('logSFR')
mycolors = plt.rcParams['axes.prop_cycle'].by_key()['color']
plt.figure()
plt.hexbin(gsw['logMstar'],gsw['logSFR'],cmap='gray_r',gridsize=75,bins='log',extent=(8,12,-4,2))
xline = np.linspace(8,11.5,100)
# from GSWLC with LCS z cut
yline = .556*xline-5.74
STD = 0.32
offset = -0.62
#plt.plot(xline,yline,lw=2,c=mycolors[0],label='GSWLC, Zcut only')
#plt.plot(xline,yline-1.5*STD,ls='--',lw=2,c=mycolors[0])
#plt.plot(xline,yline+offset,ls=':',lw=2,c=mycolors[0])
#plt.fill_between(xline,yline-1.5*STD,yline+offset,color=mycolors[0],alpha=.5)
# from GSWLC, cut according to AGC, Simard, etc
STD = 0.29
offset = -0.7
yline = 0.592*xline -6.18
#plt.plot(xline,yline,lw=2,c=mycolors[1],label='GSWLC, all cuts')
#plt.plot(xline,yline-1.5*STD,ls='--',lw=2,c=mycolors[1])
#plt.plot(xline,yline+offset,ls=':',lw=2,c=mycolors[1])
#plt.fill_between(xline,yline-1.5*STD,yline+offset,color=mycolors[1],alpha=.5)
plt.legend()
# from full GSWLC
STD = 0.3
offset = -0.82
yline = 0.799*xline -7.92
plt.plot(xline,yline,lw=2,c=mycolors[2],label='GSWLC')
plt.plot(xline,yline-1.5*STD,ls='--',lw=2,c=mycolors[2])
plt.plot(xline,yline+offset,ls=':',lw=2,c=mycolors[2])
#plt.fill_between(xline,yline-1.5*STD,yline+offset,color=mycolors[2],alpha=.5)
plt.legend()
plt.axis([8,12,-4,2])
separate_sf(b.lcs.cat['logMstar'],b.lcs.cat['logSFR'],m1=9.,m2=11,ms_slope=0.592,ms_intercept=-6.05,dm=.5)
flag = b.lcs.cat['__B_T_r'] < 0.3
lcsBTcut = b.lcs.cat[flag]
separate_sf(lcsBTcut['logMstar'],lcsBTcut['logSFR'],m1=9.,m2=11,ms_slope=0.754,ms_intercept=-7.56,dm=.5)
Explanation: Summary of fits
End of explanation
<END_TASK>