yansc/deploy-mercury
0
1{2 "cells": [3 {4 "cell_type": "code",5 "execution_count": 21,6 "metadata": {},7 "outputs": [],8 "source": [9 "import pandas as pd\n",10 "import seaborn as sns\n",11 "import plotly.express as px\n",12 "import numpy as np\n",13 "import mercury as mr\n",14 "# import ipywidgets as widgets\n",15 "# from ipywidgets import interact, interactive, IntProgress\n",16 "# from IPython.display import Markdown, HTML, Javascript, display, Image, clear_output\n",17 "def printmd(string):\n",18 " display(Markdown(string))"19 ]20 },21 {22 "cell_type": "code",23 "execution_count": 9,24 "metadata": {},25 "outputs": [26 {27 "data": {28 "application/mercury+json": {29 "allow_download": true,30 "code_uid": "App.0.40.24.2-rand05c3cf02",31 "continuous_update": true,32 "description": "A visual representation of nutrients with time during ArcticNet Campaign 2014 - Eastern Arctic Ocean",33 "full_screen": true,34 "model_id": "mercury-app",35 "notify": "{}",36 "output": "app",37 "schedule": "",38 "show_code": false,39 "show_prompt": false,40 "show_sidebar": true,41 "static_notebook": false,42 "title": "Ocean Nutrients with Time - 2014",43 "widget": "App"44 },45 "text/html": [46 "<h3>Mercury Application</h3><small>This output won't appear in the web app.</small>"47 ],48 "text/plain": [49 "mercury.App"50 ]51 },52 "metadata": {},53 "output_type": "display_data"54 }55 ],56 "source": [57 "# set Application parameters\n",58 "app = mr.App(title=\"Ocean Nutrients with Time - 2014\",\n",59 " description=\"A visual representation of nutrients with time during ArcticNet Campaign 2014 - Eastern Arctic Ocean\",\n",60 " show_code=False,\n",61 " continuous_update=True)"62 ]63 },64 {65 "cell_type": "code",66 "execution_count": 24,67 "metadata": {},68 "outputs": [],69 "source": [70 "b1_state='False'\n",71 "b2_state='False'\n",72 "b3_state='False'"73 ]74 },75 {76 "cell_type": "code",77 "execution_count": null,78 "metadata": {},79 "outputs": [],80 "source": [81 "# add file upload widget\n",82 "my_file=mr.File(label=\"Nutrient file upload\")\n",83 "button1=mr.Button(label=\"Next\", style=\"success\")"84 ]85 },86 {87 "cell_type": "code",88 "execution_count": null,89 "metadata": {},90 "outputs": [],91 "source": [92 "if button1.clicked:\n",93 " b1_state='True'\n",94 " df=pd.read_csv(my_file.filepath)\n",95 " cols=list(df.columns)\n",96 "\n",97 " #Find date and time col\n",98 " dt_col=[c for c in cols if 'Date' in c or 'date' in c or 'Time' in c or 'time' in c]\n",99 " dt_col=dt_col[0]"100 ]101 },102 {103 "cell_type": "code",104 "execution_count": null,105 "metadata": {},106 "outputs": [],107 "source": [108 "if b1_state=='True':\n",109 " # Choose the variable to plot with date_and time\n",110 " var=mr.Select(value=cols[0], choices=cols,label=\"Choose variable\")\n",111 " v=var.value\n",112 " b2_state='True'"113 ]114 },115 {116 "cell_type": "code",117 "execution_count": 13,118 "metadata": {},119 "outputs": [],120 "source": [121 "#display(df)\n",122 "if b2_state=='True':\n",123 " button2=mr.Button(label=\"Next\", style=\"success\")\n",124 " if button2.clicked:\n",125 " fig = px.scatter(df, x=dt_col, y=v, color=\"Station\")\n",126 " fig.show()"127 ]128 }129 ],130 "metadata": {131 "kernelspec": {132 "display_name": "base",133 "language": "python",134 "name": "python3"135 },136 "language_info": {137 "codemirror_mode": {138 "name": "ipython",139 "version": 3140 },141 "file_extension": ".py",142 "mimetype": "text/x-python",143 "name": "python",144 "nbconvert_exporter": "python",145 "pygments_lexer": "ipython3",146 "version": "3.8.12"147 },148 "orig_nbformat": 4149 },150 "nbformat": 4,151 "nbformat_minor": 2152}153 