Exercise related to the course “Physics and Chemistry of Air Pollution and their Effects” This exercise is mandatory in order to pass the course. The main reason why we require all students to do this is to get everybody familiar with MATLAB (or other advanced data analysis software) and spend more time on data analysis than just learning the software. The course is short and intensive, so it is imperative to have some basic skills when the course starts. While doing this exercise you are (if not experienced) likely to get stuck a few times. When that happens then read the help files, search the internet, ask colleagues and succeed! Using MATLAB is a lot about determination. And – last, working together with your fellow students to solve this exercise is of course good, but do take the time to understand the problem and the solution on your own. The University of Helsinki provides its students and staff with MATLAB. It is recommended that you learn to use a software that you can continue using after the Hyytiälä course. If you do not have access to MATLAB (and even if you do), there are several freeware and open source alternatives available. To mention a few: - FreeMat (very MATLAB like) http://freemat.sourceforge.net/ - Octave (own MATLAB like language) http://www.gnu.org/software/octave/ - http://www.r-project.org/ - SageMath (Python language) http://sagemath.org/index.html - (very MATLAB like) http://www.scilab.org/

A lot more alternatives can be found e.g. at - http://www.freestatistics.info/en/stat.php - http://en.wikipedia.org/wiki/List_of_numerical_analysis_software Please learn at least the basics of your software BEFORE the course!

The task Use the supplied data file and to make a plot with

1. Daily averaged SO2 concentration and temperature at 67.2 m against the days of 1 January

2006 – 31 March 2006

2. Label axes (NB two y-axes!), put reasonable colours/dots for the variables

3. Save the figure and send it by e-mail to [email protected] latest by Monday, th March 14 . Feel free to include suggestions how this exercise could be improved.

st 4. There will be a short MATLAB session on on Monday, March 21 . The solution for this

exercise will be shown and discussed then.

Your end result should look something like Fig. 1. On the next page you will find an outline on how to solve the problem. The supplied file is a .dat file that contains a matrix that can be directly imported to Matlab either with the load (or similar) command or using the graphical interface. The file contains the following variables as half hourly averages for from 1 January 2006 to 30 June 2006. Download it from http://www.atm.helsinki.fi/ABS/courses/matlab_exdata_2011field_course.dat

Column 1 Column 2 Column 3 Time, YYYYMMDDHHmmss [SO2], ppb, 67,2 m T, qC, 67,2 m Data that you will be working on in the course will be formatted similarly but with many more columns/variables. Since you are likely to do these operations many times later in the course it is very well worth making m-files (functions) to do the routines.

Fig. 1. The result of the exercise.

In order to successfully make the plot you have to do something like this: x Load the data file

x Convert date and time to day of the year (day with decimals) by using the datenum and floor function.

o This is not straightforward. For example the time 21 January 2006, 12:43 is written as the number 2006012124300. To extract day from this use day=floor(rem(2006012112300,10^7)/10^5)

o For info on floor and rem see the help file

x Extract/delete entries from the matrix so that you are left with values from 1 Jan to 31 March.

x Calculate daily averages for each variable and put these together in a new matrix with date and the two variables as columns

o The reshape function will be invaluable here. Count the number of days and number of data points per day…

o Since data contains NaN then you cannot use normal mean function. Use nanmean. What is the danger by doing this?

o Note: nanmean is part of the statistical toolbox. If you do not have this one you get the equivalent (and better) files from http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=68 37&objectType=file

o Put together a new matrix with date/day, and mean [SO2] and T.

x Make a plot of both T and [SO2] against time. Use connected lines in the plot. Left hand y-axis should be SO2 concentration, right hand y-axis T in qC and x-axis time in days.