Archives: MS1 - MS2 - MS3 - MS4 - MS5
At the beginning of this project, we were placed into team number one. Our team consists of Allyson Clark, Ben Green, Matthew Rydzik, and Tyler Ruff. For the first milestone our team leader was Allyson Clark. During this milestone, we decided on the team name of ‘Kiveo’. Our work will be displayed on the server http://kiveo.coaster-net.com.
Our program can be used to read data either on the provided server or on a personal server. After running the milestoneone.m file with the data in the correct remote location, the program will prompt the user for the year they wish to view. If the user enters a year within the range of data (1983 to 2005), the program will bring up a second menu; if not, they are prompted once again to enter a year found in the data. This time, the user is prompted to pick what type of graph they would like to view: time versus intensity, radii of tangential winds versus intensity, latitude versus intensity, and longitude versus intensity. Each graph displays the data for a single storm within the year. For example, if the user chose 1983 and then ‘p’ for time versus intensity, four graphs are brought up, one for each of the four storms in 1983. After the user enters a choice for a plot, they are asked whether or not they would like to graph a second plot. If they enter no, the program then asks if they would like to choose a different year. If the user enters no again, the program is finished. If they chose yes, then the program runs a second time, going through the process once more.
To complete the above process, our program goes through a series of steps. First of all, the program reads in the data from a specified location using the textread function. As a group, we chose to use the .txt version of the data provided because the .xls version of the file will not record string values. The data is read into thirteen different arrays that correspond to the different categories given. The rest of the code is contained within a while loop, based on if a variable corresponds to the character ‘y’ or not. The while loop allows the user to choose another year after they finish viewing the graphs for the year they specified originally.
The bulk of our coding comes from separating the data from the original arrays they were sorted into in the textread function. We realized that we would need to separate data by the storm it came from and decided to use a for loop to accomplish this. For example, we started work with the year 1983. First, the program finds where the value 1983 occurs in the array with storm years using the find function. The indices values were then stored in a separate array. In an if loop, the program compares value in the original storm name array in the first index as defined by the above step with the storm name found in the next index. If the two match, then a variety of values are stored in arrays. If they do not match, then the program moves to the next column and begins to fill that column with data. We separated storm name, time storm occurred, tangential wind radius, radius winds at 34 knots, radius of winds at 50 knots, radius of winds at 64 knots, latitude storms occurred, and the longitude that the storms occurred. The time the storm occurred was stored using the datenum function. We input the year, month, day, and hour that correspond to the index value and MATLAB changed it into a value. Because all of the code in the loops to store the various data was the same, we created a separate m file to store the code. Using the run function, MATLAB reads this second m file when directed in the if loop. We also realized that the loop would not function properly for the last value in the data set. To compensate for this, we defined a second if loop that would place the last value at the end of the last column automatically.
Our next task, now that our data was stored in new arrays, separated into columns by storm name, was to make the data readable and available. We decided to graph the data in four general categories: by time versus intensity, by radius versus intensity, by latitude versus intensity, and by radius versus longitude. To ensure that a user could graph only the plots they wanted to view, we placed all the code in a while loop. This let the user specify if they wanted a view a graph. Next, we separated the graph types into four different if loops, where a different loop would run based on what the user input.
If the user input was, for example, a ‘p’, the first if loop will run. In each loop is a function call that refers to an m-file with the code for just that graph type. In the tplot function, four variables are sent to the function: a counter, the time of the storms, the storm name, and the intensity of the storm. The counter variable is used to define how many rows are in each column corresponding to a storm name. The length of the counter array is how many storms occurred in one year. Using these values as endpoints on our loops, we were able to plot the graphs. Each individual storm comes up in a new window to allow for clarity and legibility. We used two functions in conjunction to create our x-axis in this category: datetick and xticklabel_rotate. Datetick takes the numerical value that was calculated using datenum and turns it into a date in the style day-month-year hour-minutes-second. Because each tick on the x-axis was long, we decided to slant the labels using a function we found on the Internet. The xticklabel_rotate function was written by Alexander Haubold from Columbia University and slants the labels by a specified degree. We also named the graphs using array with the storm names.
The graphs for radius versus intensity were more complicated. Because there are four different radii in the original data set, we decided to graph all four different kinds. We wanted to keep them together so a user could compare the various types. We decided to use the subplot feature in MATLAB to accomplish this. Also, a linear regression line is drawn on the first two plots: radius of tangential winds versus storm intensity and radius of 34 knot winds versus storm intensity. We chose to create a linear regression line for these two plots only because they showed the highest amount of correlation; we saw no distinct pattern in the other two plots. In fact, there was quite a bit of data missing from the second two plots so it would not be helpful or accurate to look at the regression of this data. To make the regression line, we used a combination of the polyval and polyfit functions in MATLAB. To make sure the regression line was an accurate description of the data, we removed 0 values that were added by MATLAB to make a rectangular array. We accomplished this by making a temporary array of the non-zero data for each plot. Because missing data is stored as the value -999, we set the axis to start at a more logical value based on the data we were graphing. This prevented MATLAB from plotting any -999s found in a column, making the graphs more representative of the data collected in a certain area. As in the time versus intensity plot, each individual storm in a year comes up in a separate window.
The last two choices of graphs are a combination of the above two graphs. The radius versus latitude and radius versus longitude graphs use subplots to compare the four different radii also. The functions run like the time versus intensity graph, simply plotting the two variables. As in the radii versus intensity graphs, we defined the x-axis to start at a specific point to allow for a better fit. Because there was data missing for a few of the storms in this category also, the plots are now easier to read and display the data more clearly for eliminating the -999 found in the data sets.
To finish off our code for this milestone, we capped the two while loops found in the program: the one that controls the graphing menu and the original loop that controls the year.
Read text file into matlab and separate into different arrays
Divide each array based on year and storm that the data belongs to
Used subplots to display similar graphs in one window
Used functions to clean up code
Created a linear regression of radius of tangential winds vs intensity and radius of 34 knot winds vs intensity using polyfit and polyval
Used datenum, datetick, and xticklabel_rotate to display time stamps on x-axis
Used while loops and user inputs to allow for user control of the program
Used string compare to separate out data based on the storm it was gathered from
Used plot and scatter functions to display data
Graphs of various variables:
Time vs intensity
Radius of tangential winds vs intensity
Radius of 34 knot winds vs intensity
Radius of 50 knot winds vs intensity
Radius of 64 knot winds vs intensity
Radius of tangential winds vs latitude
Radius of 34 knot winds vs latitude
Radius of 50 knot winds vs latitude
Radius of 64 knot winds vs latitude
Radius of tangential winds vs longitude
Radius of 34 knot winds vs longitude
Radius of 50 knot winds vs longitude
Radius of 64 knot winds vs longitude