Minor code improvements (#87)

* Shorten docs

* Renames
This commit is contained in:
Richard Stiskalek 2023-08-31 09:57:53 +01:00 committed by GitHub
parent ae92fd9b72
commit 0af925e26a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 67 deletions

View File

@ -66,7 +66,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if self._srcdir is None: if self._srcdir is None:
raise ValueError("`srcdir` is not set!") raise ValueError("`srcdir` is not set!")
@ -86,7 +86,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if self._borg_dir is None: if self._borg_dir is None:
raise ValueError("`borg_dir` is not set!") raise ValueError("`borg_dir` is not set!")
@ -106,7 +106,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if self._quijote_dir is None: if self._quijote_dir is None:
raise ValueError("`quijote_dir` is not set!") raise ValueError("`quijote_dir` is not set!")
@ -126,7 +126,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if self._postdir is None: if self._postdir is None:
raise ValueError("`postdir` is not set!") raise ValueError("`postdir` is not set!")
@ -146,7 +146,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
fpath = join(self.postdir, "temp") fpath = join(self.postdir, "temp")
try_create_directory(fpath) try_create_directory(fpath)
@ -186,7 +186,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
return join(self.borg_dir, "mcmc", f"mcmc_{nsim}.h5") return join(self.borg_dir, "mcmc", f"mcmc_{nsim}.h5")
@ -231,7 +231,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if simname == "csiborg": if simname == "csiborg":
fdir = join(self.postdir, "FoF_membership", ) fdir = join(self.postdir, "FoF_membership", )
@ -258,7 +258,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
fdir = join(self.postdir, "mmain") fdir = join(self.postdir, "mmain")
try_create_directory(fdir) try_create_directory(fdir)
@ -281,7 +281,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
assert kind in ["particles", "fit"] assert kind in ["particles", "fit"]
ftype = "npy" if kind == "fit" else "h5" ftype = "npy" if kind == "fit" else "h5"
@ -353,7 +353,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if simname == "csiborg": if simname == "csiborg":
fname = "ramses_out_{}" fname = "ramses_out_{}"
@ -411,7 +411,7 @@ class Paths:
Returns Returns
------- -------
snappath : str snapstr
""" """
simpath = self.snapshots(nsim, simname, tonew=nsnap == 1) simpath = self.snapshots(nsim, simname, tonew=nsnap == 1)
if simname == "csiborg": if simname == "csiborg":
@ -436,7 +436,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if simname == "csiborg": if simname == "csiborg":
fdir = join(self.postdir, "particles") fdir = join(self.postdir, "particles")
@ -464,7 +464,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if simname == "csiborg": if simname == "csiborg":
fdir = join(self.postdir, "structfit") fdir = join(self.postdir, "structfit")
@ -497,7 +497,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
if simname == "csiborg": if simname == "csiborg":
fdir = join(self.postdir, "overlap") fdir = join(self.postdir, "overlap")
@ -536,7 +536,7 @@ class Paths:
Returns Returns
------- -------
path : str str
References References
---------- ----------
@ -581,7 +581,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
assert kind in ["density", "velocity", "potential", "radvel", assert kind in ["density", "velocity", "potential", "radvel",
"environment"] "environment"]
@ -610,7 +610,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
fdir = join(self.postdir, "environment") fdir = join(self.postdir, "environment")
try_create_directory(fdir) try_create_directory(fdir)
@ -634,7 +634,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
fdir = join(self.postdir, "HMF") fdir = join(self.postdir, "HMF")
try_create_directory(fdir) try_create_directory(fdir)
@ -664,7 +664,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
assert simname in ["csiborg", "quijote"] assert simname in ["csiborg", "quijote"]
assert kind in ["dist", "bin_dist", "tot_counts"] assert kind in ["dist", "bin_dist", "tot_counts"]
@ -700,7 +700,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
assert simname in ["csiborg", "quijote"] assert simname in ["csiborg", "quijote"]
fdir = join(self.postdir, "knn", "auto") fdir = join(self.postdir, "knn", "auto")
@ -733,7 +733,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
fdir = join(self.postdir, "knn", "cross") fdir = join(self.postdir, "knn", "cross")
try_create_directory(fdir) try_create_directory(fdir)
@ -764,7 +764,7 @@ class Paths:
Returns Returns
------- -------
path : str str
""" """
fdir = join(self.postdir, "tpcf", "auto") fdir = join(self.postdir, "tpcf", "auto")
try_create_directory(fdir) try_create_directory(fdir)

View File

@ -28,14 +28,12 @@ import csiborgtools
def pair_match_max(nsim0, nsimx, simname, min_logmass, mult, verbose): def pair_match_max(nsim0, nsimx, simname, min_logmass, mult, verbose):
""" """
Match a pair of simulations using the method of [1]. Match a pair of simulations using the Max method.
Parameters Parameters
---------- ----------
nsim0 : int nsim0, nsimx : int
The reference simulation IC index. The reference and cross simulation IC index.
nsimx : int
The cross simulation IC index.
simname : str simname : str
Simulation name. Simulation name.
min_logmass : float min_logmass : float
@ -44,17 +42,6 @@ def pair_match_max(nsim0, nsimx, simname, min_logmass, mult, verbose):
Multiplicative factor for search radius. Multiplicative factor for search radius.
verbose : bool verbose : bool
Verbosity flag. Verbosity flag.
Returns
-------
None
References
----------
[1] Maxwell L Hutt, Harry Desmond, Julien Devriendt, Adrianne Slyz; The
effect of local Universe constraints on halo abundance and clustering;
Monthly Notices of the Royal Astronomical Society, Volume 516, Issue 3,
November 2022, Pages 35923601, https://doi.org/10.1093/mnras/stac2407
""" """
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring) paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)

View File

@ -42,13 +42,6 @@ def copy_membership(nsim, verbose=True):
""" """
Copy the FoF particle halo membership to the CSiBORG directory and write it Copy the FoF particle halo membership to the CSiBORG directory and write it
as a NumPy array instead of a text file. as a NumPy array instead of a text file.
Parameters
----------
nsim : int
IC realisation index.
verbose : bool, optional
Verbosity flag.
""" """
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring) paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
fpath = join("/mnt/extraspace/jeg/greenwhale/Constrained_Sims", fpath = join("/mnt/extraspace/jeg/greenwhale/Constrained_Sims",

View File

@ -76,19 +76,6 @@ def main(nsim, simname, verbose):
into a HDF5 file. Stores the first and last index of each halo in the into a HDF5 file. Stores the first and last index of each halo in the
particle array for fast slicing of the array to acces particles of a single particle array for fast slicing of the array to acces particles of a single
halo. halo.
Parameters
----------
nsim : int
IC realisation index.
simname : str
Simulation name.
verbose : bool
Verbosity flag.
Returns
-------
None
""" """
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring) paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
if simname == "csiborg": if simname == "csiborg":

View File

@ -44,15 +44,6 @@ def _main(nsim, simname, verbose):
""" """
Sort the initial snapshot particles according to their final snapshot Sort the initial snapshot particles according to their final snapshot
ordering and dump them into a HDF5 file. ordering and dump them into a HDF5 file.
Parameters
----------
nsim : int
IC realisation index.
simname : str
Simulation name.
verbose : bool
Verbosity flag.
""" """
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring) paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
if simname == "csiborg": if simname == "csiborg":