This repository has been archived by the owner on Feb 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
109 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
|
||
lognormcl | ||
========= | ||
normcl | ||
====== | ||
|
||
**angular power spectra of lognormal random fields** | ||
**angular power spectra conversions for normal random fields** | ||
|
||
This is a minimal Python package for working with the angular power spectra of | ||
lognormal spherical random fields. It can currently convert between the power | ||
spectra of lognormal random fields and their constituent normal random fields. | ||
spherical random fields constructed from normals. It can currently convert | ||
between the power spectra of lognormal random fields and their constituent | ||
normal random fields. | ||
|
||
The package can be installed using pip: | ||
|
||
pip install lognormcl | ||
pip install normcl | ||
|
||
Then import the `ln2n` and `n2ln` functions from the package: | ||
Then import the `lognormal` and `lognormal_normal` functions from the package: | ||
|
||
from lognormcl import ln2n, n2ln | ||
from normcl import lognormal, lognormal_normal | ||
|
||
For more information, please see the [documentation]. | ||
|
||
Current functionality covers the absolutely minimal use case. Please open an | ||
issue on GitHub if you would like to see anything added. | ||
|
||
[documentation]: https://cltools.readthedocs.io/lognormcl/ | ||
[documentation]: https://cltools.readthedocs.io/normcl/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# author: Nicolas Tessore <n.tessore@ucl.ac.uk> | ||
# license: MIT | ||
r''' | ||
Angular power spectra conversions for normal fields (:mod:`normcl`) | ||
==================================================================== | ||
This is a minimal Python package for working with the angular power spectra of | ||
spherical random fields constructed from normals. It can currently convert | ||
between the power spectra of lognormal random fields and their constituent | ||
normal random fields. | ||
The package can be installed using pip:: | ||
pip install normcl | ||
Then import the :func:`~normcl.lognormal` and :func:`~normcl.lognormal_normal` | ||
functions from the package:: | ||
from normcl import lognormal, lognormal_normal | ||
Current functionality covers the absolutely minimal use case. Please open an | ||
issue on GitHub if you would like to see anything added. | ||
Distributions | ||
------------- | ||
Lognormal | ||
~~~~~~~~~ | ||
.. math:: | ||
Y = e^X - \lambda | ||
.. math:: | ||
\alpha = {\rm E}[Y] + \lambda | ||
Reference/API | ||
------------- | ||
.. autosummary:: | ||
:toctree: api | ||
:nosignatures: | ||
lognormal | ||
lognormal_normal | ||
''' | ||
|
||
__version__ = '2021.5.5' | ||
|
||
__all__ = [ | ||
'lognormal', | ||
'lognormal_normal', | ||
] | ||
|
||
|
||
import numpy as np | ||
from transformcl import cltoxi, xitocl | ||
|
||
|
||
def lognormal(cl, alpha, alpha2=None, *, inv=True): | ||
'''lognormal angular power spectrum | ||
''' | ||
if alpha2 is None: | ||
alpha2 = alpha | ||
|
||
xi = cltoxi(cl) | ||
if not inv: | ||
xi /= alpha | ||
xi /= alpha2 | ||
np.log1p(xi, out=xi) | ||
else: | ||
np.expm1(xi, out=xi) | ||
xi *= alpha | ||
xi *= alpha2 | ||
return xitocl(xi) | ||
|
||
|
||
def lognormal_normal(cl, alpha, *, inv=False): | ||
'''lognormal cross normal angular power spectrum | ||
''' | ||
xi = cltoxi(cl) | ||
if not inv: | ||
xi /= alpha | ||
else: | ||
xi *= alpha | ||
return xitocl(xi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters