def plot_properties(query, xlabel, ylabel, output, out_folder, flux=5, band=250, pmin=0.1, pmax=1.0, xbin=15, ybin=11, xmin=7.9, xmax=11.7, ymin=0, ymax=50): ''' Plots ''' #get data data = sq.get_data_sqlitePowerTen(path, db, query) #set 1: all galaxies xd = data[:, 0] yd = data[:, 1] #set 2 mask = data[:, 1] > flux xe = data[:, 0][mask] ye = data[:, 1][mask] #x limits for the right hand (scatter) plot secxmin, secxmax = 0.99 * N.min(xe), 1.005 * N.max(xe) if 'mstardot' in query: secxmax = 1200. if 'burst' in query: secxmax = 1500. #hess sd, sdmin, sdmax = h.hess_plot(xd, yd, N.ones(len(xd)), xmin, xmax, xbin, ymin, ymax, ybin, pmax=pmax, pmin=pmin) se, semin, semax = h.hess_plot(xe, ye, N.ones(len(xe)), secxmin, secxmax, xbin - 4, flux, ymax, ybin - 1, pmax=pmax, pmin=pmin) #figure # f, (ax1, ax2) = P.subplots(1, 2, sharey=True) # f, (ax1, ax2) = P.subplots(1, 2, figsize=(10,10)) f, (ax1, ax2) = P.subplots(1, 2) f.subplots_adjust(wspace=0.0, hspace=0.01, left=0.08, bottom=0.07, right=0.97, top=0.93) #hess plots ims = ax1.imshow(sd, vmin=sdmin, vmax=sdmax, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin, xmax, ymin, ymax], aspect='auto', alpha=1) ims = ax2.imshow(se, vmin=semin, vmax=semax, origin='lower', cmap=cm.gray, interpolation=None, extent=[secxmin, secxmax, flux, ymax], aspect='auto', alpha=1) #flux limit lines ax1.axhline(flux, color='green', ls='--') ax2.axhline(flux, color='green', ls='--') #scatter to the second plot ax2.scatter(xe, ye, s=6, color='b') #percentiles xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax) md = (y50d > 0) | (y16d > 0) | (y84d > 0) xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, secxmin, secxmax) me = (y50e > 0) | (y16e > 0) | (y84e > 0) ax1.plot(xbin_midd[md], y50d[md], 'r-') ax1.plot(xbin_midd[md], y16d[md], 'r--') ax1.plot(xbin_midd[md], y84d[md], 'r--') ax2.plot(xbin_mide[me], y50e[me], 'r-') ax2.plot(xbin_mide[me], y16e[me], 'r--') ax2.plot(xbin_mide[me], y84e[me], 'r--') #add text P.text(0.5, 0.95, 'All galaxies', horizontalalignment='center', verticalalignment='center', transform=ax1.transAxes) P.text(0.5, 0.95, r'%s > %.1f $ mJy' % (ylabel.split()[0], flux), horizontalalignment='center', verticalalignment='center', transform=ax2.transAxes) #labels ax1.set_xlabel(xlabel) ax2.set_xlabel(xlabel) ax1.set_ylabel(ylabel) #y tick positions # ax1.set_yticks(yticks) #ax2.set_yticks(yticks[1:-2]) #limits ax1.set_xlim(xmin, xmax) ax2.set_xlim(secxmin, secxmax) ax1.set_ylim(ymin, ymax) ax2.set_ylim(ymin, ymax) ax2.set_yticks(ax2.get_yticks()[1:-1]) # ax2.set_xticks(ax2.get_xticks()[1:]) #make grid ax1.grid() ax2.grid() P.savefig(out_folder + output)
def plot_ssfr_paper(query1, query2, out_folder, xmin1=7.7, xmax1=11.8, xbin1=16, ymin1=-11, ymax1=-7.5, ybin1=16, xmin2=9.8, xmax2=11.8, xbin2=15, ymin2=-10, ymax2=-7.5, ybin2=15, pmax=1.0, pmin=0.01): #get data, all galaxies data1 = sq.get_data_sqliteSMNfunctions(path, db, query1) ssfr1 = N.log10(data1[:, 0] / (10 ** data1[:, 1])) x1 = data1[:, 1] #get data, S_250 > 5mJy data2 = sq.get_data_sqliteSMNfunctions(path, db, query2) ssfr2 = N.log10(data2[:, 0] / (10 ** data2[:, 1])) x2 = data2[:, 1] #make hess data s1, smin1, smax1 = h.hess_plot(x1, ssfr1, N.ones(len(x1)), xmin1, xmax1, xbin1, ymin1, ymax1, ybin1, pmax, pmin) s2, smin2, smax2 = h.hess_plot(x2, ssfr2, N.ones(len(x2)), xmin2, xmax2, xbin2, ymin2, ymax2, ybin2, pmax, pmin) #make the figure fig = P.figure() fig.subplots_adjust(wspace=0.0, hspace=0.01, bottom=0.07, right=0.97, top=0.93) ax1 = fig.add_subplot(121) ax2 = fig.add_subplot(122) ims = ax1.imshow(s1, vmin=smin1, vmax=smax1, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin1, xmax1, ymin1, ymax1], aspect='auto', alpha=1) ims = ax2.imshow(s2, vmin=smin2, vmax=smax2, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin2, xmax2, ymin2, ymax2], aspect='auto', alpha=1) #scatter plot ax2.scatter(x2, ssfr2, c='b', marker='o', s=5) #percentiles xbin_midd, y50d, y16d, y84d = dm.percentile_bins(x1, ssfr1, xmin1, xmax1) md = (y50d > -99) | (y16d > -99) | (y84d > -99) xbin_mide, y50e, y16e, y84e = dm.percentile_bins(x2, ssfr2, xmin2, xmax2) me = (y50e > -99) | (y16e > -99) | (y84e > -99) ax1.plot(xbin_midd[md], y50d[md], 'r-') ax1.plot(xbin_midd[md], y16d[md], 'r--') ax1.plot(xbin_midd[md], y84d[md], 'r--') ax2.plot(xbin_mide[me], y50e[me], 'r-') ax2.plot(xbin_mide[me], y16e[me], 'r--') ax2.plot(xbin_mide[me], y84e[me], 'r--') #labels ax1.set_xlabel(r'$\log_{10}(M_{\star} \ [M_{\odot}])$') ax2.set_xlabel(r'$\log_{10}(M_{\star} \ [M_{\odot}])$') ax1.set_ylabel(r'$\log_{10} \left (\frac{\dot{M}_{\star}}{M_{\star}} \ [\mathrm{yr}^{-1}] \right )$') #limits ax1.set_ylim(ymin1, ymax1) ax2.set_ylim(ymin1, ymax1) ax1.set_xlim(xmin1, xmax1) ax2.set_xlim(xmin2, xmax2) #add text P.text(0.5, 0.94, 'All galaxies\n$2 \leq z < 4$', horizontalalignment='center', verticalalignment='center', transform=ax1.transAxes) P.text(0.5, 0.97, '$S_{250} > 5$ mJy', horizontalalignment='center', verticalalignment='center', transform=ax2.transAxes) #yticks ax2.set_yticks(ax1.get_yticks()[1:-1]) #make grid ax1.grid() ax2.grid() P.savefig(out_folder + 'ssfr.ps') P.close()
def plot_ages(query, xlabel, ylabel, output, out_folder, flux=5, band=250, title='$2.0 < z < 4.0$', pmin=0.05, pmax=1.0, xbin=10, ybin=15, xmin=7.9, xmax=11.7, ymin=-1.5, ymax=1.8, scatters=False, mean=False): ''' Plots age versus a given quantity. ''' #get data data = N.array(sq.get_data_sqlitePowerTen(path, db, query)) #observable galaxies mask = data[:, 1] > flux xe = data[:, 0][mask] ye = N.log10(data[:, 1][mask]) #all galaxies xd = data[:, 0] yd = N.log10(data[:, 1]) mask = yd != N.nan xd = xd[mask] yd = yd[mask] #hess sd, sdmin, sdmax = h.hess_plot(xd, yd, N.ones(len(xd)), xmin, xmax, xbin, ymin, ymax, ybin, pmax=pmax, pmin=pmin) se, semin, semax = h.hess_plot(xe, ye, N.ones(len(xe)), xmin, xmax, xbin, N.log10(flux), ymax, ybin, pmax=pmax, pmin=pmin) #figure fig = P.figure() fig.suptitle(title) f, (ax1, ax2) = P.subplots(1, 2, sharey=True) f.subplots_adjust(wspace=0.0, hspace=0.01, left=0.08, bottom=0.07, right=0.97, top=0.93) #contours ims = ax1.imshow(sd, vmin=sdmin, vmax=sdmax, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin, xmax, ymin, ymax], aspect='auto', alpha=1) ims = ax2.imshow(se, vmin=semin, vmax=semax, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin, xmax, N.log10(flux), ymax], aspect='auto', alpha=1) #percentiles xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax) md = (y50d > 0) & (y16d > 0) & (y84d > 0) xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, xmin, xmax) me = (y50e > 0) & (y16e > 0) & (y84e > 0) ax1.plot(xbin_midd[md], y50d[md], 'r-') ax1.plot(xbin_midd[md], y16d[md], 'r--') ax1.plot(xbin_midd[md], y84d[md], 'r--') ax2.plot(xbin_mide[me], y50e[me], 'r-') ax2.plot(xbin_mide[me], y16e[me], 'r--') ax2.plot(xbin_mide[me], y84e[me], 'r--') #dots if scatters: ax1.scatter(xd, yd, c='b', s=10, marker='h', label='All galaxies') ax2.scatter(xe, ye, c='r', s=10, marker='o', label=r'$S_{%i} > %.1f$ mJy' % (band, flux)) #hlines if mean: #mean size mean_disk = N.mean(yd) mean_early = N.mean(ye) ax1.axhline(mean_disk, c='b', label='Mean') ax2.axhline(mean_early, c='r', label='Mean') #add text P.text(0.5, 0.95, 'All galaxies', horizontalalignment='center', verticalalignment='center', transform=ax1.transAxes) P.text(0.5, 0.95, r'$S_{%i} > %.1f$ mJy' % (band, flux), horizontalalignment='center', verticalalignment='center', transform=ax2.transAxes) #labels ax1.set_xlabel(xlabel) ax2.set_xlabel(xlabel) ax1.set_ylabel(ylabel) #ax2.set_yticks([]) #limits #ax1.set_ylim(ymin, ymax) #ax2.set_ylim(ymin, ymax) ax1.set_xlim(xmin, xmax) ax2.set_xlim(xmin, xmax) #yticks #ax1.set_yticks(y1ticks) #ax2.set_yticks(y2ticks) #make grid ax1.grid() ax2.grid() #write a legend ax1.legend(shadow=True, fancybox=True, numpoints=1, loc='upper left', scatterpoints=1) ax2.legend(shadow=True, fancybox=True, numpoints=1, loc='upper left', scatterpoints=1) P.savefig(out_folder + output)
def plot_tmerge(query1, query2, xlabel, ylabel, output, out_folder, pmin=0.05, pmax=1.0, xbin1=15, ybin1=15, xbin2=15, ybin2=15, y1ticks=[0, .4, .8, 1.2, 1.6, 2.0, 2.5, 3], y2ticks=[.4, .8, 1.2, 1.6, 2.0, 2.5], xmin1=7.9, xmax1=11.7, xmin2=7.9, xmax2=11.7, ymin=0.0, ymax=3.0, scatters=False, mean=False): #get data, all galaxies data = sq.get_data_sqliteSMNfunctions(path, db, query1) xd1 = data[:, 0] yd1 = data[:, 1] #get data, S_250 > 5 mJy data = sq.get_data_sqliteSMNfunctions(path, db, query2) xd2 = data[:, 0] yd2 = data[:, 1] #the fraction of no mergers? nm1 = len(yd1[yd1 < 0.0]) / float(len(yd1)) * 100. nm2 = len(yd2[yd2 < 0.0]) / float(len(yd2)) * 100. #print out some statistics print len(yd2) print 'Mean tmerge of all galaxies', N.mean(yd1[yd1 > 0.0]) print 'Mean tmerge of SPIRE detected galaxies', N.mean(yd2[yd2 > 0.0]) print print 'Max tmerge of all galaxies', N.max(yd1[yd1 > 0.0]) print 'Max tmerge of SPIRE detected galaxies', N.max(yd2[yd2 > 0.0]) print print 'Fraction of all galaxies that have experienced a merger', 100. - nm1 print 'Fraction of SPIRE that have experienced a merger', 100. - nm2 #calculate 2D probability fields sd1, sdmin1, sdmax1 = h.hess_plot(xd1, yd1, N.ones(len(xd1)), xmin1, xmax1, xbin1, ymin, ymax, ybin1, pmax=pmax, pmin=pmin) sd2, sdmin2, sdmax2 = h.hess_plot(xd2, yd2, N.ones(len(xd2)), xmin2, xmax2, xbin2, ymin, ymax, ybin2, pmax=pmax, pmin=pmin) #make the figure fig = P.figure() fig.subplots_adjust(wspace=0.0, hspace=0.01, left=0.08, bottom=0.07, right=0.97, top=0.93) ax1 = fig.add_subplot(121) ax2 = fig.add_subplot(122) ims = ax1.imshow(sd1, vmin=sdmin1, vmax=sdmax1, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin1, xmax1, ymin, ymax], aspect='auto', alpha=1) ims = ax2.imshow(sd2, vmin=sdmin2, vmax=sdmax2, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin2, xmax2, ymin, ymax], aspect='auto', alpha=1) ax2.scatter(xd2, yd2, s=7, marker='o', color='blue') #percentiles xbin_midd1, y50d1, y16d1, y84d1 = dm.percentile_bins(xd1, yd1, xmin1, xmax1, nxbins=xbin1) md1 = (y50d1 >= 0) & (y16d1 >= 0) & (y84d1 >= 0) xbin_midd2, y50d2, y16d2, y84d2 = dm.percentile_bins(xd2, yd2, xmin2, xmax2, nxbins=xbin2) md2 = (y50d2 >= 0) | (y16d2 >= 0) | (y84d2 >= 0) ax1.plot(xbin_midd1[md1], y50d1[md1], 'r-') ax1.plot(xbin_midd1[md1], y16d1[md1], 'r--') ax1.plot(xbin_midd1[md1], y84d1[md1], 'r--') ax2.plot(xbin_midd2[md2], y50d2[md2], 'r-') ax2.plot(xbin_midd2[md2], y16d2[md2], 'r--') ax2.plot(xbin_midd2[md2], y84d2[md2], 'r--') #add text P.text(0.5, 0.93, 'All galaxies\n$2 \leq z < 4$', horizontalalignment='center', verticalalignment='center', transform=ax1.transAxes) P.text(0.5, 0.96, '$S_{250} > 5$ mJy', horizontalalignment='center', verticalalignment='center', transform=ax2.transAxes) #labels ax1.set_xlabel(xlabel) ax2.set_xlabel(xlabel) ax1.set_ylabel(ylabel) #limits ax1.set_ylim(ymin, ymax) ax2.set_ylim(ymin, ymax) ax1.set_xlim(xmin1, xmax1) ax2.set_xlim(xmin2, xmax2) #yticks ax2.set_yticks([]) ax2.set_xticks(ax2.get_xticks()[1:]) ax1.set_yticks(y1ticks) ax2.set_yticks(y2ticks) #make grid #ax1.grid() #ax2.grid() P.savefig(out_folder + output)
def plot_size_paper(xd1, xd2, yd1, yd2, xlabel, ylabel, output, out_folder, pmin=0.05, pmax=1.0, xbin1=15, ybin1=15, xbin2=15, ybin2=15, y1ticks=[1, 3, 5, 7, 9, 12], y2ticks=[1, 3, 5, 7, 9], xmin1=7.9, xmax1=11.7, xmin2=7.9, xmax2=11.7, ymin=0.1, ymax=12, scatters=False, mean=False): #calculate hess sd1, sdmin1, sdmax1 = h.hess_plot(xd1, yd1, N.ones(len(xd1)), xmin1, xmax1, xbin1, ymin, ymax, ybin1, pmax=pmax, pmin=pmin) sd2, sdmin2, sdmax2 = h.hess_plot(xd2, yd2, N.ones(len(xd2)), xmin2, xmax2, xbin2, ymin, ymax, ybin2, pmax=pmax, pmin=pmin) #load obs data file = os.getenv( 'HOME') + '/Dropbox/Research/Herschel/obs_data/CavaSizesValues.txt' data = N.loadtxt(file, comments='#', usecols=(0, 1)) #figure fig = P.figure() #fig.suptitle('Late-type Galaxies') fig.subplots_adjust(wspace=0.0, hspace=0.01, left=0.08, bottom=0.07, right=0.97, top=0.93) ax1 = fig.add_subplot(121) ax2 = fig.add_subplot(122) ims = ax1.imshow(sd1, vmin=sdmin1, vmax=sdmax1, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin1, xmax1, ymin, ymax], aspect='auto', alpha=1) ims = ax2.imshow(sd2, vmin=sdmin2, vmax=sdmax2, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin2, xmax2, ymin, ymax], aspect='auto', alpha=1) ax2.scatter(xd2, yd2, s=1, marker='o', color='blue', label='$S_{250} > 5$ mJy') ax1.scatter(data[:, 0], data[:, 1], s=45, marker='s', color='green') ax2.scatter(data[:, 0], data[:, 1], s=45, marker='s', color='green', label='Cava et al 2010') #percentiles xbin_midd1, y50d1, y16d1, y84d1 = dm.percentile_bins(xd1, yd1, xmin1, xmax1, nxbins=2 * xbin1, limit=25) md1 = (y50d1 > 0) & (y16d1 > 0) & (y84d1 > 0) xbin_midd2, y50d2, y16d2, y84d2 = dm.percentile_bins(xd2, yd2, xmin2, xmax2, nxbins=xbin2, limit=12) md2 = (y50d2 > 0) | (y16d2 > 0) | (y84d2 > 0) ax1.plot(xbin_midd1[md1], y50d1[md1], 'r-') ax1.plot(xbin_midd1[md1], y16d1[md1], 'r--') ax1.plot(xbin_midd1[md1], y84d1[md1], 'r--') ax2.plot(xbin_midd2[md2], y50d2[md2], 'r-') ax2.plot(xbin_midd2[md2], y16d2[md2], 'r--') ax2.plot(xbin_midd2[md2], y84d2[md2], 'r--') #add text P.text(0.5, 0.95, 'Late-type galaxies\n$2 \leq z < 4$', horizontalalignment='center', verticalalignment='center', transform=ax1.transAxes) # P.text(0.5, 0.95,'$S_{250} > 5$ mJy', # horizontalalignment='center', # verticalalignment='center', # transform = ax2.transAxes) #labels ax1.set_xlabel(xlabel) ax2.set_xlabel(xlabel) ax1.set_ylabel(ylabel) #yticks ax2.set_yticks([]) ax1.set_xticks(ax1.get_xticks()[:-1]) ax2.set_xticks(ax2.get_xticks()[1:]) ax1.set_yticks(y1ticks) ax2.set_yticks(y2ticks) #limits ax1.set_ylim(ymin, ymax) ax2.set_ylim(ymin, ymax) ax1.set_xlim(xmin1, xmax1) ax2.set_xlim(xmin2, xmax2) #make grid #ax1.grid() #ax2.grid() #write a legend #ax1.legend(shadow = True, fancybox = True, # numpoints = 1, loc = 'upper left', # scatterpoints = 1) ax2.legend(shadow=True, fancybox=True, numpoints=1, loc='upper left', scatterpoints=1, markerscale=1.5) P.savefig(out_folder + output)
def plot_size(query, xlabel, ylabel, output, out_folder, bulge=0.4, title='$2.0 < z < 4.0$', pmin=0.05, pmax=1.0, xbin=15, ybin=15, y1ticks=[1, 3, 5, 7, 10], y2ticks=[1, 3, 5, 7], xmin=7.9, xmax=11.7, ymin=0.1, ymax=10, scatters=False, mean=False): ''' Plots size versus a given quantity. ''' #get data data = sq.get_data_sqlitePowerTen(path, db, query) #sphericals mask = data[:, 2] > bulge xe = data[:, 0][mask] ye = data[:, 1][mask] # disks disks = data[:, 2] <= bulge xd = data[:, 0][disks] yd = data[:, 1][disks] #hess sd, sdmin, sdmax = h.hess_plot(xd, yd, N.ones(len(xd)), xmin, xmax, xbin, ymin, ymax, ybin, pmax=pmax, pmin=pmin) se, semin, semax = h.hess_plot(xe, ye, N.ones(len(xe)), xmin, xmax, xbin, ymin, ymax, ybin, pmax=pmax, pmin=pmin) #figure # fig = P.figure(figsize = (12, 12)) fig = P.figure() fig.suptitle(title) fig.subplots_adjust(wspace=0.0, hspace=0.01, left=0.08, bottom=0.07, right=0.97, top=0.93) ax1 = fig.add_subplot(121) ax2 = fig.add_subplot(122) #contours # ax1.contourf(sd, origin = 'lower', colors = 'b', # linewidths = 0.8, linestyles = '-', # extent = [xmin, xmax, ymin, ymax], # rightside_up = True, alpha = 0.7)#, # #levels = [0.01, 0.3, 0.6, 0.9]) # ax2.contourf(se, origin = 'lower', colors = 'r', # linewidths = 0.8, linestyles = '-', # extent = [xmin, xmax, ymin, ymax], # rightside_up = True, alpha = 0.7) ims = ax1.imshow(sd, vmin=sdmin, vmax=sdmax, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin, xmax, ymin, ymax], aspect='auto', alpha=1) ims = ax2.imshow(se, vmin=semin, vmax=semax, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin, xmax, ymin, ymax], aspect='auto', alpha=1) #percentiles xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax) md = (y50d > 0) & (y16d > 0) & (y84d > 0) xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, xmin, xmax) me = (y50e > 0) & (y16e > 0) & (y84e > 0) ax1.plot(xbin_midd[md], y50d[md], 'r-') ax1.plot(xbin_midd[md], y16d[md], 'r--') ax1.plot(xbin_midd[md], y84d[md], 'r--') ax2.plot(xbin_mide[me], y50e[me], 'r-') ax2.plot(xbin_mide[me], y16e[me], 'r--') ax2.plot(xbin_mide[me], y84e[me], 'r--') #dots if scatters: ax1.scatter(xd, yd, c='b', s=10, marker='h', label='Late-type') ax2.scatter(xe, ye, c='r', s=10, marker='o', label='Early-type') #hlines if mean: #mean size mean_disk = N.mean(yd) mean_early = N.mean(ye) ax1.axhline(mean_disk, c='b', label='Mean') ax2.axhline(mean_early, c='r', label='Mean') #add text P.text(0.5, 0.95, 'Late-type galaxies', horizontalalignment='center', verticalalignment='center', transform=ax1.transAxes) P.text(0.5, 0.95, 'Early-type galaxies', horizontalalignment='center', verticalalignment='center', transform=ax2.transAxes) #labels ax1.set_xlabel(xlabel) ax2.set_xlabel(xlabel) ax1.set_ylabel(ylabel) ax2.set_yticks([]) #limits ax1.set_ylim(ymin, ymax) ax2.set_ylim(ymin, ymax) ax1.set_xlim(xmin, xmax) ax2.set_xlim(xmin, xmax) #yticks ax1.set_yticks(y1ticks) ax2.set_yticks(y2ticks) #make grid #ax1.grid() #ax2.grid() #write a legend ax1.legend(shadow=True, fancybox=True, numpoints=1, loc='upper left', scatterpoints=1) ax2.legend(shadow=True, fancybox=True, numpoints=1, loc='upper left', scatterpoints=1) P.savefig(out_folder + output)
def plot_size2(query, xlabel, ylabel, output, out_folder, bulge=0.4, title='$2.0 < z < 4.0$', pmin=0.05, pmax=1.0, xbin=15, ybin=15, xmin=7.9, xmax=11.7, ymin=0.1, ymax=10): ''' Plots size versus a given quantity. ''' #get data data = N.array(sq.get_data_sqlitePowerTen(path, db, query)) # disks disks = data[:, 2] <= bulge xd = data[:, 0][disks] yd = data[:, 1][disks] #hess sd, sdmin, sdmax = h.hess_plot(xd, yd, N.ones(len(xd)), xmin, xmax, xbin, ymin, ymax, ybin, pmax=pmax, pmin=pmin) #figure fig = P.figure() fig.suptitle(title) ax1 = fig.add_subplot(111) ims = ax1.imshow(sd, vmin=sdmin, vmax=sdmax, origin='lower', cmap=cm.gray, interpolation=None, extent=[xmin, xmax, ymin, ymax], aspect='auto', alpha=1) #percentiles xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax) md = (y50d > 0) & (y16d > 0) & (y84d > 0) ax1.plot(xbin_midd[md], y50d[md], 'r-') ax1.plot(xbin_midd[md], y16d[md], 'r--') ax1.plot(xbin_midd[md], y84d[md], 'r--') #add text P.text(0.5, 0.95, 'Late-type galaxies', horizontalalignment='center', verticalalignment='center', transform=ax1.transAxes) #labels ax1.set_xlabel(xlabel) ax1.set_ylabel(ylabel) #limits ax1.set_ylim(ymin, ymax) ax1.set_xlim(xmin, xmax) #yticks #ax1.set_yticks(y1ticks) #make grid #ax1.grid() #write a legend ax1.legend(shadow=True, fancybox=True, numpoints=1, loc='upper left', scatterpoints=1) P.savefig(out_folder + output)
def plot_ages(query, xlabel, ylabel, output, out_folder, flux = 5, band = 250, title = '$2.0 < z < 4.0$', pmin = 0.05, pmax = 1.0, xbin = 10, ybin = 15, xmin = 7.9, xmax = 11.7, ymin = -1.5, ymax = 1.8, scatters = False, mean = False): ''' Plots age versus a given quantity. ''' #get data data = N.array(sq.get_data_sqlitePowerTen(path, db, query)) #observable galaxies mask = data[:,1] > flux xe = data[:,0][mask] ye = N.log10(data[:,1][mask]) #all galaxies xd = data[:,0] yd = N.log10(data[:,1]) mask = yd != N.nan xd = xd[mask] yd = yd[mask] #hess sd, sdmin, sdmax = h.hess_plot(xd, yd, N.ones(len(xd)), xmin, xmax, xbin, ymin, ymax, ybin, pmax = pmax, pmin = pmin) se, semin, semax = h.hess_plot(xe, ye, N.ones(len(xe)), xmin, xmax, xbin, N.log10(flux), ymax, ybin, pmax = pmax, pmin = pmin) #figure fig = P.figure() fig.suptitle(title) f, (ax1, ax2) = P.subplots(1, 2, sharey=True) f.subplots_adjust(wspace = 0.0, hspace = 0.01, left = 0.08, bottom = 0.07, right = 0.97, top = 0.93) #contours ims = ax1.imshow(sd, vmin = sdmin, vmax = sdmax, origin = 'lower', cmap = cm.gray, interpolation = None, extent = [xmin, xmax, ymin, ymax], aspect = 'auto', alpha = 1) ims = ax2.imshow(se, vmin = semin, vmax = semax, origin = 'lower', cmap = cm.gray, interpolation = None, extent = [xmin, xmax, N.log10(flux), ymax], aspect = 'auto', alpha = 1) #percentiles xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax) md = (y50d > 0) & (y16d > 0) & (y84d > 0) xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, xmin, xmax) me = (y50e > 0) & (y16e > 0) & (y84e > 0) ax1.plot(xbin_midd[md], y50d[md], 'r-') ax1.plot(xbin_midd[md], y16d[md], 'r--') ax1.plot(xbin_midd[md], y84d[md], 'r--') ax2.plot(xbin_mide[me], y50e[me], 'r-') ax2.plot(xbin_mide[me], y16e[me], 'r--') ax2.plot(xbin_mide[me], y84e[me], 'r--') #dots if scatters: ax1.scatter(xd, yd, c='b', s = 10, marker = 'h', label = 'All galaxies') ax2.scatter(xe, ye, c='r', s = 10, marker = 'o', label = r'$S_{%i} > %.1f$ mJy' % (band, flux)) #hlines if mean: #mean size mean_disk = N.mean(yd) mean_early = N.mean(ye) ax1.axhline(mean_disk, c = 'b', label = 'Mean') ax2.axhline(mean_early, c = 'r', label = 'Mean') #add text P.text(0.5, 0.95, 'All galaxies', horizontalalignment='center', verticalalignment='center', transform = ax1.transAxes) P.text(0.5, 0.95, r'$S_{%i} > %.1f$ mJy' % (band, flux), horizontalalignment='center', verticalalignment='center', transform = ax2.transAxes) #labels ax1.set_xlabel(xlabel) ax2.set_xlabel(xlabel) ax1.set_ylabel(ylabel) #ax2.set_yticks([]) #limits #ax1.set_ylim(ymin, ymax) #ax2.set_ylim(ymin, ymax) ax1.set_xlim(xmin, xmax) ax2.set_xlim(xmin, xmax) #yticks #ax1.set_yticks(y1ticks) #ax2.set_yticks(y2ticks) #make grid ax1.grid() ax2.grid() #write a legend ax1.legend(shadow = True, fancybox = True, numpoints = 1, loc = 'upper left', scatterpoints = 1) ax2.legend(shadow = True, fancybox = True, numpoints = 1, loc = 'upper left', scatterpoints = 1) P.savefig(out_folder + output)