.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_ucb/plot_source_parameters.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_parameters.py: Corner plots ============ Produce corner plots for a single sources' parameters. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Load catalog and select individual source .. GENERATED FROM PYTHON SOURCE LINES 10-30 .. code-block:: default import matplotlib.pyplot as plt import numpy as np from lisacattools.catalog import GWCatalog from lisacattools.catalog import GWCatalogs from lisacattools.catalog import GWCatalogType # load catalog catPath = "../../tutorial/data/ucb" catalogs = GWCatalogs.create(GWCatalogType.UCB, catPath, "cat15728640_v2.h5") final_catalog = catalogs.get_last_catalog() detections_attr = final_catalog.get_attr_detections() detections = final_catalog.get_detections(detections_attr) # get index of source with maximum SNR sourceId = detections.index.values[ np.argmin(np.abs(np.array(detections["SNR"]) - detections["SNR"].max())) ] detections.loc[[sourceId], ["SNR", "Frequency"]] .. raw:: html
SNR Frequency
name
LDC0092117281 969.357 0.009212


.. GENERATED FROM PYTHON SOURCE LINES 31-32 Corner plot of select source parameters using `corner` module .. GENERATED FROM PYTHON SOURCE LINES 32-44 .. code-block:: default import corner # read in the chain samples for this source samples = final_catalog.get_source_samples(sourceId) # list of subset of paramters that are particularly interesting parameters = ["Frequency", "Frequency Derivative", "Amplitude", "Inclination"] # corner plot of source. fig = corner.corner(samples[parameters]) .. image:: /examples_ucb/images/sphx_glr_plot_source_parameters_001.png :alt: plot source parameters :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 45-46 Can also be done with ChainConsumer for prettier plots .. GENERATED FROM PYTHON SOURCE LINES 46-69 .. code-block:: default from chainconsumer import ChainConsumer # get dataframe into numpy array (this shouldn't be necessary) df = samples[parameters].values # rescale columns df[:, 0] = df[:, 0] * 1000 # f in mHz df[:, 1] = df[:, 1] / 1e-15 # df/dt df[:, 2] = df[:, 2] / 1e-22 # A df[:, 3] = df[:, 3] * 180.0 / np.pi # inc in deg parameter_symbols = [ r"$f\ {\rm [mHz]}$", r"$\dot{f}\ [s^{-2}]\times 10^{-16}$", r"$\mathcal{A} \times 10^{-23}$", r"$\iota\ {\rm [deg]}$", ] # add source chain to ChainConsumer object c = ChainConsumer().add_chain(df, parameters=parameter_symbols, cloud=True) # plot! fig = c.plotter.plot(figsize=1.5) plt.show() .. image:: /examples_ucb/images/sphx_glr_plot_source_parameters_002.png :alt: $f\ {\rm [mHz]} = \left( 92117281.7^{+7.6}_{-8.4} \right) \times 10^{-7}$, $\dot{f}\ [s^{-2}]\times 10^{-16} = 4.817^{+0.070}_{-0.088}$, $\mathcal{A} \times 10^{-23} = 5.864^{+0.372}_{-0.040}$, $\iota\ {\rm [deg]} = -70.6^{+5.7}_{-8.3}$ :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 2.186 seconds) .. _sphx_glr_download_examples_ucb_plot_source_parameters.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_parameters.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_source_parameters.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_