Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websky extragalactic models #129

Merged
merged 34 commits into from
Nov 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c7f180f
basic downloading functionality
xzackli Oct 26, 2022
466c7a7
add the websky SZ components
xzackli Oct 29, 2022
be7ec94
add websky radio component
xzackli Oct 29, 2022
5e9f078
fix trailing whitespace
xzackli Oct 29, 2022
c975736
add websky cmb components
xzackli Oct 29, 2022
800a1e4
feat: use logging in interpolating
zonca Nov 2, 2022
f08068a
gitignore
zonca Nov 2, 2022
55e7cfa
fix: found bug in the interpolation algorithm
zonca Nov 2, 2022
7a2fdd9
test: improve test of interpolating
zonca Nov 2, 2022
c9bcd0c
feat: support zero-padded input templates filenames
zonca Nov 2, 2022
8e9ba08
set local folder as subsequent argument, so it is easier to use the d…
zonca Nov 2, 2022
5e81cae
feat: remove verbose and black formatting
zonca Nov 2, 2022
05fd0a8
feat: support local full path
zonca Nov 2, 2022
a1babb2
test: imported so-pysm-models test
zonca Nov 2, 2022
90a1f43
remove nside 512 models
zonca Nov 2, 2022
634bc10
test: websky tsz and ksz
zonca Nov 2, 2022
e1179a4
remove unused import
zonca Nov 2, 2022
f69ab1d
implemented SPT scaling of CIB
zonca Nov 6, 2022
9697a17
started writing docstring of WebSkyCIB
zonca Nov 6, 2022
f0c5399
Finalized implementation of SPT correction in WebSkyCIB
zonca Nov 6, 2022
aaae46a
mention WebSky in changelog
zonca Nov 6, 2022
c8019c5
feat: WebSky based models and documentation
zonca Nov 6, 2022
0cd6bae
fix: make sure all models support max_nside
zonca Nov 6, 2022
60b8e0c
test: implement test for radio galaxies
zonca Nov 6, 2022
2fee23f
implement test for boundary
zonca Nov 6, 2022
d715a45
test: proper testing of trapz
zonca Nov 7, 2022
f653bd5
fix: implement get relevant frequency separately and fix bug
zonca Nov 7, 2022
34e8f90
test: revamped test of interpolating component
zonca Nov 7, 2022
3bb9830
feat: add check that weight is correct for 1 point
zonca Nov 7, 2022
7a3fa0c
radiogalaxies paper
zonca Nov 8, 2022
4a602ce
fix: bug in weights normalization with 1 point
zonca Nov 8, 2022
5ef8b1f
update test for fix on weights normalization
zonca Nov 8, 2022
c5fe30b
fix: case where last point of bandpass is right at one of the input f…
zonca Nov 8, 2022
f0781a3
mention other changes in CHANGELOG
zonca Nov 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions pysm3/models/websky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import os.path
from pathlib import Path

from numba import njit
import numpy as np

import pysm3.units as u
from .interpolating import InterpolatingComponent
from .. import utils

@njit
def y2uK_CMB(nu):
"""Compton-y distortion at a given frequency
Parmeters:
nu (float): frequency in GHz
Returns:
float: intensity variation dT_CMB in micro-Kelvin
dT_CMB = dI_nu / (dB_nu / dT)_Tcmb
where B_nu is the Planck function and dI_nu is the intensity distortion
"""

h = 6.62607004e-27
k = 1.380622e-16
Tcmb = 2.725
x = h * nu * 1e9 / k / Tcmb
return 1e6 * Tcmb * (x * (np.exp(x) + 1) / (np.exp(x) - 1) - 4)


class WebSkyCIB(InterpolatingComponent):
"""PySM component interpolating between precomputed maps"""

def __init__(
self,
local_folder=None,
websky_version="0.3",
input_units="MJy / sr",
nside=4096,
max_nside=8192,
interpolation_kind="linear",
map_dist=None,
verbose=False
):
self.local_folder = local_folder
super().__init__(
path=websky_version,
input_units=input_units,
nside=nside,
max_nside=max_nside,
interpolation_kind=interpolation_kind,
map_dist=map_dist,
verbose=verbose,
)
self.remote_data = utils.RemoteData()

def get_filenames(self, path):
"""Get filenames for a websky version
For a standard interpolating component, we list files in folder,
here we need to know the names in advance so that we can only download the required maps
"""

websky_version = path
if websky_version in "0.3":
xzackli marked this conversation as resolved.
Show resolved Hide resolved

available_frequencies = [27, 39, 93, 100, 145, 217, 225, 280, 353, 545, 857]

filenames = {
freq: "websky/0.3/cib_{:04d}.fits".format(freq)
# freq, nside="512/" if self.nside <= 512 else "")
for freq in available_frequencies
}
if self.local_folder is not None:
for freq in filenames:
filenames[freq] = os.path.join(self.local_folder, filenames[freq])

return filenames

def read_map_by_frequency(self, freq):
filename = self.remote_data.get(self.maps[freq])
return self.read_map_file(freq, filename)