diff --git a/examples/tutorials/visualising_the_results.ipynb b/examples/tutorials/visualising_the_results.ipynb index 09c5660ad767fe38d210f2664e58d63fa0c45627..9bf2de0aaf5f276dfbe821bacd8bf706da669a60 100644 --- a/examples/tutorials/visualising_the_results.ipynb +++ b/examples/tutorials/visualising_the_results.ipynb @@ -3,9 +3,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "! rm visualising_the_results/*" @@ -22,138 +20,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "10:31 bilby INFO : No power spectral density provided, using aLIGO,zero detuning, high power.\n", - "10:31 bilby INFO : Injected signal in H1:\n", - "10:31 bilby INFO : optimal SNR = 120.28\n", - "10:31 bilby INFO : matched filter SNR = 120.60-0.46j\n", - "10:31 bilby INFO : mass_1 = 36.0\n", - "10:31 bilby INFO : mass_2 = 29.0\n", - "10:31 bilby INFO : a_1 = 0.4\n", - "10:31 bilby INFO : a_2 = 0.3\n", - "10:31 bilby INFO : tilt_1 = 0.5\n", - "10:31 bilby INFO : tilt_2 = 1.0\n", - "10:31 bilby INFO : phi_12 = 1.7\n", - "10:31 bilby INFO : phi_jl = 0.3\n", - "10:31 bilby INFO : luminosity_distance = 200.0\n", - "10:31 bilby INFO : theta_jn = 0.4\n", - "10:31 bilby INFO : phase = 1.3\n", - "10:31 bilby INFO : ra = 1.375\n", - "10:31 bilby INFO : dec = -1.2108\n", - "10:31 bilby INFO : geocent_time = 1126259642.413\n", - "10:31 bilby INFO : psi = 2.659\n", - "10:31 bilby WARNING : The waveform_generator start_time is not equal to that of the provided interferometers. Overwriting the waveform_generator.\n", - "10:31 bilby INFO : Running for label 'example', output will be saved to 'visualising_the_results'\n", - "10:31 bilby INFO : Using LAL version Branch: None;Tag: lalsuite-v6.60;Id: 413788d4afeff8b759d8d75abe589ae4a846120c;;Builder: Unknown User <>;Repository status: CLEAN: All modifications committed\n", - "10:31 bilby INFO : Search parameters:\n", - "10:31 bilby INFO : mass_1 = Uniform(minimum=20, maximum=50, name='mass_1', latex_label='$m_1$', unit=None, boundary=None)\n", - "10:31 bilby INFO : mass_2 = Uniform(minimum=20, maximum=50, name='mass_2', latex_label='$m_2$', unit=None, boundary=None)\n", - "10:31 bilby INFO : luminosity_distance = Uniform(minimum=100, maximum=300, name='luminosity_distance', latex_label='$d_L$', unit=None, boundary=None)\n", - "10:31 bilby INFO : a_1 = 0.4\n", - "10:31 bilby INFO : a_2 = 0.3\n", - "10:31 bilby INFO : tilt_1 = 0.5\n", - "10:31 bilby INFO : tilt_2 = 1.0\n", - "10:31 bilby INFO : phi_12 = 1.7\n", - "10:31 bilby INFO : phi_jl = 0.3\n", - "10:31 bilby INFO : theta_jn = 0.4\n", - "10:31 bilby INFO : phase = 1.3\n", - "10:31 bilby INFO : ra = 1.375\n", - "10:31 bilby INFO : dec = -1.2108\n", - "10:31 bilby INFO : geocent_time = 1126259642.413\n", - "10:31 bilby INFO : psi = 2.659\n", - "10:31 bilby INFO : Single likelihood evaluation took 2.305e-03 s\n", - "10:31 bilby INFO : Using sampler Dynesty with kwargs {'bound': 'multi', 'sample': 'rwalk', 'verbose': True, 'periodic': None, 'reflective': None, 'check_point_delta_t': 600, 'nlive': 100, 'first_update': None, 'walks': 5, 'npdim': None, 'rstate': None, 'queue_size': None, 'pool': None, 'use_pool': None, 'live_points': None, 'logl_args': None, 'logl_kwargs': None, 'ptform_args': None, 'ptform_kwargs': None, 'enlarge': None, 'bootstrap': None, 'vol_dec': 0.5, 'vol_check': 2.0, 'facc': 0.5, 'slices': 5, 'update_interval': 60, 'print_func': <bound method Dynesty._print_func of <bilby.core.sampler.dynesty.Dynesty object at 0x1236747f0>>, 'dlogz': 0.1, 'maxiter': None, 'maxcall': None, 'logl_max': inf, 'add_live': True, 'print_progress': True, 'save_bounds': False, 'n_effective': None}\n", - "10:31 bilby INFO : Checkpoint every n_check_point = 300000\n", - "10:31 bilby INFO : Using dynesty version 0.9.7\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - " 1864| logz ratio=7255.416 +/- 0.541 | dlogz: 0.118 > 0.100000" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "10:32 bilby WARNING : Run terminated with signal 2\n", - "10:32 bilby INFO : Writing checkpoint file visualising_the_results/example_resume.pickle\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Exception while calling loglikelihood function:\n", - " params: [ 35.99600559 28.99205241 200.17592464]\n", - " args: []\n", - " kwargs: {}\n", - " exception:\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Traceback (most recent call last):\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/core/sampler/dynesty.py\", line 279, in _run_nested_wrapper\n", - " self.sampler.run_nested(**kwargs)\n", - "TypeError: run_nested() got an unexpected keyword argument 'n_effective'\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/Users/virginiademilio/anaconda3/envs/bilby_source/lib/python3.7/site-packages/dynesty/dynesty.py\", line 805, in __call__\n", - " return self.func(x, *self.args, **self.kwargs)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/core/sampler/base_sampler.py\", line 583, in log_likelihood\n", - " return Sampler.log_likelihood(self, theta)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/core/sampler/base_sampler.py\", line 381, in log_likelihood\n", - " return self.likelihood.log_likelihood_ratio()\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/gw/likelihood.py\", line 244, in log_likelihood_ratio\n", - " self.waveform_generator.frequency_domain_strain(self.parameters)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/gw/waveform_generator.py\", line 119, in frequency_domain_strain\n", - " transformed_model_data_points=self.time_array)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/gw/waveform_generator.py\", line 158, in _calculate_strain\n", - " model_strain = self._strain_from_model(model_data_points, model)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/gw/waveform_generator.py\", line 170, in _strain_from_model\n", - " return model(model_data_points, **self.parameters)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/gw/source.py\", line 71, in lal_binary_black_hole\n", - " phi_jl=phi_jl, **waveform_kwargs)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/gw/source.py\", line 272, in _base_lal_cbc_fd_waveform\n", - " waveform_dictionary, approximant)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/gw/utils.py\", line 798, in lalsim_SimInspiralChooseFDWaveform\n", - " waveform_dictionary, approximant)\n", - " File \"/Users/virginiademilio/Documents/Bilby/bilby/bilby/core/sampler/dynesty.py\", line 385, in write_current_state_and_exit\n", - " sys.exit(130)\n", - "SystemExit: 130\n" - ] - }, - { - "ename": "SystemExit", - "evalue": "130", - "output_type": "error", - "traceback": [ - "An exception has occurred, use %tb to see the full traceback.\n", - "\u001b[0;31mSystemExit\u001b[0m\u001b[0;31m:\u001b[0m 130\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/virginiademilio/anaconda3/envs/bilby_source/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3334: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.\n", - " warn(\"To exit: use 'exit', 'quit', or Ctrl-D.\", stacklevel=1)\n" - ] - } - ], + "outputs": [], "source": [ "import bilby\n", "import matplotlib.pyplot as plt\n", @@ -363,13 +232,56 @@ "result.plot_marginals()\n", "plt.show()" ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%% md\n" + } + }, + "source": [ + "#### Best-Fit Time Domain Waveform plot\n", + "Some plots sepcific to compact binary coalescence parameter estimation results can\n", + "be created by re-loading the result as a `CBCResult`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, + "outputs": [], + "source": [ + "from bilby.gw.result import CBCResult\n", + "\n", + "cbc_result = CBCResult.from_json(\"visualising_the_results/example_result.json\")\n", + "cbc_result.plot_waveform_posterior()\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": false + }, + "source": [ + "Again, notice that the plot is saved as a \"waveform.png\" in the output dir.\n", + "\n", + "\n", + "\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Bilby (source-install)", + "display_name": "Python 3", "language": "python", - "name": "bilby_source" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -382,15 +294,6 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" - }, - "pycharm": { - "stem_cell": { - "cell_type": "raw", - "metadata": { - "collapsed": false - }, - "source": [] - } } }, "nbformat": 4,