def plot_JK_runtimes_in_current_folder(show=True): '''In the current folder, plot the run times for all the .pck files.''' fnames = glob.glob('*.pck') runtimes = [] n_objects = [] for fname in fnames: jk = JK.load_JK(fname) runtimes.append(jk.runtime) n_objects.append(jk.N_objects_in_this_run) runtimes = np.array(runtimes) n_objects = np.array(n_objects) argsorted = np.argsort(n_objects) n_objects = n_objects[argsorted] runtimes = runtimes[argsorted] plt.scatter(n_objects, runtimes) ax = plt.gca() ax.set_xscale('log') ax.set_yscale('log') plt.title('Distributed iskay 50JK performance\n' '20 cores per machine, 10 machines') plt.xlabel('N$_{galaxies}$') plt.ylabel('Runtime [s]') if show: plt.show() else: if not os.path.exists('plots'): os.makedirs('plots') plt.savefig('plots/runtimes.pdf') plt.close()
def plot_all_kSZ_curves_JKs_in_current_folder(show=True): '''In the current folder, it looks for all files with .jk extension. For all those files, plots the velocity curve with JK errorbars. show: shows the plot interactively, False: saves the figure to disk.''' fnames = glob.glob('*.pck') for j, fname in enumerate(fnames): jk = JK.load_JK(fname) label = '%s (%i gals)' % (jk.query, jk.N_objects_in_this_run) plt.errorbar(jk.rsep + j, jk.kSZ_curveFullDataset, yerr=jk.errorbars, marker='o', linestyle='', label=label) plt.xlabel('$r_{sep}$[Mpc]') plt.ylabel('p [$\\mu$K]') plt.axhline(0, color='black') plt.legend(loc='upper right') if show: plt.show() else: plt.savefig('kSZ_curves.pdf') plt.savefig('kSZ_curves.png', dpi=200) plt.close()
def plot_all_JK_errorbars_in_current_folder(show=True): '''Idem to plot_all_kSZ_curves_JKs_in_current_folder but for error bar only plots.''' fnames = glob.glob('*.pck') for fname in fnames: jk = JK.load_JK(fname) label = '%s (%i gals)' % (jk.query, jk.N_objects_in_this_run) plt.scatter(jk.rsep, jk.errorbars, marker='o', label=label) plt.xlabel('$r_{sep}$[Mpc]') plt.ylabel('p [$\\mu$K]') plt.legend(loc='upper right') plt.title('JK (%i it.) errorbars' % jk.JK_Ngroups) if show: plt.show() else: plt.savefig('JK_errorbars.pdf') plt.savefig('JK_errorbars.png', dpi=200) plt.close()
def make_plots(fnames): if len(fnames) == 0: pass else: print("Making plots for:") plt.figure(figsize=[8, 4.5]) for j in range(len(fnames)): fname = fnames[j] print(fname) jk = JK.load_JK(fname) m = re.match("(lum.*e10)", jk.query) label = m.group(1) label = label + ', N: %1.1fk' % (jk.N_objects_in_this_run / 1e3 ) # noqa plt.errorbar(jk.rsep + j * 1.5, jk.kSZ_curveFullDataset, yerr=jk.errorbars, label=label, ls='', marker='.') if 'jk' in fname: folder = 'results_jk' elif 'bs' in fname: if 'bsdt' in fname: folder = 'results_bsdt' else: folder = 'results_bs' plt.axhline(0, color='black') plt.legend(loc='lower right') plt.title(jk.name[:jk.name.find('_lum_')]) plt.xlabel('$r_{sep} [Mpc]$') plt.ylabel('p [$\\mu K$]') if 'disjoint' in fname: fname_out = '%s/kSZ_velocityCurves_disjoint_bins' % (folder) else: fname_out = '%s/kSZ_velocityCurves' % (folder) plt.ylim([-0.3, 0.3]) plt.savefig(fname_out + '.png', dpi=120) plt.savefig(fname_out + '.pdf') #plt.show() plt.close()
matplotlib.rc('font', **font) fnames = glob.glob('./results_*/*.pck') assert len(fnames) > 0 show = True showTitle = False def getPath(fname): return '/'.join(fname.split('/')[:-1]) limitBins = 19 # show only these bins for fname in fnames: print("Plotting %s" % fname) jk = JK.load_JK(fname) labels = ["%i" % rsep for rsep in jk.rsep] jk.corr.index = labels jk.corr.columns = labels #plt.figure(figsize=[6, 6]) sns.heatmap(jk.corr.iloc[:limitBins, :limitBins], vmin=-1, vmax=1, cmap='seismic', cbar_kws={"ticks": [-1, -0.5, 0.0, 0.5, 1.0]}) plt.xlabel('r [Mpc]') plt.ylabel('r [Mpc]') if showTitle: plt.title(jk.name) plt.tight_layout() plt.subplots_adjust(top=0.95)