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
0 parents
commit d393b5c
Showing
6 changed files
with
145 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Nicolas Tessore | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,24 @@ | ||
|
||
lognormcl | ||
========= | ||
|
||
**angular power spectra of lognormal 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. | ||
|
||
The package can be installed using pip: | ||
|
||
pip install lognormcl | ||
|
||
Then import the `ln2n` and `n2ln` functions from the package: | ||
|
||
from lognormcl import ln2n, n2ln | ||
|
||
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/ |
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,71 @@ | ||
# author: Nicolas Tessore <n.tessore@ucl.ac.uk> | ||
# license: MIT | ||
''' | ||
Angular power spectra of lognormal fields (:mod:`lognormcl`) | ||
============================================================= | ||
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. | ||
The package can be installed using pip:: | ||
pip install lognormcl | ||
Then import the :func:`~lognormcl.ln2n` and :func:`~lognormcl.n2ln` functions | ||
from the package:: | ||
from lognormcl import ln2n, n2ln | ||
Current functionality covers the absolutely minimal use case. Please open an | ||
issue on GitHub if you would like to see anything added. | ||
Reference/API | ||
------------- | ||
.. autosummary:: | ||
:toctree: api | ||
:nosignatures: | ||
ln2n | ||
n2ln | ||
''' | ||
|
||
__version__ = '2021.4.16' | ||
|
||
__all__ = [ | ||
'ln2n', | ||
'n2ln', | ||
] | ||
|
||
|
||
import numpy as np | ||
from transformcl import cltoxi, xitocl | ||
|
||
|
||
def ln2n(cl, alpha, alpha2=None): | ||
'''lognormal to normal angular power spectrum | ||
''' | ||
|
||
xi = cltoxi(cl) | ||
xi /= alpha | ||
xi /= alpha2 if alpha2 is not None else alpha | ||
np.log1p(xi, out=xi) | ||
|
||
return xitocl(xi) | ||
|
||
|
||
|
||
def n2ln(cl, alpha, alpha2=None): | ||
'''normal to lognormal angular power spectrum | ||
''' | ||
|
||
xi = cltoxi(cl) | ||
np.expm1(xi, out=xi) | ||
xi *= alpha | ||
xi *= alpha2 if alpha2 is not None else 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel"] |
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,24 @@ | ||
[metadata] | ||
name = lognormcl | ||
version = attr:lognormcl.__version__ | ||
maintainer = Nicolas Tessore | ||
maintainer_email = n.tessore@ucl.ac.uk | ||
description = angular power spectra of lognormal random fields | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
license = MIT | ||
license_file = LICENSE | ||
url = https://github.com/ntessore/lognormcl | ||
project_urls = | ||
Documentation = https://cltools.readthedocs.io/lognormcl/ | ||
classifiers = | ||
Programming Language :: Python :: 3 | ||
License :: OSI Approved :: MIT License | ||
Operating System :: OS Independent | ||
|
||
[options] | ||
python_requires = >=3.6 | ||
install_requires = | ||
numpy | ||
transformcl | ||
py_modules = lognormcl |
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,3 @@ | ||
from setuptools import setup | ||
|
||
setup() |