{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Profile picker" ] }, { "cell_type": "markdown", "metadata": { "heading_collapsed": true }, "source": [ "## Setup notebook" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hidden": true }, "outputs": [], "source": [ "# Enable autoreloading of our modules. \n", "# Most of the code will be located in the /src/ folder, \n", "# and then called from the notebook.\n", "%matplotlib inline\n", "%reload_ext autoreload\n", "%autoreload" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hidden": true }, "outputs": [], "source": [ "from IPython.core.debugger import set_trace\n", "\n", "import pandas as pd\n", "import numpy as np\n", "import os\n", "import decimal\n", "import plotly\n", "import plotly.graph_objs as go\n", "import plotly.plotly as py\n", "import plotly.tools as tls\n", "import plotly.figure_factory as ff\n", "from plotly import tools\n", "import plotly.io as pio\n", "from scipy import stats\n", "import math\n", "import matplotlib\n", "from matplotlib import cm\n", "import colorlover as cl\n", "import numpy.ma as ma\n", "\n", "from ipywidgets import widgets, Output\n", "from IPython.display import display, clear_output, Image, HTML\n", "\n", "from sklearn.metrics import confusion_matrix\n", "\n", "import numpy as np\n", "from matplotlib import pyplot as plt\n", "\n", "from sklearn import linear_model, datasets\n", "\n", "from scipy.interpolate import UnivariateSpline\n", "from scipy.interpolate import interp1d\n", "from scipy.interpolate import splrep, splev\n", "from scipy.integrate import simps\n", "from scipy.stats import linregress\n", "from scipy.signal import find_peaks\n", "import json" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "hidden": true }, "outputs": [], "source": [ "# Matplot lib default settings\n", "plt.rcParams[\"figure.figsize\"] = (10,6)\n", "plt.rcParams['axes.grid']=True\n", "plt.rcParams['grid.alpha'] = 0.5\n", "plt.rcParams['grid.color'] = \"grey\"\n", "plt.rcParams['grid.linestyle'] = \"--\"\n", "plt.rcParams['axes.grid']=True\n", "\n", "# https://stackoverflow.com/a/20709149\n", "matplotlib.rcParams['text.usetex'] = True\n", "\n", "matplotlib.rcParams['text.latex.preamble'] = [\n", " r'\\usepackage{siunitx}', # i need upright \\micro symbols, but you need...\n", " r'\\sisetup{detect-all}', # ...this to force siunitx to actually use your fonts\n", " r'\\usepackage{helvet}', # set the normal font here\n", " r'\\usepackage{amsmath}',\n", " r'\\usepackage{sansmath}', # load up the sansmath so that math -> helvet\n", " r'\\sansmath', # <- tricky! -- gotta actually tell tex to use!\n", "] " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import data\n", "Let's first import data from our pre-processed interim data folder." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def df_from_csv(csv, index_col, data_folder='../data/interim'):\n", " print('Importing {}'.format(csv))\n", " return pd.read_csv(os.path.join(data_folder,csv), index_col=index_col)\n", "\n", "df_profiles = df_from_csv('profiles.csv', index_col=[0, 1, 2])\n", "df_profile_features_crest_toes = df_from_csv('profile_features_crest_toes.csv', index_col=[0,1])\n", "\n", "print('Done!')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Manually pick features" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook\n", "\n", "sites = df_profiles.index.get_level_values('site_id').unique()\n", "\n", "\n", "fig =plt.figure(figsize=(10, 3))\n", "\n", "df_prestorm = df_profiles.xs((sites[0],'prestorm'),level=('site_id','profile_type'))\n", "df_poststorm = df_profiles.xs((sites[0],'poststorm'),level=('site_id','profile_type'))\n", "line_prestorm, = plt.plot(df_prestorm.index, df_prestorm.z, label='prestorm')\n", "line_poststorm, = plt.plot(df_prestorm.index, df_prestorm.z, label='poststorm')\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# df_profiles.xs((sites[0],'prestorm'),level=('site_id','profile_type'))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.6.6" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }