Example #1
0
def plotSFRgal(x, y, xlabel, ylabel, xlim, ylim, age, N, fname):
    f = plt.figure()
    f.set_dpi(100)
    f.set_size_inches(11.69,8.27) 
    plot_suptitle = '%.2f Myr' % (age/1e6)
    f.suptitle(plot_suptitle)
    ax = f.gca()
    ax.set_xlabel(xlabel)
    ax.set_ylabel(ylabel)
    
    if xlim != None:
        ax.set_xlim(xlim)
        
    if ylim != None:
        ax.set_ylim(ylim)

    ax.scatter(x, y, c = 'black', marker = 'o', s = 5, edgecolor = 'none', alpha = 0.5, label='')
        
    txt = 'N: %d' % N
    plot_text_ax(ax, txt, 0.98, 0.14, 14, 'bottom', 'right')

    plotOLSbisectorAxis(ax, x, y, 0.98, 0.07, 14)

    ax.plot(ax.get_xlim(), ax.get_xlim(), ls = "--", c = ".3", label = '')

    ax.xaxis.set_major_locator(MultipleLocator(0.5))
    ax.xaxis.set_minor_locator(MultipleLocator(0.125))
    ax.yaxis.set_major_locator(MultipleLocator(0.5))
    ax.yaxis.set_minor_locator(MultipleLocator(0.125))
    ax.grid(which = 'major')
    
    ax.legend()
    f.savefig(fname)
    plt.close(f)
Example #2
0
xbinCenter = aux[0]
xMedian = aux[1]
xMean = aux[2]
xStd = aux[3]
yMedian = aux[4]
yMean = aux[5]
yStd = aux[6]
nInBin = aux[7]
xPrc = aux[8]
yPrc = aux[9]
ax.plot(xMedian, yMedian, 'k', lw = 2)
ax.plot(xPrc[0], yPrc[0], 'k--', lw = 2)
ax.plot(xPrc[1], yPrc[1], 'k--', lw = 2)
txt = '%.2f Myr' % (age / 1e6)
plot_text_ax(ax, txt, 0.02, 0.98, 14, 'top', 'left')
a_ols, b_ols, sigma_a_ols, sigma_b_ols = plotOLSbisectorAxis(ax, xm, ym, pos_x = 0.98, pos_y = 0.02, fs = 14)
##########################
x = np.ma.log10(atau_V__r)
y = np.ma.log10(aSFRSD__r * 1e6)
mask = x.mask | y.mask
xm = np.ma.masked_array(x, mask = mask)
ym = np.ma.masked_array(y, mask = mask)
#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
# xr = xm + np.cos(a_ols) + ym * np.sin(a_ols)
# vmax = xr.mean() + 2. * xr.std()
# vmin = xr.mean() - 2. * xr.std()
# ax.scatter(xm, ym, c = xr, cmap = 'winter_r', marker = 'o', s = 30, edgecolor = 'black', vmax = vmax, vmin = vmin)
#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
sc = ax.scatter(xm, ym, c = H.RbinCenter__r, cmap = 'jet_r', marker = 'o', s = 30, edgecolor = 'black', vmax = H.RbinFin, vmin = H.RbinIni)
cb = f.colorbar(ax = ax, mappable = sc, use_gridspec = True)
cb.set_label(r'R [HLR]')
Example #3
0
        kwargs_zbins.update(xlim = [-1.5, 1])
        kwargs_zbins.update(ylim = [-2.5, 2])
        kwargs_zbins.update(cb = True)
        C.plot_zbins(x = x3.flatten(), y = y3.flatten(), z = H.Rtoplot(x3.shape).flatten(), xlabel = x3label, ylabel = y3label, **kwargs_zbins)
        
        ax = plt.subplot2grid(grid_shape, loc = (0, 3))
        ax.set_axis_on()
        ax.scatter(x4, y4, **default_sc_kwargs)
        plot_text_ax(ax, 'N:%d' % x4.count() , 0.98, 0.98, 8, 'top', 'right', 'k')
        ax.set_xlim(-1.5, 0.5)
        ax.set_ylim(-3.5, 1)
        ax2 = ax.twinx()
        ax.set_xlabel(x4label)
        ax2.set_ylabel(y4label)
        plt.setp(ax2.get_yticklabels(), visible = False)
        a, b, sa, sb = plotOLSbisectorAxis(ax, x4, y4, **kwargs_ols)
        x_major_locator = 1
        x_minor_locator = 0.2
        y_major_locator = 1.
        y_minor_locator = 0.2
        ax.xaxis.set_major_locator(MultipleLocator(x_major_locator))
        ax.xaxis.set_minor_locator(MultipleLocator(x_minor_locator))
        ax.yaxis.set_major_locator(MultipleLocator(y_major_locator))
        ax.yaxis.set_minor_locator(MultipleLocator(y_minor_locator))
        ax.grid()

        ax = plt.subplot2grid(grid_shape, loc = (1, 3))
        ax.set_axis_on()
        ax.scatter(x5, y5, **default_sc_kwargs)
        plot_text_ax(ax, 'N:%d' % x5.count() , 0.98, 0.98, 8, 'top', 'right', 'k')
        ax.set_xlim(-1.5, 0.5)
Example #4
0
SFR_Ha_int_masked = get_h5_data_masked(h5, 'SFR_Ha_int_masked__Tg', **dict(dtype = np.float_))
O3N2_int_masked = get_h5_data_masked(h5, 'O3N2M13_int_masked__Tg', **dict(dtype = np.float_))
O3N2_int = np.array(h5['data/O3N2M13_int__g'].value, dtype = np.float_)
O3N2_int = np.ma.masked_array(O3N2_int, mask = np.isnan(O3N2_int))

sc_kwargs = dict(marker = 'o', s = 50, edgecolor = 'none', label = '')
kwargs_ols_plot = dict(c = 'r', ls = '--', lw = 2, label = 'OLS')
kwargs_ols = dict(c = 'k', pos_x = 0.98, pos_y = 0.01, fs = 12, rms = True, text = True, kwargs_plot = kwargs_ols_plot)

f = plt.figure()
grid_shape = (1, 2)
ax1 = plt.subplot2grid(grid_shape, loc = (0, 0))
ax2 = plt.subplot2grid(grid_shape, loc = (0, 1))
xm1, ym1 = C.ma_mask_xyz(x = O3N2_int, y = np.ma.log10(SFR_int[1]) - np.ma.log10(SFR_Ha_int[1]))
ax1.scatter(xm1, ym1, **sc_kwargs)
_ = plotOLSbisectorAxis(ax1, xm1.compressed(), ym1.compressed(), **kwargs_ols)
ax1.set_xlabel(r'12 + $\log$ O/H M13')
ax1.set_ylabel(r'$\Delta$SFR (syn - $H\alpha$)')
sc = ax2.scatter(np.ma.log10(SFR_int[1]), np.ma.log10(SFR_Ha_int[1]), c = O3N2_int, cmap = 'viridis', **sc_kwargs)
ax2.set_xlabel(r'$\log$ SFR(syn) [$M_\odot\ yr^{-1}$]')
ax2.set_ylabel(r'$\log$ SFR(H$\alpha$) [$M_\odot\ yr^{-1}$]')
f.colorbar(sc)
f.savefig('Zneb_SFR.pdf')
f.subplots_adjust(bottom = 0.15, hspace = 0.15, wspace = 0., right = 0.95, left = 0.10)

f = plt.figure()
grid_shape = (1, 2)
ax1 = plt.subplot2grid(grid_shape, loc = (0, 0))
ax2 = plt.subplot2grid(grid_shape, loc = (0, 1))
xm2, ym2 = C.ma_mask_xyz(x = O3N2_int_masked[1], y = np.ma.log10(SFR_int[1]) - np.ma.log10(SFR_Ha_int_masked[1]))
ax1.scatter(xm2, ym2, **sc_kwargs)
Example #5
0
     linewidths = (2, 1.66, 1.34, 1)
 
     ax = plt.subplot2grid(grid_shape, loc = (0, 0))
     X, Y = np.meshgrid(xyxedges, xyyedges)
     im = ax.pcolormesh(X, Y, hxy.T, cmap = cmap)
     #ax.set_aspect('equal')
     levels = (500, 100, 25, 5)
     extent = xran + yran
     cset = ax.contour(hxy.T, levels, origin = 'lower' , colors = colors, linewidths = linewidths, extent = extent)
     for c in cset.collections:
         c.set_linestyle('solid')
     ax.clabel(cset, inline = 1, fontsize = 10, fmt = '%.0f')
     rs = C.runstats(xm.compressed(), ym.compressed(), **rs_kwargs)
     ax.plot(rs.xMedian, rs.yMedian, 'k--', lw = 2)
     ax.plot(rs.inv_yMedian, rs.inv_xMedian, 'k--', lw = 2)
     plotOLSbisectorAxis(ax, xm, ym, **ols_kwargs)
     ax.set_xlim(xran)
     ax.set_ylim(yran)
     ax.set_xlabel(xlabel)
     ax.set_ylabel(ylabel)
     f.colorbar(mappable = im, ax = ax)
     
     ax = plt.subplot2grid(grid_shape, loc = (0, 1))
     X, Y = np.meshgrid(xzxedges, xzyedges)
     im = ax.pcolormesh(X, Y, hxz.T, cmap = cmap)
     levels = (500, 100, 25, 5)
     extent = xran + zran
     cset = ax.contour(hxz.T, levels, origin = 'lower', colors = colors, linewidths = linewidths, extent = extent)
     for c in cset.collections:
         c.set_linestyle('solid')
     ax.clabel(cset, inline = 1, fontsize = 10, fmt = '%.0f')
Example #6
0
 ax = f.axes[0]
 #print f.axes    
 #ax = f.axes
 
 im = ax.imshow(H, cmap=plt.cm.Blues, aspect = 'auto', interpolation='none', origin='low', extent = extent)
 #ax.scatter(xm, ym, marker = 'o', c = 'g', s = 5, edgecolor = 'none', alpha = 0.1, label = '')
 #ax.contour(H,extent=extent,linewidths=1, interpolation='nearest', origin = 'lower', levels=[16, 50, 84], cmap = plt.cm.YlGn)
 #ax.hist2d(xm.compressed(), ym.compressed(), bins = (10,10))
 
 nBox = 1000
 #nBox = len(xm.compressed()) / 50.
 #slope, intercept, sigma_slope, sigma_intercep = OLS_bisector(logOH_M13, Zneb_mpa)
 pos_x = 0.99
 pos_y = 0.
 kwargs_ols = dict(x_rms = xm, y_rms = ym, pos_x = pos_x, pos_y = pos_y, fs = 10, c = '#7B8DBF', rms = True, label = 'OLS', text = True)
 a, b, sa, sb = plotOLSbisectorAxis(ax, xm, ym, **kwargs_ols)
   
 dxBox = (xm.max() - xm.min()) / (nBox - 1.)
 kwargs_rs = dict(dxBox = dxBox, xbinIni = xm.min(), xbinFin = xm.max(), xbinStep = dxBox)    
 xbinCenter, xMedian, xMean, xStd, yMedian, \
     yMean, yStd, nInBin, xPrc, yPrc = calc_running_stats(xm, ym, **kwargs_rs)
 #ax.plot(xMedian, yMedian, '-.b', label = 'Median in x')
 sig = 40 / np.sqrt(8. * np.log(2))
 xM = np.ma.masked_array(xMedian)
 yM = np.ma.masked_array(yMedian)
 m_gs = np.isnan(xM) | np.isnan(yM) 
 xS = gaussian_filter1d(xM[~m_gs], sig)
 yS = gaussian_filter1d(yM[~m_gs], sig)
 ax.plot(xS, yS, c = 'r', ls = '--', label = 'smoothed median in x')
 pos_x = 0.99
 pos_y = 0.04
Example #7
0
    xlabel = r'$\log\ SFR^\star(t_\star)\ [M_\odot yr^{-1}]$'
    ylabel = r'$\log\ SFR^{neb}\ [M_\odot yr^{-1}]$'
    xSDlabel = r'$\log\ \Sigma_{SFR}^\star(t_\star)\ [M_\odot yr^{-1} pc^{-2}]$'
    ySDlabel = r'$\log\ \Sigma_{SFR}^{neb}\ [M_\odot yr^{-1} pc^{-2}]$'
    
    #SFR
    iT = 1
    ax = plt.subplot2grid(grid_shape, loc = (0, 0))
    ax.set_title(r'$t_\star$ = %.2f Myrs' % (tSF__T[iT] / 1e6))
    xm, ym = ma_mask_xyz(np.ma.log10(SFR__Tg[iT]), np.ma.log10(SFR_Ha__Tg[iT]))
    sc = ax.scatter(xm, ym, **default_sc_kwargs)
    ax.set_xlabel(xlabel)
    ax.set_ylabel(xlabel)
    ax.set_xlim([-6.5, 0])
    ax.set_ylim([-6.5, 0])
    a, b, sa, sb = plotOLSbisectorAxis(ax, xm, ym)
    ax.plot(ax.get_xlim(), ax.get_xlim(), 'k--')
    ax = plt.subplot2grid(grid_shape, loc = (0, 1))
    ax.set_title(r'$t_\star$ = %.2f Myrs' % (tSF__T[iT] / 1e6))
    xm, ym = ma_mask_xyz(np.ma.log10(SFRSD__Tg[iT] * 1e6), np.ma.log10(SFRSD_Ha__Tg[iT] * 1e6))
    sc = ax.scatter(xm, ym, **default_sc_kwargs)
    ax.set_xlabel(xSDlabel)
    ax.set_ylabel(xSDlabel)
    ax.set_xlim([-5, 1])
    ax.set_ylim([-5, 1])
    a, b, sa, sb = plotOLSbisectorAxis(ax, xm, ym)
    ax.plot(ax.get_xlim(), ax.get_xlim(), 'k--')

    iT = 2
    ax = plt.subplot2grid(grid_shape, loc = (1, 0))
    ax.set_title(r'$t_\star$ = %.2f Myrs' % (tSF__T[iT] / 1e6))
Example #8
0
         ax_img.set_axis_on()
 
         aSFRSD__r = getattr(H, '%s_aSFRSD__Trg' % gal)[iT]
         atau_V__r = getattr(H, '%s_tau_V__Trg' % gal)[iT]
         
         xlim = [np.log10(tauVOkMin), 0.5]
         ylim = [-3.5, 1]
         
         ##########################
         x = np.ma.log10(atau_V__r)
         y = np.ma.log10(aSFRSD__r * 1e6)
         mask = x.mask | y.mask
         xm = np.ma.masked_array(x, mask = mask)
         ym = np.ma.masked_array(y, mask = mask)
         sc = ax.scatter(xm, ym, c = H.RbinCenter__r, cmap = 'jet_r', marker = 'o', s = 50, edgecolor = 'black', vmax = H.RbinFin, vmin = H.RbinIni)
         plotOLSbisectorAxis(ax, xm, ym, 0.98, 0.05, 23, color = 'b', rms = True)
         ax.plot(ALL_X, ALL_Y, c = 'grey', ls = '--', lw = 2)
         ##########################
         ax.set_xlim(xlim)
         ax.set_ylim(ylim)
         ax.xaxis.set_major_locator(MultipleLocator(0.5))
         ax.xaxis.set_minor_locator(MultipleLocator(0.125))
         ax.yaxis.set_major_locator(MultipleLocator(0.5))
         ax.yaxis.set_minor_locator(MultipleLocator(0.125))
         ax.grid(which = 'major')
         
         ax = plot_gal_img_ax(ax_img, '/Users/lacerda/CALIFA/images/%s.jpg' % gal, gal, 0.02, 0.98, 30)
         txt = '%s' % str(arg_sorted[i])
         plot_text_ax(ax, txt, 0.98, 0.02, 30, 'bottom', 'right', color = 'w')
         
         if i == NRows - 1 and j == 1: