from IPython.display import Image
Image(url='http://python.org/images/python-logo.gif')

"""
Explanation: <p><font size="6"><b>Jupyter notebook INTRODUCTION </b></font></p>


Introduction to GIS scripting
May, 2017
© 2017, Stijn Van Hoey (&#115;&#116;&#105;&#106;&#110;&#118;&#97;&#110;&#104;&#111;&#101;&#121;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;). Licensed under CC BY 4.0 Creative Commons
End of explanation
"""


# Code cell, then we are using python
print('Hello DS')

DS = 10
print(DS + 5) # Yes, we advise to use Python 3 (!)

"""
Explanation: <big><center>To run a cell: push the start triangle in the menu or type SHIFT + ENTER/RETURN

Notebook cell types
We will work in Jupyter notebooks during this course. A notebook is a collection of cells, that can contain different content:
Code
End of explanation
"""


import os
os.mkdir

my_very_long_variable_name = 3

"""
Explanation: Writing code is what you will do most during this course!
Markdown
Text cells, using Markdown syntax. With the syntax, you can make text bold or italic, amongst many other things...

list
with
items

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:
python
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
HTML
You can also use HTML commands, just check this cell:
<h3> html-adapted titel with &#60;h3&#62; </h3>
<p></p>
<b> Bold text &#60;b&#62; </b> of <i>or italic &#60;i&#62; </i>
Headings of different sizes: section
subsection
subsubsection
Raw Text
Notebook handling ESSENTIALS
Completion: TAB


The TAB button is essential: It provides you all possible actions you can do after loading in a library AND it is used for automatic autocompletion:
End of explanation
"""


round(3.2)

os.mkdir

# An alternative is to put a question mark behind the command
os.mkdir?

"""
Explanation: Help: SHIFT + TAB


The  SHIFT-TAB combination is ultra essential to get information/help about the current operation
End of explanation
"""


# %load ../notebooks/_solutions/00-jupyter_introduction26.py

"""
Explanation: <div class="alert alert-success">
    <b>EXERCISE</b>: 
<ul>
    <li>What happens if you put two question marks behind the command?</li>
</ul>
</div>
End of explanation
"""


%psearch os.*dir

"""
Explanation: edit mode to command mode

edit mode means you're editing a cell, i.e. with your cursor inside a cell to type content --> <font color="green">green colored side</font>
command mode means you're NOT editing(!), i.e. NOT with your cursor inside a cell to type content --> <font color="blue">blue colored side</font>

To start editing, click inside a cell or 
<img src="../img/enterbutton.png" alt="Key enter" style="width:150px">
To s stop edting,
<img src="../img/keyescape.png" alt="Key A" style="width:150px">
new cell A-bove
<img src="../img/keya.png" alt="Key A" style="width:150px">
Create a new cell above with the key A... when in command mode
new cell B-elow
<img src="../img/keyb.png" alt="Key B" style="width:150px">
Create a new cell below with the key B... when in command mode
CTRL + SHIFT + P
Just do it!
Trouble...
<div class="alert alert-danger">
    <b>NOTE</b>: When you're stuck, or things do crash: 
    <ul>
    <li> first try **Kernel** > **Interrupt** -> you're cell should stop running
    <li> if no succes -> **Kernel** > **Restart** -> restart you're notebook
    </ul>
</div>

Overload?!?
<img src="../img/toomuch.jpg" alt="Key A" style="width:500px">
<br><br>
<center>No stress, just go to </center>
<br>
<center><p style="font-size: 200%;text-align: center;margin:500">Help > Keyboard shortcuts</p></center>

Stackoverflow is really, really, really nice!

http://stackoverflow.com/questions/tagged/python

Google search is with you!

<big><center>REMEMBER: To run a cell: <strike>push the start triangle in the menu or</strike> type SHIFT + ENTER

some MAGIC...
%psearch
End of explanation
"""


%%timeit

mylist = range(1000)
for i in mylist:
    i = i**2

import numpy as np

%%timeit

np.arange(1000)**2

"""
Explanation: %%timeit
End of explanation
"""


%lsmagic

"""
Explanation: %lsmagic
End of explanation
"""


from IPython.display import FileLink, FileLinks

FileLinks('.', recursive=False)

"""
Explanation: Let's get started!
End of explanation
"""


