1
0
Fork 0
mirror of https://github.com/Findus23/halo_comparison.git synced 2024-09-19 16:03:50 +02:00

Merge branch 'main' of github.com:Findus23/halo_comparison

This commit is contained in:
Lukas Winkler 2022-07-14 15:11:19 +02:00
commit 62d4efb8b5
2 changed files with 17 additions and 13 deletions

View file

@ -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="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())

View file

@ -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(loc="lower left")
ax_ics.legend(loc='lower left')
# fig.suptitle(f"Cross Spectra {time}") #Not needed for paper
# fig.tight_layout()