Commit c5d7e23f authored by Johan Gronqvist's avatar Johan Gronqvist
Browse files

Add furuta notebooks.

parent 5a482330
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Welcome to Jupyter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This course will use Jupyter as the software environment for the Automatic Control part of the course.\n",
"\n",
"Jupyter is a web-based interface, with a file browser (to the left), a main area where this notebook is now displayed, and a few other bits that you will see later.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"One useful feature of Jupyter Notebooks is that they allow mixing text (with fancy formatting) and executable code (organized in \"cells\"), and that the results of executing code gets printed.\n",
"\n",
"If you click in the below code cell, containing the code `print (\"I can see the output!\")`, and press shift+enter, then you should indeed see the output."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I can see the output.\n"
]
}
],
"source": [
"print(\"I can see the output.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You should now see the text \"I can see the output.\", and the cell should have been give a number which is shown to the left of the cell, telling us that it was the first cell to be executed. If you execute the cell again, it should get the number 2 instead.\n",
"\n",
"This notebook uses python as the programming language to execute, but jupyter can handle many other programming languages as well. \n",
"\n",
"Let's define a function in one cell and use it in the next."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def f(x):\n",
" return x*x - x + 0.18"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.42"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f(1.2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are more ways to execute the cells in a notebook than pressing shift+enter, including the buttons just above the notebook, and via the menus at the top, but we will not focus on them now."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At the bottom left of the screen, there should now be a text saying that we are using a Python 3 kernel, and that the kernel is currently *Idle*. When we run a longer computation, we will see that change to *Busy* instead. There is also a place at the top right where it says that the kernel is Python 3, with a nearby circle. When a computation is running, the circle will be filled.\n",
"\n",
"Let's try something that keeps the kernel \"busy\" for 10 seconds..."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"time.sleep(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will use Julia as our programming language of choice, but before we can do that, we need to install a Julia kernel in your home directory that jupyter can use. That can be done with the command below, so do run it, and wait until it the kernel is no longer busy.\n",
"\n",
"(It can take quite a bit of time, depending on the performance of the network-mounted home directory.)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Resolving package versions...\n",
" Installed ZeroMQ_jll ────── v4.3.2+4\n",
" Installed VersionParsing ── v1.2.0\n",
" Installed SoftGlobalScope ─ v1.1.0\n",
" Installed Conda ─────────── v1.4.1\n",
" Installed IJulia ────────── v1.21.2\n",
" Installed ZMQ ───────────── v1.2.1\n",
"Downloading artifact: ZeroMQ\n",
"######################################################################## 100.0% ##O#-# 9.9% 20.2%\n",
"\u001b[1A\u001b[2K\u001b[?25h Updating `~/.julia/environments/v1.4/Project.toml`\n",
" [7073ff75] + IJulia v1.21.2\n",
" Updating `~/.julia/environments/v1.4/Manifest.toml`\n",
" [8f4d0f93] + Conda v1.4.1\n",
" [7073ff75] + IJulia v1.21.2\n",
" [682c06a0] + JSON v0.21.0\n",
" [739be429] + MbedTLS v1.0.2\n",
" [c8ffd9c3] + MbedTLS_jll v2.16.6+1\n",
" [69de0a69] + Parsers v1.0.7\n",
" [b85f4697] + SoftGlobalScope v1.1.0\n",
" [81def892] + VersionParsing v1.2.0\n",
" [c2297ded] + ZMQ v1.2.1\n",
" [8f1865be] + ZeroMQ_jll v4.3.2+4\n",
" [2a0f44e3] + Base64 \n",
" [ade2ca70] + Dates \n",
" [8ba89e20] + Distributed \n",
" [7b1f6079] + FileWatching \n",
" [b77e0a4c] + InteractiveUtils \n",
" [76f85450] + LibGit2 \n",
" [8f399da3] + Libdl \n",
" [56ddb016] + Logging \n",
" [d6f4376e] + Markdown \n",
" [a63ad114] + Mmap \n",
" [44cfe95a] + Pkg \n",
" [de0858da] + Printf \n",
" [3fa0cd96] + REPL \n",
" [9a3f8284] + Random \n",
" [ea8e919c] + SHA \n",
" [9e88b42a] + Serialization \n",
" [6462fe0b] + Sockets \n",
" [8dfed614] + Test \n",
" [cf7118a7] + UUIDs \n",
" [4ec0a83e] + Unicode \n",
" Building Conda ─→ `~/.julia/packages/Conda/3rPhK/deps/build.log`\n",
" Building IJulia → `~/.julia/packages/IJulia/DrVMH/deps/build.log`\n",
" Building Conda ─→ `~/.julia/packages/Conda/3rPhK/deps/build.log`\n",
" Building IJulia → `~/.julia/packages/IJulia/DrVMH/deps/build.log`\n"
]
}
],
"source": [
"!julia --eval \"import Pkg; Pkg.add(\\\"IJulia\\\"); Pkg.build(\\\"IJulia\\\"); using IJulia\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If the indicators at the bottom left and top right show that the kernel is idle, and if the cell has been given a number, then the julia kernel should have been installed and be ready to use. Now we need to restart the server, and then Julia should be available to us.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To restart, you need to do 3 things.\n",
"\n",
" 1. Select the menu item \"File\" --> \"Hub Control Panel\"\n",
" 2. Stop the server\n",
" 3. Start the server again\n",
" \n",
"Then you should get back to this view of the files, and continue with the notebook named Julia.ipynb."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Remember to stop your server when you are done."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we have more than one person trying to access the lab processes at any one time, the lab computers only allow a single user to have a jupyterlab server running at a time. Therefore, when you stop working on the lab, you should stop your server, the same way you just did, and then, when you want to resume your work, your server needs to be restarted again."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment