mirror of
https://github.com/Richard-Sti/csiborgtools_public.git
synced 2025-06-08 09:51:12 +00:00
Angular momentum (#14)
* add ang mom * Update TODO * add ascii dump script * add comment * Updating TODO * add angmom * add garbage collector
This commit is contained in:
parent
92699bfb0a
commit
91beb4df50
5 changed files with 95 additions and 5 deletions
|
@ -228,6 +228,18 @@ class HaloCatalogue:
|
|||
"""
|
||||
return numpy.vstack([self["v{}".format(p)] for p in ("x", "y", "z")]).T
|
||||
|
||||
@property
|
||||
def angmomentum(self):
|
||||
"""
|
||||
Angular momentum of halos in the box coordinate system.
|
||||
|
||||
Returns
|
||||
-------
|
||||
angmom : 2-dimensional array
|
||||
Array of shape `(n_halos, 3)`.
|
||||
"""
|
||||
return numpy.vstack([self["L{}".format(p)] for p in ("x", "y", "z")]).T
|
||||
|
||||
def radius_neigbours(self, X, radius):
|
||||
"""
|
||||
Return sorted nearest neigbours within `radius` or `X`.
|
||||
|
|
|
@ -19,6 +19,7 @@ I/O functions for analysing the CSiBORG realisations.
|
|||
|
||||
import numpy
|
||||
from os.path import (join, dirname, basename, isfile)
|
||||
import gc
|
||||
from os import remove
|
||||
from tqdm import trange
|
||||
from astropy.io import ascii
|
||||
|
@ -127,6 +128,7 @@ def combine_splits(n_splits, part_reader, cols_add, remove_splits=False,
|
|||
def make_ascii_powmes(particles, fout, verbose=True):
|
||||
"""
|
||||
Write an ASCII file with appropriate formatting for POWMES.
|
||||
This is an extremely memory inefficient implementation.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
@ -154,6 +156,9 @@ def make_ascii_powmes(particles, fout, verbose=True):
|
|||
print("Writing temporary file `{}`...".format(ftemp))
|
||||
ascii.write(out, ftemp, overwrite=True, delimiter=",", fast_writer=True)
|
||||
|
||||
del out
|
||||
gc.collect()
|
||||
|
||||
# Write to the first line the number of particles
|
||||
if verbose:
|
||||
print("Writing the full file `{}`...".format(fout))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue