A New Cyberinfrastructure for the Natural Hazards Community
|
|
- Brice Holmes
- 5 years ago
- Views:
Transcription
1 A New Cyberinfrastructure for the Natural Hazards Community 1
2 Agenda Introduction to the Jupyter Notebook Programming in Python Plotting with Matplotlib Putting everything together a scientific notebook from Scott J. Brandenberg, Ph.D., P.E. Associate Professor Department of Civil and Environmental Engineering University of California 2
3 What are Jupyter Notebooks? A web-based, interactive computing tool for capturing the whole computation process: developing, documenting, and executing code, as well as communicating the results. 3
4 How do Jupyter Notebooks Work? An open notebook has exactly one interactive session connected to a kernel which will execute code sent by the user and communicate back results. This kernel remains active if the web browser window is closed, and reopening the same notebook from the dashboard will reconnect the web application to the same kernel. What's this mean? Notebooks are an interface to kernel, the kernel executes your code and outputs back to you through the notebook. The kernel is essentially our programming language we wish to interface with. 4
5 Jupyter Notebooks, Structure Code Cells Code cells allow you to enter and run code Run a code cell using Shift-Enter Markdown Cells Text can be added to Jupyter Notebooks using Markdown cells. Markdown is a popular markup language that is a superset of HTML. 5
6 Jupyter Notebooks, Structure Markdown Cells You can add headings: # Heading 1 # Heading 2 ## Heading 2.1 ## Heading 2.2 You can add lists 1. First ordered list item 2. Another item * Unordered sub-list. 1. Actual numbers don't matter, just that it's a number 1. Ordered sub-list 4. And another item. 6
7 Jupyter Notebooks, Structure Markdown Cells pure HTML <dl> <dt>definition list</dt> <dd>is something people use sometimes.</dd> <dt>markdown in HTML</dt> <dd>does *not* work **very** well. Use HTML <em>tags</em>.</dd> </dl> And even, Latex! $e^{i\pi} + 1 = 0$ 7
8 Jupyter Notebooks, Workflow Typically, you will work on a computational problem in pieces, organizing related ideas into cells and moving forward once previous parts work correctly. This is much more convenient for interactive exploration than breaking up a computation into scripts that must be executed together, as was previously necessary, especially if parts of them take a long time to run. 8
9 Jupyter Notebooks, Workflow Let a traditional paper lab notebook be your guide: Each notebook keeps a historical (and dated) record of the analysis as it s being explored. The notebook is not meant to be anything other than a place for experimentation and development. Notebooks can be split when they get too long. Notebooks can be split by topic, if it makes sense. 9
10 Jupyter Notebooks, Shortcuts Shift-Enter: run cell Execute the current cell, show output (if any), and jump to the next cell below. If Shift-Enteris invoked on the last cell, a new code cell will also be created. Note that in the notebook, typing Enter on its own never forces execution, but rather just inserts a new line in the current cell. Shift-Enter is equivalent to clicking the Cell Run menu item. 10
11 Jupyter Notebooks, Shortcuts Ctrl-Enter: run cell in-place Execute the current cell as if it were in terminal mode, where any output is shown, but the cursor remains in the current cell. The cell s entire contents are selected after execution, so you can just start typing and only the new input will be in the cell. This is convenient for doing quick experiments in place, or for querying things like filesystem content, without needing to create additional cells that you may not want to be saved in the notebook. 11
12 Jupyter Notebooks, Shortcuts Alt-Enter: run cell, insert below Executes the current cell, shows the output, and inserts a new cell between the current cell and the cell below (if one exists). (shortcut for the sequence Shift-Enter,Ctrl-m a. (Ctrl-m a adds a new cell above the current one.)) Esc and Enter: Command mode and edit mode In command mode, you can easily navigate around the notebook using keyboard shortcuts. In edit mode, you can edit text in cells. 12
13 Introduction to Python Hello World! Data types Variables Arithmetic operations Relational operations Input/Output Control Flow More Data Types! Matplotlib the magic number is: 4 13
14 Python print Hello World! Let's type that line of code into a Code Cell, and hit Shift-Enter: Hello World! 14
15 Python print 5 print 1+1 Let's add the above into another Code Cell, and hit Shift-Enter
16 Python - Variables You will need to store data into variables You can use those variables later on You can perform operations with those variables Variables are declared with a name, followed by = and a value An integer, string, When declaring a variable, capitalization is important: A <> a 16
17 Python - Variables in a code cell: five = 5 one = 1 print five print one + one message = This is a string print message Notice: We're not "typing" our variables, we're just setting them and allowing Python to type them for us. 17
18 Python - Data Types in a code cell: integer_variable = 100 floating_point_variable = string_variable = Name Notice: We're not "typing" our variables, we're just setting them and allowing Python to type them for us. 18
19 Python - Data Types Variables have a type You can check the type of a variable by using the type() function: print type(integer_variable) It is also possible to change the type of some basic types: str(int/float): converts an integer/float to a string int(str): converts a string to an integer float(str): converts a string to a float Be careful: you can only convert data that actually makes sense to be transformed 19
20 Python - Arithmetic Operations + Addition = 2 - Subtraction 5 3 = 2 / Division 4 / 2 = 2 % Modulo 5 % 2 = 1 * Multiplication 5 * 2 = 10 // Floor division 5 // 2 = 2 ** To the power of 2 ** 3 = 8 20
21 Python - Arithmetic Operations Some experiments: print 5/2 print 5.0/2 print "hello" + "world" print "some" + 1 print "number" * 5 print 3+5*2 21
22 Python - Reading from the Keyboard Let put the following into a new Code Cell: var = input("please enter a number: ") Let's run this cell! 22
23 Python - Reading from the Keyboard Let put the following into a new Code Cell: var2 = input("please enter a string: ") Let's run this cell! put the word Hello as your input. What happened? 23
24 Python - Making the output prettier Let put the following into a new Code Cell: print "The number that you wrote was : ", var print "The number that you wrote was : %d" % var print "the string you entered was: ", var2 print "the string you entered was: %s" % var2 Want to make it prettier? \n for a new line \t to insert a tab for floating points, us %f 24
25 Python - Writing to a File Let put the following into a new Code Cell: my_file = open("output_file.txt",'w') vars = "This is a string\n" my_file.write(vars) var3 = 10 my_file.write("\n") my_file.write(str(var3)) var4 = 20.0 my_file.write("\n") my_file.write(str(var4)) my_file.close() for floating points, us %f 25
26 Python - Reading from a File When opening a file, you need to decide how you want to open it: Just read? Are you going to write to the file? If the file already exists, what do you want to do with it? r w a read only (default) write mode: file will be overwritten if it already exists append mode: data will be appended to the existing file 26
27 Python - Reading from a File Let's read from the file we created in the previous cell. my_file = open( output_file.txt, r ) content = my_file.read() print content my_file.close() 27
28 Python - Reading from a File Let's read it line by line my_file = open("output_file.txt",'r') vars = my_file.readline() var5 = my_file.readline() var6 = my_file.readline() print "String: ", vars print "Integer: ", var1 print "Float: ", var2 my_file.close() 28
29 Python - Reading from a File Tweak it a bit to make the code easier to read introducing 'with'! (remember the MAGIC NUMBER! Hint: it's 4) with open("output_file.txt",'r') as f: vars = f.readline() var5 = f.readline() var6 = f.readline() print "String: ", vars print "Integer: ", var1 print "Float: ", var2 29
30 Python - Control Flow So far we have been writing instruction after instruction Every instruction is executed What happens if we want to have instructions that are only executed if a given condition is true? 30
31 Python - if/else/elif The if/else construction allows you to define conditions in your program (remember the MAGIC NUMBER! Hint: it's 4) if conditiona: statementa elif conditionb: statementb else: statementd this line will always be executed (after the if/else) 31
32 Python - if/else/elif A simple example if var>10: print "You entered a number greater than 10" else print "you entered a number less than 10" 32
33 Python - if/else/elif The if/else construction allows you to define conditions in your program (remember the MAGIC NUMBER! Hint: it's 4) if condition1: statement1 if condition2: statement2 else: if condition3: statement3 # when is this statement executed? else: # which if does this else belong to? statement4 # when is this statement executed? 33
34 Python - For Loops When we need to iterate, execute the same set of instructions over and over again we need to loop! and introducing range() (remember the MAGIC NUMBER! Hint: it's 4) for x in range(0, 3): print "Let's go %d" % (x) 34
35 Python - While Loops Sometimes we need to loop while a condition is true... (remember the MAGIC NUMBER! Hint: it's 4) i = 0 # Initialization while (i < 10): # Condition print i # do_something i = i + 1 # Why do we need this? 35
36 Python - lists A list is a sequence, where each element is assigned a position (index) First position is 0. You can access each position using [] Elements in the list can be of different type mylist1 = [ first item, second item ] mylist2 = [1, 2, 3, 4] mylist3 = [ first, second, 3] print mylist1[0], mylist1[1] print mylist2[0] print mylist3 print mylist3[0], mylist3[1], mylist3[2] print mylist2[0] + mylist3[2] 36
37 Python - lists It s possible to use slicing: print mylist3[0:3] print mylist3 To change the value of an element in a list, simply assign it a new value: mylist3[0] = 10 print mylist3 37
38 Python - lists There s a function that returns the number of elements in a list len(mylist2) Check if a value exists in a list: 1 in mylist2 Delete an element len(mylist2) del mylist2[0] print mylist2 Iterate over the elements of a list: for x in mylist2: print x 38
39 Python - lists There are more functions max(mylist), min(mylist) It s possible to add new elements to a list: my_list.append(new_item) We know how to find if an element exists, but there s a way to return the position of that element: my_list.index(item) Or how many times a given item appears in the list: my_list.count(item) 39
40 Matplotlib, What is it? It s a graphing library for Python. It has a nice collection of tools that you can use to create anything from simple graphs, to scatter plots, to 3D graphs. It is used heavily in the scientific Python community for data visualisation. 40
41 Matplotlib, First Steps Let's plot a simple sin wave from 0 to 2 pi. First lets, get our code started by importing the necessary modules. %matplotlib inline import matplotlib.pyplot as plt import numpy as np 41
42 Matplotlib, First Steps Let's add the following lines, we're setting up x as an array of 50 elements going from 0 to 2*pi x = np.linspace(0, 2 * np.pi, 50) plt.plot(x, np.sin(x)) plt.show() # Show the graph. Let's run our cell! 42
43 Matplotlib, a bit more interesting Let's plot another curve on the axis plt.plot(x, np.sin(x), x, np.sin(2 * x)) plt.show() Let's run our cell! 43
44 Matplotlib, a bit more interesting Let's see if we can make the plots easier to read plt.plot(x, np.sin(x), 'r-o', x, np.cos(x), 'g--') plt.show() Let's run this cell! 44
45 Matplotlib, a bit more interesting Colors: Blue b Green g Red r Cyan c Magenta m Yellow y Black k ( b is taken by blue so the last letter is used) White w 45
46 Matplotlib, a bit more interesting Lines: Solid Line - Dashed Dotted. Dash-dotted -: Often Used Markers: Point. Pixel, Circle o Square s Triangle ^ 46
47 Matplotlib, Subplots Let's split the plots up into subplots plt.subplot(2, 1, 1) # (row, column, active area) plt.plot(x, np.sin(x), 'r') plt.subplot(2, 1, 2) plt.plot(x, np.cos(x), 'g') plt.show() using the subplot() function, we can plot two graphs at the same time within the same "canvas". Think of the subplots as "tables", each subplot is set with the number of rows, the number of columns, and the active area, the active areas are numbered left to right, then up to down. 47
48 Matplotlib, Scatter Plots Let's take our sin curve, and make it a scatter plot y = np.sin(x) plt.scatter(x,y) plt.show() call the scatter() function and pass it two arrays of x and y coordinates. 48
49 Matplotlib, add a touch of color Let's mix things up, using random numbers and add a colormap to a scatter plot x = np.random.rand(1000) y = np.random.rand(1000) size = np.random.rand(1000) * 50 color = np.random.rand(1000) plt.scatter(x, y, size, color) plt.colorbar() plt.show() 49
50 Matplotlib, add a touch of color Let's see what we added, and where that takes us... plt.scatter(x, y, size, color) plt.colorbar()... We brought in two new parameters, size and color. Which will varies the diameter and the color of our points. Then adding the colorbar() gives us nice color legend to the side. 50
51 Matplotlib, Histograms A histogram is one of the simplest types of graphs to plot in Matplotlib. All you need to do is pass the hist() function an array of data. The second argument specifies the amount of bins to use. Bins are intervals of values that our data will fall into. The more bins, the more bars. plt.hist(x, 50) plt.show() 51
52 Matplotlib, Contour Plots Let's play with our preloaded data. import matplotlib.cm as cm with open('../mydata/contourdata/contourdata.dat') as file: array2d = [[float(digit) for digit in line.split()] for line in file] print array2d nx, ny = np.shape(array2d) cs = plt.pcolor(array2d, cmap=cm.get_cmap('afmhot')) cb = plt.colorbar(cs, orientation = 'horizontal') plt.xlim(0,nx) plt.ylim(0,ny) plt.show() 52
53 Matplotlib, Adding Labels and Legends Let's go back to our sin/cos curve example, and add a bit of clarification to our plots x = np.linspace(0, 2 * np.pi, 50) plt.plot(x, np.sin(x), 'r-x', label='sin(x)') plt.plot(x, np.cos(x), 'g-^', label='cos(x)') plt.legend() # Display the legend. plt.xlabel('rads') # Add a label to the x-axis. plt.ylabel('amplitude') # Add a label to the y-axis. plt.title('sin and Cos Waves') # Add a graph title. plt.show() 53
54 DesignSafe: Questions? For additional questions, feel free to contact us or fill out a ticket: 54
55 An example. presented by: Scott J. Brandenberg, Ph.D., P.E. Associate Professor Department of Civil and Environmental Engineering University of California 55
56 DesignSafe: Thanks Ellen Rathje, Tim Cockerill, Jamie Padgett, Scott Brandenberg, Dan Stanzione, Steve Mock, Matt Hanlon, Josue Coronel, Manuel Rojas, Joe Stubbs, Matt Stelmaszek, Hedda Prochaska, Joonyee Chuah 56
57 DesignSafe: References tml
58 DesignSafe: Next Webinar DesignSafe: Data Analysis and Plotting using Jupyter and R Wednesday, November 9 th 1:00p 3:00p For additional questions, feel free to contact us training@designsafe-ci.org or fill out a ticket: 58
Plotting With matplotlib
Lab Plotting With matplotlib and Mayavi Lab Objective: Introduce some of the basic plotting functions available in matplotlib and Mayavi. -D plotting with matplotlib The Python library matplotlib will
More informationME30_Lab1_18JUL18. August 29, ME 30 Lab 1 - Introduction to Anaconda, JupyterLab, and Python
ME30_Lab1_18JUL18 August 29, 2018 1 ME 30 Lab 1 - Introduction to Anaconda, JupyterLab, and Python ME 30 ReDev Team 2018-07-18 Description and Summary: This lab introduces Anaconda, JupyterLab, and Python.
More information5 File I/O, Plotting with Matplotlib
5 File I/O, Plotting with Matplotlib Bálint Aradi Course: Scientific Programming / Wissenchaftliches Programmieren (Python) Installing some SciPy stack components We will need several Scipy components
More information(DRAFT) PYTHON FUNDAMENTALS II: NUMPY & MATPLOTLIB
(DRAFT) PYTHON FUNDAMENTALS II: NUMPY & MATPLOTLIB TROY P. KLING Contents 1. Importing Libraries 1 2. Introduction to numpy 2 3. Introduction to matplotlib 5 4. Image Processing 8 5. The Mandelbrot Set
More informationVisualisation in python (with Matplotlib)
Visualisation in python (with Matplotlib) Thanks to all contributors: Ag Stephens, Stephen Pascoe. Introducing Matplotlib Matplotlib is a python 2D plotting library which produces publication quality figures
More informationHW0 v3. October 2, CSE 252A Computer Vision I Fall Assignment 0
HW0 v3 October 2, 2018 1 CSE 252A Computer Vision I Fall 2018 - Assignment 0 1.0.1 Instructor: David Kriegman 1.0.2 Assignment Published On: Tuesday, October 2, 2018 1.0.3 Due On: Tuesday, October 9, 2018
More informationUsing the Matplotlib Library in Python 3
Using the Matplotlib Library in Python 3 Matplotlib is a Python 2D plotting library that produces publication-quality figures in a variety of hardcopy formats and interactive environments across platforms.
More informationL15. 1 Lecture 15: Data Visualization. July 10, Overview and Objectives. 1.2 Part 1: Introduction to matplotlib
L15 July 10, 2017 1 Lecture 15: Data Visualization CSCI 1360E: Foundations for Informatics and Analytics 1.1 Overview and Objectives Data visualization is one of, if not the, most important method of communicating
More informationLECTURE 22. Numerical and Scientific Computing Part 2
LECTURE 22 Numerical and Scientific Computing Part 2 MATPLOTLIB We re going to continue our discussion of scientific computing with matplotlib. Matplotlib is an incredibly powerful (and beautiful!) 2-D
More informationLab 1 - Basic ipython Tutorial (EE 126 Fall 2014)
Lab 1 - Basic ipython Tutorial (EE 126 Fall 2014) modified from Berkeley Python Bootcamp 2013 https://github.com/profjsb/python-bootcamp and Python for Signal Processing http://link.springer.com/book/10.1007%2f978-3-319-01342-8
More informationIntro to Research Computing with Python: Visualization
Intro to Research Computing with Python: Visualization Erik Spence SciNet HPC Consortium 20 November 2014 Erik Spence (SciNet HPC Consortium) Visualization 20 November 2014 1 / 29 Today s class Today we
More informationProgramming for Engineers in Python
Programming for Engineers in Python Autumn 2016-17 Lecture 11: NumPy & SciPy Introduction, Plotting and Data Analysis 1 Today s Plan Introduction to NumPy & SciPy Plotting Data Analysis 2 NumPy and SciPy
More informationMATLAB Introduction to MATLAB Programming
MATLAB Introduction to MATLAB Programming MATLAB Scripts So far we have typed all the commands in the Command Window which were executed when we hit Enter. Although every MATLAB command can be executed
More informationNAVIGATING UNIX. Other useful commands, with more extensive documentation, are
1 NAVIGATING UNIX Most scientific computing is done on a Unix based system, whether a Linux distribution such as Ubuntu, or OSX on a Mac. The terminal is the application that you will use to talk to the
More informationPyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as
Geog 271 Geographic Data Analysis Fall 2015 PyPlot Graphicscanbeproducedin Pythonviaavarietyofpackages. We willuseapythonplotting package that is part of MatPlotLib, for which documentation can be found
More informationLab 4: Structured Programming I
4.1 Introduction Lab 4: Structured Programming I Lab this week is going to focus on selective structures and functions. 4.2 Resources The additional resources required for this assignment include: 0 Books:
More informationMatlab Tutorial 1: Working with variables, arrays, and plotting
Matlab Tutorial 1: Working with variables, arrays, and plotting Setting up Matlab First of all, let's make sure we all have the same layout of the different windows in Matlab. Go to Home Layout Default.
More informationComputational Physics Programming Style and Practices & Visualizing Data via Plotting
Computational Physics Programming Style and Practices & Visualizing Data via Plotting Prof. Paul Eugenio Department of Physics Florida State University Jan 30, 2018 http://comphy.fsu.edu/~eugenio/comphy/
More informationBasic Beginners Introduction to plotting in Python
Basic Beginners Introduction to plotting in Python Sarah Blyth July 23, 2009 1 Introduction Welcome to a very short introduction on getting started with plotting in Python! I would highly recommend that
More informationINTRODUCTION TO DATA VISUALIZATION WITH PYTHON. Working with 2D arrays
INTRODUCTION TO DATA VISUALIZATION WITH PYTHON Working with 2D arrays Reminder: NumPy arrays Homogeneous in type Calculations all at once Indexing with brackets: A[index] for 1D array A[index0, index1]
More informationScientific Python. 1 of 10 23/11/ :00
Scientific Python Neelofer Banglawala Kevin Stratford nbanglaw@epcc.ed.ac.uk kevin@epcc.ed.ac.uk Original course authors: Andy Turner Arno Proeme 1 of 10 23/11/2015 00:00 www.archer.ac.uk support@archer.ac.uk
More informationExcel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division
Excel R Tips EXCEL TIP 1: INPUTTING FORMULAS To input a formula in Excel, click on the cell you want to place your formula in, and begin your formula with an equals sign (=). There are several functions
More informationSkills Quiz - Python Edition Solutions
'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ EGR 103L Fall 2017 Skills Quiz - Python Edition Solutions Michael R. Gustafson II Name (please print): NetID (please print): In keeping with the Community
More informationPyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as
Geog 271 Geographic Data Analysis Fall 2017 PyPlot Graphicscanbeproducedin Pythonviaavarietyofpackages. We willuseapythonplotting package that is part of MatPlotLib, for which documentation can be found
More informationComputer Lab 1: Introduction to Python
Computer Lab 1: Introduction to Python 1 I. Introduction Python is a programming language that is fairly easy to use. We will use Python for a few computer labs, beginning with this 9irst introduction.
More informationTitle and Modify Page Properties
Dreamweaver After cropping out all of the pieces from Photoshop we are ready to begin putting the pieces back together in Dreamweaver. If we were to layout all of the pieces on a table we would have graphics
More informationThe Python interpreter
The Python interpreter Daniel Winklehner, Remi Lehe US Particle Accelerator School (USPAS) Summer Session Self-Consistent Simulations of Beam and Plasma Systems S. M. Lund, J.-L. Vay, D. Bruhwiler, R.
More informationSession 1 Use test driven development (i.e. write the tests first) to design functions to give the square, cube and an arbitary power N for a number a. In [1]: import unittest def square(a): return a**2
More informationPYTHON DATA VISUALIZATIONS
PYTHON DATA VISUALIZATIONS from Learning Python for Data Analysis and Visualization by Jose Portilla https://www.udemy.com/learning-python-for-data-analysis-and-visualization/ Notes by Michael Brothers
More informationMATLAB SUMMARY FOR MATH2070/2970
MATLAB SUMMARY FOR MATH2070/2970 DUNCAN SUTHERLAND 1. Introduction The following is inted as a guide containing all relevant Matlab commands and concepts for MATH2070 and 2970. All code fragments should
More informationipywidgets_demo July 17, Interactive widgets for the Jupyter notebook (ipywidgets)
ipywidgets_demo July 17, 2017 1 Interactive widgets for the Jupyter notebook (ipywidgets) Maarten Breddels - Kapteyn Astronomical Institute / RuG - Groningen Material on github https://github.com/maartenbreddels/ewass-2017
More information1 Introduction to Matlab
1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,
More informationroboturtle Documentation
roboturtle Documentation Release 0.1 Nicholas A. Del Grosso November 28, 2016 Contents 1 Micro-Workshop 1: Introduction to Python with Turtle Graphics 3 1.1 Workshop Description..........................................
More informationInstallation and Introduction to Jupyter & RStudio
Installation and Introduction to Jupyter & RStudio CSE 4/587 Data Intensive Computing Spring 2017 Prepared by Jacob Condello 1 Anaconda/Jupyter Installation 1.1 What is Anaconda? Anaconda is a freemium
More information(Ca...
1 of 8 9/7/18, 1:59 PM Getting started with 228 computational exercises Many physics problems lend themselves to solution methods that are best implemented (or essentially can only be implemented) with
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
More informationScientific Programming. Lecture A08 Numpy
Scientific Programming Lecture A08 Alberto Montresor Università di Trento 2018/10/25 Acknowledgments: Stefano Teso, Documentation http://disi.unitn.it/~teso/courses/sciprog/python_appendices.html https://docs.scipy.org/doc/numpy-1.13.0/reference/
More informationThe SciPy Stack. Jay Summet
The SciPy Stack Jay Summet May 1, 2014 Outline Numpy - Arrays, Linear Algebra, Vector Ops MatPlotLib - Data Plotting SciPy - Optimization, Scientific functions TITLE OF PRESENTATION 2 What is Numpy? 3rd
More informationIntroduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College
Introduction to Matlab to Accompany Linear Algebra Douglas Hundley Department of Mathematics and Statistics Whitman College August 27, 2018 2 Contents 1 Getting Started 5 1.1 Before We Begin........................................
More information2.1 Indefinite Loops. while <condition>: <body> rabbits = 3 while rabbits > 0: print rabbits rabbits -= 1
2.1 Indefinite Loops The final kind of control flow is Python s indefinite loop, the while loop. It functions much like the for loop in that it repeatedly executes some body of statements. The difference
More informationHow to use Excel Spreadsheets for Graphing
How to use Excel Spreadsheets for Graphing 1. Click on the Excel Program on the Desktop 2. You will notice that a screen similar to the above screen comes up. A spreadsheet is divided into Columns (A,
More informationA New Cyberinfrastructure for the Natural Hazards Community
A New Cyberinfrastructure for the Natural Hazards Community 1 DesignSafe-ci Vision A CI that is an integral and dynamic part of research discovery Cloud-based tools that support the analysis, visualization,
More informationIntroduction to Python and NumPy I
Introduction to Python and NumPy I This tutorial is continued in part two: Introduction to Python and NumPy II Table of contents Overview Launching Canopy Getting started in Python Getting help Python
More informationpython 01 September 16, 2016
python 01 September 16, 2016 1 Introduction to Python adapted from Steve Phelps lectures - (http://sphelps.net) 2 Python is interpreted Python is an interpreted language (Java and C are not). In [1]: 7
More informationNumerical Calculations
Fundamentals of Programming (Python) Numerical Calculations Sina Sajadmanesh Sharif University of Technology Some slides have been adapted from Scipy Lecture Notes at http://www.scipy-lectures.org/ Outline
More informationCourse May 18, Advanced Computational Physics. Course Hartmut Ruhl, LMU, Munich. People involved. SP in Python: 3 basic points
May 18, 2017 3 I/O 3 I/O 3 I/O 3 ASC, room A 238, phone 089-21804210, email hartmut.ruhl@lmu.de Patrick Böhl, ASC, room A205, phone 089-21804640, email patrick.boehl@physik.uni-muenchen.de. I/O Scientific
More information4. BASIC PLOTTING. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman
4. BASIC PLOTTING JHU Physics & Astronomy Python Workshop 2016 Lecturer: Mubdi Rahman INTRODUCING MATPLOTLIB! Very powerful plotting package. The Docs: http://matplotlib.org/api/pyplot_api.html GETTING
More informationDSC 201: Data Analysis & Visualization
DSC 201: Data Analysis & Visualization Python and Notebooks Dr. David Koop Computer-based visualization systems provide visual representations of datasets designed to help people carry out tasks more effectively.
More informationIntroduction to the workbook and spreadsheet
Excel Tutorial To make the most of this tutorial I suggest you follow through it while sitting in front of a computer with Microsoft Excel running. This will allow you to try things out as you follow along.
More informationAppendix A. Introduction to MATLAB. A.1 What Is MATLAB?
Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system
More informationIntroduction to Matlab
What is Matlab? Introduction to Matlab Matlab is software written by a company called The Mathworks (mathworks.com), and was first created in 1984 to be a nice front end to the numerical routines created
More informationcosmos_python_ Python as calculator May 31, 2018
cosmos_python_2018 May 31, 2018 1 Python as calculator Note: To convert ipynb to pdf file, use command: ipython nbconvert cosmos_python_2015.ipynb --to latex --post pdf In [3]: 1 + 3 Out[3]: 4 In [4]:
More informationCISC 1600 Lecture 3.1 Introduction to Processing
CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists
More informationSTAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006
STAT 39 Handout Making Plots with Matlab Mar 26, 26 c Marina Meilă & Lei Xu mmp@cs.washington.edu This is intended to help you mainly with the graphics in the homework. Matlab is a matrix oriented mathematics
More informationGetting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text
Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go
More informationAdditional Plot Types and Plot Formatting
Additional Plot Types and Plot Formatting The xy plot is the most commonly used plot type in MAT- LAB Engineers frequently plot either a measured or calculated dependent variable, say y, versus an independent
More information1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman
1. BASICS OF PYTHON JHU Physics & Astronomy Python Workshop 2017 Lecturer: Mubdi Rahman HOW IS THIS WORKSHOP GOING TO WORK? We will be going over all the basics you need to get started and get productive
More information: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics
Assignment 1: Turtle Graphics Page 1 600.112: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics Peter H. Fröhlich phf@cs.jhu.edu Joanne Selinski joanne@cs.jhu.edu Due Date: Wednesdays
More informationCollections. Lists, Tuples, Sets, Dictionaries
Collections Lists, Tuples, Sets, Dictionaries Homework notes Homework 1 grades on canvas People mostly lost points for not reading the document carefully Didn t play again Didn t use Y/N for playing again
More informationActivity: page 1/10 Introduction to Excel. Getting Started
Activity: page 1/10 Introduction to Excel Excel is a computer spreadsheet program. Spreadsheets are convenient to use for entering and analyzing data. Although Excel has many capabilities for analyzing
More information06/11/2014. Subjects. CS Applied Robotics Lab Gerardo Carmona :: makeroboticsprojects.com June / ) Beginning with Python
CS95003 - Applied Robotics Lab Gerardo Carmona :: makeroboticsprojects.com June / 2014 Subjects 1) Beginning with Python 2) Variables 3) Strings 4) Basic arithmetic operators 5) Flow control 6) Comparison
More informationPART 1 PROGRAMMING WITH MATHLAB
PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment
More informationChemistry Excel. Microsoft 2007
Chemistry Excel Microsoft 2007 This workshop is designed to show you several functionalities of Microsoft Excel 2007 and particularly how it applies to your chemistry course. In this workshop, you will
More informationLogical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression.
What is the answer? >> Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression. The finite(x)is true for all finite numerical
More informationIntroduction to Scientific Computing with Python, part two.
Introduction to Scientific Computing with Python, part two. M. Emmett Department of Mathematics University of North Carolina at Chapel Hill June 20 2012 The Zen of Python zen of python... fire up python
More informationExcel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller
Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing
More informationQUICK INTRODUCTION TO MATLAB PART I
QUICK INTRODUCTION TO MATLAB PART I Department of Mathematics University of Colorado at Colorado Springs General Remarks This worksheet is designed for use with MATLAB version 6.5 or later. Once you have
More informationCommand Line and Python Introduction. Jennifer Helsby, Eric Potash Computation for Public Policy Lecture 2: January 7, 2016
Command Line and Python Introduction Jennifer Helsby, Eric Potash Computation for Public Policy Lecture 2: January 7, 2016 Today Assignment #1! Computer architecture Basic command line skills Python fundamentals
More informationPython for Analytics. Python Fundamentals RSI Chapters 1 and 2
Python for Analytics Python Fundamentals RSI Chapters 1 and 2 Learning Objectives Theory: You should be able to explain... General programming terms like source code, interpreter, compiler, object code,
More informationInteractive Mode Python Pylab
Short Python Intro Gerald Schuller, Nov. 2016 Python can be very similar to Matlab, very easy to learn if you already know Matlab, it is Open Source (unlike Matlab), it is easy to install, and unlike Matlab
More informationTitle and Modify Page Properties
Dreamweaver After cropping out all of the pieces from Photoshop we are ready to begin putting the pieces back together in Dreamweaver. If we were to layout all of the pieces on a table we would have graphics
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 4 Visualising Data Dr Richard Greenaway 4 Visualising Data 4.1 Simple Data Plotting You should now be familiar with the plot function which is
More informationThe Mathcad Workspace 7
For information on system requirements and how to install Mathcad on your computer, refer to Chapter 1, Welcome to Mathcad. When you start Mathcad, you ll see a window like that shown in Figure 2-1. By
More informationFlow Control: Branches and loops
Flow Control: Branches and loops In this context flow control refers to controlling the flow of the execution of your program that is, which instructions will get carried out and in what order. In the
More informationWriting and Running Programs
Introduction to Python Writing and Running Programs Working with Lab Files These instructions take you through the steps of writing and running your first program, as well as using the lab files in our
More informationwindrose Documentation Lionel Roubeyrie & Sebastien Celles
Lionel Roubeyrie & Sebastien Celles Sep 04, 2018 Contents: 1 Install 3 1.1 Requirements............................................... 3 1.2 Install latest release version via pip...................................
More informationTechnology Assignment: Scatter Plots
The goal of this assignment is to create a scatter plot of a set of data. You could do this with any two columns of data, but for demonstration purposes we ll work with the data in the table below. You
More informationEpisode 8 Matplotlib, SciPy, and Pandas. We will start with Matplotlib. The following code makes a sample plot.
Episode 8 Matplotlib, SciPy, and Pandas Now that we understand ndarrays, we can start using other packages that utilize them. In particular, we're going to look at Matplotlib, SciPy, and Pandas. Matplotlib
More informationStandardized Tests: Best Practices for the TI-Nspire CX
The role of TI technology in the classroom is intended to enhance student learning and deepen understanding. However, efficient and effective use of graphing calculator technology on high stakes tests
More informationSequences: Strings, Lists, and Files
Sequences: Strings, Lists, and Files Read: Chapter 5, Sections 11.1-11.3 from Chapter 11 in the textbook Strings: So far we have examined in depth two numerical types of data: integers (int) and floating
More informationPython Matplotlib. MACbioIDi February March 2018
Python Matplotlib MACbioIDi February March 2018 Introduction Matplotlib is a Python 2D plotting library Its origins was emulating the MATLAB graphics commands It makes heavy use of NumPy Objective: Create
More informationCOMP 364: Computer Tools for Life Sciences
COMP 364: Computer Tools for Life Sciences Using libraries: NumPy & Data visualization with MatPlotLib Christopher J.F. Cameron and Carlos G. Oliver 1/27 Key course information Midterm I how was it? too
More informationOffice 2016 Excel Basics 01 Video/Class Project #13 Excel Basics 1: Excel Grid, Formatting, Formulas, Cell References, Page Setup (O16-13)
Office 2016 Excel Basics 01 Video/Class Project #13 Excel Basics 1: Excel Grid, Formatting, Formulas, Cell References, Page Setup (O16-13) Topics Covered in Video: 1) Excel file = Workbook, not Document
More informationHomework 11 - Debugging
1 of 7 5/28/2018, 1:21 PM Homework 11 - Debugging Instructions: Fix the errors in the following problems. Some of the problems are with the code syntax, causing an error message. Other errors are logical
More informationCS1110 Lab 1 (Jan 27-28, 2015)
CS1110 Lab 1 (Jan 27-28, 2015) First Name: Last Name: NetID: Completing this lab assignment is very important and you must have a CS 1110 course consultant tell CMS that you did the work. (Correctness
More informationGet comfortable using computers
Mouse A computer mouse lets us click buttons, pick options, highlight sections, access files and folders, move around your computer, and more. Think of it as your digital hand for operating a computer.
More informationPython Crash Course Numpy, Scipy, Matplotlib
Python Crash Course Numpy, Scipy, Matplotlib That is what learning is. You suddenly understand something you ve understood all your life, but in a new way. Doris Lessing Steffen Brinkmann Max-Planck-Institut
More informationMOVING FROM CELL TO CELL
VCAE: EXCEL Lesson 1 Please send comments to Author: Zahra Siddiqui at zed_ess@hotmail.com Concepts Covered: Cell Address; Cell Pointer; Moving across Cells Constants: Entering, Editing, Formatting Using
More informationModels for Nurses: Quadratic Model ( ) Linear Model Dx ( ) x Models for Doctors:
The goal of this technology assignment is to graph several formulas in Excel. This assignment assumes that you using Excel 2007. The formula you will graph is a rational function formed from two polynomials,
More informationAPPM 2460 PLOTTING IN MATLAB
APPM 2460 PLOTTING IN MATLAB. Introduction Matlab is great at crunching numbers, and one of the fundamental ways that we understand the output of this number-crunching is through visualization, or plots.
More informationVariables and Constants
87 Chapter 5 Variables and Constants 5.1 Storing Information in the Computer 5.2 Declaring Variables 5.3 Inputting Character Strings 5.4 Mistakes in Programs 5.5 Inputting Numbers 5.6 Inputting Real Numbers
More informationA. Python Crash Course
A. Python Crash Course Agenda A.1 Installing Python & Co A.2 Basics A.3 Data Types A.4 Conditions A.5 Loops A.6 Functions A.7 I/O A.8 OLS with Python 2 A.1 Installing Python & Co You can download and install
More informationGraphing on Excel. Open Excel (2013). The first screen you will see looks like this (it varies slightly, depending on the version):
Graphing on Excel Open Excel (2013). The first screen you will see looks like this (it varies slightly, depending on the version): The first step is to organize your data in columns. Suppose you obtain
More informationProgramming for Non-Programmers
Programming for Non-Programmers Python Chapter 2 Source: Dilbert Agenda 6:00pm Lesson Begins 6:15pm First Pillow example up and running 6:30pm First class built 6:45pm Food & Challenge Problem 7:15pm Wrap
More informationComputer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14
Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14 Scan Converting Lines, Circles and Ellipses Hello everybody, welcome again
More informationMatlab Introduction. Scalar Variables and Arithmetic Operators
Matlab Introduction Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic. It is a large software package that has many advanced
More informationProgramming with Python
Programming with Python EOAS Software Carpentry Workshop September 21st, 2016 https://xkcd.com/353 Getting started For our Python introduction we re going to pretend to be a researcher studying inflammation
More informationINTViewer Tutorial Cube Tutorial
INTViewer Tutorial Cube Tutorial This tutorial shows how to use INTViewer to display a seismic cube stored in a Seismic file. Windows created will include INLINE, XLINE, Time Slice and an arbitrary traverse,
More informationAbout the Tutorial. Audience. Prerequisites. Copyright & Disclaimer
i About the Tutorial Project is a comprehensive software suite for interactive computing, that includes various packages such as Notebook, QtConsole, nbviewer, Lab. This tutorial gives you an exhaustive
More informationIntroduction to Scientific Programming in MATLAB
Introduction to Scientific Programming in MATLAB Derrick Kearney HUBzero Platform for Scientific Collaboration Purdue University Original slides by Michael McLennan This work licensed under Creative Commons
More information