Description: In this assignment, you will practice what you have learned about file handling and the CSV library in python as well as plotting data.

computer science

Description

CS 490 DB - Applications in Natural Sciences

Assignment 2

Description: In this assignment, you will practice what you have learned about file handling and the CSV library in python as well as plotting data.  

Submission Instructions: 

- You must submit your work on schoology via pdf using the latex template provided here: 

https://github.com/trevortomesh/assignmentTemplate

If you have any questions about how to use latex, do not hesitate to ask!

- Organize your submission in the order that the questions are asked.

        Always comment your code! There is no excuse for poorly commented code!

Deliverables: 

     - Your code write-up with your source code in the appendix.

     - Screenshot of the plot produced within the body of the code write-up 

     - Output of your text file for 2c in appendix

Background: 
Climate change stands out as one of the most troubling and contentious issues of the 21st century. Still, few people outside of the disciplines of climatology and glaciology have actually worked with the datasets. Below is the GISTEMP surface temperature plot that most people are familiar with. This plot shows a clear upward trend in the global annual temperature since 1880. 

This plot is the product of direct measurements of surface temperatures. However, to assess temperatures from the distant past, we analyze the content of oxygen-18 isotopes and deuterium frozen within ancient ice-core samples. These samples come from deep within the ice of Antarctica. The Vostok Ice Cores, (named after Vostok, Antarctica where they have been taken from) represent some of the most complete longitudinal global temperature Data points, going back some 400,000 years before present (BP)!

In this assignment, you will use your knowledge of python file handling and the CSV library as well as plotting and error handling to work with the raw data from the Vostok ice cores and to produce a plot of global temperature over a far greater time range than presented in the GISTEMP data. 

 

Part 1) Getting and Importing Data

a) Download the Vostok Ice Core Data from here:

 https://cdiac.ess-dive.lbl.gov/ftp/trends/temp/vostok/vostok.1999.temp.dat 

It's also a good idea to read the accompanying literature which can be found here: https://cdiac.ess-dive.lbl.gov/trends/co2/ice_core_co2.html

b) Use the CSV library to import the depth, age of the ice, Deuterium content and temperature variation into separate lists. 

c) Check for the following exceptions: 
- Does the file exist? 

Part 2) Transforming data and writing to a file

As it is, the data is in ascending order by "age of ice". In other words, it starts in the year 2000 and goes back through time.  

a) Transform the data so that it is organized by year starting with   BC and ending with 2000 AD. The values of the zeroth element in each of the lists (depth[0], year[0], deuterium[0], tempVariation[0]) should then be:

3310   -422766       -436.6        0.23

and the very last values in each of these lists should be: 

   0      2000       -438.0        0.00

b) The GISTEMP plot has a "5 year average" trend line. To compute a proportional trend line for the Vostok data, we should compute a new list that calculates a 10,000 year average. This means that you'll have only ~42 data points in this list. 

c) Write these transformed values out to a file so that others can benefit from your work in the future! Note: you will need to decide how to write out the 42 data points from the 10,000 year average to match up with the appropriate time periods! There are a few ways you might choose to do this. 

Part 3) Plotting your data

a) import matplotlib

b) From the data that you've stored in your lists, plot temperature variation over time and the 10,000 year average over time using matplotlib. This should be done on the same graph so that your plot looks like the plot given by GISTEMP above. 

c) Be sure to label your axes and provide a legend for your plot that identifies what each set of points is showing. Take a screenshot of your plot.  

The resulting plot will show an interesting trend. What you see are known as "Milankovic Cycles". Feel free to research Milankovic cycles as well as other drivers of the Earth's climate and draw your own informed conclusions! 

 


Related Questions in computer science category