mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-22 17:38:02 +00:00
Fix units
This commit is contained in:
parent
060ccf4feb
commit
015e6fb596
1 changed files with 12 additions and 3 deletions
|
@ -86,7 +86,7 @@ def evaluate_sky(*fields, pos, box, isdeg=True):
|
||||||
return evaluate_cartesian(*fields, pos=X)
|
return evaluate_cartesian(*fields, pos=X)
|
||||||
|
|
||||||
|
|
||||||
def make_sky(field, angpos, dist, box, verbose=True):
|
def make_sky(field, angpos, dist, box, volume_weight=True, verbose=True):
|
||||||
r"""
|
r"""
|
||||||
Make a sky map of a scalar field. The observer is in the centre of the
|
Make a sky map of a scalar field. The observer is in the centre of the
|
||||||
box the field is evaluated along directions `angpos`. Along each
|
box the field is evaluated along directions `angpos`. Along each
|
||||||
|
@ -105,6 +105,9 @@ def make_sky(field, angpos, dist, box, verbose=True):
|
||||||
Uniformly spaced radial distances to evaluate the field.
|
Uniformly spaced radial distances to evaluate the field.
|
||||||
box : :py:class:`csiborgtools.read.CSiBORGBox`
|
box : :py:class:`csiborgtools.read.CSiBORGBox`
|
||||||
The simulation box information and transformations.
|
The simulation box information and transformations.
|
||||||
|
volume_weight : bool, optional
|
||||||
|
Whether to weight the field by the volume of the pixel, i.e. a
|
||||||
|
:math:`r^2` correction.
|
||||||
verbose : bool, optional
|
verbose : bool, optional
|
||||||
Verbosity flag.
|
Verbosity flag.
|
||||||
|
|
||||||
|
@ -118,13 +121,19 @@ def make_sky(field, angpos, dist, box, verbose=True):
|
||||||
# We loop over the angular directions, at each step evaluating a vector
|
# We loop over the angular directions, at each step evaluating a vector
|
||||||
# of distances. We pre-allocate arrays for speed.
|
# of distances. We pre-allocate arrays for speed.
|
||||||
dir_loop = numpy.full((dist.size, 3), numpy.nan, dtype=numpy.float32)
|
dir_loop = numpy.full((dist.size, 3), numpy.nan, dtype=numpy.float32)
|
||||||
|
boxdist = box.mpc2box(dist)
|
||||||
ndir = angpos.shape[0]
|
ndir = angpos.shape[0]
|
||||||
out = numpy.full(ndir, numpy.nan, dtype=numpy.float32)
|
out = numpy.full(ndir, numpy.nan, dtype=numpy.float32)
|
||||||
for i in trange(ndir) if verbose else range(ndir):
|
for i in trange(ndir) if verbose else range(ndir):
|
||||||
dir_loop[:, 0] = dist
|
dir_loop[:, 0] = dist
|
||||||
dir_loop[:, 1] = angpos[i, 0]
|
dir_loop[:, 1] = angpos[i, 0]
|
||||||
dir_loop[:, 2] = angpos[i, 1]
|
dir_loop[:, 2] = angpos[i, 1]
|
||||||
out[i] = numpy.sum(
|
if volume_weight:
|
||||||
dist**2 * evaluate_sky(field, pos=dir_loop, box=box, isdeg=True))
|
out[i] = numpy.sum(
|
||||||
|
boxdist**2
|
||||||
|
* evaluate_sky(field, pos=dir_loop, box=box, isdeg=True))
|
||||||
|
else:
|
||||||
|
out[i] = numpy.sum(
|
||||||
|
evaluate_sky(field, pos=dir_loop, box=box, isdeg=True))
|
||||||
out *= dx
|
out *= dx
|
||||||
return out
|
return out
|
||||||
|
|
Loading…
Reference in a new issue