.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_ucb/plot_source_joint_sky_pdf.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_ucb_plot_source_joint_sky_pdf.py: Joint PDF of sky location ========================= Plot joint posterior of all catalog sources in galactic coordinates. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Load catalogs and combine chain samples .. GENERATED FROM PYTHON SOURCE LINES 10-53 .. code-block:: default import logging import ligo.skymap.plot import matplotlib.pyplot as plt import numpy as np import pandas as pd from lisacattools import convert_ecliptic_to_galactic from lisacattools import HPhist from lisacattools import OFF from lisacattools.catalog import GWCatalogs from lisacattools.catalog import GWCatalogType logger = logging.getLogger("lisacattools") logger.setLevel( OFF ) # Set the logger to OFF. By default, the logger is set to INFO # Start by loading the main catalog file processed from GBMCMC outputs catPath = "../../tutorial/data/ucb" catalogs = GWCatalogs.create(GWCatalogType.UCB, catPath, "cat15728640_v2.h5") catalog = catalogs.get_last_catalog() # loop over all sources in catalog and append chain samples to new dataframe sources = list(catalog.get_detections()) samples_list = list() for source in sources: # get chain samples samples = catalog.get_source_samples( source, ["coslat", "Ecliptic Longitude"] ) # recompute ecliptic latitude to correct error in HDF5 files samples["Ecliptic Latitude"] = np.pi / 2 - np.arccos(samples["coslat"]) # append sky location parameters to joint posterior list samples_list.append(samples[["Ecliptic Latitude", "Ecliptic Longitude"]]) # combine all source samples into one dataframe all_sources = pd.concat(samples_list) .. GENERATED FROM PYTHON SOURCE LINES 54-55 Produce healpix map of joint posterior .. GENERATED FROM PYTHON SOURCE LINES 55-65 .. code-block:: default nside = 64 hpmap = HPhist(all_sources, nside) fig = plt.figure(figsize=(8, 6), dpi=100) ax = plt.axes([0.05, 0.05, 0.9, 0.9], projection="geo degrees mollweide") ax.grid() # use logarithmic scaling for density ax.imshow_hpx(np.log10(hpmap + 1), cmap="plasma") plt.show() .. image:: /examples_ucb/images/sphx_glr_plot_source_joint_sky_pdf_001.png :alt: plot source joint sky pdf :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 5 minutes 4.517 seconds) .. _sphx_glr_download_examples_ucb_plot_source_joint_sky_pdf.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_source_joint_sky_pdf.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_source_joint_sky_pdf.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_