sort multiple angular power spectra in healpy input order
Project description
sortcl
sort multiple angular power spectra in healpy input order
This is a minimal Python package to sort input angular power spectra cls
into the order expected by healpy's synalm
and synfast
functions.
The package can be installed using pip:
pip install sortcl
Then import the sortcl
function from the package:
from sortcl import sortcl
Current functionality covers the absolutely minimal use case. Please open an issue on GitHub if you would like to see anything added.
Documentation
def sortcl(cls, pairs, new=True):
'''sort cls in healpy synalm/synfast order
Given a list of cls and a list of pairs, return a new list of cls in the
order that healpy's ``synalm`` and ``synfast`` expect.
The list of pairs is any list of objects of length 2, for example strings:
``['TT', 'TE', 'TB']``.
Parameters
----------
cls : list
List of objects that will be sorted.
pairs : list of pairs
An iterable of objects of length two.
new : bool
Sort along diagonals if ``True``, or along rows if ``False``.
Returns
-------
sorted_cls : list
Sorted list of objects. Missing entries are set to ``None``.
Examples
--------
The typical use case is to bring a list of input cls into the right order
to pass it to ``synalm``.
>>> # 5 random example cls up to lmax = 1000
>>> cls = np.random.rand(5, 1001)
>>> pairs = ['TT', 'TE', 'TB', 'EE', 'BB']
>>> from sortcl import sortcl
>>> sorted_cls = sortcl(cls, pairs)
To illustrate what's going on, we can use the fact that the cls can be any
object, such as the labels themselves.
>>> sortcl(pairs, pairs)
['TT', 'EE', 'BB', 'TE', None, 'TB']
>>> # can also sort in old order, along rows
>>> sortcl(pairs, pairs, new=False)
['TT', 'TE', 'TB', 'EE', None, 'BB']
'''
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sortcl-2021.3.11.tar.gz
(3.7 kB
view details)
File details
Details for the file sortcl-2021.3.11.tar.gz
.
File metadata
- Download URL: sortcl-2021.3.11.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a535f0c7116f4b172057560629fec41c6c7de4861d240effa54a780060bb7b7b |
|
MD5 | 37b5b08238ed1ae7b03f4f4bfbde5c3e |
|
BLAKE2b-256 | b96c1a654b441b1111446b839b6523a5a2895bdaf70db9869ca3fb573583f6f7 |