def mk_lightcurve_fig(  ):
    from hstsnpipe.tools import snana
    from hstsnpipe.tools.figs import plotsetup
    plotsetup.fullpaperfig( figsize=[8,4] )
    pl.clf()

    simIa = snana.SimTable( 'snIa_zgrid' )
    FLTMATRIX = simIa.FLT.reshape( simIa.LCMATRIX.shape )
    bandlist = FLTMATRIX[0,0,0,0,:,0]
    def iband(band) : 
        return( np.where( bandlist==band )[0][0] )
    iz18 = np.argmin( np.abs( simIa.z-1.8 ) )
    ilp0 = np.argmin( np.abs( simIa.x1 ) )
    iF160W = iband('H')
    iF140W = iband('N')
    iF110W = iband('M')
    muIa = 5.

    ax1 = pl.subplot(121)
    ax2 = pl.subplot(122, sharex=ax1 )
    # snIaMAGH = simIa.LCMATRIX[ ilp0, 0, 0, iz18, iF160W, : ]
    snIaMAGN = vega2ab( simIa.LCMATRIX[ ilp0, 0, 0, iz18, iF140W, : ], 'F140W' )
    snIaMAGM = vega2ab( simIa.LCMATRIX[ ilp0, 0, 0, iz18, iF110W, : ], 'F140W' )
    snIaMJD = simIa.TOBS[ iz18, : ]

    # ax1.plot( snIaMJD, snIaMAGH - 2.5*np.log10( muIa ), 'k-', lw=2, marker=' ', )
    ax1.plot( snIaMJD, snIaMAGN - 2.5*np.log10( muIa ), 'r-', lw=2, marker=' ', )
    ax2.plot( snIaMJD, snIaMAGM - 2.5*np.log10( muIa ), 'r-', lw=2, marker=' ', )
    ax1.invert_yaxis()

    simII = snana.SimTable( 'snII_zgrid' )
    FLTMATRIX = simII.FLT.reshape( simII.LCMATRIX.shape )
    bandlist = FLTMATRIX[0,0,0,0,:,0]
    def iband(band) : 
        return( np.where( bandlist==band )[0][0] )
    iz20 = np.argmin( np.abs( simII.z-2.0 ) )
    iF140W = iband('N')
    iF110W = iband('M')
    muII = 12.
    ilpII=13  # select one representative II-P model

    snIIMAGN = vega2ab( simII.LCMATRIX[ ilpII, 0, 0, iz20, iF140W, : ], 'F140W' )
    snIIMAGM = vega2ab( simII.LCMATRIX[ ilpII, 0, 0, iz20, iF110W, : ], 'F110W' )
    snIIMJD = simII.TOBS[ iz20, : ]
    ax1.plot( snIIMJD, snIIMAGN - 2.5*np.log10( muII ), 'b--', lw=2, marker=' ', )
    ax2.plot( snIIMJD, snIIMAGM - 2.5*np.log10( muII ), 'b--', lw=2, marker=' ', )

    ax1.axhline( vega2ab( 24.6, 'f140w'), color='k',ls=':', lw=2, )
    ax2.axhline( vega2ab( 25.3, 'f110w'), color='k',ls=':', lw=2, )

    # ax2.text(0.95,0.95,'F160W', fontsize='large', ha='right',va='top', transform=ax2.transAxes )
    ax1.text(0.95,0.95,'F140W', fontsize='large', ha='right',va='top', transform=ax1.transAxes )
    ax2.text(0.95,0.95,'F110W', fontsize='large', ha='right',va='top', transform=ax2.transAxes )

    ax1.text( 115, 25.65, '30 min SNAP\n detection limit', ha='right',va='bottom')
    # ax2.text( 115, 26.0, '30 min SNAP\n detection limit', ha='right',va='bottom')

    ax1.text( 38, 25.3, 'Type Ia SN\n z=1.8, $\mu$=5\n t$_{vis}$=75 days', ha='left',va='bottom', color='r', fontsize='large')
    # ax2.text( 25, 25.5, 'Type II-P SN\n z=2.0, $\mu$=12\n t$_{vis}$=50 days', ha='left',va='center', color='b', fontsize='large')
    # ax1.text( 67, 25.6, 'Type II-P SN\n z=2.0, $\mu$=12\n t$_{vis}$=50 days', ha='left',va='top', color='b', fontsize='large', backgroundcolor='w' )
    ax2.text( 67.5, 26.15, 'Type II-P SN\n z=2.0, $\mu$=12\n t$_{vis}$=50 days', ha='left',va='top', color='b', fontsize='large', backgroundcolor='w' )

    ax1.set_xlim(-35,119)
    ax1.set_ylim(27, 27-2.51)
    ax2.set_ylim(27.4, 27.4-2.51)
    ax2.yaxis.set_ticks_position('right')
    ax2.yaxis.set_ticks_position('both')
    ax2.yaxis.set_label_position('right')
    fig = pl.gcf()
    fig.subplots_adjust( left=0.13, right=0.87, bottom=0.12, top=0.95, wspace=0.05 )
    ax2.set_xlabel('Observer-frame Time [days]')
    ax1.set_xlabel('Observer-frame Time [days]')
    ax1.set_ylabel('Observed F140W magnitue [AB]')
    ax2.set_ylabel('Observed F110W magnitue [AB]', labelpad=20, rotation=-90)
Example #2
0
import djs_angle_match
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import plotsetup
from matplotlib import gridspec

plotsetup.fullpaperfig()
co=0
xlabel=['g mag','MJD/100','Airmass','Ang. Dist. (Deg)']
fil2=['g','r','i','z']
fields=['053','054','055','057','058','059']
fields=['0','053','054','056','057','058','059']
fbin=[0,0.1,0.2,0.3,0.5,0.7,1.0,1.3,2.0]
        
if (1>0):

    co=0
    l1=0
    jj=0
    gs1 = gridspec.GridSpec(1, 4)
    gs1.update(bottom=0.17, top=0.95, wspace=0.0)
    ax1= plt.subplot(gs1[0])
    ax2= plt.subplot(gs1[1])
    ax3= plt.subplot(gs1[2])
    ax4= plt.subplot(gs1[3])
    ax=[ax1,ax2,ax3,ax4]    
    for k1 in range(0,2):
        for k2 in range(0,2):
        
            if (co==0):fil,mag,color,off1,off1e,num = np.loadtxt('/project/rkessler/dscolnic/DougComp/ps1star/ncomp_'+fil2[l1]+'_'+fields[jj]+'_1_mag.txt', usecols=(0,1,2,3,4,5), unpack=True, dtype='string')
def mkTvisHistFigs():

    import plotsetup
    plotsetup.fullpaperfig(1, [8,3])

    datfile1 = 'lensed_galaxies.txt'
    dat1 = ascii.read(datfile1, header_start=-1)
    mu1 = dat1['mu1']
    z1 = dat1['z']
    dt1 = dat1['dt1']

    datfile2 = 'lensed_galaxies2.txt'
    dat2 = ascii.read(datfile2)
    mu2 = dat2['col6']
    z2 = dat2['col5']
    dt2 = dat2['col1']
    dterr2p = dat2['col2']/11.2
    dterr2m = dat2['col3']/11.2
    dterr2 = dat2['col4']/11.2

    ax1 = pl.subplot(131)
    z = np.append( z1, z2 )
    dt = np.append( dt1, dt2 )

    i5 = np.where( (dt>0) & (dt<5) )[0]
    print( len(i5) / float(len(dt) ) )
    print( len(i5) )
    randoff = (np.random.randn( len(z) ) -0.5 ) * 0.1
    z = z+randoff
    pl.hist( z , normed=False, bins=np.arange(0.1,4.51,0.2), color='darkcyan')#, alpha=0.3  )
    # pl.hist( z[i5] , bins=np.arange(0.1,4.51,0.2), color='darkorange')#, alpha=0.3  )
    ax1.set_xlabel('Redshift')
    ax1.set_ylabel(r'Number of Lensed Galaxy Images')

    ax2 = pl.subplot(132)
    pl.hist( dt[i5] , bins=np.arange(0.0,5.01,0.5), color='darkcyan')#, alpha=0.3  )
    ax2.set_xlabel(r'Time Delay $\Delta$t')


    ax3 = pl.subplot(133)

    ipos = np.where( (dt2>0) )
    # err = dterr2[i5] / dt2[i5]
    err = dterr2[ipos] / dt2[ipos]
    pl.hist( err ,normed=False,  bins=np.arange(0.0,3.0,0.05), color='darkcyan' )#, alpha=0.3  )
    ax3.set_xlabel(r'Time Delay \%Error')


    # pl.hist( z[i5] , bins=np.arange(0.1,4.51,0.2), color='darkorange', alpha=0.3  )
    #ax3 = pl.axes( [0.5,0.5,0.4,0.4], transform=ax2.transAxes )
    #ax3.hist( dt, bins=np.arange(0.0,0.1,0.02), color='darkorange', alpha=0.3  )

    fig = pl.gcf()
    fig.subplots_adjust(left=0.08, bottom=0.18,right=0.95, top=0.90, wspace=0.05,)
    
    ax1.set_xlim(0.3,4.6)
    ax2.set_xlim([0.01, 4.99])
    ax3.set_xlim([0.01, 0.99])


    # ax1.set_xticklabels([1,2,3,4])
    ax2.set_yticklabels([])
    ax3.set_yticklabels([])