From e45d88b7eb072c7386b596c57d3eda46311111d1 Mon Sep 17 00:00:00 2001 From: glatterf42 Date: Wed, 13 Jul 2022 15:56:30 +0200 Subject: [PATCH 1/2] Adapted spectra plot for 1024 particles and sizes to plot...wait, I am confused --- sizes.py | 2 +- spectra_plot.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sizes.py b/sizes.py index a72cc00..87ba63a 100644 --- a/sizes.py +++ b/sizes.py @@ -68,7 +68,7 @@ def plot_comparison_hist2d(file: Path, property: str, mode: str): if mode == "concentration_bla" and property == 'cNFW': colors = [] for i, row in df.iterrows(): - cnfw, colour = concentration(row, halo_type="ref") # or comp + cnfw, colour = concentration(row, halo_type="comp") # ref or comp colors.append(colour) ax.scatter(df[x_col], df[y_col], c=colors, s=1, alpha=.3) else: diff --git a/spectra_plot.py b/spectra_plot.py index b0e62c3..49ee044 100644 --- a/spectra_plot.py +++ b/spectra_plot.py @@ -14,7 +14,7 @@ from utils import figsize_from_page_fraction Lbox = 100 h = 0.690021 k0 = 3.14159265358979323846264338327950 / Lbox -resolutions = [128, 256, 512] +resolutions = [128, 256, 512, 1024] waveforms = ["DB2", "DB4", "DB8", "shannon"] # Careful: k is actually in Mpc^-1, the column is just named weirdly. @@ -110,7 +110,7 @@ def create_plot(mode): transform=ax.transAxes, ) ax.text( - 0.98 if mode == "cross" else 0.93, + 0.98, 0.85, axes_names[ax], horizontalalignment="right", @@ -122,7 +122,7 @@ def create_plot(mode): k0 * res, color=colors[j], linestyle="dashed", - label=f"{res}", + label=f"$k_\\mathrm{{ny, {res}}}$" if mode =="power" else None, ) # ax.set_xticklabels([]) # ax.set_yticklabels([]) @@ -133,21 +133,21 @@ def create_plot(mode): ics_data = spectra_data(waveform, resolution, resolution, Lbox, "ics") ics_k = ics_data["k [Mpc]"] ics_p1 = ics_data["P1"] - comp_data = spectra_data(waveform, 512, 512, Lbox, "ics") + comp_data = spectra_data(waveform, resolutions[-1], resolutions[-1], Lbox, "ics") comp_p1 = comp_data["P1"] ics_p1 /= comp_p1 end_data = spectra_data(waveform, resolution, resolution, Lbox, "end") end_k = end_data["k [Mpc]"] end_p1 = end_data["P1"] - comp_data = spectra_data(waveform, 512, 512, Lbox, "end") + comp_data = spectra_data(waveform, resolutions[-1], resolutions[-1], Lbox, "end") comp_p1 = comp_data["P1"] end_p1 /= comp_p1 z1_data = spectra_data(waveform, resolution, resolution, Lbox, "z=1") z1_k = z1_data["k [Mpc]"] z1_p1 = z1_data["P1"] - comp_data = spectra_data(waveform, 512, 512, Lbox, 'z=1') + comp_data = spectra_data(waveform, resolutions[-1], resolutions[-1], Lbox, 'z=1') comp_p1 = comp_data["P1"] z1_p1 /= comp_p1 @@ -190,7 +190,7 @@ def create_plot(mode): ax_end.set_ylim(0.8, 1.02) if bottom_row: # ax_z1.legend() - ax_end.legend() + ax_ics.legend(loc='lower left') # fig.suptitle(f"Cross Spectra {time}") #Not needed for paper # fig.tight_layout() From fcca9db01b3d8ab5ed4f9cb52fc632b02644bbd3 Mon Sep 17 00:00:00 2001 From: glatterf42 Date: Thu, 14 Jul 2022 13:16:59 +0200 Subject: [PATCH 2/2] Adapted sizes/comparison plot to only show proper cnfw values --- sizes.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sizes.py b/sizes.py index 87ba63a..6880b56 100644 --- a/sizes.py +++ b/sizes.py @@ -28,10 +28,10 @@ def concentration(row, halo_type: str): if VmaxVvir2 <= 1.05: if m_200crit == 0: cnfw = r_size / rmax - colour = 'red' + colour = 'white' else: cnfw = r_200crit / rmax - colour = 'green' + colour = 'white' else: if npart >= 100: # only calculate cnfw for groups with more than 100 particles cnfw = row[f'{halo_type}_cNFW'] @@ -39,10 +39,10 @@ def concentration(row, halo_type: str): else: if m_200crit == 0: cnfw = r_size / rmax - colour = 'blue' + colour = 'white' else: cnfw = r_200crit / rmax - colour = 'purple' + colour = 'white' assert np.isclose(cnfw, row[f'{halo_type}_cNFW']) @@ -68,8 +68,12 @@ def plot_comparison_hist2d(file: Path, property: str, mode: str): if mode == "concentration_bla" and property == 'cNFW': colors = [] for i, row in df.iterrows(): - cnfw, colour = concentration(row, halo_type="comp") # ref or comp - colors.append(colour) + comp_cnfw, comp_colour = concentration(row, halo_type="comp") # ref or comp + ref_cnfw, ref_colour = concentration(row, halo_type='ref') + if comp_colour == 'white' or ref_colour == 'white': + colors.append('white') + else: + colors.append('black') ax.scatter(df[x_col], df[y_col], c=colors, s=1, alpha=.3) else: _, _, _, hist = ax.hist2d(df[x_col], df[y_col], bins=(bins, bins), norm=LogNorm())