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:
Richard Stiskalek 2022-11-30 16:12:39 +00:00 committed by GitHub
parent 92699bfb0a
commit 91beb4df50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 95 additions and 5 deletions

View file

@ -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`.

View file

@ -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))