We chose to develop our package based on ENSO data, as climate change is expected to intensify impacts from El Nino and La Nina. We created two functions to summarize the monthly ENSO data from 1950-2018 (which ranges from -3 to 3 and is based on sea surface temperature monitoring) and three functions to estimate weather impacts and costs from increased risk of environmental disturbances.
Data sources: NOAA ESRL
1) Summary functions - enso_extremes(): Function that finds the minimum/maximum values from the data set - enso_plot() Function that graphs the data over time
2) Impact calculation functions - predict_precip(): Function that predicts precipitation in Port Moresby, Papua New Guinea based on ONI (The oceanic nino index). Function works by using a linear model of precipitation as a function of ONI index score from historical data. The user inputs an index score, and the output will be predicted rainfall in inches. - predict_temp(): Function predicts temperature in Port Moresby, Papua new Guinea based on ONI and month. Function works by using a linear model from historical data. The user inputs an index score and month (which must be entered numerically, 1 for January, 2 for February, etc.)
3) Cost estimation function - enso_cost(): Function which estimates annual natural disaster damage costs in Papua New Guinea which could be attributed to El Nino. The International Monetary Fund found that at baseline, Papua New Guinea is at 81.1% risk of a natural disaster in a given year, and that mean damages of disasters are equal to .3% of PNGs GDP. For the purposes of this assignment, let's assume research finds that when it is an El Nino season (defined as a period where ONI > .05) every increase in 1 ONI point results in an equivellent 6% increase increase in the risk of a mean damage causing storm. This function calcualtes expected increase in El Nino attributed damgage costs based on this assumption and the GDP of of Papua New Guinea.
https://www.imf.org/en/Publications/WP/Issues/2018/05/10/The-Economic-Impact-of-Natural-Disasters-in-Pacific-Island-Countries-Adaptation-and-45826
knitr::opts_chunk$set(echo = TRUE) library(tidyverse) library(zoo) library(here) library(roxygen2) library(devtools) install_github("molly-williams/enso") library(enso) library(testthat) devtools::build()
# Import data from ONI databse (NOAA ESRL) as a multi-dimensional array enso_data_raw <- read_delim( "data/enso_data_raw.csv", delim = ",", col_types = cols(.default = col_character()) ) # Organize and tidy ## Each row has a single ONI value for a month and year enso_data <- enso_data_raw %>% tidyr::gather(key="month", value="ONI", -(year)) %>% dplyr::transmute(year = parse_double(year), month = parse_double(month), ONI = parse_double(ONI)) enso_data <- mutate(enso_data, date=with(enso_data, sprintf("%d-%02d", year, month))) use_data(enso_data, overwrite = TRUE) # Adding weather data from Port Moresby, Papua New Guinea, taken from NOAA data tool and creating a dataframe which contains monthly ONI value along with Precipitation and Temperature for every month available (up tell 2003) weather <- read_csv("data/port_moresby_weather.csv") colnames(weather)[colnames(weather)=="DATE"] <- "date" port_moresby <- left_join(weather, enso_data, by = "date") port_moresby$month <- as.factor(port_moresby$month)
#Function which reterms min and max ONI values in dataset enso_extremes(enso_data)
#Functions which returns a plot of ONI score overtime, we used a smooth lined plot which helps us visualize long term trends in ONI levels (i.e., are there changes with climate change?) # Plot uses geom_smooth, with blue line representing the average and gray area representing the range of ONI data enso_plot(enso_data)
#precipitation function, user inputs ONI only, result is in monthly rainfall in inches predict_precip(port_moresby, ONI = 1) predict_precip(fake_oni_data, ONI = 1)
#temperature function, user inputs ONI and month, where 1 corresponds to January, 2 to February, etc. predict_temp(port_moresby, ONI = 3, month = 12)
#See explanation of function above, #Expected costs = Risk * Mean Damage of Storm in Papua New Guinea #Suppose increase in 1 point of ONI, once it's El Nino, results in 6% increase in risk of mean storm enso_costs(ONI = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.