Jupyter notebook INTRODUCTION
Introduction to GIS scripting
May, 2017© 2017, Stijn Van Hoey (mailto:stijnvanhoey@gmail.com). Licensed under CC BY 4.0 Creative Commons
In [ ]:
from IPython.display import Image
Image(url='http://python.org/images/python-logo.gif')
We will work in Jupyter notebooks during this course. A notebook is a collection of cells, that can contain different content:
In [ ]:
# Code cell, then we are using python
print('Hello DS')
In [ ]:
DS = 10
print(DS + 5) # Yes, we advise to use Python 3 (!)
Writing code is what you will do most during this course!
Text cells, using Markdown syntax. With the syntax, you can make text bold or italic, amongst many other things...
Link to interesting resources or images:
Blockquotes if you like them This line is part of the same blockquote.
Mathematical formulas can also be incorporated (LaTeX it is...) $$\frac{dBZV}{dt}=BZV_{in} - k_1 .BZV$$ $$\frac{dOZ}{dt}=k_2 .(OZ_{sat}-OZ) - k_1 .BZV$$
Or tables:
| course | points |
|---|---|
| Math | 8 |
| Chemistry | 4 |
or tables with Latex..
| Symbool | verklaring |
|---|---|
| $BZV_{(t=0)}$ | initiële biochemische zuurstofvraag (7.33 mg.l-1) |
| $OZ_{(t=0)}$ | initiële opgeloste zuurstof (8.5 mg.l-1) |
| $BZV_{in}$ | input BZV(1 mg.l-1.min-1) |
| $OZ_{sat}$ | saturatieconcentratie opgeloste zuurstof (11 mg.l-1) |
| $k_1$ | bacteriële degradatiesnelheid (0.3 min-1) |
| $k_2$ | reäeratieconstante (0.4 min-1) |
Code can also be incorporated, but than just to illustrate:
BOT = 12
print(BOT)
In other words, it is markdown, just as you've written in Rmarkdown (!)
See also: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
You can also use HTML commands, just check this cell:
In [ ]:
import os
os.mkdir
In [ ]:
my_very_long_variable_name = 3
In [ ]:
round(3.2)
In [ ]:
os.mkdir
In [ ]:
# An alternative is to put a question mark behind the command
os.mkdir?
In [ ]:
# %load ../notebooks/_solutions/00-jupyter_introduction26.py
To start editing, click inside a cell or
To s stop edting,
Just do it!
`Help` > `Keyboard shortcuts`
Stackoverflow is really, really, really nice!
push the start triangle in the menu or type SHIFT + ENTER
In [ ]:
%psearch os.*dir
In [ ]:
%%timeit
mylist = range(1000)
for i in mylist:
i = i**2
In [ ]:
import numpy as np
In [ ]:
%%timeit
np.arange(1000)**2
In [ ]:
%lsmagic
In [ ]:
from IPython.display import FileLink, FileLinks
In [ ]:
FileLinks('.', recursive=False)
For now, we will work on the 01-python-introduction.ipynb notebook, which is a short introduction to some essential basic Python concepts required to start programming in Python.
Additional material is available here (largely adopted from the scientific python notes, which you can explore on your own to get more background on the Python syntax if specific elements would not be clear.
In [ ]: