def make_mag(targetSN, w1, w2): tables = [] for i in range(len(targetSN)): tables.append("magab_w{0}_{1}.dat".format(w1, w2)) columns = (2,) lims = [[19, 23]] cmaps = [nc.cmap_discretize(cm.get_cmap("hot"), 8)] labels = ["$m_{V}$"] cb_fmts = ["%.1f"] yloss = [0.5] names = ["magv"] plot(targetSN, 4500, 5500, tables, names, columns, lims, cmaps, labels, cb_fmts, yloss) return
def make_ssps_individual(targetSN, field, model, w1, w2): """ Make maps for the kinematics. """ filename = "logs_sn{2}/mcmc_{0}_{1}.txt".format(field, model, targetSN) binimg = pf.getdata("voronoi_sn{0}_w{1}_{2}.fits".format(targetSN, w1, w2)) intens = "collapsed_w{0}_{1}.fits".format(w1, w2) extent = calc_extent(intens) bins = np.loadtxt(filename, usecols=(0,), dtype=str).tolist() bins = np.array([x.split("bin")[1] for x in bins]).astype(int) data = np.loadtxt(filename, usecols=(1,4,7,4)).T data[3] -= 0.94 * data[1] cmaps = [brewer2mpl.get_map('Reds', 'sequential', 6).mpl_colormap, brewer2mpl.get_map('Blues', 'sequential', 6).mpl_colormap, brewer2mpl.get_map('Greens', 'sequential', 6).mpl_colormap, brewer2mpl.get_map('Oranges', 'sequential', 6).mpl_colormap] # cmaps = [nc.cmap_map(lambda x: x*0.54 + 0.43, x) for x in cmaps] cmaps = [nc.cmap_discretize(x, 6) for x in cmaps] labels = [r'$\log $ Age (yr)', r'[Z/H]', r"[$\alpha$/Fe]", r"[Fe/H]"] lims = [[None, None], [None, None], [None, None], [None, None]] pdf = PdfPages("figs/populations_sn{0}.pdf".format(targetSN)) fig = plt.figure(1, figsize=(6.25,5)) plt.subplots_adjust(bottom=0.12, right=0.965, left=0.09, top=0.96) plt.minorticks_on() ax = plt.subplot(111) ax.minorticks_on() for i, vector in enumerate(data): print "Making plot for {0}...".format(labels[i]) kmap = np.zeros_like(binimg) kmap[:] = np.nan for bin,v in zip(bins, vector): idx = np.where(binimg == bin) kmap[idx] = v vmin = lims[i][0] if lims[i][0] else np.median(vector) - 1 * vector.std() vmax = lims[i][1] if lims[i][1] else np.median(vector) + 1 * vector.std() m = plt.imshow(kmap, cmap=cmaps[i], origin="bottom", vmin=vmin, vmax=vmax, extent=extent, aspect="equal") make_contours() plt.minorticks_on() plt.xlabel("X [kpc]") plt.ylabel("Y [kpc]") plt.xlim(extent[0], extent[1]) plt.ylim(extent[2], extent[3]) cbar = plt.colorbar(m) cbar.set_label(labels[i]) pdf.savefig() plt.clf() pdf.close() return
lick3311 = lick[:, idx3311] lickhalo = lick[:, idxhalo] errs1_3311 = lickerr[:, idx3311] errs_halo = lickerr[:, idxhalo] ######################################################################### # First figure, simple indices app = "_pa" if restrict_pa else "" mkfig1 = True gray = "0.75" ########################################################################## lims, ranges = get_model_lims(os.path.join(tables_dir, "models_thomas_2010_metal_extrapolated.dat")) idx = np.array([12, 13, 16, 17, 18, 19, 20]) lims = lims[idx] # Setting the colormap properties for the scatter plots cmap = brewer2mpl.get_map("Blues", "sequential", 9).mpl_colormap cmap = nc.cmap_discretize(cmap, 3) color = cm.get_cmap(cmap) norm = Normalize(vmin=0, vmax=45) if mkfig1: plt.figure(1, figsize=(6, 14)) gs = gridspec.GridSpec(7, 1) gs.update(left=0.15, right=0.95, bottom=0.1, top=0.94, wspace=0.1, hspace=0.09) tex = [] for j, ll in enumerate(lick): # print indices[j], ranges[j], ssp.fn(9.,0.12,.4)[ii[j]] if j == 0: labels = ["This work", "Coccato et al. 2011", "This work (binned)"] else: labels = [None, None, None] notnans = ~np.isnan(ll) ax = plt.subplot(gs[j])
lickhalo = lick[:, idxhalo] errs1_3311 = lickerr[:, idx3311] errs_halo = lickerr[:, idxhalo] ######################################################################### # First figure, simple indices app = "_pa" if restrict_pa else "" mkfig1 = True gray = "0.75" ########################################################################## lims, ranges = get_model_lims( os.path.join(tables_dir, "models_thomas_2010_metal_extrapolated.dat")) idx = np.array([12, 13, 16, 17, 18, 19, 20]) lims = lims[idx] # Setting the colormap properties for the scatter plots cmap = brewer2mpl.get_map('Blues', 'sequential', 9).mpl_colormap cmap = nc.cmap_discretize(cmap, 3) color = cm.get_cmap(cmap) norm = Normalize(vmin=0, vmax=45) if mkfig1: plt.figure(1, figsize=(6, 14)) gs = gridspec.GridSpec(7, 1) gs.update(left=0.15, right=0.95, bottom=0.1, top=0.94, wspace=0.1, hspace=0.09) tex = [] for j, ll in enumerate(lick): # print indices[j], ranges[j], ssp.fn(9.,0.12,.4)[ii[j]] if j == 0: