{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Get import" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['', '/Users/tlinnet/anaconda/envs/py36/lib/python36.zip', '/Users/tlinnet/anaconda/envs/py36/lib/python3.6', '/Users/tlinnet/anaconda/envs/py36/lib/python3.6/lib-dynload', '/Users/tlinnet/anaconda/envs/py36/lib/python3.6/site-packages', '/Users/tlinnet/anaconda/envs/py36/lib/python3.6/site-packages/IPython/extensions', '/Users/tlinnet/.ipython', '/Users/tlinnet/software/drawnmr/examples/..']\n" ] } ], "source": [ "try:\n", " from drawnmr import draw\n", "except ModuleNotFoundError:\n", " import sys, os\n", " sys.path.append( os.getcwd()+os.sep+\"..\")\n", " print(sys.path)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Get import" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from drawnmr import draw\n", "import nmrglue as ng\n", "import bokeh.plotting as bplt\n", "from bokeh.models import Range1d" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Get data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Get data\n", "import os, os.path\n", "ng_dir = 'nmrglue_data/s4_2d_plotting'\n", "if not os.path.exists(ng_dir):\n", " print(\"No %s. Downloading.\"%ng_dir)\n", " import urllib.request, zipfile\n", " zipf = 'jbnmr_s4_2d_plotting.zip'\n", " urllib.request.urlretrieve('https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/nmrglue/%s'%zipf, zipf)\n", " with zipfile.ZipFile(zipf,\"r\") as zip_ref:\n", " zip_ref.extractall(\"nmrglue_data\")\n", " os.remove(zipf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Read data" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Specify data\n", "ng_ft2 = 'nmrglue_data/s4_2d_plotting/test.ft2'\n", "\n", "# read in data\n", "ng_dic, ng_data = ng.pipe.read(ng_ft2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Create figure" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Pass to figure class\n", "fig2d = draw.fig2d(ng_dic, ng_data)\n", "# Change contour_start\n", "fig2d.contour_start = 85e3\n", "\n", "# Get the bokeh figure\n", "fig= fig2d.get_fig()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Alter figure" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Alter the figure after creation\n", "#fig.xaxis.axis_label = \"Nonsense\"\n", "\n", "# Set limits for view\n", "fig.x_range = Range1d(183.5, 167.5)\n", "fig.y_range = Range1d(139.5, 95.5)\n", "\n", "# Set larger image size\n", "fig.plot_width = 800\n", "fig.plot_height = 800" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Get peaks" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " x_ppm y_ppm x_p y_p cID VOL zs\n", "0 175.266401 131.102998 4081 788 1 14297425.0 339577.93750\n", "1 173.809599 130.187133 4111 807 2 14197980.0 339726.21875\n", "2 174.295200 129.946116 4101 812 3 10963096.0 288179.81250\n", "3 173.081198 127.535946 4126 862 4 36947544.0 316585.34375\n", "4 175.217841 126.764691 4082 878 5 18468114.0 360951.87500\n" ] } ], "source": [ "peaks = fig2d.get_peakpick(pthres=200e3)\n", "print(peaks.head())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Show output" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(root) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " root._bokeh_onload_callbacks = [];\n", " root._bokeh_is_loading = undefined;\n", " }\n", "\n", "\n", " \n", " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"
\\n\"+\n",
" \"