From dc13208abd61cc3ac7c64a4373f3ad85689f1293 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Tue, 29 Apr 2025 18:38:21 -0600 Subject: Finished of module 1 tutorials (.md) and added documentation to module 2 --- book/module1/array.tex | 19 ++--- book/module1/jupyter_lab_notebook.tex | 131 ++++++++++---------------------- book/module1/spyder_getting_started.tex | 8 +- 3 files changed, 49 insertions(+), 109 deletions(-) (limited to 'book/module1') diff --git a/book/module1/array.tex b/book/module1/array.tex index c79c6c0..9482065 100644 --- a/book/module1/array.tex +++ b/book/module1/array.tex @@ -35,13 +35,7 @@ the value of the element as a property. In other words, if we were to analyze the stress concentration of an aluminum block, the property would be stress. -\begin{itemize} -\tightlist -\item - From - \href{https://numpy.org/doc/2.2/user/absolute_beginners.html}{Numpy - documentation} \includegraphics{figures/multi-dimensional-array.gif} -\end{itemize} +\includegraphics{figures/multi-dimensional-array.png} If the load on this block changes over time, then we may want to add a 4th dimension i.e.~additional sets of 3-D arrays for each time @@ -197,7 +191,7 @@ recorded as a function of time. \begin{Highlighting}[] \NormalTok{thrust\_lbf }\OperatorTok{=}\NormalTok{ np.array(}\FloatTok{0.603355}\NormalTok{, }\FloatTok{2.019083}\NormalTok{, }\FloatTok{2.808092}\NormalTok{, }\FloatTok{4.054973}\NormalTok{, }\FloatTok{1.136618}\NormalTok{, }\FloatTok{0.943668}\NormalTok{)} -\OperatorTok{\textgreater{}\textgreater{}\textgreater{}}\NormalTok{ thrust\_lbs[}\DecValTok{3}\NormalTok{]} +\BuiltInTok{print}\NormalTok{(thrust\_lbs[}\DecValTok{3}\NormalTok{])} \end{Highlighting} \end{Shaded} @@ -211,10 +205,7 @@ product - \texttt{np.matmul()} for matrix multiplication - \#\#\#\#\# Statistics - \texttt{np.mean()}, \texttt{np.median()}, \texttt{np.std()}, \texttt{np.var()} - \texttt{np.min()}, \texttt{np.max()}, \texttt{np.argmin()}, \texttt{np.argmax()} - -Summation along axes: \texttt{np.sum(arr,\ axis=0)} \#\#\#\#\# Combining -arrays - Concatenation: \texttt{np.concatenate((arr1,\ arr2),\ axis=0)} -- Stacking: \texttt{np.vstack()}, \texttt{np.hstack()} - Splitting: -\texttt{np.split()} +Summation along axes: \texttt{np.sum(arr,\ axis=0)} \subsection{Exercise}\label{exercise} @@ -256,9 +247,9 @@ point must be zero. \subparagraph{System of Equations:}\label{system-of-equations} -\{RA+RB−10−15−20=05(10)+10(15)+15(20)−20RB=020RA−5(10)−10(15)−15(20)=0 - +\[ \begin{cases} R_A + R_B - 10 - 15 - 20 = 0 \\ 5(10) + 10(15) + 15(20) - 20 R_B = 0 \\ 20 R_A - 5(10) - 10(15) - 15(20) = 0 \end{cases} +\] \subsubsection{Solution}\label{solution} diff --git a/book/module1/jupyter_lab_notebook.tex b/book/module1/jupyter_lab_notebook.tex index 5c06f5d..c08fd74 100644 --- a/book/module1/jupyter_lab_notebook.tex +++ b/book/module1/jupyter_lab_notebook.tex @@ -21,32 +21,6 @@ Terminal: \texttt{conda\ install\ conda-forge::jupyterlab} \subsection{Notebook Basics}\label{notebook-basics} -\begin{itemize} -\tightlist -\item - Creating a new notebook (\texttt{.ipynb}) -\item - Types of cells: - - \begin{itemize} - \tightlist - \item - Code - \item - Markdown - \item - Raw - \end{itemize} -\item - Running a cell: \texttt{Shift\ +\ Enter} -\item - Adding/removing cells -\item - Restarting the kernel -\item - Saving and auto-checkpoints -\end{itemize} - Jupyter Notebooks are files which allows you to combine \emph{Code} and \emph{Markdown} cells in one single document. The code cells, allow you to interactively run python code and print and plot data in your @@ -100,7 +74,8 @@ affects the results of any cells that use that variable afterward --- but not any previously run results unless you rerun them too. Variables and imports persist in memory between cells, but only based on the current session state --- if you restart the kernel, you lose all -previous definitions unless you re-run the necessary cells. +previous definitions unless you re-run the necessary cells. Therefore, +let's press the \texttt{Restart\ the\ kernel} button on the top window.3 Because of this, it's best practice to; Run cells in order, restart the kernel and run all cells @@ -109,85 +84,57 @@ everything works cleanly and predictably and lastly, initialize important variables or imports in early cells, so they are always defined before they are needed. -\subsection{Writing and Running Code}\label{writing-and-running-code} +\subsection{Making your document look good with +Markdown}\label{making-your-document-look-good-with-markdown} -\begin{itemize} -\tightlist -\item - Python syntax: - \texttt{print("Hello,\ world!")} - Variables and - functions - Loops and conditionals -\item - Importing libraries: - \texttt{import\ numpy\ as\ np} - - \texttt{import\ pandas\ as\ pd} - - \texttt{import\ matplotlib.pyplot\ as\ plt} -\end{itemize} +Creating titles or headers is done with the hash symbol. The number of +hashes determines whether it's a sub-title \texttt{\#}, \texttt{\#\#}, +\texttt{\#\#\#} -\subsection{Using Markdown}\label{using-markdown} +\subsubsection{Lists}\label{lists} + +There are two types of list in - Bullet lists: \texttt{-\ item} - +Numbered lists: \texttt{1.\ item} \#\#\# Style - Emphasis: +\emph{italic}, \textbf{bold}, \texttt{monospace} \#\#\# Mathematical +Equation Markdown supports LaTeX format equations. Inline equation is +opened and closed with a single \texttt{\$}. For a block math a double +\texttt{\$\$} is used instead of single. \begin{itemize} \tightlist \item - Headers: \texttt{\#}, \texttt{\#\#}, \texttt{\#\#\#} -\item - Bullet lists: \texttt{-\ item} -\item - Numbered lists: \texttt{1.\ item} -\item - Emphasis: \emph{italic}, \textbf{bold}, \texttt{monospace} + Inline: This equation is inline \texttt{\$E\ =\ mc\^{}2\$} in with the + markdown text. \item - LaTeX equations: - - \begin{itemize} - \tightlist - \item - Inline: \texttt{\$E\ =\ mc\^{}2\$} - \item - Block: - \texttt{\$\$\textbackslash{}int\_0\^{}\textbackslash{}infty\ e\^{}\{-x\^{}2\}\ dx\ =\ \textbackslash{}frac\{\textbackslash{}sqrt\{\textbackslash{}pi\}\}\{2\}\$\$} - \end{itemize} -\item - Embedding links and images + Block: Whilst this is a block: + \texttt{\$\$\textbackslash{}int\_0\^{}\textbackslash{}infty\ e\^{}\{-x\^{}2\}\ dx\ =\ \textbackslash{}frac\{\textbackslash{}sqrt\{\textbackslash{}pi\}\}\{2\}\$\$} + \#\#\# Links and images You can insert links to a different local file + or online urls like this: {[}Link{]}(file.md). I insert an image it's + the same however start with an exclamation mark \texttt{!} like this: + !{[}Image Caption{]}(picture.png) \end{itemize} -\subsection{Interactive Widgets -(optional)}\label{interactive-widgets-optional} - -Install \texttt{ipywidgets} from your package manager - -\begin{Shaded} -\begin{Highlighting}[] -\ImportTok{import}\NormalTok{ ipywidgets }\ImportTok{as}\NormalTok{ widgets} -\NormalTok{widgets.IntSlider()} -\end{Highlighting} -\end{Shaded} - -Example using interact: +\subsection{Exporting and Sharing}\label{exporting-and-sharing} -\begin{Shaded} -\begin{Highlighting}[] -\ImportTok{from}\NormalTok{ ipywidgets }\ImportTok{import}\NormalTok{ interact} -\NormalTok{interact(}\KeywordTok{lambda}\NormalTok{ x: x}\OperatorTok{**}\DecValTok{2}\NormalTok{, x}\OperatorTok{=}\DecValTok{5}\NormalTok{)} -\end{Highlighting} -\end{Shaded} +To export your notebook go to -\subsection{Exporting and Sharing}\label{exporting-and-sharing} +\texttt{File} \textgreater{} \texttt{Download\ As} -By default, jupyter auto-saves your notebooks as you work. +You can then select these options. \begin{itemize} \tightlist \item - File \textgreater{} Download As: - - \begin{itemize} - \tightlist - \item - Notebook (\texttt{.ipynb}) - \item - HTML - \item - PDF (requires LaTeX) - \item - Markdown - \end{itemize} + Notebook (\texttt{.ipynb}) +\item + HTML +\item + PDF (requires LaTeX) +\item + Markdown \end{itemize} + +For homework assignments, download an HTML version of your document, +then from your browser, save or print as a PDF. Alternatively, you can +install the LaTeX typesetting system and export your document directly +as PDF from jupyter. diff --git a/book/module1/spyder_getting_started.tex b/book/module1/spyder_getting_started.tex index 70a3d41..3133b15 100644 --- a/book/module1/spyder_getting_started.tex +++ b/book/module1/spyder_getting_started.tex @@ -86,9 +86,11 @@ computations, assign and modify variables. \item Display of Matplotlib graphics in Spyder's \href{https://docs.spyder-ide.org/5/panes/plots.html}{Plots} pane, if - the Inline backend is selected under Preferences ‣ IPython console ‣ - Graphics ‣ Graphics backend, and inline in the console if Mute inline - plotting is unchecked under the Plots pane's options menu. + the Inline backend is selected under \texttt{Preferences} + \textgreater{} \texttt{IPython\ console} \textgreater{} + \texttt{Graphics} \textgreater{} \texttt{Graphics\ backend}, and + inline in the console if Mute inline plotting is unchecked under the + Plots pane's options menu. \end{itemize} \subsubsection{Variable Explorer}\label{variable-explorer} -- cgit v1.2.3