USA: +1(715)227-4880, UK: +44-7896988486, AU:+61-452503850

# Assignment

Computing Skills Assignment Help

### USING JUPYTER NOTEBOOK PYTHON 3

Rating:

a

USING JUPYTER NOTEBOOK (PYTHON 3)

Fossil fuels and global temperatures¶

For this assignment we will be using data collected by the National Oceanic and Atmospheric Administration (NOAA) and by Carbon Dioxide Information Analysis Center (CDIAC), both US governmental science organizations.

The NOAA data consists of yearly global average temperatures, more specifically, the total land-and-sea global average which combines measurements on both land and sea. This temperature was around 13 °C in the last century although most datasets subtract this average to work with the deviation instead. This temperature is one of the main indicators for the warming of our planet in very recent history.

The CDIAC dataset (available here) lists CO2-emissions from fossil fuels, measured in thousand metric tons of carbon. The original dataset refines this data by nation and by type of fuel (solid, liquid, gas, etc.) but here we will only work with yearly totals.

1. The following code cell is supposed to read the dataset contained in 01-resources/temp-vs-fossil.csv and put the each column ("Year", "Temp", "Emissions") into the corresponding lists (years,temps,emissions). Complete the code so that it fulfills this task, the subsequent cell contains a test that must be passed!

In [8]:

years = []

temps = []

emissions = []

with open('01-resources/temp-vs-fossil.csv', 'r') as f:

it = iter(f)

next(it)

for l in it:

df=temp-vs-fossil()

array(['Year',Temp','Emissions])

print(type line

.split(','))

In [ ]:

### Do not change the code in this cell ###

fromIPython.core.display import HTML

try:

assert len(emissions) == len(years) and len(years) == len(temps), "Lists have wrong length"

print("List lengths okay")

assert all(isinstance(y, int) for y in years), "`years` data should be integers"

assert sum(years) == 262845, "`years` data is incorrect"

print("`years` okay")

assert all(isinstance(t, float) for t in temps), "`temps` data should be floats"

assert int(sum(temps)) == 1881, "`temps` data is incorrect"

print("`temps` okay")

assert all(isinstance(e, int) for e in emissions), "`emissions` data should be integers"

assert sum(emissions) == 386100147, "`emissions` data is incorrect"

print("`emissions` okay")

test = [int(sum(e))*(i**2) % 1000 for i,e in enumerate(zip(years,temps,emissions))]

assert sum(test[::2])-sum(test[1::2]) == -3848, "Lists are in wrong order"

print("Order okay")

display(HTML('<div class="okay">All tests passed!</div>'))

except AssertionError as msg:

display(HTML('<div class="errormsg">{}</div><div class="warn">Not all tests passed</div>'.format(msg)))

pass

Hint: Think about the data types we discussed, about whether the data is complete, what the range of the individual columns is.

Write your answer into this cell (~150 words). You can remove this text.

3. Complete the code in the next cell to plot the yearly temperatures (x-axis: time, y-axis: temperature). Make sure the axes of the plots are labelled correctly.

In [ ]:

importmatplotlib.pyplot as plt

plt.figure(figsize=(10,4))

# Complete the code here

4. Complete the code in the next cell to plot the yearly CO2 emission (x-axis: time, y-axis: emissions). Make sure the axes of the plots are labelled correctly.

In [ ]:

importmatplotlib.pyplot as plt

plt.figure(figsize=(10,4))

# Complete the code here

5. Compute the mean and the covariance of temps. Call the resulting variables tmean and tvar.

In [ ]:

# Use this cell to compute tmean and tvar

6. Compute the mean and the covariance of emissions. Call the resulting variables fmean and fvar.

In [ ]:

# Use this cell to compute fmean and fvar

7. Compute the covariance between temps and emissions. Call the resulting variable covar.

In [ ]:

# Use this cell to compute covar

If your computations are correct, the test in the following cell should pass.

In [ ]:

fromIPython.core.display import HTML

try:

assertisinstance(tmean, float), "`tmean` should be a float"

assert abs(tmean%10-3.9347) < 0.01, "Value of `tmean` is wrong"

print("`tmean` okay")

assertisinstance(tvar, float), "`tvar` should be a float"

assert abs(tvar%10 - 0.09346) < 0.001, "Value of `tvar` is wrong"

print("`tvar` okay")

assertisinstance(fmean, float), "`fmean` should be a float"

assert abs(fmean%10-1.088) < 0.001, "Value of `fmean` is wrong"

print("`fmean` okay")

assertisinstance(fvar, float), "`fvar` should be a float"

assert abs(fvar%10 - 7.9912) < 0.001, "Value of `fvar` is wrong"

print("`fvar` okay")

assertisinstance(covar, float), "`covar` should be a float"

assert abs(covar%10 - 2.83565) < 0.001, "Value of `covar` is wrong"

print("`covar` okay")

display(HTML('<div class="okay">All tests passed!</div>'))

except AssertionError as msg:

display(HTML('<div class="errormsg">{}</div><div class="warn">Not all tests passed</div>'.format(msg)))

pass

8. Given the values covar, fvar, and tvar compute the Pearson correlation coefficient for CO2 emissions by fossil fuels and the planetary temperature. Interpret the resulting value (~100 words) and describe what the Pearson correlation coefficients measures.

In [ ]:

# Use this cell to compute and output the correlations coefficient

Write your answer into this cell (~100 words). You can remove this text.

9. If you passed the above tests, the cell below should output a scatter plot of fossil fuel emission against global mean temperatures as well as a linear regression of these two variables. Describe and interpret this plot (~200 words). Feel free to quote external sources to supplement information.

In [3]:

plt.figure(figsize=(10,6))

xs, ys = temps, emissions

plt.scatter(xs, ys)

a = covar / tvar

b = fmean - a * tmean

xmin, xmax = min(xs), max(xs)

plt.xlabel('Global mean temperature (°C)')

plt.ylabel('Emissions from fossil fuels (carbon kilotonnes)')

plt.plot([xmin,xmax], [a*xmin + b, a*xmax + b], color='red', ls=":")

#### Details

• Number of views:
59
• PRICE :
AU\$ 60.00

### Our Top Experts

Holding a PhD degree in Finance, Dr. John Adams is experienced in assisting students who are in dire need...

55 - Completed Orders

Canada, Toronto I have acquired my degree from Campion College at the University of Regina Occuption/Desi...

52 - Completed Orders

Even since I was a student in Italy I had a passion for languages, in fact I love teaching Italian, and I...

102 - Completed Orders

To work with an organization where I can optimally utilize my knowledge and skills for meeting challenges...

109 - Completed Orders

JOB OBJECTIVE Seeking entry level assignments in Marketing & Business Development with an organization...

202 - Completed Orders

Current work profile Project manager- The Researchers Hub (2nd Jan 2016 to presently working) Researc...

20 - Completed Orders

Sales Assistant, Mito Marina Assigned to the Stationery dept – assisted in merchandising, stock taking...

100 - Completed Orders

Personal Profile Dedicated and highly experienced private chauffeur. High energy, hardworking, punctua...

200 - Completed Orders

I'm Lizzy, full time education specialist in English, Essay Writing, Economics and Maths. Having Assi...

109 - Completed Orders

HSC PREPARATION I specialise in English coaching programs for HSC students. My personalised and results-...

202 - Completed Orders