Skip to content
This repository has been archived by the owner on Feb 8, 2025. It is now read-only.
/ gaussiancl Public archive

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ntessore committed Apr 16, 2021
0 parents commit d393b5c
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
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.
24 changes: 24 additions & 0 deletions README.md
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/
71 changes: 71 additions & 0 deletions lognormcl.py
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)
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel"]
24 changes: 24 additions & 0 deletions setup.cfg
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
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()

0 comments on commit d393b5c

Please sign in to comment.