Difference between revisions of "Scientific Python Primer"
(→SSH Tunnel on Chromebook) |
Aplstudent (talk | contribs) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
'''Step 1''' | '''Step 1''' | ||
− | ''SSH into the remote machine'' and run the IPython web-based environment and direct it to a specific port. The command for this should look something like: | + | ''SSH into the remote machine'' and run the IPython web-based environment and direct it to a specific port. The command for this should look something like (you replace the xx with numbers): |
− | + | jupyter notebook --no-browser --port=70xx | |
'''Step 2''' | '''Step 2''' | ||
Line 19: | Line 19: | ||
==SSH Tunnel on Chromebook== | ==SSH Tunnel on Chromebook== | ||
− | + | Step 1: Open two secure shells. Right click the secure shell icon and open it in window mode. Enter ctrl+shift+n to create a second shell. | |
− | + | Step 2: From secure shell enter username as the user name and host as the host name. Open an ipython notebook with the command | |
− | + | jupyter notebook --no-browser --port=70xx | |
− | + | Step3: In the second shell use the same user name and host name | |
in SSH arguments enter | in SSH arguments enter | ||
-L 70xx:localhost:70xx | -L 70xx:localhost:70xx | ||
− | + | Step4: Go to http//:localhost:70xx and the ipython notebook should be running. | |
note: if multiple instances of ipython are running the notebook might not execute commands | note: if multiple instances of ipython are running the notebook might not execute commands | ||
Line 60: | Line 60: | ||
codecademy - https://www.codecademy.com/ | codecademy - https://www.codecademy.com/ | ||
+ | Python Flow Visualization - http://pythontutor.com/ | ||
==Chapter 1== | ==Chapter 1== |
Latest revision as of 09:38, 11 March 2020
This Python Primer utilizes an IPython notebook kernel running on a computer in the APL and a browser-based IPython notebook front end located on your computer. That is, you don't need any special software just a computer with a web-browser and a SSH client.
You will start your IPython session by establishing a SSH tunnel.
Step 1 SSH into the remote machine and run the IPython web-based environment and direct it to a specific port. The command for this should look something like (you replace the xx with numbers):
jupyter notebook --no-browser --port=70xx
Step 2 On the local machine you can access this remote port using an SSH tunnel with port forwarding. The command for that will look like:
ssh -N -f -L localhost:70xx:localhost:70xx username@remotemachine
Step 3 Now to use the session all you have to do is (from the local machine) run your preferred web browser with the URL:
Contents
SSH Tunnel on Chromebook
Step 1: Open two secure shells. Right click the secure shell icon and open it in window mode. Enter ctrl+shift+n to create a second shell.
Step 2: From secure shell enter username as the user name and host as the host name. Open an ipython notebook with the command
jupyter notebook --no-browser --port=70xx
Step3: In the second shell use the same user name and host name in SSH arguments enter
-L 70xx:localhost:70xx
Step4: Go to http//:localhost:70xx and the ipython notebook should be running.
note: if multiple instances of ipython are running the notebook might not execute commands
note: occasionally the kernel cannot be killed in the shell and must be killed in the system monitor on mother
Textbook for the module
A Primer on Scientific Programming with Python by Hans Petter Langtangen (3rd Edition). Available online through the UO Library. To access it, follow this link: http://link.springer.com/book/10.1007%2F978-3-642-30293-0
Activities
Intro to Python, Definitions - Chapter 1
Loops, logic, and lists - Chapter 2
Functions - Chapter 3 and NumPy
Input data and error handling - Chapter 4 and PANDAS
Functions on arrays and curve fitting - Chapter 5
String handling, files, and dictionaries - Chapter 6 and PANDAS
Useful Links
PANDAS - http://pandas.pydata.org/
NumPy - http://www.numpy.org
codecademy - https://www.codecademy.com/
Python Flow Visualization - http://pythontutor.com/
Chapter 1
Section 1.1: If this is your first time programming anything, begin with 1.1.1. Otherwise, it will suffice to read 1.1.1 for a statement of the problem and skip to 1.1.11. This introduces the syntax for commenting and basic arithmetic operations.
Section 1.2: This will give you relevant vocabulary for talking about Python and programs more generally. If this is not your first time programming, this section should just be skimmed.
Section 1.3: Introduction to potential calculation difficulties, primarily floating point versus integer data.
Section 1.4: Importing mathematical functions from a library.
Section 1.5: Interactive computing. This section will teach you how to have the user input various parameters. IPython is introduced as well.
Section 1.6: Complex numbers in Python.
Section 1.7: Summary
Section 1.8: Suggested exercises: While all are useful (after 1.6), the following will help immensely in debugging. 1.6 - Introduction to basic functions 1.9 - Error Correction 1.17 - Error Finding in a program that uses the quadratic formula