Homework 3 BMElib track
Starting with MATLAB and BMElib
Date given: 9/28
Due: 10/07 noon
Start MATLAB (preferably using version 7.x, but version 6.x will also work).
1) Use the help on the command line and explore the general functions of MATLAB (using >> help; then >> help general). Find the command that “List current variables”. Using the help for that command, describe very briefly what this command does.
2) Use the help on the desktop to open the Help dialog box. From that dialog box select and read the content of MATLAB à Getting Started. From what you have learned, explain very briefly how to edit a file (hint: See MATLAB à Getting Started à Desktop Tools and Development Environment à Desktop Tools à Editor/Debugger )
3) Use the help on the desktop to learn about the use of Matrices in MATLAB (hint: See MATLAB à Mathematics à Matrices and Linear Algebra). Use what you have learned to write a program that solves the following linear algebra problem to obtain the value of x :
Where A= and y=. Provide the MATLAB program you have written and the value of x.
Provide a succinct write up for this part 1 of the homework that answers the questions in 1), 2) and 3).
Install the BMElib version 2.0b numerical library by following the instructions in installingBMELIB2.0bInSPHlab.htm and run all the tutorials to get acquainted with BMElib functions. You will not be able to do this part of the homework if you do not install BMElib first. Then create a new directory and download in it the following MATLAB files MATLABtutorial.m, myfunc.m, create2relatedFields.m, ENVR468hwk3Part2.m. Start MATLAB and change your working directory to this new directory you have created.
1) Study MATLABtutorial.m in details by editing this file and executing it in MATLAB, until you understand each command of this file. It is very important that you learn each of these MATLAB commands in order to be able to follow this class!! You will need this knowledge to do this homework and the following ones. Note that MATLABtutorial.m is a program, while myfunc.m is a function. Explain what the main difference is. Could you execute MATLABtutorial.m without myfunc.m, and why?
2) Review and explain what the create2relatedFields.m function is doing (by using help and edit for this function).
3) Review the ENVR468hwk3Part2.m file. This program uses the create2relatedFields.m function to generate a pair of fields Z1 and Z2 that are somewhat related. We are interested in measuring the degree by which the fields Z1 and Z2 are related. One way to do this is to find the area of Z2 that is above some cutoff value, and calculate the fraction of that area overlapping the area where Z1 is above a given cutoff value. The cutoff values may be selected as the 90% quantile of Z1 and Z2. The ENVR167hwk3Part2.m achieves this by doing the following:
· It selects a relation coefficient and generate two related fields Z1 and Z2 using create2relatedFields.m
· It uses pcolor.m to create a check board color plot of Z1 and Z2.
· It obtains cutoff values for Z1 and Z2 corresponding to their 90% quantile ratio.
· It uses pcolor.m to plot the area where Z1 is greater than is cutoff value, and where Z2 is greater than is cutoff value.
· It calculates the fraction of area where Z2 is greater than it’s cutoff value that overlaps the area where Z1 is greater than its cutoff value.
Run this program. What is the value of the relation coefficient used to generate the fields Z1 and Z2, and what is the overlap fraction calculated? Modify the program using different relation coefficients, report the overlap ratio you are getting, and discuss the results you are getting. In particular is there a trend between the relation coefficient and the overlap ratio?
Provide a write up for this part 2 of the homework that addresses questions in 1), 2) and 3).
After doing Part 2 and learning MATLAB, go ahead and run again all the tutorials of BMElib. It is important that you run each tutorial now, and that you keep running them throughout the duration of the class to keep yourself updated.
Provide a write up for this part 3 of the homework explaining what machine you are using (type of computer, operating system), the version of MATLAB you are using (6.0 or higher), and state very briefly each of the tutorials of the BMElib package, and describe in more details the following tutorials:
The objective of this part of the homework is to start doing an exploratory analysis of a space/time dataset.
First get yourself familiar with the GeoEAS file format used to store datasets (for example see the help for the readGeoEAS.m function in the iolib directory of BMElib). Note that when considering monitored data coming from a fixed set of monitoring stations taking measurements at synchronized time events, then you can use text file in the GeoEAS format to store the space/time data in a table like manner. For example each line of the table may correspond to a monitoring station, while each column corresponds to a specific time event. An example of such file is COy.dat available at the Data For ENVR468 link on the class website.
Once you are familiar with this way of storing space/time data with text file in the GeoEAS format, then browse the Data For ENVR468 link located on the class website, and find a dataset in that format (other than the CO dataset above).
Perform an exploratory analysis on the dataset you have selected. To perform this exploratory analysis you will have to write a Matlab program using BMElib functions described in the IOLIBtutorial, GRAPHLIBtutorial and STATLIBtutorial. At a minimum, the exploratory data analysis should consist in reading the data file in BMElib and making maps of the data for different time events.
Provide a write up describing the dataset you have selected, explaining the exploratory data analysis you have conducted using all the figures you have created, and any findings resulting from the exploratory data analysis. Add as an appendix the program you have written to create all the figures in your write up.
Download the files Raritan_Phos.txt, exploreDataTutorial.m and raritan_river.e00. Run the exploreDataTutorial.m function to perform an exploratory analysis of the Phosphorus data on the Raritan river basin. Notice the use of the histogram of the data to display the distribution of the data. Then modify the input arguments to make temporal plots of the data for several monitoring stations, using no time aggregation, then monthly time aggregation, and finally yearly time aggregation. Then do spatial maps of the data using monthly and then yearly time aggregation. Finally answer the following question: Is the data normally distributed? What temporal aggregation duration do you think is better, and why? What’s the trade off between the monthly and yearly aggregation periods?
Once you have answered these questions, study the code for this function so you can write a similar one for your own purpose to complete the next part of this homework. Notice particularly how the data is transformed from a space/time vector to a space/time grid format (use the help for the stgridsyntax.m function to learn more about these two space/time data formats).
Select a space/time dataset of scientific interest that you will use as the basis for your class project. You may use the dataset created for homework 2, or you may use one from your own research, or you may browse for additional dataset from the Data for ENVR 468 link on the class website.
Create a GeoEAS data file with your dataset in space/time vector format, and write your own Matlab function to perform an exploratory data analysis of this dataset. Write a report describing your exploratory data analysis, provide all the relevant figures, discuss any findings, and provide in an appendix the function you have written which can reproduce all your figures.
Identify a research question that will serve as your proposal for the class project. For example provide background information about the space/time field of interest, describe the dataset available, formulate the general lines of the analysis you plan to perform, and describe the potential application of any findings.
Your answer will serve as a starting point to your class project.