Exemplo n.º 1
0
def pulses(xs, size=(10, 4), c=None):
    c = np.linspace(0, 1, xs.shape[0]) if isinstance(c, type(None)) else c
    color = cm.coolwarm_r(c)
    fig = plt.figure(figsize=size)
    for xi, ci in zip(xs, color):
        plt.plot(xi, color=ci)
    plt.title("Centered pulses")
    return fig
Exemplo n.º 2
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
Exemplo n.º 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
def map_color(val):
    color = cm.coolwarm_r(val/max_val)
    return '#%02x%02x%02x' % (round(color[0]*255), round(color[1]*255), round(color[2]*255))
Exemplo n.º 5
0
        ssfr
    ) - 1  # --- correct SFR for duration (WILL NOT BE NEEDED IN FUTURE)
    ssfr += 9  # convert to Gyr^-1

    # --- apply mass cut

    s = np.log10(mstar) > 9.

    # --- add scatter plot color-coded by sSFR

    norm = mpl.colors.Normalize(vmin=-0.5,
                                vmax=1.5)  # +1 gets rid of the yellow colour

    ax.scatter(VJ[s],
               UV[s],
               c=cm.coolwarm_r(norm(ssfr[s])),
               s=1,
               alpha=0.5,
               zorder=1)

    # --- UVJ selection region

    UVJ_region = [[-1., 0.75, 1.4, 1.4], [1.2, 1.2, 1.75, 2.0]]

    ax.fill_between(*UVJ_region, [xlims[1]] * len(UVJ_region[0]),
                    color='k',
                    alpha=0.1)
    ax.plot(*UVJ_region, c='k', lw=1)

    # --- add redshift label
# sampling frequency
sampl_freq = 200
# total nr of samples for 1h
NSAMP = sampl_freq * 60 * min_compute

comp_colors = {"Z": "orange", "N": "blue", "E": "green"}

#%% Settings

win_sizes = [30, 20, 15, 10, 5, 1]
win_size = 1

components = ("Z", "N", "E")
component = "E"

winsize_colors = [cm.coolwarm_r(x) for x in np.linspace(0, 1, len(win_sizes))]

depths = [0, 100, 200, 300, 400, 500]

# define Modus for plotting
modus = "norm_stack"

#%% 3D MFP

### COMP-ANALYSIS: norm_stack
if modus == "norm_stack":
    # stack normalized beampower of all windows (one component)

    with open(r"C:\Users\Philip\Desktop\MA\Data\MFP_norm_stacked.pickle",
              'rb') as pickle_dict:
        MFP_norm_stacked = pickle.load(pickle_dict)