mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-05-12 13:41:13 +00:00
Add density field plot and start preparing CSiBORG2 (#94)
* Add RAMSES2HDF5 conversion * Upload changes * Clean up * More clean up * updates * Little change * pep9 * Add basic SPH calculation for a snapshot * Add submit script * Remove echo * Little changes * Send off changes * Little formatting * Little updates * Add nthreads argument * Upload chagnes * Add nthreads arguemnts * Some local changes.. * Update scripts * Add submission script * Update script * Update params * Rename CSiBORGBox to CSiBORG1box * Rename CSiBORG1 reader * Move files * Rename folder again * Add basic plotting here * Add new skeletons * Move def * Update nbs * Edit directories * Rename files * Add units to converted snapshots * Fix empty dataset bug * Delete file * Edits to submission scripts * Edit paths * Update .gitignore * Fix attrs * Update weighting * Fix RA/dec bug * Add FORNAX cluster * Little edit * Remove boxes since will no longer need * Move func back * Edit to include sort by membership * Edit paths * Purge basic things * Start removing * Bring file back * Scratch * Update the rest * Improve the entire file * Remove old things * Remove old * Delete old things * Fully updates * Rename file * Edit submit script * Little things * Add print statement * Add here cols_to_structured * Edit halo cat * Remove old import * Add comment * Update paths manager * Move file * Remove file * Add chains
This commit is contained in:
parent
6042a87111
commit
aaa14fc880
30 changed files with 1682 additions and 1728 deletions
256
scripts_plots/paper_environment.ipynb
Normal file
256
scripts_plots/paper_environment.ipynb
Normal file
File diff suppressed because one or more lines are too long
|
@ -307,7 +307,7 @@ def plot_projected_field(kind, nsim, grid, in_rsp, smooth_scale, MAS="PCS",
|
|||
print(f"Plotting projected field `{kind}`. ", flush=True)
|
||||
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
|
||||
nsnap = max(paths.get_snapshots(nsim, "csiborg"))
|
||||
box = csiborgtools.read.CSiBORGBox(nsnap, nsim, paths)
|
||||
box = csiborgtools.read.CSiBORG1Box(nsnap, nsim, paths)
|
||||
|
||||
if kind == "overdensity":
|
||||
field = load_field("density", nsim, grid, MAS=MAS, in_rsp=in_rsp)
|
||||
|
@ -437,128 +437,6 @@ def plot_projected_field(kind, nsim, grid, in_rsp, smooth_scale, MAS="PCS",
|
|||
plt.close()
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Sky distribution #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def get_sky_label(kind, volume_weight: bool):
|
||||
"""
|
||||
Get the sky label for a given field kind.
|
||||
"""
|
||||
if volume_weight:
|
||||
if kind == "density":
|
||||
label = r"$\log \int_{0}^{R} r^2 \rho(r, \mathrm{RA}, \mathrm{dec}) \mathrm{d} r$" # noqa
|
||||
if kind == "overdensity":
|
||||
label = r"$\log \int_{0}^{R} r^2 \left[\delta(r, \mathrm{RA}, \mathrm{dec}) + 1\right] \mathrm{d} r$" # noqa
|
||||
elif kind == "potential":
|
||||
label = r"$\int_{0}^{R} r^2 \phi(r, \mathrm{RA}, \mathrm{dec}) \mathrm{d} r$" # noqa
|
||||
elif kind == "radvel":
|
||||
label = r"$\int_{0}^{R} r^2 v_r(r, \mathrm{RA}, \mathrm{dec}) \mathrm{d} r$" # noqa
|
||||
else:
|
||||
label = None
|
||||
else:
|
||||
if kind == "density":
|
||||
label = r"$\log \int_{0}^{R} \rho(r, \mathrm{RA}, \mathrm{dec}) \mathrm{d} r$" # noqa
|
||||
if kind == "overdensity":
|
||||
label = r"$\log \int_{0}^{R} \left[\delta(r, \mathrm{RA}, \mathrm{dec}) + 1\right] \mathrm{d} r$" # noqa
|
||||
elif kind == "potential":
|
||||
label = r"$\int_{0}^{R} \phi(r, \mathrm{RA}, \mathrm{dec}) \mathrm{d} r$" # noqa
|
||||
elif kind == "radvel":
|
||||
label = r"$\int_{0}^{R} v_r(r, \mathrm{RA}, \mathrm{dec}) \mathrm{d} r$" # noqa
|
||||
else:
|
||||
label = None
|
||||
return label
|
||||
|
||||
|
||||
def plot_sky_distribution(field, nsim, grid, nside, smooth_scale=None,
|
||||
MAS="PCS", plot_groups=True, dmin=0, dmax=220,
|
||||
plot_halos=None, volume_weight=True, pdf=False):
|
||||
r"""
|
||||
Plot the sky distribution of a given field kind on the sky along with halos
|
||||
and selected observations.
|
||||
|
||||
TODO
|
||||
----
|
||||
- Add distance for groups.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
field : str
|
||||
Field kind.
|
||||
nsim : int
|
||||
Simulation index.
|
||||
grid : int
|
||||
Grid size.
|
||||
nside : int
|
||||
Healpix nside of the sky projection.
|
||||
smooth_scale : float
|
||||
Smoothing scale in :math:`\mathrm{Mpc} / h`.
|
||||
MAS : str, optional
|
||||
Mass assignment scheme.
|
||||
plot_groups : bool, optional
|
||||
Whether to plot the 2M++ groups.
|
||||
dmin : float, optional
|
||||
Minimum projection distance in :math:`\mathrm{Mpc}/h`.
|
||||
dmax : float, optional
|
||||
Maximum projection distance in :math:`\mathrm{Mpc}/h`.
|
||||
plot_halos : list, optional
|
||||
Minimum halo mass to plot in :math:`M_\odot`.
|
||||
volume_weight : bool, optional
|
||||
Whether to volume weight the field.
|
||||
pdf : bool, optional
|
||||
Whether to save the figure as a pdf.
|
||||
"""
|
||||
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
|
||||
nsnap = max(paths.get_snapshots(nsim, "csiborg"))
|
||||
box = csiborgtools.read.CSiBORGBox(nsnap, nsim, paths)
|
||||
|
||||
if field == "overdensity":
|
||||
field = load_field("density", nsim, grid, MAS=MAS, in_rsp=False,
|
||||
smooth_scale=smooth_scale)
|
||||
density_gen = csiborgtools.field.DensityField(box, MAS)
|
||||
field = density_gen.overdensity_field(field) + 1
|
||||
else:
|
||||
field = load_field(kind, nsim, grid, MAS=MAS, in_rsp=False,
|
||||
smooth_scale=smooth_scale)
|
||||
|
||||
angpos = csiborgtools.field.nside2radec(nside)
|
||||
dist = numpy.linspace(dmin, dmax, 500)
|
||||
out = csiborgtools.field.make_sky(field, angpos=angpos, dist=dist, box=box,
|
||||
volume_weight=volume_weight)
|
||||
|
||||
with plt.style.context(plt_utils.mplstyle):
|
||||
label = get_sky_label(kind, volume_weight)
|
||||
if kind in ["density", "overdensity"]:
|
||||
out = numpy.log10(out)
|
||||
healpy.mollview(out, fig=0, title="", unit=label, rot=90)
|
||||
|
||||
if plot_halos is not None:
|
||||
bounds = {"dist": (dmin, dmax),
|
||||
"totpartmass": (plot_halos, None)}
|
||||
cat = csiborgtools.read.CSiBORGHaloCatalogue(nsim, paths,
|
||||
bounds=bounds)
|
||||
X = cat.position(cartesian=False)
|
||||
healpy.projscatter(numpy.deg2rad(X[:, 2] + 90),
|
||||
numpy.deg2rad(X[:, 1]),
|
||||
s=5, c="red", label="CSiBORG haloes")
|
||||
|
||||
if plot_groups:
|
||||
groups = csiborgtools.read.TwoMPPGroups(fpath="/mnt/extraspace/rstiskalek/catalogs/2M++_group_catalog.dat") # noqa
|
||||
healpy.projscatter(numpy.deg2rad(groups["DEC"] + 90),
|
||||
numpy.deg2rad(groups["RA"]), s=1, c="blue",
|
||||
label="2M++ groups")
|
||||
|
||||
if plot_halos is not None or plot_groups:
|
||||
plt.legend(markerscale=5)
|
||||
|
||||
for ext in ["png"] if pdf is False else ["png", "pdf"]:
|
||||
fout = join(plt_utils.fout, f"sky_{kind}_{nsim}_from_{dmin}_to_{dmax}_vol{volume_weight}.{ext}") # noqa
|
||||
print(f"Saving to `{fout}`.")
|
||||
plt.savefig(fout, dpi=plt_utils.dpi, bbox_inches="tight")
|
||||
plt.close()
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Command line interface #
|
||||
###############################################################################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue