#!/usr/bin/env python # coding: utf-8 #

Mini-Project 0: Installation Test

#

MCHE513: Intermediate Dynamics

#

Dr. Joshua Vaughan
# joshua.vaughan@louisiana.edu
# http://www.ucs.louisiana.edu/~jev9637/

# In this notebook, we'll simply be testing that all the tools that we'll be using this semester have been installed correctly, while hopefully providing a simple first exercise with the Jupyter Notebook. # We'll first place a "watermark" that will display our system information. You should have followed the instructions on the lab handout to install this package. You can see more information about this package at: # # [https://github.com/rasbt/watermark](https://github.com/rasbt/watermark) # # If you haven't yet installed it, you can by issuing the command below from a terminal window: # # ```bash # conda install -c conda-forge watermark # ``` # # Many more examples of its use are included in [this example Jupyter Notebook](http://nbviewer.jupyter.org/github/rasbt/watermark/blob/master/docs/watermark.ipynb). # In[1]: # We first need to tell the Jupyter Notebook to load the extension get_ipython().run_line_magic('load_ext', 'watermark') # In[2]: # The base usage will tell us information about our machine and the version of Python we're using get_ipython().run_line_magic('watermark', '') # We can also use the options in the package to tell us about versions of specific python packages. In this case, we'll check the versions of the NumPy, SciPy, matplotlib, Jupyter Notebook, and Control packages. # In[3]: get_ipython().run_line_magic('watermark', '-v -m -p numpy,scipy,control,notebook,matplotlib') # The output of that command look similar to the first, but with the versions of the NumPy, SciPy, matplotlib, Jupyter Notebook, and Control packages indicated as well. Now, let's run some simple commands to double-check that everything is working. # # We'll first import NumPy, the set up the notebook for plotting using the matplotlib library. # In[4]: # Grab all of the NumPy functions with namespace np import numpy as np # In[5]: get_ipython().run_line_magic('matplotlib', 'inline') # Import the plotting functions import matplotlib.pyplot as plt # Let's plot an array of random numbers. We'll use the numeric portion of our CLID's as a "seed" for the random number generator. This will make the string of numbers *i.)* repeatable and *ii.)* unique to the seed value, meaning your plots will be unique to your CLID numerals. # # In the first code block below, change 1234 to be the numeric portion of your CLID. This creates a random number generator with that as the seed. Eliminate the leading zeros from the number, so that if your ULID is `C00123456`, you would change the seed to be `123456`. # In[6]: # Change 1234 to match the numeric portion of your ULID my_random_generator = np.random.RandomState(seed=123456) # Now, we'll use this generator to generate an array of 500 elements and plot them. # In[7]: my_random_numbers = my_random_generator.rand(500) # Generate 500 random numbers # Now, we'll plot them. Here, we'll just use the matplotlib defaults. # By default, no axis labels, etc are included. # Later, we'll generate nicer plots by modifying some of those defaults. plt.plot(my_random_numbers) # Now, let's import the scipy, sympy, and Control modules, just to check that they will load. If there were no errors from the: # # ```%watermark -v -m -p numpy,scipy,control,notebook,matplotlib``` # # command above, then they should load without any issue. # In[8]: import control # This will import the control library. We'll need to preface any commands from it with control. # In[9]: import scipy # This will import the scipy libary. We'll almost never import this entire library again. # In[10]: import sympy # This will import the sympy libary. We'll almost never import this entire library again. #
# # #### Licenses # Code is licensed under a 3-clause BSD style license. See the licenses/LICENSE.md file. # # Other content is provided under a [Creative Commons Attribution-NonCommercial 4.0 International License](http://creativecommons.org/licenses/by-nc/4.0/), CC-BY-NC 4.0. # In[11]: # This cell will just improve the styling of the notebook from IPython.core.display import HTML import urllib.request response = urllib.request.urlopen("https://cl.ly/1B1y452Z1d35") HTML(response.read().decode("utf-8"))