- Create a data report project where you will need to find three data sets online to tell a data story that is supported by those data. What question are you going to work on? A topic related to the correlation of CO2 and climate change in certain location. Data research will be needed. Example projects include Greenhouse Gas.zip. Please turn this in as a zipped R project. Put your draft in an Rmarkdown file and include a compiled version of your report.
GreenhouseGas/GreenhouseGas_old.Rmd --- title: "Greenhouse gas and global temperature data report" author: date: "4/2/2020" output: html_document: toc: yes --- ```{r setUp, echo=FALSE, message=FALSE} library(tidyverse) source('R/readGISTempv4.R') source('R/readERSL_CO2.R') ``` # Introduction How to respond to climate change is one of the key challenges facing society. Warmer temperatures are causing more severe storms, hotter heat waves, and increases in wildfires. To understand how to respond to these challenges, it helps to understand what is driving climate change. Carbon dioxide is a well-established greenhouse gas who’s concentration has increased over time as we burn more and more fossil fuels. Carbon that had previously been locked up in oil and coal reserves are now instead blanketing the Earth as carbon dioxide. Over the last 50 years the Earth has seen a rise in both carbon dioxide concentrations and global temperatures. In this report we will examine the relationship between carbon dioxide and global temperatures, and try to see empirically how strong this effect is. # Methods We want data on the CO2 levels in the atmosphere for as long as we can get and global temperature records. We found CO2 levels from the Global Monitoring Division, Earth System Reserach Laboratory. Obsevervations by Dr. Pieter Tans, NOAA/ESRL (www.esrl.noaa.gov/gmd/ccgg/trends/) and Dr. Ralph Keeling, Scripps Institution of Oceanography (scrippsco2.ucsd.edu/). Download data [here](https://www.esrl.noaa.gov/gmd/ccgg/trends/data.html) We found global temperature data from Goddard Institute for Space Studies (NASA) specifically GISS Surface Temperature Analysis (GISTEMP v4) from [here](https://data.giss.nasa.gov/gistemp/), we downloaded the Combined Land-Surface Air and Sea-Surface Water Temperature Anomalies (Land-Ocean Temperature Index, LOTI):[Global-mean monthly, seasonal, and annual means, 1880-present, updated through most recent month](https://data.giss.nasa.gov/gistemp/tabledata_v4/GLB.Ts+dSST.txt). ```{r loadData, echo=FALSE, message=FALSE, warning=FALSE} ERSL_CO2 <- readersl_co2()="" gistemp="">-><- readgistempv4()="" ```="" ```{r="" cleandata,="" echo="FALSE," warning="FALSE}" ###co2="" data="" co2.df="">-><- ersl_co2$data[,="" 1:6]="" %="">% #leave off the last three columns that are recording old CO2 mutate(CO2 = gsub('-999.99', 'NA', CO2)) %>% #clean up the NA values mutate_all(as.numeric) #convert everything to numerical CO2.attr <- ersl_co2$meta[1:6,]="" ###temperature="" data="" temperature.df="">-><- gistemp$data[,1:13]="" %="">% #just take the year and months pivot_longer(col=-Year, names_to = 'month', values_to = 'temperature_index') %>% rename('year' = 'Year') %>% mutate(month = as.numeric(recode(month, 'Jan' = '1', 'Feb' = '2', 'Mar' = '3', 'Apr'= '4', 'May'='5', 'Jun'='6', 'Jul'='7', 'Aug'='8', 'Sep'='9', 'Oct'='10', 'Nov'='11', 'Dec'='12'))) #recode as opposed to pull the data since we did so much transforms on it. temperature.attr <- data.frame(column_name="c('year'," 'month',="" 'temperature_index'),="" description="c('year'," 'month',="" 'global="" land-ocean="" temperature="" index'),="" units="c('AD" calendar="" year',="" 'month="" index',="" '0.01="" degrees="" celsius="" change="" from="" 1951-1980'),="" stringsasfactors="FALSE)" ```="" ```{r="" mergingdata,="" echo="FALSE," message="FALSE," warning="FALSE}" data.df="">-><- co2.df="" %="">% #change everything to numbers group_by(year, month) %>% summarise(CO2 = mean(CO2, na.rm=TRUE), day_count = sum(day_count)) %>% full_join(temperature.df, by = c("year", "month")) data.attr <- co2.attr="" %="">% filter(column_name %in% c('year', 'month', 'CO2', 'day_count')) %>% bind_rows(temperature.attr[3,]) ``` # Results Both carbon dioxide levels and global temperature has increased over the last 50 years (see Figures 1 and 2). The carbon dioxide levels have been extremely regular in their variation, showing seasonal oscillations overlaid on a clear quasi-linear multi-decade trend (Figure 1). Global temperatures in contrast show a high degree of irregular noise on both the sub-annual and annual scales overlaying a quasi-linear trend (Figure 2). They have a loose correlation to each other, but there is not a clear one-to-one function (Figure 3). ```{r plotData, echo=FALSE, message=FALSE, warning=FALSE} ggplot(data.df %>% filter(is.finite(CO2)), aes(x=year+month/12, y=CO2)) + geom_line(color='grey') + geom_point() + labs(title= 'Figure 1: CO2 over time', x = 'Time', y= 'CO2 [ppm]') ggplot(data.df, aes(x=year+month/12, y=temperature_index)) + geom_line(color='grey') + geom_point()+ labs(title= 'Figure 2: Temperature index over time', x = 'Time', y= 'GLOBAL Land-Ocean Temperature Index \n[0.01 degrees Celsius change from 1951-1980]') ggplot(data.df) + geom_point(aes(x=CO2, y=temperature_index)) + labs(title = 'Figure 3: CO2 vs temperature index', x = 'CO2 [ppm]', y = 'GLOBAL Land-Ocean Temperature Index \n[0.01 degrees Celsius change from 1951-1980]') ``` # Discussion While it’s clear that both carbon dioxide and global temperature have been increasing over the past several decades, there are significant departures from the expected one-to-one correlation between the two measurements. During the 1950’s and 1980’s there are notable dips in global temperatures despite continual increase in carbon dioxide levels. In addition, the seasonal oscillations that are very apparent in the carbon dioxide data, disappear in the global temperature data. This implies that the climate system is complicated, and has other factors influencing global temperature. These could include energy locked up in more water vapor, shifts in albedo as ice melts and snow patterns shift, as well as the response of the land carbon cycle. While this does not disprove that carbon dioxide is a greenhouse gas, it does mean that we need a more complete understanding of the Earth system to predict future temperatures and make informed policy decisions around fossil fuel emissions. # Model 1) Is the start of the temperature record different then the end ```{r startEndComp} #look at the temperature for 1880-1889 and 2010-2019 plot.df <- temperature.df="" %="">% mutate(timePeriod = if_else(year < 1890,="" 'start',="" if_else(year=""> 2009, 'end', 'middle'))) %>% filter(timePeriod != 'middle') #the histograms are very different ggplot(plot.df) + geom_histogram(aes(x = temperature_index, fill = timePeriod)) #the T-test shows the distirbutions are unlikely to be the same firstDecade <- plot.df$temperature_index[plot.df$timeperiod="=" 'start']="" lastdecade="">-><- plot.df$temperature_index[plot.df$timeperiod="=" 'end']="" t.test(x="firstDecade," y="lastDecade)" ```="" #="" model="" 2)="" monthly="" co2="" concentrations="" across="" the="" 21st="" century="" -="" make="" seasonal="" points="" ```{r}="" #strong="" seasonality="" implied="" by="" plotting="" the="" co2="" over="" time="" and="" comparing="" it="" with="" plot="" over="" time="" broken="" out="" by="" month.="" ggplot(co2.df)="" +="" geom_line(aes(x="year" +="" month/12,="" y="CO2))" ggplot(co2.df)="" +="" geom_line(aes(x="year," y="CO2))" +="" facet_wrap(~month)="" #seasonal="" ossilations="" plus="" annual="" increase="" increasingco2a="">-><- function(mytime,="" parms="list(exp_coeff" =="" 10,="" exp_power="1.1," seasonal_amp="3," seasonal_offset="2/12," intercept="330)){" ans="">-><- parms$intercept + parms$exp_coeff * (mytime - 1974) ^ parms$exp_power - parms$seasonal_amp*cos((mytime+parms$seasonal_offset)*2*pi) } ggplot(data.frame(mytime = seq(1974, 2030, by = 1/12))) + geom_point(data=co2.df, aes(x=year + month/12, y=co2)) + #geom_line(aes(x=mytime, y=330+1*((mytime - 1974)^1.15)-3*cos((mytime+2/12)*2*pi)), color='red') #add by constant to increase y #geom_line(aes(x=mytime, y=330+10*exp((mytime - 1974)/23)-3*cos((mytime+2/12)*2*pi)), color='red') #add by constant to increase y geom_line(aes(x=mytime, y=increasingco2a(mytime, parms = list(exp_coeff = 1, exp_power = 1.15, seasonal_amp = 3, seasonal_offset = 2/12, intercept = 333))), color='red') + #add by constant to increase y geom_line(aes(x=mytime, y=increasingco2a(mytime, parms = list(exp_coeff = 1, exp_power = 1.15, parms$intercept="" +="" parms$exp_coeff="" *="" (mytime="" -="" 1974)="" ^="" parms$exp_power="" -="" parms$seasonal_amp*cos((mytime+parms$seasonal_offset)*2*pi)="" }="" ggplot(data.frame(mytime="seq(1974," 2030,="" by="1/12)))" +="" geom_point(data="CO2.df," aes(x="year" +="" month/12,="" y="CO2))" +="" #geom_line(aes(x="myTime," y="330+1*((myTime" -="" 1974)^1.15)-3*cos((mytime+2/12)*2*pi)),="" color='red' )="" #add="" by="" constant="" to="" increase="" y="" #geom_line(aes(x="myTime," y="330+10*exp((myTime" -="" 1974)/23)-3*cos((mytime+2/12)*2*pi)),="" color='red' )="" #add="" by="" constant="" to="" increase="" y="" geom_line(aes(x="myTime," y="increasingCO2a(myTime," parms="list(exp_coeff" =="" 1,="" exp_power="1.15," seasonal_amp="3," seasonal_offset="2/12," intercept="333)))," color='red' )="" +="" #add="" by="" constant="" to="" increase="" y="" geom_line(aes(x="myTime," y="increasingCO2a(myTime," parms="list(exp_coeff" =="" 1,="" exp_power="">- parms$intercept + parms$exp_coeff * (mytime - 1974) ^ parms$exp_power - parms$seasonal_amp*cos((mytime+parms$seasonal_offset)*2*pi) } ggplot(data.frame(mytime = seq(1974, 2030, by = 1/12))) + geom_point(data=co2.df, aes(x=year + month/12, y=co2)) + #geom_line(aes(x=mytime, y=330+1*((mytime - 1974)^1.15)-3*cos((mytime+2/12)*2*pi)), color='red') #add by constant to increase y #geom_line(aes(x=mytime, y=330+10*exp((mytime - 1974)/23)-3*cos((mytime+2/12)*2*pi)), color='red') #add by constant to increase y geom_line(aes(x=mytime, y=increasingco2a(mytime, parms = list(exp_coeff = 1, exp_power = 1.15, seasonal_amp = 3, seasonal_offset = 2/12, intercept = 333))), color='red') + #add by constant to increase y geom_line(aes(x=mytime, y=increasingco2a(mytime, parms = list(exp_coeff = 1, exp_power = 1.15,>->->->->->