-
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
36 changed files
with
1,660 additions
and
459 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
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
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,9 +1,9 @@ | ||
__author__ = "Christian Hellum Bye" | ||
__version__ = "3.0.0" | ||
__version__ = "4.0.0" | ||
|
||
from . import constants, dpss, sphtransform | ||
from .healpix import Alm, HealpixMap | ||
from .beam import Beam | ||
from .rotations import Rotator | ||
from .simulator import Simulator | ||
from .sky import Sky | ||
from . import constants | ||
from . import core | ||
from . import dpss | ||
from . import jax | ||
from . import utils | ||
from .core import * # noqa F403 |
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,12 +1,12 @@ | ||
import numpy as np | ||
|
||
# nside's for which healpix has computed pixel weights: | ||
PIX_WEIGHTS_NSIDE = (32, 64, 128, 256, 512, 1024, 2048, 4096) | ||
from math import pi, sqrt | ||
|
||
# sidereal days in seconds | ||
# https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html | ||
sidereal_day_earth = 23.9345 * 3600 | ||
# https://nssdc.gsfc.nasa.gov/planetary/factsheet/moonfact.html | ||
sidereal_day_moon = 655.720 * 3600 | ||
|
||
Y00 = 1 / np.sqrt(4 * np.pi) # the 0,0 spherical harmonic function | ||
sidereal_day = {"earth": sidereal_day_earth, "moon": sidereal_day_moon} | ||
|
||
Y00 = 1 / sqrt(4 * pi) # the 0,0 spherical harmonic function | ||
PIX_WEIGHTS_NSIDE = (32, 64, 128, 512, 1024, 2048, 4096) |
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,6 @@ | ||
from . import simulator, sphtransform | ||
from .healpix import Alm, HealpixMap | ||
from .beam import Beam | ||
from .rotations import Rotator | ||
from .simulator import Simulator | ||
from .sky import Sky |
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
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
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
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
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
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,77 @@ | ||
import numpy as np | ||
import healpy as hp | ||
from ..constants import PIX_WEIGHTS_NSIDE | ||
|
||
|
||
def alm2map(alm, nside, lmax=None): | ||
""" | ||
Compute the healpix map from the spherical harmonics coefficients. | ||
Parameters | ||
---------- | ||
alm : array-like | ||
The spherical harmonics coefficients in the healpy convention. Shape | ||
([nfreq], hp.Alm.getsize(lmax)). | ||
nside : int | ||
The nside of the output map(s). | ||
lmax : int | ||
The lmax of the spherical harmonics transform. Defaults to 3*nside-1. | ||
Returns | ||
------- | ||
map : np.ndarray | ||
The healpix map. Shape ([nfreq], hp.nside2npix(nside)). | ||
""" | ||
alm = np.array(alm, copy=True) | ||
if alm.ndim == 1: | ||
return hp.alm2map(alm, nside, lmax=lmax) | ||
else: | ||
npix = hp.nside2npix(nside) | ||
nfreqs = alm.shape[0] | ||
hp_map = np.empty((nfreqs, npix)) | ||
for i in range(nfreqs): | ||
map_i = hp.alm2map(alm[i], nside, lmax=lmax) | ||
hp_map[i] = map_i | ||
return hp_map | ||
|
||
|
||
def map2alm(data, lmax=None): | ||
""" | ||
Compute the spherical harmonics coefficents of a healpix map. | ||
Parameters | ||
---------- | ||
data : array-like | ||
The healpix map(s). Shape ([nfreq], hp.nside2npix(nside)). | ||
lmax : int | ||
The lmax of the spherical harmonics transform. Defaults to 3*nside-1. | ||
Returns | ||
------- | ||
alm : np.ndarray | ||
The spherical harmonics coefficients in the healpy convention. Shape | ||
([nfreq], hp.Alm.getsize(lmax)). | ||
""" | ||
data = np.array(data, copy=True) | ||
npix = data.shape[-1] | ||
nside = hp.npix2nside(npix) | ||
use_pix_weights = nside in PIX_WEIGHTS_NSIDE | ||
use_ring_weights = not use_pix_weights | ||
kwargs = { | ||
"lmax": lmax, | ||
"pol": False, | ||
"use_weights": use_ring_weights, | ||
"use_pixel_weights": use_pix_weights, | ||
} | ||
if data.ndim == 1: | ||
alm = hp.map2alm(data, **kwargs) | ||
else: | ||
# compute the alms of the first map to determine the size of the array | ||
alm0 = hp.map2alm(data[0], **kwargs) | ||
alm = np.empty((len(data), alm0.size), dtype=alm0.dtype) | ||
alm[0] = alm0 | ||
for i in range(1, len(data)): | ||
alm[i] = hp.map2alm(data[i], **kwargs) | ||
return alm |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.