Skip to content

Commit

Permalink
Update CHIMERA documentation and version and remove unnecessary files
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoborghi committed Dec 11, 2023
1 parent 9a26b75 commit cc5f1b3
Show file tree
Hide file tree
Showing 17 changed files with 878,373 additions and 388 deletions.
27 changes: 4 additions & 23 deletions CHIMERA/Likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,36 +451,17 @@ def compute(self, lambda_cosmo, lambda_mass, lambda_rate, inspect=False):
like_events = np.empty(self.nevents)

# Compute overall rate normalization given lambda_rate (returns 1. if self.z_det_range is None)
p_z_norm = self.get_p_z_norm(lambda_cosmo, lambda_rate)
fR = self.completeness.get_fR(lambda_cosmo, z_det_range=[0,0.12])
p_z_norm = self._get_p_z_norm(lambda_cosmo, lambda_rate)

# fR_ev = self.get_fR(lambda_cosmo)
fR_ev = self.get_fR(lambda_cosmo)

# Compute like for each event
for e in range(self.nevents):
z_grid = self.z_grids[e]
p_cat = self.p_cat_all[e]

idxs_mask = self.completeness.get_pix2mask(self.pix_conf[e], self.nside[e])
fR_ev = fR[idxs_mask]
compl = self.completeness.P_compl(z_grid, self.pix_conf[e], self.nside[e])

# compl = self.P_compl(z_grid)

p_gal = fR_ev * p_cat + ( (1.-compl)*np.array(self.model_cosmo.dV_dz(z_grid, lambda_cosmo)[:, np.newaxis] ))

# p_gal = fR_ev * p_cat + ( (1.-compl)*np.array(self.model_cosmo.dV_dz(z_grid, lambda_cosmo)))[:, np.newaxis]

if 0:
# print(fR_ev * p_cat )
for pix in range(self.npix_event[e]):
zz = np.linspace(0, 10, 1000)
compl = self.P_compl(z_grid, self.pix_conf[e][pix], self.nside[e])
# print(compl)
fR = np.trapz(self.P_compl(zz, self.pix_conf[e][pix], self.nside[e])*np.array(self.model_cosmo.dV_dz(zz, lambda_cosmo)), zz)
p_gal[:,pix] = fR * p_cat[:,pix] + (1.-compl)*np.array(self.model_cosmo.dV_dz(z_grid, lambda_cosmo))


compl = self.P_compl(z_grid)
p_gal = fR_ev * p_cat + ( (1.-compl)*np.array(self.model_cosmo.dV_dz(z_grid, lambda_cosmo)))[:, np.newaxis]
p_rate = self.gw.model_rate(z_grid, lambda_rate)/(1.+z_grid)
p_z = (p_rate/p_z_norm)[:,np.newaxis] * p_gal
p_gw = self.gw.compute_event(e, z_grid, lambda_cosmo, lambda_mass)
Expand Down
2 changes: 1 addition & 1 deletion CHIMERA/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.dev58+ge14c507.d20231208"
__version__ = "1.0.0"
46 changes: 0 additions & 46 deletions CHIMERA/astro/spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,49 +64,3 @@ def logpdf_G(chi_eff, chi_p, lambda_s):


return logpdf_eff + logpdf_p














class UniformSpinDistChiz(BBHDistFunction):

'''
Uniform distribution in chi1z, chi2z, uncorrelated
'''

def __init__(self, ):
BBHDistFunction.__init__(self)
self.params = ['chiMin', 'chiMax', ] #'rho' ] # For the moment we ignore correlation

self.baseValues = {

'chiMin': -0.75,
'chiMax':0.75,
}

self.names = {
'chiMin':r'$\chi_{ z, Min}$',
'chiMax':r'$\chi_{ z, Max}$', }

self.n_params = len(self.params)

self.maxChi = 1
self.minChi = -1
self.nVars = 2



print('Uniform spin distribution in (chi1z, chi2z) base values: %s' %self.baseValues)



10 changes: 6 additions & 4 deletions CHIMERA/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def load_data_h5(fname):
from scipy.optimize import fmin


def get_confidence_HDI(post, grid, kde=None, interval=0.683, ax=None, color="k", lab=None, median=False, ls='--'):
def get_confidence_HDI(post, grid, kde=None, interval=0.683, ax=None, color="k", lab="auto", median=False, ls='--'):

if kde is not None:
N_samples = 10**6
Expand Down Expand Up @@ -177,10 +177,12 @@ def width(low):
xmax = med
xlow = lo
xup = hi


if ax is not None:
# lab = "$H_0={:.0f}^{{+{:.0f}}}_{{-{:.0f}}}$".format(xmax, xup-xmax, xmax-xlow)
if lab == "auto":
lab = r"$H_0={:.0f}^{{+{:.0f}}}_{{-{:.0f}}}$".format(xmax, xup-xmax, xmax-xlow)

ax.fill_between(xx, 0, yy, where=(xx >= xlow) & (xx <= xup), color=color, alpha=0.2, linewidth=0.0)
ax.plot([xmax,xmax], [0, float(post_int(xmax))/norm], color=color, linestyle=ls, label=lab)
ax.plot(xx, yy, lw=1, color=color, ls="-")
Expand Down
13 changes: 5 additions & 8 deletions CHIMERA/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def plot_2Dcoring(like,
event = 0,
do_boundaries = True,
do_KDE = False,
do_gal = True,
do_gal = False,
do_p_gal = True,
do_p_gw = True,
do_p_z = False,
Expand All @@ -51,7 +51,7 @@ def plot_2Dcoring(like,
KDE_levels = [0.1,0.8,0.9, 0.99],
lw = 1,
lab_p_gal = "$p_{\mathrm{gal},k}(z)$",
lab_p_gw = "$p_{\mathrm{gw},k}(z)$",
lab_p_gw = "$p_{\mathrm{gw},k}(z|H_0)$",
lab_p_z = "$p_{z,k}(z)$",
ax = None,
):
Expand All @@ -75,7 +75,6 @@ def pdf(y):
# Individual galaxies
alpha = misc.remapMinMax(-zgal, a=.2, b=.7)
ax[0].scatter(ragal, decgal, marker='x', c='darkred', s=30, label="Potential hosts", alpha=alpha)
# ax[0].scatter(ragal, decgal, marker='x', c='darkred', s=30, label="All galaxies", alpha=0.5)

if do_boundaries: # Highlight Healpixels
for jpix in pixels:
Expand All @@ -101,21 +100,19 @@ def pdf(y):
[ax[1].plot(z_grid, pdf(like.p_gal_all[event][:,pix]), c="darkred", lw=lw, alpha=0.7, label=lab_p_gal if pix==0 else None) for pix in range(len(pixels))]

if do_p_gw: # Plot p(z)_gw for each pixel
[ax[1].plot(z_grid, pdf(like.p_gw_all[iteration][event][:,pix]), c="darkblue", lw=lw, alpha=0.7, label=lab_p_gw if pix==0 else None) for pix in range(len(pixels))]
[ax[1].plot(z_grid, pdf(like.p_gw_all[iteration][:,pix]), c="darkblue", lw=lw, alpha=0.7, label=lab_p_gw if pix==0 else None) for pix in range(len(pixels))]

if do_p_z: # Plot p(z) for each pixel
[ax[1].plot(z_grid, pdf(like.p_z_all[iteration][event][:,pix]), c="teal", lw=lw, alpha=0.7, label=lab_p_z if pix==0 else None) for pix in range(len(pixels))]

ax[0].set_xlabel("RA")
ax[0].set_ylabel("DEC")
ax[0].set_ylabel("Dec")
ax[1].set_xlabel(r"$z$")
ax[1].set_ylabel(r"$p(z)~\textit{renormalized}$" if renorm_all else r"$p(z)$")
ax[1].set_ylabel(r"$p(z)$")
ax[1].set_xlim(*z_lims)
ax[0].legend()
ax[1].legend()

return fig




Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The code is designed to be accurate for different scenarios, encompassing bright

## Installation

The code can be easily installed with pip:
The code can be easily installed with pip (available soon):

pip install chimera-gw

Expand All @@ -28,7 +28,7 @@ or by cloning the source repository hosted on GitHub

## Documentation

Read the docs at [chimera-gw.readthedocs.io](https://chimera-gw.readthedocs.io)
The full documentation is provided at [chimera-gw.readthedocs.io](https://chimera-gw.readthedocs.io)



Expand Down
2 changes: 1 addition & 1 deletion docs/_static/CHIMERA_diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions docs/api/GW.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ GW

.. autoclass:: CHIMERA.DataGW.DataLVK
:members:
:inherited-members:
3
:inherited-members:
2 changes: 1 addition & 1 deletion docs/api/Models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fLCDM
^^^^^

.. autofunction:: CHIMERA.cosmo.fLCDM.dC
.. autofunction:: CHIMERA.cosmo.fLCDM.d_L
.. autofunction:: CHIMERA.cosmo.fLCDM.dL
.. autofunction:: CHIMERA.cosmo.fLCDM.ddL_dz
.. autofunction:: CHIMERA.cosmo.fLCDM.V
.. autofunction:: CHIMERA.cosmo.fLCDM.dV_dz
Expand Down
48 changes: 21 additions & 27 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,29 @@

<div style="min-height:0.1em;"></div>


*******
CHIMERA
*******

.. .. raw:: html
.. <img src="_static/CHIMERA_logoNB2.svg";" style="width:350px; margin:5px;"/>
.. <br/>
**CHIMERA** (Combined Hierarchical Inference Model for Electromagnetic and gRavitational-wave Analysis), is a flexible Python code to analyze standard sirens with galaxy catalogs, allowing for a joint fitting of the cosmological and astrophysical population parameters within a Hierarchical Bayesian Inference framework.

.. The code is designed to be accurate for different scenarios, encompassing bright, dark, and spectral sirens methods, and computationally efficient in view of next-generation GW observatories and galaxy surveys. It uses the LAX-backend implementation and Just In Time (JIT) computation capabilities of JAX.

.. image:: https://img.shields.io/badge/GitHub-CHIMERA-9e8ed7
:target: https://github.com/CosmoStatGW/CHIMERA/
:alt: GitHub
.. image:: https://img.shields.io/badge/arXiv-2106.14894-28bceb
:target: https://arxiv.org/abs/2106.14894
:alt: arXiv
.. image:: https://readthedocs.org/projects/chimera-gw/badge/?version=latest
:target: https://chimera-gw.readthedocs.io/en/latest/?badge=latest
:target: https://chimera-gw.readthedocs.io/latest/?badge=latest
:alt: Documentation Status
.. image:: https://img.shields.io/badge/license-MIT-fb7e21
:target: https://github.com/CosmoStatGW/CHIMERA/blob/main/LICENSE
:alt: License
.. image:: https://img.shields.io/gitlab/v/release/14528131
:target: https://gitlab.com/mmoresco/CHIMERA/-/tags
:alt: Release

.. raw:: html

Expand All @@ -53,7 +50,6 @@ Installation
pip install chimera-gw
License & Attribution
---------------------

Expand All @@ -77,44 +73,46 @@ If you find this code useful in your research, please cite the following paper (
}



The team
--------

Main developers:
**Core team**

- `Nicola Borghi (nicola.borghi6@unibo.it) <https://orcid.org/0000-0002-2889-8997>`_
- `Michele Mancarella (michele.mancarella@unimib.it) <https://orcid.org/0000-0002-0675-508X>`_
- `Nicola Borghi <https://orcid.org/0000-0002-2889-8997>`_ (**main developer**, nicola.borghi6@unibo.it)
- `Michele Mancarella <https://orcid.org/0000-0002-0675-508X>`_ (michele.mancarella@unimib.it)
- `Michele Moresco <https://orcid.org/0000-0002-7616-7136>`_ (michele.moresco@unibo.it)

**Contributors**

Contributors:

- `Michele Moresco (michele.moresco@unibo.it) <https://orcid.org/0000-0002-7616-7136>`_
- `Matteo Tagliazucchi <https://orcid.org/0000-0002-2889-8997>`_
- `Francesco Iacovelli <https://orcid.org/0000-0002-4875-5862>`_
- Niccolò Passaleva

- `Francesco Iacovelli <https://orcid.org/0000-0002-4875-5862>`_

The code was developed starting from https://github.com/CosmoStatGW/DarkSirensStat (`Finke et al. 2019 <https://orcid.org/0000-0002-2889-8997>`_) and https://github.com/CosmoStatGW/MGCosmoPop (`Mancarella et al. 2021 <https://orcid.org/0000-0002-2889-8997>`_).



Documentation
-------------

.. toctree::
:maxdepth: 2
:maxdepth: 1
:caption: User Guide

user_guide/installation
user_guide/introduction
user_guide/getting_started
user_guide/framework
user_guide/changelog
user_guide/citing

.. toctree::
:maxdepth: 1
:caption: Tutorials

tutorials/GW170817

.. toctree::
:maxdepth: 2
:maxdepth: 1
:caption: Python APIs

api/MCMC
Expand All @@ -125,11 +123,7 @@ Documentation
api/Models


.. .. toctree::
.. :maxdepth: 1
.. :caption: Tutorials

.. tutorials/quickstart


.. Changelog
Expand Down
Loading

0 comments on commit cc5f1b3

Please sign in to comment.