# Python: An Introduction to Scientific Programming

## Installation

In these set of guides we will use the open-source Anaconda which is a Python distribution compiled for data scientists. It has the Spyder graphical user interface inbuilt as well as the numerical numpy, the fundamental package for scientific computing and matplotlib which is required for plotting. These can be used as an Open Source alternative to replace much of the functionality of the commercial software MATLAB.

## Python Basics: Using the IPython Console As a Basic Calculator

In this guide we look at some of the fundamentals of core python such as datatypes. These are numerical – integers (whole numbers) and floats (numbers with a decimal point), strings (text input) and Boolean (logical – true or false). We also look at the assignment of variables and the use of elementary mathematics between scalars. Some basic functions are also introduced.

## Python Basics: Scripts

Earlier we typed in all code in the IPython Console. Now we will have a look at using a script, with comments and how to print commands to the console.

## Python Basics: 0 Order Indexing

Python uses 0 order indexing. When starting with Python (particularly if one is used to MATLAB). we need to spend a moment relearn how to count to get used to zero order indexing.

## Scalars, Vectors and Matrices

In this guide we look further at some of the fundamentals of core python and examine numerical data in the form of a list. This list can be a scalar, vector, matrix, book or more complicated multi-dimensional array. We discuss some of the basics behind indexing and examining the dimensions of an array.

## Numerical Python: NumPy (Basics)

This section looks at using the Numerical Python NumPy to create vectors and matrices of data. It looks at indexing of rows or columns from such data, which is of course a perquisite when it comes to plotting. NumPy arrays for working with time (dates and duration) are also discussed.

## Numerical Python: Mathematical Operations

This section looks at using fundamental mathematical operations when working with scalars, vectors and matrices. It looks at element by element operations where each element in the array is treated individually for example in the operations of addition, subtraction, element by element division and element by element multiplication. It then moves on to look at the fundamentals behind array multiplication and array division. Finally it moves onto look at the use of a number of NumPy basic statistical functions which can be used with scalars, vectors and matrices.

## Introduction to Pandas

Pandas is used to create dataframes within Python which are like tables in Microsoft Excel. There are a number of advantages to creating a dataframe opposed to using a multi-column variable when it comes to sorting and organising data. We discuss how to import data from excel to a dataframe.

## Plotting

This section is all about plotting data, we revise some of the basics such as indexing a column within a variable, or selecting a column with a column. We start with a Histogram plot, the progress to a bar graph, piechart, line plot and scatter plot. Next we look at saving plots and axes to variables and how doing so allows us to modify a figure that has already been plotted. This gives us some of the perquisites to move onto 3D plotting, where we look at 2D contour plots and 3D contour plots, surface plots and wireframe plots. We also discuss the meshgrid function and discuss how we encode colour.

## Interpolation

In this section we look at a practical example. Here we practice linear algebra of matrices to interpolate a single point in a curve. We then see how we interpolate a series of points from a data curve using interpolation functions. This also reinforces some of the basics when it comes to plotting.

## Curve Fitting

In this section we look at curve fitting using the polyfit and polyval functions. Again this gives practice for plotting and here we also introduce subplotting.

## Trigonometry

Here we practice plotting using right angle triangles. We then plot a series of normalised right angle triangles on a circle to obtain the ratio of sides with respect to the angle. Then use rules of symmetry to obtain equally spaced values around the entire circle. This demonstrates the properties of the sin, cos and tan waveforms.

logical

test

## Python Intermediate: Creating a Custom Function

Here we will discuss how to define a custom function, how to load the custom function and how to run the custom function. We will discuss also the assignment of function input arguments and the creation of function output arguments.

## Python Intermediate: For Loop

In this section we look at using a for loop to automate some repetitive tasks. We see how we can use a for loop to perform the same calculations for a series of lines in a variable or dataframe. We also touch upon using For Loops for plotting.

## Integration and Differentiation

Here we visualise how we perform integration, employing indexing, plotting techniques and for loops.

## Not Complete Yet

Conditional Logic and While Loops

Use a for loop to save a series of frames of a figure while it rotates, see if there is a way to make a mp4 of it like in MATLAB

Use if, else, elseif to find the 2nd max, 3rd max, 4th max and their location etc etc do this under a for loop

Time/Date under Pandas

covariance after plotting?