Beispiel #1
0
def plot_maprmax(savefilename, plotname):
    with open(savefilename, 'rb') as savefile:
        bf = numpy.array(pickle.load(savefile))
        samples = numpy.array(pickle.load(savefile))
        bf_g15 = numpy.array(pickle.load(savefile))
        samples_g15 = numpy.array(pickle.load(savefile))
        bf_zero = numpy.array(pickle.load(savefile))
        samples_zero = numpy.array(pickle.load(savefile))
    maps = define_rcsample.MAPs()
    plotthis = numpy.zeros(len(bf)) + numpy.nan
    for ii, map in enumerate(maps.map()):
        tmed = numpy.median(
            numpy.exp(samples[ii, 3])[True -
                                      numpy.isnan(numpy.exp(samples[ii, 3]))])
        if tmed < 5.:
            tmed = 0.
        plotthis[ii] = tmed
    bovy_plot.bovy_print()
    maps.plot(plotthis,
              vmin=5.,
              vmax=13.,
              minnstar=15,
              zlabel=r'$R_{\mathrm{peak}}\,(\mathrm{kpc})$',
              shrink=0.68,
              cmap='coolwarm_r')
    # Sequences
    haloc = define_rcsample.highalphalocus()
    bovy_plot.bovy_plot(haloc[:, 0],
                        haloc[:, 1],
                        '-',
                        color='0.75',
                        lw=2.5,
                        overplot=True)
    haloc = define_rcsample.lowalphalocus()
    haloc = haloc[(haloc[:, 0] > -0.55) * (haloc[:, 0] < 0.225)]
    bovy_plot.bovy_plot(haloc[:, 0],
                        haloc[:, 1],
                        '-',
                        color='0.75',
                        lw=2.5,
                        overplot=True)
    # Label
    #t= pyplot.text(-0.51,0.235,r'$\mathrm{single}$',
    #                size=16.,color='w')
    #t.set_bbox(dict(alpha=0.5,color=cm.coolwarm(0.),
    #                edgecolor='none'))
    #t= pyplot.text(-0.475,0.195,r'$\mathrm{exponential}$',
    #                size=16.,color='w')
    t = pyplot.text(-0.625,
                    0.195,
                    r'$R_{\mathrm{peak}} < 5\,\mathrm{kpc}$',
                    size=16.,
                    color='w')
    t.set_bbox(dict(alpha=0.5, color=cm.coolwarm_r(0.), edgecolor='none'))
    pyplot.tight_layout()
    bovy_plot.bovy_end_print(plotname, dpi=300)
    return None
Beispiel #2
0
def plot_maphz(plotname):
    # Load the three fits
    with open('../mapfits/tribrokenexpflare.sav','rb') as savefile:
        bf= numpy.array(pickle.load(savefile))
        samples= numpy.array(pickle.load(savefile))
    with open('../mapfits/tribrokenexp.sav','rb') as savefile:
        bfnf= numpy.array(pickle.load(savefile))
        samplesnf= numpy.array(pickle.load(savefile))
    with open('../mapfits/tribrokenexpfixedflare.sav','rb') as savefile:
        bfff= numpy.array(pickle.load(savefile))
        samplesff= numpy.array(pickle.load(savefile))
    maps= define_rcsample.MAPs()
    plotthisz= numpy.zeros(len(bf))+numpy.nan
    plotthisze= numpy.zeros(len(bf))+numpy.nan
    for ii, map in enumerate(maps.map()):
        if numpy.median(numpy.exp(samples[ii,3])[True-numpy.isnan(numpy.exp(samples[ii,3]))]) < 5.:
            tmed= numpy.median((1./samplesnf[ii,1])[True-numpy.isnan(1./samplesnf[ii,1])])
            terr= numpy.std((1./samplesnf[ii,1])[True-numpy.isnan(1./samplesnf[ii,1])])
        else:
            tmed= numpy.median((1./samplesff[ii,1])[True-numpy.isnan(1./samplesff[ii,1])])
            terr= numpy.std((1./samplesff[ii,1])[True-numpy.isnan(1./samplesff[ii,1])])
        plotthisz[ii]= tmed
        plotthisze[ii]= terr
    plotthisz[plotthisze/plotthisz > 0.2]= numpy.nan
    bovy_plot.bovy_print()
    maps.plot(plotthisz*1000.,
              vmin=200.,vmax=1000.,
              minnstar=15,
              zlabel=r'$h_Z\,(\mathrm{pc})$',
              shrink=0.655)
    # Sequences
    haloc= define_rcsample.highalphalocus()
    bovy_plot.bovy_plot(haloc[:,0],haloc[:,1],'-',color='0.75',
                        lw=2.5,overplot=True)
    haloc= define_rcsample.lowalphalocus()
    haloc= haloc[(haloc[:,0] > -0.55)*(haloc[:,0] < 0.225)]
    bovy_plot.bovy_plot(haloc[:,0],haloc[:,1],'-',color='0.75',
                        lw=2.5,overplot=True)
    # Label
    #t= pyplot.text(-0.51,0.235,r'$\mathrm{single}$',
    #                size=16.,color='w')
    #t.set_bbox(dict(alpha=0.5,color=cm.coolwarm(0.),
    #                edgecolor='none'))
    #t= pyplot.text(-0.475,0.195,r'$\mathrm{exponential}$',
    #                size=16.,color='w')
    #t.set_bbox(dict(alpha=0.5,color=cm.coolwarm(0.),
    #                edgecolor='none'))
    pyplot.tight_layout()
    bovy_plot.bovy_end_print(plotname,dpi=300)
    return None
Beispiel #3
0
def plot_maprmax(savefilename,plotname):
    with open(savefilename,'rb') as savefile:
        bf= numpy.array(pickle.load(savefile))
        samples= numpy.array(pickle.load(savefile))
        bf_g15= numpy.array(pickle.load(savefile))
        samples_g15= numpy.array(pickle.load(savefile))
        bf_zero= numpy.array(pickle.load(savefile))
        samples_zero= numpy.array(pickle.load(savefile))
    maps= define_rcsample.MAPs()
    plotthis= numpy.zeros(len(bf))+numpy.nan
    for ii, map in enumerate(maps.map()):
        tmed= numpy.median(numpy.exp(samples[ii,3])[True-numpy.isnan(numpy.exp(samples[ii,3]))])
        if tmed < 5.:
            tmed= 0.
        plotthis[ii]= tmed
    bovy_plot.bovy_print()
    maps.plot(plotthis,
              vmin=5.,vmax=13.,
              minnstar=15,
              zlabel=r'$R_{\mathrm{peak}}\,(\mathrm{kpc})$',
              shrink=0.68,cmap='coolwarm_r')
    # Sequences
    haloc= define_rcsample.highalphalocus()
    bovy_plot.bovy_plot(haloc[:,0],haloc[:,1],'-',color='0.75',
                        lw=2.5,overplot=True)
    haloc= define_rcsample.lowalphalocus()
    haloc= haloc[(haloc[:,0] > -0.55)*(haloc[:,0] < 0.225)]
    bovy_plot.bovy_plot(haloc[:,0],haloc[:,1],'-',color='0.75',
                        lw=2.5,overplot=True)
    # Label
    #t= pyplot.text(-0.51,0.235,r'$\mathrm{single}$',
    #                size=16.,color='w')
    #t.set_bbox(dict(alpha=0.5,color=cm.coolwarm(0.),
    #                edgecolor='none'))
    #t= pyplot.text(-0.475,0.195,r'$\mathrm{exponential}$',
    #                size=16.,color='w')
    t= pyplot.text(-0.625,0.195,r'$R_{\mathrm{peak}} < 5\,\mathrm{kpc}$',
                    size=16.,color='w')
    t.set_bbox(dict(alpha=0.5,color=cm.coolwarm_r(0.),
                    edgecolor='none'))
    pyplot.tight_layout()
    bovy_plot.bovy_end_print(plotname,dpi=300)
    return None
Beispiel #4
0
def plot_afefeh(plotfilename):
    # Load the data
    data = define_rcsample.get_rcsample()
    # Plot the data
    bovy_plot.bovy_print()
    bovy_plot.scatterplot(data[define_rcsample._FEHTAG],
                          data[define_rcsample._AFETAG],
                          'k.',
                          ms=.8,
                          levels=special.erf(
                              numpy.arange(1, 2) / numpy.sqrt(2.)),
                          xrange=[-1., 0.4],
                          yrange=[-0.15, 0.35],
                          xlabel=r'$[\mathrm{Fe/H}]$',
                          ylabel=define_rcsample._AFELABEL)
    # Overplot sub-samples
    # low alpha, low feh
    lowfeh = define_rcsample._lowlow_lowfeh(0.)
    highfeh = define_rcsample._lowlow_highfeh(0.)
    pyplot.plot([lowfeh, lowfeh], [
        define_rcsample._lowlow_lowafe(lowfeh),
        define_rcsample._lowlow_highafe(lowfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([highfeh, highfeh], [
        define_rcsample._lowlow_lowafe(highfeh),
        define_rcsample._lowlow_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._lowlow_lowafe(lowfeh),
        define_rcsample._lowlow_lowafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._lowlow_highafe(lowfeh),
        define_rcsample._lowlow_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    # high alpha
    lowfeh = define_rcsample._highalpha_lowfeh(0.)
    highfeh = define_rcsample._highalpha_highfeh(0.)
    pyplot.plot([lowfeh, lowfeh], [
        define_rcsample._highalpha_lowafe(lowfeh),
        define_rcsample._highalpha_highafe(lowfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([highfeh, highfeh], [
        define_rcsample._highalpha_lowafe(highfeh),
        define_rcsample._highalpha_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._highalpha_lowafe(lowfeh),
        define_rcsample._highalpha_lowafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._highalpha_highafe(lowfeh),
        define_rcsample._highalpha_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    # solar
    lowfeh = define_rcsample._solar_lowfeh(0.)
    highfeh = define_rcsample._solar_highfeh(0.)
    pyplot.plot([lowfeh, lowfeh], [
        define_rcsample._solar_lowafe(lowfeh),
        define_rcsample._solar_highafe(lowfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([highfeh, highfeh], [
        define_rcsample._solar_lowafe(highfeh),
        define_rcsample._solar_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._solar_lowafe(lowfeh),
        define_rcsample._solar_lowafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._solar_highafe(lowfeh),
        define_rcsample._solar_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    # high [Fe/H]
    lowfeh = define_rcsample._highfeh_lowfeh(0.)
    highfeh = define_rcsample._highfeh_highfeh(0.)
    pyplot.plot([lowfeh, lowfeh], [
        define_rcsample._highfeh_lowafe(lowfeh),
        define_rcsample._highfeh_highafe(lowfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([highfeh, highfeh], [
        define_rcsample._highfeh_lowafe(highfeh),
        define_rcsample._highfeh_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._highfeh_lowafe(lowfeh),
        define_rcsample._highfeh_lowafe(highfeh)
    ],
                'k--',
                lw=2.)
    pyplot.plot([lowfeh, highfeh], [
        define_rcsample._highfeh_highafe(lowfeh),
        define_rcsample._highfeh_highafe(highfeh)
    ],
                'k--',
                lw=2.)
    # Label them
    bovy_plot.bovy_text(-0.4,
                        0.265,
                        r'$\mathrm{high}\ [\alpha/\mathrm{Fe}]$',
                        size=15.,
                        backgroundcolor='w')
    bovy_plot.bovy_text(-0.975,
                        0.05,
                        r'$\mathrm{low\ [Fe/H]}$',
                        size=15.,
                        backgroundcolor='w')
    bovy_plot.bovy_text(0.,
                        -0.125,
                        r'$\mathrm{high\ [Fe/H]}$',
                        size=15.,
                        backgroundcolor='w')
    bovy_plot.bovy_text(-0.225,
                        -0.125,
                        r'$\mathrm{solar}$',
                        size=15.,
                        backgroundcolor='w')
    # Loci
    if False:
        haloc = define_rcsample.highalphalocus()
        bovy_plot.bovy_plot(haloc[:, 0],
                            haloc[:, 1],
                            'k-',
                            lw=2.,
                            overplot=True)
        haloc = define_rcsample.lowalphalocus()
        bovy_plot.bovy_plot(haloc[:, 0],
                            haloc[:, 1],
                            'k-',
                            lw=2.,
                            overplot=True)
    bovy_plot.bovy_end_print(plotfilename)
    return None
Beispiel #5
0
def plot_afefeh(plotfilename):
    # Load the data
    data= define_rcsample.get_rcsample()
    # Plot the data
    bovy_plot.bovy_print()
    bovy_plot.scatterplot(data[define_rcsample._FEHTAG],
                          data[define_rcsample._AFETAG],
                          'k.',ms=.8,
                          levels=special.erf(numpy.arange(1,2)/numpy.sqrt(2.)),
                          xrange=[-1.,0.4],
                          yrange=[-0.15,0.35],
                          xlabel=r'$[\mathrm{Fe/H}]$',
                          ylabel=define_rcsample._AFELABEL)
    # Overplot sub-samples
    # low alpha, low feh
    lowfeh= define_rcsample._lowlow_lowfeh(0.)
    highfeh= define_rcsample._lowlow_highfeh(0.)
    pyplot.plot([lowfeh,lowfeh],[define_rcsample._lowlow_lowafe(lowfeh),
                                 define_rcsample._lowlow_highafe(lowfeh)],
                'k--',lw=2.)
    pyplot.plot([highfeh,highfeh],[define_rcsample._lowlow_lowafe(highfeh),
                                   define_rcsample._lowlow_highafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._lowlow_lowafe(lowfeh),
                                  define_rcsample._lowlow_lowafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._lowlow_highafe(lowfeh),
                                  define_rcsample._lowlow_highafe(highfeh)],
                'k--',lw=2.)
    # high alpha
    lowfeh= define_rcsample._highalpha_lowfeh(0.)
    highfeh= define_rcsample._highalpha_highfeh(0.)
    pyplot.plot([lowfeh,lowfeh],[define_rcsample._highalpha_lowafe(lowfeh),
                                 define_rcsample._highalpha_highafe(lowfeh)],
                'k--',lw=2.)
    pyplot.plot([highfeh,highfeh],[define_rcsample._highalpha_lowafe(highfeh),
                                   define_rcsample._highalpha_highafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._highalpha_lowafe(lowfeh),
                                  define_rcsample._highalpha_lowafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._highalpha_highafe(lowfeh),
                                  define_rcsample._highalpha_highafe(highfeh)],
                'k--',lw=2.)
    # solar
    lowfeh= define_rcsample._solar_lowfeh(0.)
    highfeh= define_rcsample._solar_highfeh(0.)
    pyplot.plot([lowfeh,lowfeh],[define_rcsample._solar_lowafe(lowfeh),
                                 define_rcsample._solar_highafe(lowfeh)],
                'k--',lw=2.)
    pyplot.plot([highfeh,highfeh],[define_rcsample._solar_lowafe(highfeh),
                                   define_rcsample._solar_highafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._solar_lowafe(lowfeh),
                                  define_rcsample._solar_lowafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._solar_highafe(lowfeh),
                                  define_rcsample._solar_highafe(highfeh)],
                'k--',lw=2.)
    # high [Fe/H]
    lowfeh= define_rcsample._highfeh_lowfeh(0.)
    highfeh= define_rcsample._highfeh_highfeh(0.)
    pyplot.plot([lowfeh,lowfeh],[define_rcsample._highfeh_lowafe(lowfeh),
                                 define_rcsample._highfeh_highafe(lowfeh)],
                'k--',lw=2.)
    pyplot.plot([highfeh,highfeh],[define_rcsample._highfeh_lowafe(highfeh),
                                   define_rcsample._highfeh_highafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._highfeh_lowafe(lowfeh),
                                  define_rcsample._highfeh_lowafe(highfeh)],
                'k--',lw=2.)
    pyplot.plot([lowfeh,highfeh],[define_rcsample._highfeh_highafe(lowfeh),
                                  define_rcsample._highfeh_highafe(highfeh)],
                'k--',lw=2.)
    # Label them
    bovy_plot.bovy_text(-0.4,0.265,r'$\mathrm{high}\ [\alpha/\mathrm{Fe}]$',
                         size=15.,backgroundcolor='w')
    bovy_plot.bovy_text(-0.975,0.05,r'$\mathrm{low\ [Fe/H]}$',
                         size=15.,backgroundcolor='w')
    bovy_plot.bovy_text(0.,-0.125,r'$\mathrm{high\ [Fe/H]}$',
                         size=15.,backgroundcolor='w')
    bovy_plot.bovy_text(-0.225,-0.125,r'$\mathrm{solar}$',
                         size=15.,backgroundcolor='w')
    # Loci
    if False:
        haloc= define_rcsample.highalphalocus()
        bovy_plot.bovy_plot(haloc[:,0],haloc[:,1],'k-',lw=2.,overplot=True)
        haloc= define_rcsample.lowalphalocus()
        bovy_plot.bovy_plot(haloc[:,0],haloc[:,1],'k-',lw=2.,overplot=True)
    bovy_plot.bovy_end_print(plotfilename)
    return None
Beispiel #6
0
def plot_maphz(plotname):
    # Load the three fits
    with open('../mapfits/tribrokenexpflare.sav', 'rb') as savefile:
        bf = numpy.array(pickle.load(savefile))
        samples = numpy.array(pickle.load(savefile))
    with open('../mapfits/tribrokenexp.sav', 'rb') as savefile:
        bfnf = numpy.array(pickle.load(savefile))
        samplesnf = numpy.array(pickle.load(savefile))
    with open('../mapfits/tribrokenexpfixedflare.sav', 'rb') as savefile:
        bfff = numpy.array(pickle.load(savefile))
        samplesff = numpy.array(pickle.load(savefile))
    maps = define_rcsample.MAPs()
    plotthisz = numpy.zeros(len(bf)) + numpy.nan
    plotthisze = numpy.zeros(len(bf)) + numpy.nan
    for ii, map in enumerate(maps.map()):
        if numpy.median(
                numpy.exp(
                    samples[ii,
                            3])[True -
                                numpy.isnan(numpy.exp(samples[ii, 3]))]) < 5.:
            tmed = numpy.median(
                (1. / samplesnf[ii, 1])[True -
                                        numpy.isnan(1. / samplesnf[ii, 1])])
            terr = numpy.std(
                (1. / samplesnf[ii, 1])[True -
                                        numpy.isnan(1. / samplesnf[ii, 1])])
        else:
            tmed = numpy.median(
                (1. / samplesff[ii, 1])[True -
                                        numpy.isnan(1. / samplesff[ii, 1])])
            terr = numpy.std(
                (1. / samplesff[ii, 1])[True -
                                        numpy.isnan(1. / samplesff[ii, 1])])
        plotthisz[ii] = tmed
        plotthisze[ii] = terr
    plotthisz[plotthisze / plotthisz > 0.2] = numpy.nan
    bovy_plot.bovy_print()
    maps.plot(plotthisz * 1000.,
              vmin=200.,
              vmax=1000.,
              minnstar=15,
              zlabel=r'$h_Z\,(\mathrm{pc})$',
              shrink=0.655)
    # Sequences
    haloc = define_rcsample.highalphalocus()
    bovy_plot.bovy_plot(haloc[:, 0],
                        haloc[:, 1],
                        '-',
                        color='0.75',
                        lw=2.5,
                        overplot=True)
    haloc = define_rcsample.lowalphalocus()
    haloc = haloc[(haloc[:, 0] > -0.55) * (haloc[:, 0] < 0.225)]
    bovy_plot.bovy_plot(haloc[:, 0],
                        haloc[:, 1],
                        '-',
                        color='0.75',
                        lw=2.5,
                        overplot=True)
    # Label
    #t= pyplot.text(-0.51,0.235,r'$\mathrm{single}$',
    #                size=16.,color='w')
    #t.set_bbox(dict(alpha=0.5,color=cm.coolwarm(0.),
    #                edgecolor='none'))
    #t= pyplot.text(-0.475,0.195,r'$\mathrm{exponential}$',
    #                size=16.,color='w')
    #t.set_bbox(dict(alpha=0.5,color=cm.coolwarm(0.),
    #                edgecolor='none'))
    pyplot.tight_layout()
    bovy_plot.bovy_end_print(plotname, dpi=300)
    return None