Data Analysis & Reporting

Programming

Computational scripts can greatly aid the analysis of data, particularly where the same analysis is to be carried out for multiple sets of data. The sections below contain pre-written scripts which can be used and edited in order to carry out data analysis. The scripts below are all written in Python, and are clearly commented to allow the user to understand the operations being carried out.

Running Scripts

The Python scripts are written to be operating system agnostic, and should perform the same functions regardless of the operating system environment used to run the script. Guides are given below for some operating systems:


Running Python Scripts - Windows (PDF) ↓ 

Running Python Scripts - Linux (PDF) ↓

Test Scripts

This is a test script which can be used to ensure the computer being used to execute scripts is performing correctly. The script imports various libraries, providing a success message after each import. On completion of all libraries being imported a message will be displayed indicating that you have a correctly configured environment for Python which is capable of running the other scripts included in this collection.


Script for testing Python installations (Python) ↓


The following libraries are imported as required packages. You should seek help if your setup reports failure for the importing of any of these.



The following packages are also imported, which are used with only a small number of scripts. If your setup reports that any of these libraries have not imported this is not usually a problem.



For instance, serial, is used for some scripts which interact with hardware in the laboratory. If you have issues with scripts using serial, please consult a senior demonstrator in the lab.

Graph Plotting and Non-linear Regression

This script reads in data from CSV files and outputs plotted graphs, and can be run on single, multiple or all CSV files within a directory.


Script for graph plotting and non-linear regression (Python) ↓


The script accepts filenames as arguments, eg:



The script includes a number of configurable options which can be set in the script including:



The script is capable of carrying out calculations on the data prior to plotting. This might be a simple unit conversion, eg time in minutes to time in seconds, where x = x*60, or might involve more complex functions.The document below contains some example calculations. The calculations are using numpy. If you wish to perform an arithmetic function not listed in the support document, try searching 'numpy' and the function you wish to use.


Example functions (PDF) ↓

File Format Conversion

These scripts convert file formats for data collected from instruments into alternative file formats for subsequent data processing.


Shimadzu Fluorimetry


Shimadzu Fluorimetry SPC to DX (Python) ↓

Shimadzu Fluorimetry SPC to XLSX (Python) ↓


Shimadzu UV-Probe


Shimadzu UV-Probe SPC to DX (Python) ↓

Shimadzu UV-Probe KIN to DX (Python) ↓

Constructing a photometer using an Arduino

These scripts are used for the lab practical for constructing a photometer. The PySerial library is required for this script.


The take_measurement.py script reads serial data sent to the computer from the Arduino. The script will need the interface variable editing to reflect the hardware setup of the specific computer (see below for information about determining hardware interfaces).

Take Measurement Script (Python) ↓


The arduino_photometer.ino is an Arduino script which runs on the Arduino, configuring the device to send serial data from pin A0 to the computer.

Arduino Photometer Script (Arduino Sketch) ↓


To determine the hardware interface being used by the Arduino, the following python command can be run:

python -m serial.tools.list_ports -v