BWI Climate Data Analysis with MatLab

SO503 Spring 2013


We will investigate the PGO (Professor Guth Oscillation), which proposes that severe snowfall occurs at BWI every year Professor Guth has a sabbatical (AY 95-96, 02-03, and 09-10).  These are the years with the greatest snowfall on record. 

This will be due at 1330 on Tues 5 March 2013.

There is an m file to get you started.  The main learning point of this lab is to create a double loop, which this sample does, and deal with nasty climate data in matrix format.

Modified BWI temperature file for easy import to Matlab.  This came from (link now broken).  The website has the average monthly temperatures at the bottom of the table; you can either get them from the web, or compute them in Matlab or Excel.

The sample program uses a double loop to create time and temperature vectors.  If you are feel adventurous, you could import this data as a matrix instead of vectors, and shorten the program substantially. 

Matlab resources.

Much of the buzz about our weather has blamed El Nino.  You can get the SOI (Southern Oscillation Index) at:

Get the data, clean it up if required, and import it into Matlab.  Call it the SOI.

To compare the BWI data with the SOI, we want to compute the monthly deviation in temperature (the anomaly) from average temperature for that month.  Positive values will be higher than normal, and negative values lower.  We will call this the BWI temperature anomaly. Note that  you can get monthly averages.

There is an NAO, Northern Oscillation Index, that might be more relevant to our snow

Adjust the SOI and BWI temperature anomaly so they have the same length (they are much longer than the NAO).  This will be your long time series.

Adjust all the time series so they start at the same time, and end at the same time.   These will be your short time series.

Perform cross correlations for (insure that you get the symbol for squared, and not the ^2 or "squared" in your discussion).  Get both the maximum and minimum r values, and the lags were each occurs.


Create graphs with the following, in a format that they can be quickly compared to see if there are any relationships:

Discuss what these show, including the results of your cross correlations. 

Discuss whether the temperature variability is better shown as the temperature readings below, or as the anomaly.


You are likely to encounter two types of errors:

  1. Syntax errors.  You will write something that Matlab does not like, and it will not go past the offending line.  You should look in the command window, where you should see a message.  Part of debugging is learning what the various messages mean.  These are usually (at least with experience) the easier class of error to correct.
  2. Logic errors.  Matlab has no problems with what you commanded, but when it does the computations, you get bad results.  In this case, looking at either a graph of the results, or the array editor (click on your new variables in the workspace panel to bring it up).  In this case you should be able to follow the monthly temperatures and see how they are being entered in the final array.
This shows the results from the time and temp arrays.

While the graph looks fine (see below), there is actually a subtle error here in the time column.

Look carefully at rows 4 and 5, or 16 and 17.  You now have to go back to your code, and see what you did wrong.