{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Calibration of the 9-Mythen detector at the Cristal beamline at Soleil\n", "\n", "Mythen detectors are 1D-strip detector sold by Dectris. \n", "On the Cristal beamline at Soleil, 9 of them are mounted on the goniometer. \n", "\n", "This notebook explains how to calibrate precisely their position (including the wavelength used) as function of the goniometer position.\n", "\n", "All input data are provided in a Nexus file wich contrains both the (approximate) energy, the goniometer positions (500 points have been measured) and the measured signal.\n", "\n", "As pyFAI is not made for 1D data, the Mythen detector will be considered as a 1x1280 image.\n", "\n", "We start by importing a whole bunch of modules:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib nbagg" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from collections import OrderedDict\n", "from matplotlib import pyplot as plt\n", "import numpy\n", "import os\n", "import h5py\n", "from silx.resources import ExternalResources\n", "\n", "from pyFAI import goniometer\n", "from pyFAI.detectors import Detector\n", "from pyFAI.goniometer import ExtendedTransformation, GoniometerRefinement\n", "from pyFAI.control_points import ControlPoints\n", "from pyFAI.geometryRefinement import GeometryRefinement\n", "from pyFAI.gui import jupyter\n", "from pyFAI.units import hc\n", "from pyFAI.calibrant import get_calibrant\n", "from pyFAI.containers import Integrate1dResult\n", "\n", "import ipywidgets as widgets\n", "\n", "from scipy.signal import find_peaks_cwt\n", "from scipy.interpolate import interp1d\n", "from scipy.optimize import bisect, minimize\n", "from scipy.spatial import distance_matrix\n", "import time\n", "\n", "start_time = time.time()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#Nota: Useful to configure a proxy if you are behind a firewall\n", "#os.environ[\"http_proxy\"] = \"http://proxy.company.fr:3128\"\n", "\n", "downloader = ExternalResources(\"detector_calibration\", \"http://www.silx.org/pub/pyFAI/gonio/\")\n", "mythen_ring_file = downloader.getfile(\"LaB6_17keV_att3_tth2C_24_01_2018_19-43-20_1555.nxs\")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The data file can be downoaded from:\n", "http://www.silx.org/pub/pyFAI/gonio/LaB6_17keV_att3_tth2C_24_01_2018_19-43-20_1555.nxs" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Positions: [90.00000001 89.79994445 89.5998889 89.39994445 89.19994445] ...\n" ] } ], "source": [ "#Open the Nexus file and retrieve the actual positions:\n", "\n", "h5 = h5py.File(mythen_ring_file, mode=\"r\")\n", "position = h5[\"/LaB6_17keV_att3_1555/scan_data/actuator_1_1\"][:]\n", "print(\"Positions: \", position[:5], \"...\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "data_01 (501, 5120)\n", "data_02 (501, 1280)\n", "data_03 (501, 1280)\n", "data_04 (501, 1280)\n", "data_05 (501, 1280)\n", "data_06 (501, 5120)\n", "data_07 (501, 1280)\n", "data_08 (501, 1280)\n", "data_09 (501, 1280)\n", "data_10 (501, 1280)\n", "data_11 (501, 1280)\n", "data_12 (501, 1280)\n", "['data_02', 'data_03', 'data_04', 'data_05', 'data_07', 'data_08', 'data_09', 'data_10', 'data_11', 'data_12']\n" ] } ], "source": [ "#Read all data\n", "\n", "data = {}\n", "ds_names = []\n", "for idx in range(1,13):\n", " name = \"data_%02i\"%idx\n", " ds = h5[\"/LaB6_17keV_att3_1555/scan_data/\"+name][:]\n", " print(name, ds.shape)\n", " if ds.shape[1]<2000:\n", " #Keep only the single modules\n", " data[name] = ds\n", " ds_names.append(name)\n", "\n", "print(ds_names)\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "#Define a Mythen-detector mounted vertically:\n", "\n", "class MythenV(Detector):\n", " \"Verical Mythen dtrip detector from Dectris\"\n", " aliases = [\"MythenV 1280\"]\n", " force_pixel = True\n", " MAX_SHAPE = (1280, 1)\n", "\n", " def __init__(self,pixel1=50e-6, pixel2=8e-3):\n", " super(MythenV, self).__init__(pixel1=pixel1, pixel2=pixel2)\n", "\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "data_02 MythenV 1280\n", "data_03 MythenV 1280\n", "data_04 MythenV 1280\n", "data_05 MythenV 1280\n", "data_07 MythenV 1280\n", "data_08 MythenV 1280\n", "data_09 MythenV 1280\n", "data_10 MythenV 1280\n", "data_11 MythenV 1280\n", "data_12 MythenV 1280\n" ] } ], "source": [ "#Define all modules as single detectors of class MythenV. \n", "# Each one has a mask defined from dummy-values in the dataset\n", "\n", "modules = {}\n", "for name, ds in data.items():\n", " one_module = MythenV()\n", " mask = ds[0]<0\n", " #discard the first 20 and last 20 pixels as their intensities are less reliable\n", " mask[:20] = True\n", " mask[-20:] = True\n", " one_module.mask = mask.reshape(-1,1)\n", " modules[name] = one_module\n", "\n", "for k,v in modules.items():\n", " print(k, v.name)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "18.1 ms ± 25.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n", "[[287.06072343 0.5 ]]\n" ] } ], "source": [ "# Define a peak-picking function based on the dataset-name and the frame_id:\n", "\n", "def peak_picking(module_name, frame_id, \n", " threshold=500):\n", " \"\"\"Peak-picking base on find_peaks_cwt from scipy plus \n", " second-order tailor exapention refinement for sub-pixel resolution.\n", " \n", " The half-pixel offset is accounted here, i.e pixel #0 has its center at 0.5\n", " \n", " \"\"\"\n", " module = modules[module_name]\n", " msk = module.mask.ravel()\n", " \n", " spectrum = data[module_name][frame_id]\n", " guess = find_peaks_cwt(spectrum, [20])\n", " \n", " valid = numpy.logical_and(numpy.logical_not(msk[guess]), \n", " spectrum[guess]>threshold)\n", " guess = guess[valid]\n", " \n", " #Based on maximum is f'(x) = 0 ~ f'(x0) + (x-x0)*(f''(x0))\n", " df = numpy.gradient(spectrum)\n", " d2f = numpy.gradient(df)\n", " bad = d2f==0\n", " d2f[bad] = 1e-10 #prevent devision by zero. Discared later on\n", " cor = df / d2f\n", " cor[abs(cor)>1] = 0\n", " cor[bad] = 0\n", " ref = guess - cor[guess] + 0.5 #half a pixel offset\n", " x = numpy.zeros_like(ref) + 0.5 #half a pixel offset\n", " return numpy.vstack((ref,x)).T\n", "\n", "%timeit peak_picking(ds_names[0], 93)\n", "print(peak_picking(ds_names[0], 93))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Energy (keV): 17.027082549190933 \n", "Wavelength (A): 7.281587849134994e-11\n", "LaB6 Calibrant with 109 reflections at wavelength 7.281587849134994e-11\n" ] } ], "source": [ "nrj = h5[\"/LaB6_17keV_att3_1555/CRISTAL/Monochromator/energy\"][0]\n", "wl = hc / nrj *1e-10\n", "print(\"Energy (keV): \",nrj, \"\\nWavelength (A): \",wl)\n", "\n", "LaB6 = get_calibrant(\"LaB6\")\n", "LaB6.wavelength = wl\n", "print(LaB6)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "#This cell defines the transformation of coordinates for a simple goniometer mounted vertically.\n", "\n", "trans = ExtendedTransformation(dist_expr=\"dist\", \n", " poni1_expr=\"poni1\", \n", " poni2_expr=\"poni2\", \n", " rot1_expr=\"rot1\", \n", " rot2_expr=\"pi*(offset+scale*angle)/180.\", \n", " rot3_expr=\"0.0\", \n", " wavelength_expr=\"hc/nrj*1e-10\", \n", " param_names=[\"dist\", \"poni1\", \"poni2\", \"rot1\", \"offset\", \"scale\", \"nrj\"], \n", " pos_names=[\"angle\"], \n", " constants={\"hc\": hc})" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Approximated offset for the first module: 82.79994445106844\n" ] } ], "source": [ "def get_position(idx):\n", " \"Returns the postion of the goniometer for the given frame_id\"\n", " return position[idx]\n", "\n", "#Approximate offset for the module #0 at 0°\n", "print(\"Approximated offset for the first module: \",get_position(36))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Plot the integrated pattern vs expected peak positions:\n", "\n", "LaB6_new = get_calibrant(\"LaB6\")\n", "LaB6_new.wavelength = hc/gonioref0.param[-1]*1e-10\n", "p = jupyter.plot1d(res_mg, calibrant=LaB6_new)\n", "p.figure.show()" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "#Peak profile function based on a bilinear interpolations: \n", "\n", "def calc_fwhm(integrate_result, calibrant, tth_min=None, tth_max=None):\n", " \"calculate the tth position and FWHM for each peak\"\n", " delta = integrate_result.intensity[1:] - integrate_result.intensity[:-1]\n", " maxima = numpy.where(numpy.logical_and(delta[:-1]>0, delta[1:]<0))[0]\n", " minima = numpy.where(numpy.logical_and(delta[:-1]<0, delta[1:]>0))[0]\n", " maxima += 1\n", " minima += 1\n", " tth = []\n", " FWHM = []\n", " if tth_min is None:\n", " tth_min = integrate_result.radial[0]\n", " if tth_max is None:\n", " tth_max = integrate_result.radial[-1]\n", " for tth_rad in calibrant.get_2th():\n", " tth_deg = tth_rad*integrate_result.unit.scale\n", " if (tth_deg<=tth_min) or (tth_deg>=tth_max):\n", " continue\n", " idx_theo = abs(integrate_result.radial-tth_deg).argmin()\n", " id0_max = abs(maxima-idx_theo).argmin()\n", " id0_min = abs(minima-idx_theo).argmin()\n", " I_max = integrate_result.intensity[maxima[id0_max]]\n", " I_min = integrate_result.intensity[minima[id0_min]]\n", " tth_maxi = integrate_result.radial[maxima[id0_max]]\n", " I_thres = (I_max + I_min)/2.0\n", " if minima[id0_min]>maxima[id0_max]:\n", " if id0_min == 0:\n", " min_lo = integrate_result.radial[0]\n", " else:\n", " min_lo = integrate_result.radial[minima[id0_min-1]]\n", " min_hi = integrate_result.radial[minima[id0_min]]\n", " else:\n", " if id0_min == len(minima) -1:\n", " min_hi = integrate_result.radial[-1]\n", " else:\n", " min_hi = integrate_result.radial[minima[id0_min+1]]\n", " min_lo = integrate_result.radial[minima[id0_min]]\n", " \n", " f = interp1d(integrate_result.radial, integrate_result.intensity-I_thres)\n", " try:\n", " tth_lo = bisect(f, min_lo, tth_maxi)\n", " tth_hi = bisect(f, tth_maxi, min_hi)\n", " except:\n", " pass\n", " else:\n", " FWHM.append(tth_hi-tth_lo)\n", " tth.append(tth_deg)\n", " return tth, FWHM\n", " \n" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "# Peak error:\n", "\n", "def calc_peak_error(integrate_result, calibrant, tth_min=10, tth_max=95):\n", " \"calculate the tth position and FWHM for each peak\"\n", " peaks = find_peaks_cwt(integrate_result.intensity, [10])\n", " df = numpy.gradient(integrate_result.intensity)\n", " d2f = numpy.gradient(df)\n", " bad = d2f==0\n", " d2f[bad] = 1e-10\n", " cor = df / d2f\n", " print((abs(cor)>1).sum())\n", " cor[abs(cor)>1] = 0\n", " cor[bad] = 0\n", " got = numpy.interp(peaks-cor[peaks], \n", " numpy.arange(len(integrate_result.radial)), \n", " integrate_result.radial)\n", " mask = numpy.logical_and(got>=tth_min,\n", " got<=tth_max)\n", " got = got[mask]\n", " target = numpy.array(calibrant.get_2th())*integrate_result.unit.scale\n", " mask = numpy.logical_and(target>=tth_min,\n", " target<=tth_max)\n", " target = target[mask]\n", " print(len(got), len(target))\n", " d2 = distance_matrix(target.reshape(-1, 1 ),\n", " got.reshape(-1, 1), p=1)\n", " \n", " return target, target-got[d2.argmin(axis=-1)]\n" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LaB6_new = get_calibrant(\"LaB6\")\n", "LaB6_new.wavelength = hc/gonioref1.param[-1]*1e-10\n", "p = jupyter.plot1d(res_mg1, calibrant=LaB6_new)\n", "p.figure.show()" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "area_pixel=0.05054585816712631 area_sum=0.05084240089824814, Error= -0.005866805745810646\n", "area_pixel=0.05448433978731071 area_sum=0.05460194376540826, Error= -0.002158491385903477\n", "area_pixel=0.05706893234299759 area_sum=0.057097754167008734, Error= -0.0005050352762500703\n", "area_pixel=0.04575136894640419 area_sum=0.046103520693760155, Error= -0.007697075638731046\n", "area_pixel=0.0503875602291064 area_sum=0.05041948354020665, Error= -0.0006335554044510445\n", "area_pixel=0.050887046288177196 area_sum=0.05090400923674137, Error= -0.0003333451202514585\n", "area_pixel=0.047764037615231736 area_sum=0.047787742717740125, Error= -0.0004962960355099896\n", "area_pixel=0.054600585079026764 area_sum=0.05461392295287675, Error= -0.00024428078619822223\n", "area_pixel=0.04398098576245957 area_sum=0.0451093409852144, Error= -0.025655523704017393\n", "area_pixel=0.05413585962925449 area_sum=0.054261047973434326, Error= -0.0023124846458000116\n", "area_pixel=0.05074179597564754 area_sum=0.051022305153632666, Error= -0.005528168102677118\n", "area_pixel=0.05670749981502521 area_sum=0.0567493721010123, Error= -0.0007383906207058524\n", "area_pixel=0.0522725582237884 area_sum=0.052599157191360185, Error= -0.006248000455105984\n", "area_pixel=0.04886833409786284 area_sum=0.05916004122953074, Error= -0.21060073607293242\n", "area_pixel=0.05605479751870135 area_sum=0.06334656311501353, Error= -0.13008281037639038\n", "area_pixel=0.07613865216960036 area_sum=0.07747175549456228, Error= -0.01750889051716343\n", "area_pixel=0.08243566371888811 area_sum=0.0829475211134128, Error= -0.006209174178182975\n", "area_pixel=0.05072162137920344 area_sum=0.060175244255315306, Error= -0.18638250550854787\n", "area_pixel=0.05147481897381212 area_sum=0.060582440472418876, Error= -0.17693353138823606\n", "area_pixel=0.07995593516658417 area_sum=0.08078232411070743, Error= -0.010335554732760278\n", "area_pixel=0.07870547782261994 area_sum=0.07967188659348057, Error= -0.012278799361826395\n", "area_pixel=0.05682851643920728 area_sum=0.06386061246732938, Error= -0.12374238267586556\n", "area_pixel=0.0400252869217077 area_sum=0.05503561919587382, Error= -0.3750212285430305\n", "area_pixel=0.06340122634469303 area_sum=0.06793436007101032, Error= -0.07149914895450184\n", "area_pixel=0.07356612496032433 area_sum=0.07505451304442162, Error= -0.020231976128958933\n", "area_pixel=0.08519548136319521 area_sum=0.08544563508127642, Error= -0.0029362322282655237\n", "area_pixel=0.053160030339890696 area_sum=0.06157431522706344, Error= -0.1582821686401251\n", "area_pixel=0.045930287163253425 area_sum=0.057201385537067204, Error= -0.2453957741163707\n", "area_pixel=0.06732209973204561 area_sum=0.07040744500060567, Error= -0.045829605446655645\n", "area_pixel=0.07017129920940413 area_sum=0.0721841810894871, Error= -0.02868525882748959\n", "area_pixel=0.048616431082022515 area_sum=0.058747282374172344, Error= -0.2083832783829341\n", "area_pixel=0.05084741072757204 area_sum=0.06014651274983808, Error= -0.1828825084543311\n", "area_pixel=0.08582264210207136 area_sum=0.08598966627233767, Error= -0.0019461550725468225\n", "area_pixel=0.07293769354366653 area_sum=0.07452580505574181, Error= -0.021773536218615323\n", "area_pixel=0.06333498912628421 area_sum=0.06785807669315522, Error= -0.07141530501966896\n", "area_pixel=0.03963769199827816 area_sum=0.054891531459535764, Error= -0.3848316764235472\n", "area_pixel=0.06112439445008455 area_sum=0.0664864916591485, Error= -0.08772434078578469\n", "area_pixel=0.07314430360340829 area_sum=0.07481382789893049, Error= -0.022825076093067092\n", "area_pixel=0.0854466193934389 area_sum=0.08560825287900438, Error= -0.0018916311343020336\n", "area_pixel=0.04673599374915405 area_sum=0.057774642096181, Error= -0.23619158300719262\n", "area_pixel=0.05583010601315941 area_sum=0.06324832936851839, Error= -0.13287138221823314\n", "area_pixel=0.07322943409217153 area_sum=0.07499526481604342, Error= -0.02411367431365501\n", "area_pixel=0.0852345027976682 area_sum=0.08533894045176349, Error= -0.0012252978625710697\n", "area_pixel=0.04599237073951734 area_sum=0.05746828088313036, Error= -0.24951769084938125\n", "area_pixel=0.06070260492291091 area_sum=0.061073736040080526, Error= -0.006113924067030317\n", "area_pixel=0.044319725410217004 area_sum=0.047768636124481664, Error= -0.07781886467801953\n", "area_pixel=0.044174329257337774 area_sum=0.047917627993498656, Error= -0.0847392320176335\n", "area_pixel=0.05696363265076698 area_sum=0.05803312066746481, Error= -0.018774926508894813\n", "area_pixel=0.058320415107782964 area_sum=0.059174815319163986, Error= -0.014650105109882882\n", "area_pixel=0.042924164383912 area_sum=0.04741622416589007, Error= -0.10465107117290089\n", "area_pixel=0.06337332199284873 area_sum=0.06344873015210023, Error= -0.0011899038409255117\n", "area_pixel=0.052121672519851 area_sum=0.05393823010119017, Error= -0.03485225038869034\n", "area_pixel=0.0479534333591225 area_sum=0.05044117779204517, Error= -0.05187833818471332\n", "area_pixel=0.04600451074681722 area_sum=0.048891635204346216, Error= -0.06275742118893726\n", "area_pixel=0.05666618800179535 area_sum=0.057795805715150514, Error= -0.01993459862377502\n", "area_pixel=0.053340349058393244 area_sum=0.055062805328933664, Error= -0.03229180725185726\n", "area_pixel=0.04918182529843129 area_sum=0.05170780411764328, Error= -0.051360005528151\n", "area_pixel=0.0542987243748243 area_sum=0.05587411994858145, Error= -0.029013491419838604\n", "area_pixel=0.048922568471164496 area_sum=0.05165291259833061, Error= -0.05580950086002555\n", "area_pixel=0.041726822421832566 area_sum=0.042106909997024614, Error= -0.00910895086497591\n", "area_pixel=0.039582151362063556 area_sum=0.04069836796135787, Error= -0.02819999825386246\n", "area_pixel=0.05048661327088855 area_sum=0.051104638944560715, Error= -0.012241377142018202\n", "area_pixel=0.05462653755615676 area_sum=0.054859630660605146, Error= -0.004267030547355515\n", "area_pixel=0.052955102565457324 area_sum=0.053292036127629394, Error= -0.006362626939596422\n", "area_pixel=0.05776491656818106 area_sum=0.05779778818874337, Error= -0.0005690585655657377\n", "area_pixel=0.04640522109095535 area_sum=0.0470074553630645, Error= -0.012977726599529699\n", "area_pixel=0.04660652023051526 area_sum=0.04708417266487089, Error= -0.010248618261847633\n", "area_pixel=0.055970272141323996 area_sum=0.05607648098314985, Error= -0.0018975938076141565\n", "area_pixel=0.04137995412261919 area_sum=0.04379345464441353, Error= -0.058325355186294676\n", "area_pixel=0.04876562355702152 area_sum=0.04919111397280354, Error= -0.008725212244738255\n", "area_pixel=0.052309101601506036 area_sum=0.05260266489758367, Error= -0.005612088280812288\n", "area_pixel=0.043221450987522836 area_sum=0.044503584967261894, Error= -0.029664297482960136\n", "area_pixel=0.042611371967804956 area_sum=0.04391185184599117, Error= -0.030519549550500034\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/mntdirect/_scisoft/users/kieffer/.jupy37/lib/python3.7/site-packages/ipykernel_launcher.py:22: RuntimeWarning: invalid value encountered in true_divide\n" ] } ], "source": [ "fig, ax = plt.subplots()\n", "summed, counted, radial = None, None, None\n", "\n", "for i in range(9):\n", " name = ds_names[i]\n", " ds = data[name]\n", " gonioref = goniometers[name]\n", " mg = gonioref.get_mg(position)\n", " mg.radial_range = (0, 95)\n", " images = [i.reshape(-1, 1) for i in ds]\n", " res_mg = mg.integrate1d(images, 50000)\n", " results[name] = res_mg \n", " if summed is None:\n", " summed = res_mg.sum\n", " counted = res_mg.count\n", " else:\n", " summed += res_mg.sum\n", " counted += res_mg.count\n", " radial = res_mg.radial\n", " jupyter.plot1d(res_mg, label=\"%i %s\"%(i, name), calibrant=LaB6, ax=ax )\n", " \n", "ax.plot(radial, summed/counted, label=\"Merged\")\n", "ax.legend()\n", "fig.show() " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Multi-Gonio fit\n", "\n", "Can we fit everything togeather ?\n", "Just assume energy and scale parameter of the goniometer are the same for all modules and fit everything." ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [], "source": [ "from scipy.optimize import minimize\n", "class MultiGoniometer:\n", " def __init__(self, list_of_goniometers,\n", " param_name_split,\n", " param_name_common):\n", " self.nb_gonio = len(list_of_goniometers)\n", " self.goniometers = list_of_goniometers\n", " self.names_split = param_name_split\n", " self.names_common = param_name_common\n", " self.param = None\n", " \n", " def init_param(self):\n", " param = []\n", " for gonio in self.goniometers:\n", " param += list(gonio.param[:len(self.names_split)])\n", " param += list(gonio.param[len(self.names_split):])\n", " self.param = numpy.array(param)\n", " \n", " def residu2(self, param):\n", " \"Actually performs the calulation of the average of the error squared\"\n", " sumsquare = 0.0\n", " npt = 0\n", " for idx, gonio in enumerate(self.goniometers):\n", " gonio_param = numpy.concatenate((param[len(self.names_split)*idx:len(self.names_split)*(1+idx)],\n", " param[len(self.names_split)*len(self.goniometers):]))\n", " sumsquare += gonio.residu2(gonio_param)\n", " return sumsquare\n", "\n", " def chi2(self, param=None):\n", " \"\"\"Calculate the average of the square of the error for a given parameter set\n", " \"\"\"\n", " if param is not None:\n", " return self.residu2(param)\n", " else:\n", " if self.param is None:\n", " self.init_param()\n", " return self.residu2(self.param)\n", " def refine2(self, method=\"slsqp\", **options):\n", " \"\"\"Geometry refinement tool\n", "\n", " See https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.minimize.html\n", "\n", " :param method: name of the minimizer\n", " :param options: options for the minimizer\n", " \"\"\"\n", " if method.lower() in [\"simplex\", \"nelder-mead\"]:\n", " method = \"Nelder-Mead\"\n", "\n", " former_error = self.chi2()\n", " print(\"Cost function before refinement: %s\" % former_error)\n", " param = numpy.asarray(self.param, dtype=numpy.float64)\n", " print(param)\n", " res = minimize(self.residu2, param, method=method,\n", " tol=1e-12,\n", " options=options)\n", " print(res)\n", " newparam = res.x\n", " new_error = res.fun\n", " print(\"Cost function after refinement: %s\" % new_error)\n", "\n", " if new_error < former_error:\n", " self.param = newparam\n", " return self.param\n", " \n", " def integrate(self, list_of_dataset, npt=50000, radial_range=(0,100)):\n", " summed = None\n", " counted = None\n", " param = self.param\n", " for idx, ds in enumerate(list_of_dataset):\n", " gonio = self.goniometers[idx]\n", " gonio_param = numpy.concatenate((param[len(self.names_split)*idx:len(self.names_split)*(1+idx)],\n", " param[len(self.names_split)*len(self.goniometers):]))\n", " print(gonio_param)\n", " gonio.param = gonio_param\n", " mg = gonio.get_mg(position)\n", " mg.radial_range = radial_range\n", " images = [i.reshape(-1, 1) for i in ds]\n", " res_mg = mg.integrate1d(images, 50000)\n", " if summed is None:\n", " summed = res_mg.sum\n", " counted = res_mg.count\n", " else:\n", " summed += res_mg.sum\n", " counted += res_mg.count\n", " radial = res_mg.radial\n", " res = Integrate1dResult(radial, summed/numpy.maximum(counted, 1e-10))\n", " res._set_unit(res_mg.unit)\n", " res._set_count(counted)\n", " res._set_sum(summed)\n", " return res" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [], "source": [ "multigonio = MultiGoniometer([goniometers[ds_names[i]] for i in range(9)],\n", " [\"dist\", \"poni1\", \"poni2\", \"rot1\", \"offset\"], \n", " [\"scale\", \"nrj\"])\n" ] }, { "cell_type": "code", "execution_count": 64, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "8.603112017040267e-09\n", "CPU times: user 10.1 s, sys: 382 ms, total: 10.5 s\n", "Wall time: 663 ms\n", "6.1395983620232986e-09\n", "CPU times: user 9.9 s, sys: 392 ms, total: 10.3 s\n", "Wall time: 651 ms\n" ] } ], "source": [ "%time print(multigonio.chi2())\n", "multigonio.param = numpy.array([ 7.20594053e-01, 3.22408604e-02, 4.05228023e-03, -2.75578440e-05,\n", " -8.27999414e+01, 7.20612302e-01, 3.36369797e-02, 4.02094516e-03,\n", " -1.74996556e-05, -7.71999791e+01, 7.20636130e-01, 3.47920978e-02,\n", " 4.01341931e-03, -1.21330600e-05, -7.15999090e+01, 7.20757808e-01,\n", " 3.33850817e-02, 3.95036100e-03, 3.46517345e-05, -6.57999267e+01,\n", " 7.20813915e-01, 3.22167822e-02, 3.97128822e-03, 2.00055269e-05,\n", " -6.00000525e+01, 7.20881596e-01, 3.33801850e-02, 3.97760147e-03,\n", " 1.47074593e-05, -5.43998157e+01, 7.21048510e-01, 3.22346939e-02,\n", " 4.02104962e-03, -1.69519259e-05, -4.85998856e+01, 7.21074630e-01,\n", " 3.08484557e-02, 4.09385968e-03, -6.91378973e-05, -4.27999030e+01,\n", " 7.21154891e-01, 3.20619921e-02, 4.24950906e-03, -1.81328256e-04,\n", " -3.71999987e+01, 9.99038595e-01, 1.70266104e+01])\n", "%time print(multigonio.chi2())\n" ] }, { "cell_type": "code", "execution_count": 65, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Cost function before refinement: 6.1395983620232986e-09\n", "[ 7.20594053e-01 3.22408604e-02 4.05228023e-03 -2.75578440e-05\n", " -8.27999414e+01 7.20612302e-01 3.36369797e-02 4.02094516e-03\n", " -1.74996556e-05 -7.71999791e+01 7.20636130e-01 3.47920978e-02\n", " 4.01341931e-03 -1.21330600e-05 -7.15999090e+01 7.20757808e-01\n", " 3.33850817e-02 3.95036100e-03 3.46517345e-05 -6.57999267e+01\n", " 7.20813915e-01 3.22167822e-02 3.97128822e-03 2.00055269e-05\n", " -6.00000525e+01 7.20881596e-01 3.33801850e-02 3.97760147e-03\n", " 1.47074593e-05 -5.43998157e+01 7.21048510e-01 3.22346939e-02\n", " 4.02104962e-03 -1.69519259e-05 -4.85998856e+01 7.21074630e-01\n", " 3.08484557e-02 4.09385968e-03 -6.91378973e-05 -4.27999030e+01\n", " 7.21154891e-01 3.20619921e-02 4.24950906e-03 -1.81328256e-04\n", " -3.71999987e+01 9.99038595e-01 1.70266104e+01]\n", " fun: 6.1395983620232986e-09\n", " jac: array([ 5.90883473e-08, -1.08561671e-07, -2.52646911e-08, 1.79747064e-08,\n", " -1.72926662e-09, 1.79298213e-08, 9.69570013e-09, 4.03865801e-08,\n", " -2.91714863e-08, -1.94683714e-10, 2.72323741e-08, -6.07769467e-08,\n", " 2.33525472e-08, -1.69337616e-08, -1.17130239e-09, 2.09023376e-07,\n", " -5.80926751e-09, 1.58839289e-08, -1.22906173e-08, -4.71553241e-10,\n", " 1.47614749e-07, -1.33281402e-07, -1.82833877e-08, 1.25890469e-08,\n", " -2.00339789e-09, 2.45125083e-07, -6.85051675e-08, -3.08888884e-08,\n", " 2.12864152e-08, -1.23765842e-09, 2.99788196e-07, -2.02647332e-08,\n", " -7.85245061e-08, 5.54326079e-08, -5.67168867e-10, 2.54716680e-07,\n", " 1.39967174e-07, -1.44580129e-07, 1.03263413e-07, 1.46673401e-09,\n", " 1.30733052e-08, 8.84376917e-08, -1.94036564e-07, 1.39886310e-07,\n", " 7.47406914e-10, -3.89892417e-08, 6.53007231e-07])\n", " message: 'Optimization terminated successfully.'\n", " nfev: 49\n", " nit: 1\n", " njev: 1\n", " status: 0\n", " success: True\n", " x: array([ 7.20594053e-01, 3.22408604e-02, 4.05228023e-03, -2.75578440e-05,\n", " -8.27999414e+01, 7.20612302e-01, 3.36369797e-02, 4.02094516e-03,\n", " -1.74996556e-05, -7.71999791e+01, 7.20636130e-01, 3.47920978e-02,\n", " 4.01341931e-03, -1.21330600e-05, -7.15999090e+01, 7.20757808e-01,\n", " 3.33850817e-02, 3.95036100e-03, 3.46517345e-05, -6.57999267e+01,\n", " 7.20813915e-01, 3.22167822e-02, 3.97128822e-03, 2.00055269e-05,\n", " -6.00000525e+01, 7.20881596e-01, 3.33801850e-02, 3.97760147e-03,\n", " 1.47074593e-05, -5.43998157e+01, 7.21048510e-01, 3.22346939e-02,\n", " 4.02104962e-03, -1.69519259e-05, -4.85998856e+01, 7.21074630e-01,\n", " 3.08484557e-02, 4.09385968e-03, -6.91378973e-05, -4.27999030e+01,\n", " 7.21154891e-01, 3.20619921e-02, 4.24950906e-03, -1.81328256e-04,\n", " -3.71999987e+01, 9.99038595e-01, 1.70266104e+01])\n", "Cost function after refinement: 6.1395983620232986e-09\n", "CPU times: user 7min 48s, sys: 17.8 s, total: 8min 6s\n", "Wall time: 30.6 s\n" ] }, { "data": { "text/plain": [ "array([ 7.20594053e-01, 3.22408604e-02, 4.05228023e-03, -2.75578440e-05,\n", " -8.27999414e+01, 7.20612302e-01, 3.36369797e-02, 4.02094516e-03,\n", " -1.74996556e-05, -7.71999791e+01, 7.20636130e-01, 3.47920978e-02,\n", " 4.01341931e-03, -1.21330600e-05, -7.15999090e+01, 7.20757808e-01,\n", " 3.33850817e-02, 3.95036100e-03, 3.46517345e-05, -6.57999267e+01,\n", " 7.20813915e-01, 3.22167822e-02, 3.97128822e-03, 2.00055269e-05,\n", " -6.00000525e+01, 7.20881596e-01, 3.33801850e-02, 3.97760147e-03,\n", " 1.47074593e-05, -5.43998157e+01, 7.21048510e-01, 3.22346939e-02,\n", " 4.02104962e-03, -1.69519259e-05, -4.85998856e+01, 7.21074630e-01,\n", " 3.08484557e-02, 4.09385968e-03, -6.91378973e-05, -4.27999030e+01,\n", " 7.21154891e-01, 3.20619921e-02, 4.24950906e-03, -1.81328256e-04,\n", " -3.71999987e+01, 9.99038595e-01, 1.70266104e+01])" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%time multigonio.refine2()" ] }, { "cell_type": "code", "execution_count": 66, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "LaB6 Calibrant with 109 reflections at wavelength 7.281789761742598e-11 \n", " LaB6 Calibrant with 109 reflections at wavelength 7.281789768115395e-11\n" ] } ], "source": [ "LaB6_new = get_calibrant(\"LaB6\")\n", "LaB6_new.wavelength = 1e-10*hc/multigonio.param[-1]\n", "print(LaB6,\"\\n\", LaB6_new)" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 7.20594053e-01 3.22408604e-02 4.05228023e-03 -2.75578440e-05\n", " -8.27999414e+01 9.99038595e-01 1.70266104e+01]\n", "area_pixel=0.053413862261281864 area_sum=0.055214882933248166, Error= -0.033718225863472326\n", "area_pixel=0.045333067243413794 area_sum=0.04986384765291535, Error= -0.09994427213966664\n", "area_pixel=0.03918749031126367 area_sum=0.04563241935519968, Error= -0.16446393970995232\n", "area_pixel=0.04641997394066166 area_sum=0.05056017758649528, Error= -0.0891901329183427\n", "area_pixel=0.04963019502342725 area_sum=0.052784706110374724, Error= -0.06356032019335069\n", "area_pixel=0.041808779534353135 area_sum=0.04729034242949584, Error= -0.13111033032281305\n", "area_pixel=0.053529818242976646 area_sum=0.05553764984245543, Error= -0.03750865714441734\n", "area_pixel=0.05746249488342414 area_sum=0.05828939512131753, Error= -0.014390259935127214\n", "area_pixel=0.03804626259786659 area_sum=0.04468957516491201, Error= -0.17461143653615904\n", "area_pixel=0.0579645518625469 area_sum=0.05860457337617547, Error= -0.011041602031984604\n", "area_pixel=0.0514530597536762 area_sum=0.05403218600224738, Error= -0.05012580905622247\n", "area_pixel=0.04708587038231293 area_sum=0.05104328125237842, Error= -0.08404667552990643\n", "area_pixel=0.0414210821500145 area_sum=0.04727614277194664, Error= -0.1413546029707022\n", "area_pixel=0.057188034039880264 area_sum=0.05760891916847055, Error= -0.0073596712259208176\n", "[ 7.20612302e-01 3.36369797e-02 4.02094516e-03 -1.74996556e-05\n", " -7.71999791e+01 9.99038595e-01 1.70266104e+01]\n", "[ 7.20636130e-01 3.47920978e-02 4.01341931e-03 -1.21330600e-05\n", " -7.15999090e+01 9.99038595e-01 1.70266104e+01]\n", "[ 7.20757808e-01 3.33850817e-02 3.95036100e-03 3.46517345e-05\n", " -6.57999267e+01 9.99038595e-01 1.70266104e+01]\n", "area_pixel=0.06406776393820302 area_sum=0.06431614060731783, Error= -0.003876780674824036\n", "area_pixel=0.036519974544861 area_sum=0.045063743745274665, Error= -0.23394784106211602\n", "area_pixel=0.06022365655235262 area_sum=0.06045501049825683, Error= -0.0038415791924405825\n", "area_pixel=0.06470520384919531 area_sum=0.06480584410676266, Error= -0.0015553657446454841\n", "area_pixel=0.042761484590993604 area_sum=0.04894851144272455, Error= -0.14468690483758498\n", "area_pixel=0.05556804666999149 area_sum=0.0572738285392099, Error= -0.030697171692011003\n", "area_pixel=0.05157759645584292 area_sum=0.054703089692101546, Error= -0.06059788456669262\n", "area_pixel=0.04628344743831292 area_sum=0.051193164385785, Error= -0.1060793268266329\n", "area_pixel=0.04441767384784612 area_sum=0.04995426406033848, Error= -0.12464836027789516\n", "area_pixel=0.05377034832596905 area_sum=0.05619131504982555, Error= -0.04502419640616803\n", "area_pixel=0.05745532746690074 area_sum=0.0586344668434077, Error= -0.020522716143011228\n", "area_pixel=0.04107664840957703 area_sum=0.047752702889470366, Error= -0.16252675761970906\n", "area_pixel=0.05946818134114551 area_sum=0.05993335889343876, Error= -0.00782229322979813\n", "area_pixel=0.07058082407797173 area_sum=0.07058105681613237, Error= -3.2974701512325326e-06\n", "area_pixel=0.046987941054872806 area_sum=0.05167050922411581, Error= -0.09965467871372943\n", "area_pixel=0.051123579128637076 area_sum=0.05437612755835594, Error= -0.063621297357425\n", "area_pixel=0.05248017980128061 area_sum=0.055180053859511885, Error= -0.05144559466934963\n", "area_pixel=0.047912061925078575 area_sum=0.05226569446005236, Error= -0.09086715035937463\n", "area_pixel=0.04572012763952671 area_sum=0.05084193350468269, Error= -0.11202518736470006\n", "[ 7.20813915e-01 3.22167822e-02 3.97128822e-03 2.00055269e-05\n", " -6.00000525e+01 9.99038595e-01 1.70266104e+01]\n", "[ 7.20881596e-01 3.33801850e-02 3.97760147e-03 1.47074593e-05\n", " -5.43998157e+01 9.99038595e-01 1.70266104e+01]\n", "[ 7.21048510e-01 3.22346939e-02 4.02104962e-03 -1.69519259e-05\n", " -4.85998856e+01 9.99038595e-01 1.70266104e+01]\n", "[ 7.21074630e-01 3.08484557e-02 4.09385968e-03 -6.91378973e-05\n", " -4.27999030e+01 9.99038595e-01 1.70266104e+01]\n", "area_pixel=0.0991017473223863 area_sum=0.10463027384689139, Error= -0.05578636778744499\n", "area_pixel=0.07069194828200054 area_sum=0.08784192624601114, Error= -0.24260157458946852\n", "area_pixel=0.07363944575302739 area_sum=0.08917599048958212, Error= -0.21098128289369983\n", "area_pixel=0.11866235123215318 area_sum=0.12004419996868715, Error= -0.011645216213780306\n", "area_pixel=0.042113113396123225 area_sum=0.07678977886848182, Error= -0.8234172844497124\n", "area_pixel=0.10206300321222628 area_sum=0.10662320384564644, Error= -0.044680251314355705\n", "area_pixel=0.09032959255696227 area_sum=0.09890206075850298, Error= -0.09490210194554875\n", "area_pixel=0.05405730719101953 area_sum=0.0803776405557316, Error= -0.4868968643167011\n", "area_pixel=0.06486418102965885 area_sum=0.08504369583806178, Error= -0.3111041330989122\n", "area_pixel=0.07961206312065627 area_sum=0.09217586427332167, Error= -0.15781278188487957\n", "area_pixel=0.11567416847953638 area_sum=0.11751408489279526, Error= -0.015906026707979987\n", "area_pixel=0.03899188493468486 area_sum=0.07583816249914746, Error= -0.9449729764586564\n", "area_pixel=0.10530031424726971 area_sum=0.10890885634782618, Error= -0.03426905348148129\n", "area_pixel=0.08974770209027838 area_sum=0.09849411368900213, Error= -0.09745554922315022\n", "area_pixel=0.05474040940657332 area_sum=0.08072049604999723, Error= -0.47460526738961833\n", "area_pixel=0.06644918714957981 area_sum=0.08579443366184009, Error= -0.29112841468945794\n", "area_pixel=0.07815101996878226 area_sum=0.09155079246491357, Error= -0.17145998224314793\n", "area_pixel=0.11811873530334793 area_sum=0.11959505854816217, Error= -0.012498637417872821\n", "area_pixel=0.0413972494959971 area_sum=0.07656418842293432, Error= -0.8494994076922351\n", "area_pixel=0.10302869305435536 area_sum=0.10744525208257137, Error= -0.04286727218684554\n", "area_pixel=0.09483751702327226 area_sum=0.10192184423145179, Error= -0.07469962764251938\n", "area_pixel=0.04968735428679949 area_sum=0.07918713886310795, Error= -0.5937080973567899\n", "area_pixel=0.12624685135862634 area_sum=0.12658534425443493, Error= -0.002681198716370686\n", "area_pixel=0.07292481749928825 area_sum=0.08901112957273391, Error= -0.22058762195191864\n", "area_pixel=0.07174377634256857 area_sum=0.08841385728354262, Error= -0.23235577761304713\n", "area_pixel=0.12450135731947398 area_sum=0.1250951579271622, Error= -0.004769430795557527\n", "area_pixel=0.04788770278107535 area_sum=0.07864101722504067, Error= -0.6421964859028207\n", "area_pixel=0.09665547391303164 area_sum=0.10315078444549604, Error= -0.0672006485458726\n", "area_pixel=0.10207284410790507 area_sum=0.10684959089949136, Error= -0.04679743014250308\n", "area_pixel=0.042451700156050265 area_sum=0.0768864287184544, Error= -0.8111507533461285\n", "area_pixel=0.11913084304184807 area_sum=0.12046110661371978, Error= -0.011166407774050775\n", "area_pixel=0.08064791594041765 area_sum=0.09288655545895187, Error= -0.1517539464699383\n", "area_pixel=0.06402646673778989 area_sum=0.08456843952285309, Error= -0.32083564550250054\n", "area_pixel=0.05908485149852538 area_sum=0.082224048127862, Error= -0.3916265513490226\n", "area_pixel=0.08552527294591528 area_sum=0.09559064428749622, Error= -0.11768885377245293\n", "area_pixel=0.1130597812463634 area_sum=0.1152323204339288, Error= -0.019215844605530538\n", "area_pixel=0.03630453556874613 area_sum=0.07491578714204401, Error= -1.0635379565780083\n", "area_pixel=0.10811519768928335 area_sum=0.11098173966156559, Error= -0.026513774506711926\n", "area_pixel=0.09033065463596301 area_sum=0.09884960024462953, Error= -0.09430846751856599\n", "area_pixel=0.054267862709590275 area_sum=0.08066441123732206, Error= -0.486412163843463\n", "area_pixel=0.0660267344673997 area_sum=0.08556065653189811, Error= -0.295848677389053\n", "area_pixel=0.07857345851699904 area_sum=0.09182668967701964, Error= -0.16867312970770298\n", "area_pixel=0.12006247452697849 area_sum=0.1212559689588405, Error= -0.009940611640432457\n", "area_pixel=0.043405378913874415 area_sum=0.07716694788085048, Error= -0.7778199341138401\n", "area_pixel=0.10101357172294456 area_sum=0.10609344882377486, Error= -0.0502890553634036\n", "area_pixel=0.09613856114754782 area_sum=0.10276910367737876, Error= -0.06896860584021826\n", "area_pixel=0.0483056484857336 area_sum=0.0787464207027933, Error= -0.6301700354162506\n", "area_pixel=0.12487824294881023 area_sum=0.1253883621026603, Error= -0.004084932185178019\n", "area_pixel=0.07046401268653213 area_sum=0.08773584962849086, Error= -0.2451157162847741\n", "area_pixel=0.07408554985093474 area_sum=0.08955623311268268, Error= -0.20882187272519442\n", "area_pixel=0.12263118597297762 area_sum=0.12342299996291214, Error= -0.006456872969564248\n", "area_pixel=0.04610184051389865 area_sum=0.077977834716309, Error= -0.6914256317554276\n", "area_pixel=0.09827120932201439 area_sum=0.10420386190981694, Error= -0.06037020027261983\n", "area_pixel=0.09671215194481775 area_sum=0.10311234681820346, Error= -0.06617777336851678\n", "area_pixel=0.04760569306460383 area_sum=0.07848600072570878, Error= -0.648668377103522\n", "area_pixel=0.12413022185356226 area_sum=0.12469829377225909, Error= -0.004576419104180694\n", "area_pixel=0.06980256509773852 area_sum=0.08738524192866963, Error= -0.25189155737058655\n", "area_pixel=0.0746069729825436 area_sum=0.08975411958430458, Error= -0.20302588345602884\n", "area_pixel=0.11830304345944853 area_sum=0.11971177541148283, Error= -0.011907825114551468\n", "area_pixel=0.04176754779718905 area_sum=0.07662006234205823, Error= -0.8344400469499132\n", "area_pixel=0.10237967149596372 area_sum=0.10685275736700003, Error= -0.04369115280090212\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "[ 7.21154891e-01 3.20619921e-02 4.24950906e-03 -1.81328256e-04\n", " -3.71999987e+01 9.99038595e-01 1.70266104e+01]\n", "area_pixel=0.3162483597934198 area_sum=0.3174253016954389, Error= -0.003721574723068656\n", "area_pixel=0.24311057254745805 area_sum=0.2600497496702889, Error= -0.0696768427030219\n", "area_pixel=0.16860365236765773 area_sum=0.21967653369346593, Error= -0.3029168147226045\n", "area_pixel=0.09285566528839695 area_sum=0.19579635166280646, Error= -1.108609647614821\n", "area_pixel=0.01576774945500148 area_sum=0.18814793828945114, Error= -10.932453570903947\n", "area_pixel=0.06752863879084003 area_sum=0.19124575955043382, Error= -1.8320689262342347\n", "area_pixel=0.14373310781029858 area_sum=0.20978466196882295, Error= -0.4595430737203592\n", "area_pixel=0.2186034780352415 area_sum=0.24470325423963207, Error= -0.11939323399137768\n", "area_pixel=0.29216108377022465 area_sum=0.2964675523040342, Error= -0.014740048463115846\n", "area_pixel=0.2878799981328086 area_sum=0.29298295310643363, Error= -0.01772597959817564\n", "area_pixel=0.2141720790742454 area_sum=0.24241780051917625, Error= -0.13188330414973987\n", "area_pixel=0.13916339910938547 area_sum=0.20843974100945917, Error= -0.4978057617407073\n", "area_pixel=0.0628024143954562 area_sum=0.1908539162651179, Error= -2.0389582646193034\n", "area_pixel=0.02057417287076646 area_sum=0.18799678892623883, Error= -8.137513819248632\n", "area_pixel=0.09756650515308962 area_sum=0.1966136235495598, Error= -1.0151754256346208\n", "area_pixel=0.17331785333976057 area_sum=0.22152013322326974, Error= -0.2781149140418713\n", "area_pixel=0.24768782015379998 area_sum=0.26307840899106155, Error= -0.062137043427104736\n", "area_pixel=0.32077011484482654 area_sum=0.32158395824315333, Error= -0.002537154680761005\n", "area_pixel=0.3351439885154548 area_sum=0.33514501546596653, Error= -3.064206869080088e-06\n", "area_pixel=0.2622778760051361 area_sum=0.2734626246584369, Error= -0.04264465163307102\n", "area_pixel=0.18810753539353442 area_sum=0.22869440854779, Error= -0.21576420673071356\n", "area_pixel=0.112597089661854 area_sum=0.2004521249652375, Error= -0.780260267536447\n", "area_pixel=0.03576657783084869 area_sum=0.18854905950201395, Error= -4.271655018093185\n", "area_pixel=0.04773197420838926 area_sum=0.18923075728158525, Error= -2.964444388062342\n", "area_pixel=0.12433631227782627 area_sum=0.20352544620810403, Error= -0.6368946647969718\n", "area_pixel=0.1996043725727077 area_sum=0.23418135417408037, Error= -0.1732275759078259\n", "area_pixel=0.27356688770897364 area_sum=0.2817900736563061, Error= -0.030059142084770358\n", "area_pixel=0.30870886862268065 area_sum=0.31065734495751024, Error= -0.006311695363734788\n", "area_pixel=0.23532601277882037 area_sum=0.2552151726304691, Error= -0.08451747266181867\n", "area_pixel=0.1606497150495585 area_sum=0.21645063902789305, Error= -0.3473453031716903\n", "area_pixel=0.08461056606855522 area_sum=0.1941600618585331, Error= -1.2947495907451565\n", "area_pixel=0.007332538774193154 area_sum=0.1882600255178571, Error= -24.674603478462007\n", "area_pixel=0.07599244125652405 area_sum=0.19260768104550913, Error= -1.534563673186029\n", "area_pixel=0.15213168229737306 area_sum=0.21286801714864104, Error= -0.39923528047593765\n", "area_pixel=0.22694519825502368 area_sum=0.24981889990694206, Error= -0.1007895378610948\n", "area_pixel=0.30045187561808007 area_sum=0.30355525113576626, Error= -0.010329026940843773\n", "area_pixel=0.28385714726268674 area_sum=0.2899091102978157, Error= -0.021320453240264367\n", "area_pixel=0.2100425868147937 area_sum=0.24016681336221424, Error= -0.14341961315674875\n", "area_pixel=0.1348303695541304 area_sum=0.20700277247283105, Error= -0.5352829867437658\n", "area_pixel=0.0583768113827432 area_sum=0.19030045072148266, Error= -2.2598637406519515\n", "area_pixel=0.02517023462095125 area_sum=0.1882066162598655, Error= -6.477348506843306\n", "area_pixel=0.10217425061892982 area_sum=0.19774440981658253, Error= -0.9353644251729548\n", "area_pixel=0.17791520734201782 area_sum=0.22364028455116752, Error= -0.2570048839121967\n", "area_pixel=0.25227715387468663 area_sum=0.26636300595097906, Error= -0.05583483030448836\n", "area_pixel=0.32534669913203373 area_sum=0.32585733184571547, Error= -0.0015695032869367097\n", "area_pixel=0.3325208268647728 area_sum=0.332574505940386, Error= -0.00016143071734583676\n", "area_pixel=0.25955692012336584 area_sum=0.2715951569509286, Error= -0.046379949422427555\n", "area_pixel=0.1852598537926653 area_sum=0.22735970352347062, Error= -0.22724755994853388\n", "area_pixel=0.10962093428884856 area_sum=0.1996581937297021, Error= -0.8213509584182843\n", "area_pixel=0.03270177267216923 area_sum=0.18846476744745183, Error= -4.7631361252732445\n", "area_pixel=0.050905655057214005 area_sum=0.18960967509690219, Error= -2.72472714247161\n", "area_pixel=0.12750526999172962 area_sum=0.2045753610924949, Error= -0.6044463190091225\n", "area_pixel=0.20284220619853954 area_sum=0.23605078743082697, Error= -0.16371632834531125\n", "area_pixel=0.2767808299573389 area_sum=0.2843384019164127, Error= -0.027305257955323996\n", "area_pixel=0.3091107047459474 area_sum=0.311041079994932, Error= -0.0062449317326981335\n", "area_pixel=0.23571594882840685 area_sum=0.25550239591555235, Error= -0.08394191053041283\n", "area_pixel=0.16096577478506902 area_sum=0.2166355213576317, Error= -0.34584834351834237\n", "area_pixel=0.08487537174418236 area_sum=0.1942563498502238, Error= -1.2887245835661247\n", "area_pixel=0.007541255126128021 area_sum=0.1883390724048897, Error= -23.974499503717286\n", "area_pixel=0.07587563674286457 area_sum=0.1927295874102262, Error= -1.5400720927505192\n", "area_pixel=0.15205655202905177 area_sum=0.21297699584831323, Error= -0.40064333306480643\n", "area_pixel=0.22698276515797033 area_sum=0.24989298302707477, Error= -0.1009337332425213\n", "area_pixel=0.3005084896190553 area_sum=0.3036349158753642, Error= -0.01040378679574792\n", "area_pixel=0.28301025224994447 area_sum=0.28927039620193623, Error= -0.02211984867058111\n", "area_pixel=0.20910608233180739 area_sum=0.2396737877741661, Error= -0.14618276571149272\n", "area_pixel=0.1338366984023267 area_sum=0.20668548113632879, Error= -0.5443109670488975\n", "area_pixel=0.05732856593776603 area_sum=0.19028903236880437, Error= -2.319270755444603\n", "area_pixel=0.02633581865649859 area_sum=0.18833998696365073, Error= -6.151476451907305\n", "area_pixel=0.10334170301746326 area_sum=0.19810608231739957, Error= -0.9170003641600767\n", "area_pixel=0.17911164193798612 area_sum=0.2242924149012735, Error= -0.2522492255357155\n", "area_pixel=0.2535589826204898 area_sum=0.26731587383154576, Error= -0.05425519170680039\n", "area_pixel=0.3266280719613661 area_sum=0.32707163550693535, Error= -0.0013580080331298092\n", "area_pixel=0.2633131348180413 area_sum=0.27429164136797396, Error= -0.04169372924567242\n", "area_pixel=0.18902017801996607 area_sum=0.22923213673949794, Error= -0.2127389739061843\n", "area_pixel=0.11342920572148785 area_sum=0.20075891426654055, Error= -0.7699049639779775\n", "area_pixel=0.03652948116938859 area_sum=0.18868389615681366, Error= -4.165249823338012\n", "area_pixel=0.04716666270215342 area_sum=0.18943842789912257, Error= -3.0163627665451442\n", "area_pixel=0.12387038478473755 area_sum=0.2036488774743464, Error= -0.6440481542722922\n", "area_pixel=0.19928650128962033 area_sum=0.23423648635203115, Error= -0.17537557655055866\n", "area_pixel=0.2733680167453443 area_sum=0.28170080809666015, Error= -0.030481954145639048\n", "area_pixel=0.3151046330341387 area_sum=0.31633237117646545, Error= -0.003896287180879773\n", "area_pixel=0.24177139290826233 area_sum=0.25938686981480646, Error= -0.07286005467664303\n", "area_pixel=0.16712300479208864 area_sum=0.21924139304837004, Error= -0.31185645759014385\n", "area_pixel=0.0910896551757503 area_sum=0.195600147785569, Error= -1.1473365708561962\n", "area_pixel=0.013839860300606688 area_sum=0.18831736949485467, Error= -12.606883697128037\n", "area_pixel=0.06971547380450005 area_sum=0.1919289271858045, Error= -1.7530319556318605\n", "area_pixel=0.1460448710809601 area_sum=0.21093711727245834, Error= -0.4443308807162778\n", "area_pixel=0.2211077637641452 area_sum=0.2464380208952605, Error= -0.11456068615543955\n", "area_pixel=0.2947892935060068 area_sum=0.29874459478635623, Error= -0.01341738444197885\n", "area_pixel=0.2931110358344142 area_sum=0.29731957113173924, Error= -0.014358160501682777\n", "area_pixel=0.21932969808296576 area_sum=0.2454634010956124, Error= -0.1191525964840432\n", "area_pixel=0.14425529718059948 area_sum=0.2103559341545839, Error= -0.45821982461573074\n", "area_pixel=0.0678768532043108 area_sum=0.19170761485521115, Error= -1.8243444680348846\n", "area_pixel=0.015722368042034418 area_sum=0.18830140786212451, Error= -10.976656910631574\n", "area_pixel=0.09294335108705098 area_sum=0.19596483295523684, Error= -1.1084330472622583\n", "area_pixel=0.16891666467091682 area_sum=0.21997849216163964, Error= -0.3022900528506255\n", "area_pixel=0.24357351180874787 area_sum=0.2605144924477917, Error= -0.06955181831243516\n", "area_pixel=0.3168708228495447 area_sum=0.3179731509015596, Error= -0.003478793162784448\n", "area_pixel=0.2710631871144926 area_sum=0.27991283223707675, Error= -0.03264790478113202\n", "area_pixel=0.19696115396294545 area_sum=0.23316205130188028, Error= -0.18379714278961504\n", "area_pixel=0.1214387298301034 area_sum=0.20303492624664138, Error= -0.6719124659051822\n", "area_pixel=0.0446689612829303 area_sum=0.18930859299093517, Error= -3.238034365560167\n", "area_pixel=0.03903613195652156 area_sum=0.18885585878134378, Error= -3.8379757244311867\n", "area_pixel=0.11591426957792095 area_sum=0.20145300012799877, Error= -0.7379482341695316\n", "area_pixel=0.19150018698596227 area_sum=0.23045358088976126, Error= -0.20341177999295856\n", "area_pixel=0.2657337485833722 area_sum=0.2760045347974807, Error= -0.038650665445627994\n", "area_pixel=0.3222386194771545 area_sum=0.3229856609524451, Error= -0.002318286605443799\n", "area_pixel=0.2490296734347055 area_sum=0.26414082364545255, Error= -0.06068011896867032\n", "area_pixel=0.17448194563318253 area_sum=0.2223541778052593, Error= -0.2743678264152308\n", "area_pixel=0.09859402488583413 area_sum=0.1971960039311532, Error= -1.0000806758776117\n", "area_pixel=0.021441183690896537 area_sum=0.18837731126207918, Error= -7.785770131807607\n", "area_pixel=0.06218567341007741 area_sum=0.19086877457137236, Error= -2.0693367797548268\n", "area_pixel=0.13869416433347936 area_sum=0.20839072580829415, Error= -0.5025197837973544\n", "area_pixel=0.21387740728798832 area_sum=0.24236963199299888, Error= -0.1332175523646846\n", "area_pixel=0.2877265125863744 area_sum=0.29298711444407266, Error= -0.018283340698814\n", "area_pixel=0.3004402363939178 area_sum=0.303600641483933, Error= -0.010519247115328041\n", "area_pixel=0.2268235323436727 area_sum=0.24984623093141892, Error= -0.10150048520037716\n", "area_pixel=0.15189401551023707 area_sum=0.21303058804816452, Error= -0.40249493920191404\n", "area_pixel=0.07560254653373022 area_sum=0.19280996485282426, Error= -1.5503104550426978\n", "area_pixel=0.007855636670086596 area_sum=0.1883701121219128, Error= -22.978974592753957\n", "area_pixel=0.08524286926645885 area_sum=0.19435012991211917, Error= -1.2799576267734991\n", "area_pixel=0.16136464619074076 area_sum=0.21680879610280904, Error= -0.3435953985021641\n", "area_pixel=0.23612869121810576 area_sum=0.2557847081568589, Error= -0.08324281491315001\n", "area_pixel=0.3095662602127476 area_sum=0.31145228925042306, Error= -0.006092489008263765\n", "area_pixel=0.27737650871887354 area_sum=0.28484318767074285, Error= -0.02691893046875478\n", "area_pixel=0.20335720410827207 area_sum=0.2364081307812203, Error= -0.16252646085432584\n", "area_pixel=0.12796221102990302 area_sum=0.20484257754165658, Error= -0.6008052368975374\n", "area_pixel=0.05132761493532456 area_sum=0.18980200252948415, Error= -2.697853538853197\n", "area_pixel=0.032348638250020656 area_sum=0.18852647031578124, Error= -4.827956925378794\n", "area_pixel=0.10935502368892713 area_sum=0.19961445968068325, Error= -0.8253798769090792\n", "area_pixel=0.18502779705186612 area_sum=0.22726292353672958, Error= -0.2282636833914437\n", "area_pixel=0.25940934304914265 area_sum=0.2715159237570396, Error= -0.04666979440907595\n", "area_pixel=0.33239200799186364 area_sum=0.3324826590476647, Error= -0.0002727233315528516\n", "area_pixel=0.32806663025375826 area_sum=0.32842573916217543, Error= -0.0010946218703785946\n", "area_pixel=0.25501563476734646 area_sum=0.2683640057705975, Error= -0.05234334363627901\n", "area_pixel=0.1805523038249106 area_sum=0.22502046808368545, Error= -0.24628965300768216\n", "area_pixel=0.10484839677616975 area_sum=0.19849448753573104, Error= -0.8931571072038123\n", "area_pixel=0.027780706427876112 area_sum=0.18839753156619068, Error= -5.781596143183247\n", "area_pixel=0.055901844324466765 area_sum=0.19019891689204785, Error= -2.4023728410120233\n", "area_pixel=0.13245086773965653 area_sum=0.20621132104509224, Error= -0.5568891662561106\n", "area_pixel=0.2077403838853087 area_sum=0.23890216466206007, Error= -0.15000348123913876\n", "area_pixel=0.28168838271031404 area_sum=0.2882412679482228, Error= -0.023262887787061096\n", "area_pixel=0.3036679509148854 area_sum=0.3063570335937469, Error= -0.008855339099038458\n", "area_pixel=0.23013353029770656 area_sum=0.2519202767485691, Error= -0.09467002232433774\n", "area_pixel=0.15527976347109984 area_sum=0.21418418731666777, Error= -0.37934385349917815\n", "area_pixel=0.07912305701536582 area_sum=0.1932629017618802, Error= -1.442561107369098\n", "area_pixel=0.004270495138143815 area_sum=0.188569657946917, Error= -43.15639213884679\n", "area_pixel=0.08171443432242143 area_sum=0.19372282563559082, Error= -1.370729568673471\n", "area_pixel=0.15785913032920718 area_sum=0.21533079423596513, Error= -0.36406930525275116\n", "area_pixel=0.23267664257012655 area_sum=0.25358055258180084, Error= -0.08984103337907696\n", "area_pixel=0.30615817813110624 area_sum=0.30851641426865656, Error= -0.007702672363501097\n", "area_pixel=0.2827987436141157 area_sum=0.28907071497267317, Error= -0.022178215074094083\n", "area_pixel=0.20893762266676674 area_sum=0.23950680288442894, Error= -0.1463076866075804\n", "area_pixel=0.13369499035069055 area_sum=0.20655228590143038, Error= -0.5449515749216217\n", "area_pixel=0.05717610973642451 area_sum=0.19016647747794538, Error= -2.3259779015150146\n", "area_pixel=0.026447626860885975 area_sum=0.18843138062414674, Error= -6.124698999093276\n", "area_pixel=0.10350506590110342 area_sum=0.19822878807513072, Error= -0.9151602518135057\n", "area_pixel=0.17925718032221027 area_sum=0.2244265387471306, Error= -0.25198074823964944\n", "area_pixel=0.2537146360561806 area_sum=0.2674670217120998, Error= -0.054204147895015264\n", "area_pixel=0.32676999984669663 area_sum=0.32721468540180676, Error= -0.0013608518386594483\n", "area_pixel=0.33228527791060714 area_sum=0.33234618542055966, Error= -0.00018329885192478853\n", "area_pixel=0.2593125452043026 area_sum=0.27137676375823494, Error= -0.04652385230505303\n", "area_pixel=0.1850399926603572 area_sum=0.22717013127999455, Error= -0.22768125967756417\n", "area_pixel=0.10939551576598205 area_sum=0.19950410594224735, Error= -0.8236954645291387\n", "area_pixel=0.0324803256059738 area_sum=0.188350920570647, Error= -4.798923411531484\n", "area_pixel=0.05116354009351909 area_sum=0.1897881212412188, Error= -2.7094407637609765\n", "area_pixel=0.12777032001296362 area_sum=0.20477853245211183, Error= -0.6027081440457763\n", "area_pixel=0.20311429628934263 area_sum=0.2362889406485346, Error= -0.16332993277801403\n", "area_pixel=0.27710401884821323 area_sum=0.2846414590272934, Error= -0.02720076096481611\n", "area_pixel=0.3064926910713126 area_sum=0.3087457943571933, Error= -0.007351246380477145\n", "area_pixel=0.23304752811979768 area_sum=0.25371599247601223, Error= -0.08868776477899379\n", "area_pixel=0.15832508960892255 area_sum=0.2153977937851785, Error= -0.36047795278203065\n", "area_pixel=0.08224645176300527 area_sum=0.19358374996717953, Error= -1.3537033612707674\n", "area_pixel=0.0048831529783157634 area_sum=0.18833217194333302, Error= -37.567739487098805\n", "area_pixel=0.07843739213718948 area_sum=0.1931715652964236, Error= -1.4627484422042032\n", "area_pixel=0.15459365008597103 area_sum=0.21394863116266327, Error= -0.38394190863392097\n", "area_pixel=0.2294679376169313 area_sum=0.25152957536458437, Error= -0.09614257214653789\n", "area_pixel=0.30292545925210845 area_sum=0.3057232072472447, Error= -0.009235763814780104\n", "area_pixel=0.28499139748399926 area_sum=0.2907294346234526, Error= -0.020134071379384253\n", "area_pixel=0.2112129043374864 area_sum=0.2407098282028552, Error= -0.13965493234370352\n", "area_pixel=0.1360951441490741 area_sum=0.20730767684290902, Error= -0.5232554999598743\n", "area_pixel=0.05965767815867906 area_sum=0.1903207599058092, Error= -2.190213997259314\n", "area_pixel=0.023880824440844606 area_sum=0.1883405233019016, Error= -6.88668430474172\n", "area_pixel=0.10089743077433866 area_sum=0.1975985528551173, Error= -0.9584101531490405\n", "area_pixel=0.1766548864688673 area_sum=0.22318010267156244, Error= -0.2633678418564125\n", "area_pixel=0.25109088769037413 area_sum=0.2655975809287263, Error= -0.057774670247056986\n", "area_pixel=0.32417700640380787 area_sum=0.32478500869308446, Error= -0.0018755256457617078\n", "area_pixel=0.33145182584890165 area_sum=0.3315266847325048, Error= -0.00022585147452852428\n", "area_pixel=0.2585468538588884 area_sum=0.2707660793719313, Error= -0.0472611649713285\n", "area_pixel=0.18431353138899453 area_sum=0.22673224761704203, Error= -0.230144341049614\n", "area_pixel=0.10871529186361073 area_sum=0.19921525714434177, Error= -0.832449269365603\n", "area_pixel=0.031879361127160166 area_sum=0.18817886639838455, Error= -4.902843085461407\n", "area_pixel=0.0516786050759066 area_sum=0.18972920865569384, Error= -2.6713299125821153\n", "area_pixel=0.12821845710443824 area_sum=0.20480976716609148, Error= -0.5973501147285452\n", "area_pixel=0.20348000269607525 area_sum=0.23646917599420864, Error= -0.1621248911983118\n", "area_pixel=0.27742223519467046 area_sum=0.2848668964954997, Error= -0.026835128394107295\n", "area_pixel=0.30448904708695324 area_sum=0.3069801039112242, Error= -0.008181104864371699\n", "area_pixel=0.23109311817280087 area_sum=0.25240391903066006, Error= -0.09221737551666921\n", "area_pixel=0.1563911444396311 area_sum=0.21450563771866094, Error= -0.37159708426753507\n", "area_pixel=0.08034023396766088 area_sum=0.19312989938141578, Error= -1.403900136252476\n", "area_pixel=0.003030390955018447 area_sum=0.18826638002902615, Error= -61.12610281100846\n", "area_pixel=0.08016458138626348 area_sum=0.19330112071777367, Error= -1.411303313446811\n", "area_pixel=0.15625257357013567 area_sum=0.2146009744277408, Error= -0.3734236148847482\n", "area_pixel=0.23094086131234093 area_sum=0.25241853923906143, Error= -0.09300077000090755\n", "area_pixel=0.3043974758491643 area_sum=0.3069515382822804, Error= -0.008390550631180861\n", "area_pixel=0.2794759217164895 area_sum=0.2863588885133661, Error= -0.024628120929354843\n", "area_pixel=0.2056873359875837 area_sum=0.23752623815656224, Error= -0.15479271981479928\n", "area_pixel=0.1305269986732256 area_sum=0.20527723159311873, Error= -0.5726802399481381\n", "area_pixel=0.05410651131387567 area_sum=0.1895974495526617, Error= -2.5041521796294273\n", "area_pixel=0.029328670887437625 area_sum=0.18822537933908215, Error= -5.417794384937672\n", "area_pixel=0.10622409484210493 area_sum=0.19865334343013114, Error= -0.8701344899706244\n", "area_pixel=0.18179639942024295 area_sum=0.22559809131176356, Error= -0.2409381705644678\n", "area_pixel=0.25606986659449404 area_sum=0.26906495574232875, Error= -0.05074821696382342\n", "area_pixel=0.32897514851033804 area_sum=0.32921667662545373, Error= -0.0007341834670775917\n", "area_pixel=0.324203523021545 area_sum=0.32475121655333133, Error= -0.0016893509567135576\n", "area_pixel=0.2512669572231374 area_sum=0.26555627768050605, Error= -0.05686907906748367\n", "area_pixel=0.17697580562618498 area_sum=0.22307486174973945, Error= -0.26048225044346823\n", "area_pixel=0.10136939449070326 area_sum=0.19729598245497995, Error= -0.9463072009675886\n", "area_pixel=0.024478376357279785 area_sum=0.18793028725846134, Error= -6.6774000250458405\n", "area_pixel=0.05889322163771027 area_sum=0.19029184769810842, Error= -2.231133268081594\n", "area_pixel=0.13523648926715737 area_sum=0.20704031204379167, Error= -0.5309500650729485\n", "area_pixel=0.21030702373043653 area_sum=0.2402176739630025, Error= -0.14222373414833878\n", "area_pixel=0.28401961730821057 area_sum=0.28994393843399036, Error= -0.020858844828844585\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 1min 59s, sys: 4.61 s, total: 2min 3s\n", "Wall time: 7.97 s\n" ] } ], "source": [ "%time res = multigonio.integrate([data[ds_names[i]] for i in range(9)])" ] }, { "cell_type": "code", "execution_count": 68, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/mntdirect/_scisoft/users/kieffer/.jupy37/lib/python3.7/site-packages/matplotlib/pyplot.py:514: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).\n", " max_open_warning, RuntimeWarning)\n" ] }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "28457\n", "68 60\n" ] } ], "source": [ "fig, ax = plt.subplots()\n", "ax.plot(*calc_fwhm(res, LaB6_new, 10, 95), \"o\", label=\"FWHM\")\n", "ax.plot(*calc_peak_error(res, LaB6_new, 10, 95), \"o\", label=\"error\")\n", "ax.set_title(\"Peak shape & error as function of the angle\")\n", "ax.set_xlabel(res.unit.label)\n", "ax.legend()\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": 70, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "total run time: 1788.4090461730957\n" ] } ], "source": [ "print(\"total run time: \", time.time()-start_time)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conclusion\n", "The calibration works and the FWHM of every single peak is pretty small: 0.02°. \n", "The geometry has been refined with the wavelength: \n", "The goniometer scale parameter refines to 0.999 instead of 1 and the wavelength is fitted with a change at the 5th digit which is pretty precise." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7 local venv", "language": "python", "name": "python3.7" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": { "00be1d22c3714f99b4998fbfa214c8a7": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "013e6a7942fb40a6b72992b3f85f561a": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "0150e71008d34e71a80301d2a9d1e76b": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "0205d5daad574287a5e36dafcec7ecab": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "module_id", "layout": "IPY_MODEL_61007b90b4d04930a85fe7b55b9c65c1", "max": 9, "style": "IPY_MODEL_e87923908dee47598e73e14d161d2349" } }, "03c04b2b16674d1691bb790f76a8b467": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "040f091b7afb4b5faedad29670cde2c5": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "module_id", "layout": "IPY_MODEL_a7e32f3234924ddaa85afa83a12f29de", "max": 9, "style": "IPY_MODEL_dcb97e7e3ff84fd1972570d86608ae86" } }, "04a886f335d14bc08afd4308ce6472a5": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "0507af15cbd64bc3954c8955bbd5a1de": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_ce406a83f91a4492b820d715c0f66df2" } }, "070af2d9d61f4e0ba8b84f45dd383ea5": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_e7dedbc092f0422e943528d878bc7b91" } }, "08239fa193184ee28f28f29951ff2ab6": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "0cbd50d48b8a476ca67f7eff91ed942d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "0d938ccb67e74edea9aa8f55108d8943": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_1161c0efee034045b4716939c217f8b2" } }, "0dd43bfdb5664d78a53630b07bf966e7": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "1161c0efee034045b4716939c217f8b2": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "1639c8b38d5e4c0091a402ac212117e3": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "1ab6a052f2cb4341b0e7bb59593027cc": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "1bbcc83ae38a4b6dadc93d0049db98c5": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "1c514eb48a154c7688c4205f96328493": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_74c1ea6a280f41baa91ca8f9ef727774" } }, "2179b3cb4dbb4dd98728e17d9070ccf9": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "25942cb3e2494e15803c2b1d32b6d4ff": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "2774ca85f5ed480d8593321207297a92": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "28357404eecc40c88018a9308d195bf2": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_0dd43bfdb5664d78a53630b07bf966e7" } }, "2bf4b349fc094ce487b5efb81aa42380": { "model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": { "layout": "IPY_MODEL_5f991c83f92345fbab1c3b19535c123f" } }, "307fd8cc829246458237712078718fdb": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "394ca8987deb4b07a4c7a866e836c679": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "3b863574b18f49b893cff8153211bf06": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "3d199ff19a02415eae116528c5dc16f6": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "41e0e4a35d294726b8fcda341f21e775": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_307fd8cc829246458237712078718fdb" } }, "425b83359dde4380ac0a4e4cfeb0283e": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "frame_id", "layout": "IPY_MODEL_8559ac90ab924f8885feab7a2f46e293", "max": 500, "style": "IPY_MODEL_4343b6421068418db324226a69e2a33c", "value": 214 } }, "4343b6421068418db324226a69e2a33c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "44a238152860438585576e2a18626c93": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "4bb61694d54843b6b13421e600465348": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "4e7a7469400d4b328755ece3a70e9953": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_856dd89d9a4445e1b11c285ebeb2de20" } }, "5285e75b3f3b4edeb2f45474250f267d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "55033a5e8dd947e2886556cdb9d8e92d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "591b1e4e24ff4a6f8b1c44e2b64cecf0": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "5a453b3b96bc41d4a62affc50ba873d8": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "5b12719654274f1d842eeb2b60d298d2": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "5c339a2d07da4e2abe205b8f3282fdbf": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_1ab6a052f2cb4341b0e7bb59593027cc" } }, "5f991c83f92345fbab1c3b19535c123f": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "5fb082dca8264d6191ad7f07de0c4f9a": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_d18b801643a54baf97048a81b491e1c8" } }, "61007b90b4d04930a85fe7b55b9c65c1": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "62c60c6ad25d44a3aeeb64cd2280576f": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "62ce0c23ef574f639f9de0920030a78e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "6416199483114ebf9d034232e8033fc4": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "644063599cd94a41961de434b1923475": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "6563060642ab4ebe84e9c9c17d928752": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "65d46021945a4d2d833e8a988972ee28": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "694bb2d7e05b4500ab105b7afae0918c": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "VBoxModel", "state": { "_dom_classes": [ "widget-interact" ], "children": [ "IPY_MODEL_0205d5daad574287a5e36dafcec7ecab", "IPY_MODEL_809d081102924a8695397a137bb45d4d", "IPY_MODEL_effe69d56e374ee28668c85a8959bcec" ], "layout": "IPY_MODEL_08239fa193184ee28f28f29951ff2ab6" } }, "6ce9a736558a4ab99c33f65e0cd932f3": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "6f9689536e214a4190553796ba6bf091": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "709c2bb5cb9a47d58ad71ffaa9b14949": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "VBoxModel", "state": { "_dom_classes": [ "widget-interact" ], "children": [ "IPY_MODEL_040f091b7afb4b5faedad29670cde2c5", "IPY_MODEL_908f72e622ba483194fa6e33551e491b", "IPY_MODEL_8bccbcf68c444b0fbab1bbc43e5df7af" ], "layout": "IPY_MODEL_591b1e4e24ff4a6f8b1c44e2b64cecf0" } }, "709d08c580cb4bb7a1b3144179de759e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "73761ce121a94af293289bbd1e5bcf02": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "74c1ea6a280f41baa91ca8f9ef727774": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "74d599e1b8bf492a844975dcd563213b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "frame_id", "layout": "IPY_MODEL_841889510bc64a6e9e17f3c76ab6327a", "max": 500, "style": "IPY_MODEL_73761ce121a94af293289bbd1e5bcf02", "value": 250 } }, "79e01aa171324ebfaa812305d8598e3a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "VBoxModel", "state": { "_dom_classes": [ "widget-interact" ], "children": [ "IPY_MODEL_cca78b86c1d140d79ec5003709dffd15", "IPY_MODEL_425b83359dde4380ac0a4e4cfeb0283e", "IPY_MODEL_2bf4b349fc094ce487b5efb81aa42380" ], "layout": "IPY_MODEL_bf8985f8594c4bbe91d810b4780a4704" } }, "7a549c9118e34ac0bb49bc543eeaa5b1": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "7dbf697ea64a4eb9be2fe116cac9d0f3": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "7fd8c56dacd64c78879a1667e5804bd3": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_b941d34d7b8b426ebd8a63fbadbc598b" } }, "80774e3ee4d5422a89f2803e0beb04a0": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "809d081102924a8695397a137bb45d4d": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "frame_id", "layout": "IPY_MODEL_5b12719654274f1d842eeb2b60d298d2", "max": 500, "style": "IPY_MODEL_644063599cd94a41961de434b1923475", "value": 480 } }, "8330adbf332a4074b6a91b1d176d13ea": { "model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": { "layout": "IPY_MODEL_e6b238f1fb434d7e84fdbb96a4022d42" } }, "841889510bc64a6e9e17f3c76ab6327a": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "84634a8f7dce472abe79b0e24069754f": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_6416199483114ebf9d034232e8033fc4" } }, "84f2c61385d543caaf09088fbed49402": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "8559ac90ab924f8885feab7a2f46e293": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "856dd89d9a4445e1b11c285ebeb2de20": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "89f8a8891a414ef7b84886a9fa0eb873": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_0150e71008d34e71a80301d2a9d1e76b" } }, "8ba0dc114726493fa636d40f818258a2": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "8bccbcf68c444b0fbab1bbc43e5df7af": { "model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": { "layout": "IPY_MODEL_d25a2af2da9c4b2ab62016079e11fbb9" } }, "8f28275fdbba43b5a17d6553abfdce23": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "908f72e622ba483194fa6e33551e491b": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "frame_id", "layout": "IPY_MODEL_b15d4bf3f52f4f1da53233143ef0b5bd", "max": 500, "style": "IPY_MODEL_c3ab50d1c01649fdb62018d0abc10db8", "value": 495 } }, "90f5051569e9467891e502389a4b803b": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_d8fe52e2b5e048ffbc7495127f6c79d6" } }, "934ad7f899ef41368b7f233e00506642": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "VBoxModel", "state": { "_dom_classes": [ "widget-interact" ], "children": [ "IPY_MODEL_fff31fb004ae4bf6b7ccc8b2ac205de8", "IPY_MODEL_74d599e1b8bf492a844975dcd563213b", "IPY_MODEL_8330adbf332a4074b6a91b1d176d13ea" ], "layout": "IPY_MODEL_03c04b2b16674d1691bb790f76a8b467" } }, "96cb6816c0c94655ac5f1872cc7aee1f": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_f9492ba5e81e40fabeedf91cc29a812f" } }, "9968edfd33d0425ab43cf581e4ef50c7": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_2179b3cb4dbb4dd98728e17d9070ccf9" } }, "a60aa3bc8aa84668b11742bd9e7c495a": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_a927a844201b428b8140b5ee06629b77" } }, "a61d1c1bdc924b2e965f5a59653698df": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "a7e32f3234924ddaa85afa83a12f29de": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "a927a844201b428b8140b5ee06629b77": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "ac90715928094acba545a86e996c384c": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "b15d4bf3f52f4f1da53233143ef0b5bd": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "b2306b33f90c4473bd7ec0198a32edfa": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "b73f32f580914908ae1c03cf4bb05e3f": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_e74470112e0b4253a6995395971459bf" } }, "b7f38bb28e44465e8cb468415685207e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "b941d34d7b8b426ebd8a63fbadbc598b": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "ba8f82017a424118a591f055eab51c8b": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "bebfe94de147496fa38f9f0954738683": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "bf8985f8594c4bbe91d810b4780a4704": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "c084be3c23c648058c01b4712b75bae1": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_1639c8b38d5e4c0091a402ac212117e3" } }, "c1c0ab3ef278440c83c1f6494b3eec33": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_62c60c6ad25d44a3aeeb64cd2280576f" } }, "c3ab50d1c01649fdb62018d0abc10db8": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "c422f02a19b24cf59ffa27e59e6cbe76": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_3b863574b18f49b893cff8153211bf06" } }, "c474be73f07e4a6bbc12f49e07924ce1": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "c516afff7ba44410b69f48d37b46cfa2": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "c5576a2c1810481d879da75b01c08534": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "c826fa00cb0447e8b03b01940c449536": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "c9cb9135eace43da87b31436944104aa": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_7a549c9118e34ac0bb49bc543eeaa5b1" } }, "cca78b86c1d140d79ec5003709dffd15": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "module_id", "layout": "IPY_MODEL_80774e3ee4d5422a89f2803e0beb04a0", "max": 9, "style": "IPY_MODEL_f3b61123c15f4320ba75cb4b5f40a68a" } }, "ce406a83f91a4492b820d715c0f66df2": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "d18b801643a54baf97048a81b491e1c8": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "d1953c95a05140598de14c4222d5e471": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "d25a2af2da9c4b2ab62016079e11fbb9": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "d8137862d3c5400dbfa0ad6e265b4ce3": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "d8fe52e2b5e048ffbc7495127f6c79d6": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "dcb882225ae9416aa0b9829d77dbd0cb": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "dcb97e7e3ff84fd1972570d86608ae86": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "df5ecf54da984e68852e5c90bed11ad7": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "e126c84b89cd4731ade33684de68df8c": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_fcce55c2ae964623b8bd523832bea047" } }, "e1e1012b18864633a1210945f8c320a5": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "e3a4e8a244524b34a312540188a1468e": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "e6b238f1fb434d7e84fdbb96a4022d42": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "e74470112e0b4253a6995395971459bf": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "e7dedbc092f0422e943528d878bc7b91": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "e87923908dee47598e73e14d161d2349": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "ef361c8bcf2e43cea87accf1f8a50258": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "efb9ab08375a43d89192229cbfece970": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "effe69d56e374ee28668c85a8959bcec": { "model_module": "@jupyter-widgets/output", "model_module_version": "1.0.0", "model_name": "OutputModel", "state": { "layout": "IPY_MODEL_6563060642ab4ebe84e9c9c17d928752" } }, "f3b61123c15f4320ba75cb4b5f40a68a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "f4a882a6889a40b99a1289e8c480f13b": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_00be1d22c3714f99b4998fbfa214c8a7" } }, "f76dc12d5f8f4d2d9fa0ebe01319d9ae": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "SliderStyleModel", "state": { "description_width": "" } }, "f9492ba5e81e40fabeedf91cc29a812f": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "fa9b3a8e1a0a4870bd35b5ca0507f82d": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "faced9f196f1415090e677c0d225fcbf": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "fcce55c2ae964623b8bd523832bea047": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.0.0", "model_name": "LayoutModel", "state": {} }, "fd28abe8abec4d0e8e265f2f34affd0a": { "model_module": "jupyter-matplotlib", "model_module_version": "^0.3.0", "model_name": "MPLCanvasModel", "state": { "_dom_classes": [], "_id": "", "_toolbar_items": [ [ "Home", "Reset original view", "fa fa-home icon-home", "home" ], [ "Back", "Back to previous view", "fa fa-arrow-left icon-arrow-left", "back" ], [ "Forward", "Forward to next view", "fa fa-arrow-right icon-arrow-right", "forward" ], [ "", "", "", "" ], [ "Pan", "Pan axes with left mouse, zoom with right", "fa fa-arrows icon-move", "pan" ], [ "Zoom", "Zoom to rectangle", "fa fa-square-o icon-check-empty", "zoom" ], [ "", "", "", "" ], [ "Download", "Download plot", "fa fa-floppy-o icon-save", "download" ] ], "layout": "IPY_MODEL_8ba0dc114726493fa636d40f818258a2" } }, "fff31fb004ae4bf6b7ccc8b2ac205de8": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.1.0", "model_name": "IntSliderModel", "state": { "description": "module_id", "layout": "IPY_MODEL_ac90715928094acba545a86e996c384c", "max": 9, "style": "IPY_MODEL_f76dc12d5f8f4d2d9fa0ebe01319d9ae", "value": 4 } } }, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 2 }