Join David Gassner for an in-depth discussion in this video Introducing Lake Pend Oreille, part of Code Clinic: C#.
Hello and welcome to Code Clinic. My name is David Gasner. Code Clinic is a monthly course, where a unique problem is introduced to a collection of lynda.com authors. In response, each author will create a solution using their programing language of choice. You can learn several things from Code Clinic. Different approaches to solving a problem, the pros and cons of different languages, and some tips and tricks, to incorporate into your own coding practices.
This month, we'll work on a problem in statistical analysis, and to some extent, handling big data. Its common to use a computer, to manipulate and summarize large amounts of information. Providing important insights on how to improve or handle a situation. In this problem, we'll use weather data collected by the U.S. Navy, from Lake Pend Oreille in Northern Idaho. Lake Pend Oreille is the fifth deepest freshwater lake in the United States. So deep in fact, that the U.S. Navy uses it to test submarines.
As part of that testing, the U.S. Navy compiles an exhaustive list of weather statistics. Wind speed, air temperature, barometric pressure and so on. You can browse this data, by pointing your web browser at http://lpo.dt.navy.mil. You'll find several weather summaries, a webcam, and the raw data they collect every five minutes, archived as, standard text files. For anyone living or working on Lake Pend Oreille. Weather statistics are an important part of everyday life.
Average wind speed can be very different than median wind speed. Especially if you are on a small boat in the middle of the lake. In this challenge, each of our authors will use their favorite language, to calculate the mean and median of the wind speed, air temperature, and barometric pressure. Recorded at the Deep Moore station for a given range of dates. First, let's briefly review mean and median. These are both statistics. To explain statistics, we need a set of numbers.
How about 14 readings for wind gust at Deep More weather station on January 1st 2014. You can see the data at this web page. The first column in the data, is the day the wind gust was recorded. The second column is the time it was recorded, and the third column, is the wind gust in miles per hour. The mean, is also known as the average. To calculate the mean of a range of numbers, simply add the values in the set, then divide by the number of values.
In this example, we add 14, plus 14, plus 11 and so on. Then divide the sum by 14. The count, of the numbers in the set. In this case, the mean is equal to nine. The median, is the number halfway between all the values in a sorted range of values. Think of the median as in the median strip of the road. It always marks the center of the road. To calculate the median, first sort the numbers from lowest to highest. If there is an odd number of values, then just take the middle number.
If there's an even number of values, then calculate the average of the central two numbers. In this case, there's an even number of values so we sort, then take the average of the middle two values, eight and 11. The median is 9.5. Now, some authors have chosen to implement a web service, allowing other websites or other web service consumers, to access the new weather statistics created by the author's program. This is typically done by creating a RESTful API, which, when called, returns information in a format known as JSON.
I'll describe later on how you can call this web service in a variety of ways. When I make the web service call, I expect to receive the mean and median for windSpeed, airTemperature and barometricPressure for the range of dates. If I wanted the range of dates from January 1st to January 7th, I would simply change that value in the URL. And I would get back a different calculation. And when formatted in JSON, it looks like this. So there's our first challenge. Pulls statistics from a data set available online.
And then calculate them, creating aggregate values. Perhaps you want to pause and create a solution of your own. How would you solve the problem? In the following movies, I'll show you how I solved the challenge.
David introduces challenges and then provides an overview of his solutions in C#. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Visit other courses in the series to see how to solve the exact same challenges in languages like C++, Java, PHP, Python, and Ruby.
Skill Level Intermediate
Q: Why can't I access the Lake Pend Orielle site (http://lpo.dt.navy.mil)?
A: The Lake Pend Orielle site is not accessible in some geographical areas. We have contacted the owner of the server to try to resolve this issue.
Q: I am unable to access the Lake Pend Oreille data from outside the U.S.
A: A static copy of this data is provided here for lynda.com members outside of the U.S