mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-06-08 09:51:12 +00:00
Add cleaner paths (#43)
* ignore venv * ignore pylians if unavaible * Edit loading paths * Edit paths * Stop having default paths * Add nb * Add glamdring paths --------- Co-authored-by: Richard Stiskalek <dc-stis1@login8b.pri.cosma7.alces.network> Co-authored-by: Richard Stiskalek <dc-stis1@login8a.pri.cosma7.alces.network>
This commit is contained in:
parent
1344fa40b6
commit
e0d3854277
15 changed files with 1421 additions and 50 deletions
|
@ -13,3 +13,10 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
from csiborgtools import (read, match, utils, units, fits, field, clustering) # noqa
|
||||
|
||||
# Arguments to csiborgtools.read.CSiBORGPaths.
|
||||
paths_glamdring = {
|
||||
"srcdir": "/mnt/extraspace/hdesmond/",
|
||||
"dumpdir": "/mnt/extraspace/rstiskalek/csiborg/",
|
||||
"mmain_path": "/mnt/zfsusers/hdesmond/Mmain",
|
||||
"initmatch_path": "/mnt/extraspace/rstiskalek/csiborg/initmatch/"}
|
||||
|
|
|
@ -12,4 +12,9 @@
|
|||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
from .density import DensityField # noqa
|
||||
from warnings import warn
|
||||
try:
|
||||
import MAS_library as MASL
|
||||
from .density import DensityField
|
||||
except ImportError:
|
||||
warn("MAS_library not found, `DensityField` will not be available", UserWarning) # noqa
|
||||
|
|
|
@ -99,9 +99,7 @@ class HaloCatalogue:
|
|||
Loads the data, merges with mmain, does various coordinate transforms.
|
||||
"""
|
||||
# Load the processed data
|
||||
fname = "ramses_out_{}_{}.npy".format(
|
||||
str(self.nsim).zfill(5), str(self.nsnap).zfill(5))
|
||||
data = numpy.load(join(self.paths.dumpdir, fname))
|
||||
data = numpy.load(self.paths.hcat_path(self.nsim))
|
||||
|
||||
# Load the mmain file and add it to the data
|
||||
mmain = read_mmain(self.nsim, self.paths.mmain_path)
|
||||
|
|
|
@ -35,13 +35,13 @@ class CSiBORGPaths:
|
|||
|
||||
Parameters
|
||||
----------
|
||||
srcdir : str, optional
|
||||
srcdir : str
|
||||
Path to the folder where CSiBORG simulations are stored.
|
||||
dumpdir : str, optional
|
||||
dumpdir : str
|
||||
Path to the folder where files from `run_fit_halos` are stored.
|
||||
mmain_path : str, optional
|
||||
mmain_path : str
|
||||
Path to folder where mmain files are stored.
|
||||
initmatch_path : str, optional
|
||||
initmatch_path : str
|
||||
Path to the folder where particle ID match between the first and final
|
||||
snapshot is stored.
|
||||
"""
|
||||
|
@ -50,16 +50,12 @@ class CSiBORGPaths:
|
|||
_mmain_path = None
|
||||
_initmatch_path = None
|
||||
|
||||
def __init__(self, srcdir="/mnt/extraspace/hdesmond/",
|
||||
dumpdir="/mnt/extraspace/rstiskalek/csiborg/",
|
||||
mmain_path="/mnt/zfsusers/hdesmond/Mmain",
|
||||
initmatch_path="/mnt/extraspace/rstiskalek/csiborg/initmatch/"): # noqa
|
||||
for path in [srcdir, dumpdir, mmain_path, initmatch_path]:
|
||||
self._check_directory(path)
|
||||
self._srcdir = srcdir
|
||||
self._dumpdir = dumpdir
|
||||
self._mmain_path = mmain_path
|
||||
self._initmatch_path = initmatch_path
|
||||
def __init__(self, srcdir=None, dumpdir=None, mmain_path=None,
|
||||
initmatch_path=None):
|
||||
self.srcdir = srcdir
|
||||
self.dumpdir = dumpdir
|
||||
self.mmain_path = mmain_path
|
||||
self.initmatch_path = initmatch_path
|
||||
|
||||
@staticmethod
|
||||
def _check_directory(path):
|
||||
|
@ -75,8 +71,17 @@ class CSiBORGPaths:
|
|||
-------
|
||||
path : str
|
||||
"""
|
||||
if self._srcdir is None:
|
||||
raise ValueError("`srcdir` is not set!")
|
||||
return self._srcdir
|
||||
|
||||
@srcdir.setter
|
||||
def srcdir(self, path):
|
||||
if path is None:
|
||||
return
|
||||
self._check_directory(path)
|
||||
self._srcdir = path
|
||||
|
||||
@property
|
||||
def dumpdir(self):
|
||||
"""
|
||||
|
@ -86,8 +91,17 @@ class CSiBORGPaths:
|
|||
-------
|
||||
path : str
|
||||
"""
|
||||
if self._dumpdir is None:
|
||||
raise ValueError("`dumpdir` is not set!")
|
||||
return self._dumpdir
|
||||
|
||||
@dumpdir.setter
|
||||
def dumpdir(self, path):
|
||||
if path is None:
|
||||
return
|
||||
self._check_directory(path)
|
||||
self._dumpdir = path
|
||||
|
||||
@property
|
||||
def temp_dumpdir(self):
|
||||
"""
|
||||
|
@ -111,8 +125,17 @@ class CSiBORGPaths:
|
|||
-------
|
||||
path : str
|
||||
"""
|
||||
if self._mmain_path is None:
|
||||
raise ValueError("`mmain_path` is not set!")
|
||||
return self._mmain_path
|
||||
|
||||
@mmain_path.setter
|
||||
def mmain_path(self, path):
|
||||
if path is None:
|
||||
return
|
||||
self._check_directory(path)
|
||||
self._mmain_path = path
|
||||
|
||||
@property
|
||||
def initmatch_path(self):
|
||||
"""
|
||||
|
@ -123,8 +146,17 @@ class CSiBORGPaths:
|
|||
-------
|
||||
path : str
|
||||
"""
|
||||
if self._initmatch_path is None:
|
||||
raise ValueError("`initmatch_path` is not set!")
|
||||
return self._initmatch_path
|
||||
|
||||
@initmatch_path.setter
|
||||
def initmatch_path(self, path):
|
||||
if path is None:
|
||||
return
|
||||
self._check_directory(path)
|
||||
self._initmatch_path = path
|
||||
|
||||
def ic_ids(self, tonew):
|
||||
"""
|
||||
CSiBORG IC realisation IDs from the list of folders in `self.srcdir`.
|
||||
|
@ -211,7 +243,7 @@ class CSiBORGPaths:
|
|||
cdir = join(self.dumpdir, "initmatch")
|
||||
return join(cdir, "clump_{}_{}.npy".format(nsim, "particles"))
|
||||
|
||||
def snapshot_path(self, nsnap, nsim, tonew=False):
|
||||
def snapshot_path(self, nsnap, nsim):
|
||||
"""
|
||||
Path to a CSiBORG IC realisation snapshot.
|
||||
|
||||
|
@ -221,16 +253,33 @@ class CSiBORGPaths:
|
|||
Snapshot index.
|
||||
nsim : int
|
||||
IC realisation index.
|
||||
tonew : bool, optional
|
||||
Whether to return the path to the '_new' IC realisation.
|
||||
|
||||
Returns
|
||||
-------
|
||||
snappath : str
|
||||
"""
|
||||
if nsnap == 1:
|
||||
tonew = True
|
||||
simpath = self.ic_path(nsim, tonew=tonew)
|
||||
return join(simpath, "output_{}".format(str(nsnap).zfill(5)))
|
||||
|
||||
def hcat_path(self, nsim):
|
||||
"""
|
||||
Path to the final snapshot halo catalogue from `fit_halos.py`.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
nsim : int
|
||||
IC realisation index.
|
||||
|
||||
Returns
|
||||
-------
|
||||
path : str
|
||||
"""
|
||||
nsnap = str(max(self.get_snapshots(nsim))).zfill(5)
|
||||
fname = "ramses_out_{}_{}.npy".format(str(self.nsim).zfill(5), nsnap)
|
||||
return join(self.dumpdir, fname)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Fortran readers #
|
||||
|
@ -248,7 +297,7 @@ class ParticleReader:
|
|||
_paths = None
|
||||
|
||||
def __init__(self, paths):
|
||||
assert isinstance(paths, CSiBORGPaths)
|
||||
# assert isinstance(paths, CSiBORGPaths)
|
||||
self._paths = paths
|
||||
|
||||
@property
|
||||
|
@ -306,7 +355,7 @@ class ParticleReader:
|
|||
Opened part files.
|
||||
"""
|
||||
snappath = self.paths.snapshot_path(nsnap, nsim)
|
||||
ncpu = int(self.read_info()["ncpu"])
|
||||
ncpu = int(self.read_info(nsnap, nsim)["ncpu"])
|
||||
nsnap = str(nsnap).zfill(5)
|
||||
if verbose:
|
||||
print("Reading in output `{}` with ncpu = `{}`."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue