Skip to content

Commit

Permalink
start binning
Browse files Browse the repository at this point in the history
  • Loading branch information
mtristram committed Nov 22, 2023
1 parent f5b6dcd commit be484d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
35 changes: 29 additions & 6 deletions planck_2020_hillipop/hillipop.py
Expand Up @@ -8,6 +8,7 @@
import re
from itertools import combinations
from typing import Optional
from copy import deepcopy

import astropy.io.fits as fits
import numpy as np
Expand All @@ -33,6 +34,11 @@
"szxcib": fg.szxcib_model,
}

#bintab for hillipop_light
light_lmins = list( np.arange(30, 251, 1))+list( np.arange(251, 2500, 10))
light_lmaxs = list( np.arange(30, 251, 1))+list( np.arange(251, 2500, 10)+9)



# ------------------------------------------------------------------------------------------------
# Likelihood
Expand Down Expand Up @@ -90,6 +96,13 @@ def initialize(self):
self._lmins, self._lmaxs = self._set_multipole_ranges(filename)
self.lmax = np.max([max(l) for l in self._lmaxs.values()])

#Bin version
self.light = True if 'light' in likelihood_name else False
if self.light:
self.wf = tools.Bins( light_lmins, light_lmaxs)
else:
self.wf = tools.Bins.fromdeltal( 2, self.lmax+1, 1)

# Data
basename = os.path.join(self.data_folder, self.xspectra_basename)
self._dldata = self._read_dl_xspectra(basename)
Expand All @@ -98,7 +111,6 @@ def initialize(self):
dlsig = self._read_dl_xspectra(basename, hdu=2)
for m,w8 in dlsig.items(): w8[w8==0] = np.inf
self._dlweight = {k:1/v**2 for k,v in dlsig.items()}
# self._dlweight = np.ones(np.shape(self._dldata))

# Inverted Covariance matrix
filename = os.path.join(self.data_folder, self.covariance_matrix_file)
Expand Down Expand Up @@ -275,7 +287,8 @@ def _select_spectra(self, cl, mode):
for xf in range(self._nxfreq):
lmin = self._lmins[mode][self._xspec2xfreq.index(xf)]
lmax = self._lmaxs[mode][self._xspec2xfreq.index(xf)]
xl += list(acl[xf, lmin : lmax + 1])
mywf = self.wf.cut_binning( lmin, lmax)
xl += list(mywf.bin_spectra(acl[xf]))
return xl

def _xspectra_to_xfreq(self, cl, weight, normed=True):
Expand Down Expand Up @@ -472,7 +485,7 @@ def _get_install_options(filename):


class TTTEEE(_HillipopLikelihood):
"""High-L TT+TE+EE Likelihood for Polarized Planck spectra-based Gaussian-approximated likelihood
"""High-L TT+TE+EE Likelihood for Polarized Planck Spectra-based Gaussian-approximated likelihood
with foreground models for cross-correlation spectra from Planck 100, 143 and 217 GHz
split-frequency maps
Expand All @@ -481,8 +494,18 @@ class TTTEEE(_HillipopLikelihood):
install_options = _get_install_options("planck_2020_hillipop_TTTEEE_v4.2.tar.gz")


class TTTE(_HillipopLikelihood):
"""High-L TT+TE Likelihood for Polarized Planck Spectra-based Gaussian-approximated likelihood
with foreground models for cross-correlation spectra from Planck 100, 143 and 217 GHz
split-frequency maps
"""

install_options = _get_install_options("planck_2020_hillipop_TTTE_v4.2.tar.gz")


class TT(_HillipopLikelihood):
"""High-L TT Likelihood for Polarized Planck spectra-based Gaussian-approximated likelihood with
"""High-L TT Likelihood for Polarized Planck Spectra-based Gaussian-approximated likelihood with
foreground models for cross-correlation spectra from Planck 100, 143 and 217 GHz split-frequency
maps
Expand All @@ -492,7 +515,7 @@ class TT(_HillipopLikelihood):


class EE(_HillipopLikelihood):
"""High-L EE Likelihood for Polarized Planck spectra-based Gaussian-approximated likelihood with
"""High-L EE Likelihood for Polarized Planck Spectra-based Gaussian-approximated likelihood with
foreground models for cross-correlation spectra from Planck 100, 143 and 217 GHz split-frequency
maps
Expand All @@ -502,7 +525,7 @@ class EE(_HillipopLikelihood):


class TE(_HillipopLikelihood):
"""High-L TE Likelihood for Polarized Planck spectra-based Gaussian-approximated likelihood with
"""High-L TE Likelihood for Polarized Planck Spectra-based Gaussian-approximated likelihood with
foreground models for cross-correlation spectra from Planck 100, 143 and 217 GHz split-frequency
maps
Expand Down
1 change: 1 addition & 0 deletions planck_2020_hillipop/tools.py
Expand Up @@ -157,6 +157,7 @@ def cut_binning(self, lmin, lmax):
self.lmins = self.lmins[sel]
self.lmaxs = self.lmaxs[sel]
self._derive_ext()
return self

def _bin_operators(self, Dl=False, cov=False):
if Dl:
Expand Down

0 comments on commit be484d8

Please sign in to comment.