Outline Preparing data sets CTD Data from Tomales Bay Clean up Binning Combined Temperature Depth plots T S scatter plots Multiple plots on a single figure What haven't you learned in this class?
Preparing Data Data needs to be prepped for loading into matlab. Comment out all extraneous (usually non number) material that matlab can't use. Make sure there are no empty elements fill with missing data. Use a consistent symbol or marker for problem data If you are using excel, I suggest looking into the Matlab Excel Toolbox, particularly for time series data. Lets you pull and push data from excel to matlab Converts times and dates to matlab format for you You will still need to have relatively clean and organized data
Example: CTD data from Tomales Bay CTD stands for conductivity, temperature, depth. Measures temperature and salinity (as well as other things) as a function of depth underwater. Lowered into water from a boat on a rope down to a certain depth and then raised. Take a look at a data file in z:\pkg\wfcb\class5\data\tomales to see format. I have modified the files somewhat so they can easily be loaded. Meanings of each column are specified in the header of the files.
Basic plot A standard and interesting plot from a CTD is temperature (along the x axis) vs. depth (along the y axis) Exercise: Do this plot for the data file 13Oct2005_2108.cnv Hint: You will probably want to reverse the direction of the depth so that deeper is at the bottom. Correct plot is on next slide.
Depth / Temperature plot (5) At surface (1) Calibration (4) Surface Stratification (2) Downcast (3) Upcast
Cleaning up data Typically, only downcast is used as it is generally more accurate and has quicker response time. Also, need to remove calibration data near surface. Manufacturer has lots of GOOD programs to do this, but basic stuff can be done in matlab. Exercise: Remove upcast data and data within 0.5 meters of surface. Put code in a script so that you can later do it for all data files. Finally replot. Hint: Use the maximum depth to define split between down and up. Exercise 2: Make a function that would do this data cleanup for an arbitrary data matrix.
Binning data The next step is to bin data into depth bins. Again, manufacturer has programs for this. Exercise: Bin data so by the average value over every 0.5 meters starting at 0.5 meters depth. Then replot. Hint: Make a list of bin starting and ending points and then step through the list and compute average values. Hint: You will need to check to see if a bin actually has data. If not, then use NaN. continue might be useful for doing this. Exercise 2: Make a function that would do the binning for an arbitrary data matrix.
Loading in all the data So now that we know how to process one dataset, how about all of them. Files are numbered: 06 is at Tomales mouth, 08 is 2 km from mouth,..., 15 is 18 km from mouth. Exercise: Load and process all of the data files. As there are only ten, you could do each one separately. Or, you could use a more advanced approach and load them all using iteration. Hint: If doing each separately, cut & paste in a script. Hint: If using iteration, you might use a cell array to store filenames. Hint: Use a 3 D array to store all the results.
Combined Temperature Depth Plots Exercise: Plot all the Temp Depth curves on a single figure with a different color for each curve. Add a legend. Hint: This can be done with a single plot command if you pull out the appropriate data. The squeeze command might be useful. Or, you can use a for loop. Hint: You might want to use the jet command to get nice color. Exercise: Do the same thing for Salinity Depth and Fluorescence Depth. Do you see any patterns?
T S Scatter Plot Exercise: Using very similar techniques to the previous exercises, you can make a scatter plot of temperature vs. salinity. Hint: Use a 'linestyle' of '.'
Multiple axes on a single figure You can use the subplot command to put more than one set of plots on a single figure window. An example is:» clf» subplot( 1, 2, 1 )» plot( 1:10 )» subplot( 1, 2, 2 )» plot( (1:10).^2 ) Exercise: Can you use this model to place the T Depth figures on the left and the S Depth figures on the right.
What haven't you learned? I just want to point out a few things I haven't really taught in this class that might be of interest: Strings and cell arrays: These are quite important for dealing with text information Structures in more depth Debugging: Really important. There are some notes in class 4 related to this. 3D Graphics Exporting Figures to files Graphical User Interfaces (GUI): You can make interactive graphs. Look at guidetemplate for an example. Object oriented Programming: Often useful for modeling.