├── .gitignore ├── 0737.png ├── 0_Test_Installation.ipynb ├── 1_Introduction_to_pulsar_search_and_timing.ipynb ├── 2_Aperiodic_Timing.ipynb ├── 3_Fitting_Power_Density_Spectra.ipynb ├── 4_Orbital_Doppler.ipynb ├── License.md ├── QPO_NS_BH.png ├── README.md ├── buriedclock.jpg ├── modeling_tutorial_mcmc_corner.pdf ├── no-binder ├── Timing_Mainstream_Software.ipynb └── Timing_residuals.ipynb ├── oh_deer.png ├── requirements.txt └── smallmodpulsar.gif /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /0737.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matteobachetti/timing-lectures/820f14edd68e3495546c77131009837ed895040b/0737.png -------------------------------------------------------------------------------- /0_Test_Installation.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import importlib\n", 10 | "\n", 11 | "def check_library(libname, path=None):\n", 12 | " if path is None:\n", 13 | " path = libname\n", 14 | "\n", 15 | " try:\n", 16 | " library = importlib.import_module(libname)\n", 17 | " print(f\"Installed: {library.__version__}\")\n", 18 | " except ImportError:\n", 19 | " print(f\"Please install {libname}:\")\n", 20 | " print(f\"pip install {path}\")" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": null, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "check_library(\"stingray\", 'git+https://github.com/stingraysoftware/stingray.git')" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "check_library(\"hendrics\", 'git+https://github.com/stingraysoftware/hendrics.git')" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": null, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "check_library(\"emcee\")" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": null, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "check_library(\"astropy\")" 57 | ] 58 | }, 59 | { 60 | "cell_type": "code", 61 | "execution_count": null, 62 | "metadata": {}, 63 | "outputs": [], 64 | "source": [ 65 | "check_library(\"numba\")" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": null, 71 | "metadata": {}, 72 | "outputs": [], 73 | "source": [ 74 | "check_library(\"pint\", \"git+https://github.com/nanograv/pint.git\")" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "metadata": {}, 81 | "outputs": [], 82 | "source": [] 83 | } 84 | ], 85 | "metadata": { 86 | "kernelspec": { 87 | "display_name": "Python 3", 88 | "language": "python", 89 | "name": "python3" 90 | }, 91 | "language_info": { 92 | "codemirror_mode": { 93 | "name": "ipython", 94 | "version": 3 95 | }, 96 | "file_extension": ".py", 97 | "mimetype": "text/x-python", 98 | "name": "python", 99 | "nbconvert_exporter": "python", 100 | "pygments_lexer": "ipython3", 101 | "version": "3.7.5" 102 | } 103 | }, 104 | "nbformat": 4, 105 | "nbformat_minor": 2 106 | } 107 | -------------------------------------------------------------------------------- /4_Orbital_Doppler.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 17, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "%matplotlib nbagg\n", 12 | "import matplotlib.pyplot as plt\n", 13 | "import numpy as np\n", 14 | "from PyAstronomy import pyasl\n", 15 | "from matplotlib.gridspec import GridSpec" 16 | ] 17 | }, 18 | { 19 | "cell_type": "markdown", 20 | "metadata": {}, 21 | "source": [ 22 | "## Orbital Doppler" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 80, 28 | "metadata": { 29 | "collapsed": false 30 | }, 31 | "outputs": [ 32 | { 33 | "data": { 34 | "application/javascript": [ 35 | "/* Put everything inside the global mpl namespace */\n", 36 | "window.mpl = {};\n", 37 | "\n", 38 | "mpl.get_websocket_type = function() {\n", 39 | " if (typeof(WebSocket) !== 'undefined') {\n", 40 | " return WebSocket;\n", 41 | " } else if (typeof(MozWebSocket) !== 'undefined') {\n", 42 | " return MozWebSocket;\n", 43 | " } else {\n", 44 | " alert('Your browser does not have WebSocket support.' +\n", 45 | " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", 46 | " 'Firefox 4 and 5 are also supported but you ' +\n", 47 | " 'have to enable WebSockets in about:config.');\n", 48 | " };\n", 49 | "}\n", 50 | "\n", 51 | "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", 52 | " this.id = figure_id;\n", 53 | "\n", 54 | " this.ws = websocket;\n", 55 | "\n", 56 | " this.supports_binary = (this.ws.binaryType != undefined);\n", 57 | "\n", 58 | " if (!this.supports_binary) {\n", 59 | " var warnings = document.getElementById(\"mpl-warnings\");\n", 60 | " if (warnings) {\n", 61 | " warnings.style.display = 'block';\n", 62 | " warnings.textContent = (\n", 63 | " \"This browser does not support binary websocket messages. \" +\n", 64 | " \"Performance may be slow.\");\n", 65 | " }\n", 66 | " }\n", 67 | "\n", 68 | " this.imageObj = new Image();\n", 69 | "\n", 70 | " this.context = undefined;\n", 71 | " this.message = undefined;\n", 72 | " this.canvas = undefined;\n", 73 | " this.rubberband_canvas = undefined;\n", 74 | " this.rubberband_context = undefined;\n", 75 | " this.format_dropdown = undefined;\n", 76 | "\n", 77 | " this.image_mode = 'full';\n", 78 | "\n", 79 | " this.root = $('
');\n", 80 | " this._root_extra_style(this.root)\n", 81 | " this.root.attr('style', 'display: inline-block');\n", 82 | "\n", 83 | " $(parent_element).append(this.root);\n", 84 | "\n", 85 | " this._init_header(this);\n", 86 | " this._init_canvas(this);\n", 87 | " this._init_toolbar(this);\n", 88 | "\n", 89 | " var fig = this;\n", 90 | "\n", 91 | " this.waiting = false;\n", 92 | "\n", 93 | " this.ws.onopen = function () {\n", 94 | " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", 95 | " fig.send_message(\"send_image_mode\", {});\n", 96 | " fig.send_message(\"refresh\", {});\n", 97 | " }\n", 98 | "\n", 99 | " this.imageObj.onload = function() {\n", 100 | " if (fig.image_mode == 'full') {\n", 101 | " // Full images could contain transparency (where diff images\n", 102 | " // almost always do), so we need to clear the canvas so that\n", 103 | " // there is no ghosting.\n", 104 | " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", 105 | " }\n", 106 | " fig.context.drawImage(fig.imageObj, 0, 0);\n", 107 | " };\n", 108 | "\n", 109 | " this.imageObj.onunload = function() {\n", 110 | " this.ws.close();\n", 111 | " }\n", 112 | "\n", 113 | " this.ws.onmessage = this._make_on_message_function(this);\n", 114 | "\n", 115 | " this.ondownload = ondownload;\n", 116 | "}\n", 117 | "\n", 118 | "mpl.figure.prototype._init_header = function() {\n", 119 | " var titlebar = $(\n", 120 | " '
');\n", 122 | " var titletext = $(\n", 123 | " '
');\n", 125 | " titlebar.append(titletext)\n", 126 | " this.root.append(titlebar);\n", 127 | " this.header = titletext[0];\n", 128 | "}\n", 129 | "\n", 130 | "\n", 131 | "\n", 132 | "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", 133 | "\n", 134 | "}\n", 135 | "\n", 136 | "\n", 137 | "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", 138 | "\n", 139 | "}\n", 140 | "\n", 141 | "mpl.figure.prototype._init_canvas = function() {\n", 142 | " var fig = this;\n", 143 | "\n", 144 | " var canvas_div = $('
');\n", 145 | "\n", 146 | " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", 147 | "\n", 148 | " function canvas_keyboard_event(event) {\n", 149 | " return fig.key_event(event, event['data']);\n", 150 | " }\n", 151 | "\n", 152 | " canvas_div.keydown('key_press', canvas_keyboard_event);\n", 153 | " canvas_div.keyup('key_release', canvas_keyboard_event);\n", 154 | " this.canvas_div = canvas_div\n", 155 | " this._canvas_extra_style(canvas_div)\n", 156 | " this.root.append(canvas_div);\n", 157 | "\n", 158 | " var canvas = $('');\n", 159 | " canvas.addClass('mpl-canvas');\n", 160 | " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", 161 | "\n", 162 | " this.canvas = canvas[0];\n", 163 | " this.context = canvas[0].getContext(\"2d\");\n", 164 | "\n", 165 | " var rubberband = $('');\n", 166 | " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", 167 | "\n", 168 | " var pass_mouse_events = true;\n", 169 | "\n", 170 | " canvas_div.resizable({\n", 171 | " start: function(event, ui) {\n", 172 | " pass_mouse_events = false;\n", 173 | " },\n", 174 | " resize: function(event, ui) {\n", 175 | " fig.request_resize(ui.size.width, ui.size.height);\n", 176 | " },\n", 177 | " stop: function(event, ui) {\n", 178 | " pass_mouse_events = true;\n", 179 | " fig.request_resize(ui.size.width, ui.size.height);\n", 180 | " },\n", 181 | " });\n", 182 | "\n", 183 | " function mouse_event_fn(event) {\n", 184 | " if (pass_mouse_events)\n", 185 | " return fig.mouse_event(event, event['data']);\n", 186 | " }\n", 187 | "\n", 188 | " rubberband.mousedown('button_press', mouse_event_fn);\n", 189 | " rubberband.mouseup('button_release', mouse_event_fn);\n", 190 | " // Throttle sequential mouse events to 1 every 20ms.\n", 191 | " rubberband.mousemove('motion_notify', mouse_event_fn);\n", 192 | "\n", 193 | " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", 194 | " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", 195 | "\n", 196 | " canvas_div.on(\"wheel\", function (event) {\n", 197 | " event = event.originalEvent;\n", 198 | " event['data'] = 'scroll'\n", 199 | " if (event.deltaY < 0) {\n", 200 | " event.step = 1;\n", 201 | " } else {\n", 202 | " event.step = -1;\n", 203 | " }\n", 204 | " mouse_event_fn(event);\n", 205 | " });\n", 206 | "\n", 207 | " canvas_div.append(canvas);\n", 208 | " canvas_div.append(rubberband);\n", 209 | "\n", 210 | " this.rubberband = rubberband;\n", 211 | " this.rubberband_canvas = rubberband[0];\n", 212 | " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", 213 | " this.rubberband_context.strokeStyle = \"#000000\";\n", 214 | "\n", 215 | " this._resize_canvas = function(width, height) {\n", 216 | " // Keep the size of the canvas, canvas container, and rubber band\n", 217 | " // canvas in synch.\n", 218 | " canvas_div.css('width', width)\n", 219 | " canvas_div.css('height', height)\n", 220 | "\n", 221 | " canvas.attr('width', width);\n", 222 | " canvas.attr('height', height);\n", 223 | "\n", 224 | " rubberband.attr('width', width);\n", 225 | " rubberband.attr('height', height);\n", 226 | " }\n", 227 | "\n", 228 | " // Set the figure to an initial 600x600px, this will subsequently be updated\n", 229 | " // upon first draw.\n", 230 | " this._resize_canvas(600, 600);\n", 231 | "\n", 232 | " // Disable right mouse context menu.\n", 233 | " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", 234 | " return false;\n", 235 | " });\n", 236 | "\n", 237 | " function set_focus () {\n", 238 | " canvas.focus();\n", 239 | " canvas_div.focus();\n", 240 | " }\n", 241 | "\n", 242 | " window.setTimeout(set_focus, 100);\n", 243 | "}\n", 244 | "\n", 245 | "mpl.figure.prototype._init_toolbar = function() {\n", 246 | " var fig = this;\n", 247 | "\n", 248 | " var nav_element = $('
')\n", 249 | " nav_element.attr('style', 'width: 100%');\n", 250 | " this.root.append(nav_element);\n", 251 | "\n", 252 | " // Define a callback function for later on.\n", 253 | " function toolbar_event(event) {\n", 254 | " return fig.toolbar_button_onclick(event['data']);\n", 255 | " }\n", 256 | " function toolbar_mouse_event(event) {\n", 257 | " return fig.toolbar_button_onmouseover(event['data']);\n", 258 | " }\n", 259 | "\n", 260 | " for(var toolbar_ind in mpl.toolbar_items) {\n", 261 | " var name = mpl.toolbar_items[toolbar_ind][0];\n", 262 | " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", 263 | " var image = mpl.toolbar_items[toolbar_ind][2];\n", 264 | " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", 265 | "\n", 266 | " if (!name) {\n", 267 | " // put a spacer in here.\n", 268 | " continue;\n", 269 | " }\n", 270 | " var button = $('