diff --git a/examples/tutorials/visualising_the_results.ipynb b/examples/tutorials/visualising_the_results.ipynb index 4a27fb2d1e5c496242424628f504847bed27895c..09c5660ad767fe38d210f2664e58d63fa0c45627 100644 --- a/examples/tutorials/visualising_the_results.ipynb +++ b/examples/tutorials/visualising_the_results.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "code", + "execution_count": null, "metadata": { "collapsed": true }, @@ -21,9 +22,138 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "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" + ] + } + ], "source": [ "import bilby\n", "import matplotlib.pyplot as plt\n", @@ -34,6 +164,7 @@ "outdir = 'visualising_the_results' # directory in which to store output\n", "label = 'example' # identifier to apply to output files\n", "\n", + "# specify injection parameters\n", "injection_parameters = dict(\n", "mass_1=36., # source frame (non-redshifted) primary mass (solar masses)\n", "mass_2=29., # source frame (non-redshifted) secondary mass (solar masses)\n", @@ -44,22 +175,25 @@ "phi_12=1.7, # azimuthal angle between primary and secondary spin (radians)\n", "phi_jl=0.3, # azimuthal angle between total angular momentum and orbital angular momentum (radians)\n", "luminosity_distance=200., # luminosity distance to source (Mpc)\n", - "iota=0.4, # inclination angle between line of sight and orbital angular momentum (radians)\n", + "theta_jn=0.4, # inclination angle between line of sight and orbital angular momentum (radians)\n", "phase=1.3, # phase (radians)\n", - "waveform_approximant='IMRPhenomPv2', # waveform approximant name\n", - "reference_frequency=50., # gravitational waveform reference frequency (Hz)\n", "ra=1.375, # source right ascension (radians)\n", "dec=-1.2108, # source declination (radians)\n", "geocent_time=1126259642.413, # reference time at geocentre (time of coalescence or peak amplitude) (GPS seconds)\n", "psi=2.659 # gravitational wave polarisation angle\n", ")\n", "\n", + "# specify waveform arguments\n", + "waveform_arguments = dict(\n", + "waveform_approximant='IMRPhenomPv2', # waveform approximant name\n", + "reference_frequency=50., # gravitational waveform reference frequency (Hz)\n", + ")\n", "\n", "# set up the waveform generator\n", "waveform_generator = bilby.gw.waveform_generator.WaveformGenerator(\n", " sampling_frequency=sampling_frequency, duration=time_duration,\n", " frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole,\n", - " parameters=injection_parameters)\n", + " parameters=injection_parameters, waveform_arguments=waveform_arguments)\n", "# create the frequency domain signal\n", "hf_signal = waveform_generator.frequency_domain_strain()\n", "\n", @@ -69,7 +203,7 @@ " sampling_frequency=sampling_frequency, outdir=outdir)]\n", "\n", "# first, set up all priors to be equal to a delta function at their designated value\n", - "priors = injection_parameters.copy()\n", + "priors = bilby.gw.prior.BBHPriorDict(injection_parameters.copy())\n", "# then, reset the priors on the masses and luminosity distance to conduct a search over these parameters\n", "priors['mass_1'] = bilby.core.prior.Uniform(20, 50, 'mass_1')\n", "priors['mass_2'] = bilby.core.prior.Uniform(20, 50, 'mass_2')\n", @@ -233,21 +367,30 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Bilby (source-install)", "language": "python", - "name": "python2" + "name": "bilby_source" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.14" + "pygments_lexer": "ipython3", + "version": "3.7.3" + }, + "pycharm": { + "stem_cell": { + "cell_type": "raw", + "metadata": { + "collapsed": false + }, + "source": [] + } } }, "nbformat": 4,