if ('tidyverse' %in% rownames(installed.packages()) == 'FALSE') install.packages('tidyverse')
if ('noaaoceans' %in% rownames(installed.packages()) == 'FALSE') install.packages('noaaoceans')
if ('cowplot' %in% rownames(installed.packages()) == 'FALSE') install.packages('cowplot')
if ('lubridate' %in% rownames(installed.packages()) == 'FALSE') install.packages('lubridate')
if ('rnoaa' %in% rownames(installed.packages()) == 'FALSE') install.packages('rnoaa')
if ('daymetr' %in% rownames(installed.packages()) == 'FALSE') install.packages('daymetr')
if ('heatwaveR' %in% rownames(installed.packages()) =='FALSE') install.packages('heatwaveR')
if ('tiff' %in% rownames(installed.packages()) == 'FALSE') install.packages('tiff')
“Air temperature and tide data Air temperature and tide level data was obtained from various sources depending on the location. Hourly temperature and tide data for Toke Point and Port Townsend and tide data from Neah Bay and Budd Inlet was obtained from publically available National Oceanic and Atmospheric Administration (NOAA) tide station data using the ‘rnoaa’ package in R (Chamberlin et al. 2021, R Core Team 2021). Hourly temperature and tide data for Vancouver and tide data for Pruth Bay was obtained from publically available Department of Fisheries and Oceans (DFO) Canada tide station data. Air temperature data for Pruth Bay was obtained from the Hakai Institute weather station (Giesbrecht et al. 2021). Air temperature data for Neah Bay was obtained from a weather station on nearby Tatoosh Island, WA (C. Pfister and T. Wootton personal communication). Air temperature data for Budd Inlet was obtained from the nearby Evergreen State College weather station. If raw data was reported at time scale less than one hour, mean hourly temperature was calculated. These data can be accessed two ways, both of which are available (Raymond, 2022). There, static data files are archived as well as code to query and process them if necessary. Long term, 1991 – 2020, air temperature data was obtained from the National Aeronautical and Space Agency (NASA) DAYMET surface temperature database using the ‘daymetr’ package in R (Hufkens 2021). We extracted maximum and minimum daily surface air temperatures from 2° latitude by 2° longitude grids. Grids were selected by the location of the hourly temperatures/tide stations above. These are Toke Point 46.7499° N -124.0250°W, Budd Inlet 47.0643°N -122.9106°W, Neah Bay 48.3770°N -124.6897°W, Port Townsend and Vancouver 48.1172°N -122.7890°W, and Pruth Bay 51.6271°N -127.6450°W. From this raw daily data, long term daily mean high and low temperatures were calculated. Code to obtain and processes these data in the R environment are available (Raymond, 2022).”
archived in Zenodo https://zenodo.org/records/6555076
https://github.com/wraymond/Ecology_heatwave-salish-sea-shellfish/tree/v1.0
Install packages
Load libraries
library(noaaoceans)
Warning: package 'noaaoceans' was built under R version 4.2.3
library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.2.3
Warning: package 'ggplot2' was built under R version 4.2.3
Warning: package 'tidyr' was built under R version 4.2.3
Warning: package 'readr' was built under R version 4.2.3
Warning: package 'purrr' was built under R version 4.2.3
Warning: package 'stringr' was built under R version 4.2.3
Warning: package 'forcats' was built under R version 4.2.3
Warning: package 'lubridate' was built under R version 4.2.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.2 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(cowplot)
Warning: package 'cowplot' was built under R version 4.2.3
Attaching package: 'cowplot'
The following object is masked from 'package:lubridate':
stamp
library(lubridate)
library(rnoaa)
Warning: package 'rnoaa' was built under R version 4.2.3
The rnoaa package will soon be retired and archived because the underlying APIs have changed dramatically. The package currently works but does not pull the most recent data in all cases. A noaaWeather package is planned as a replacement but the functions will not be interchangeable.
library(daymetr)
Warning: package 'daymetr' was built under R version 4.2.3
library(heatwaveR)
Warning: package 'heatwaveR' was built under R version 4.2.3
library(tiff)
Warning: package 'tiff' was built under R version 4.2.3
theme_set(theme_classic())
Load Data
Import NOAA tide and weather station data
# NOAA Air temp data from Toke Point, Port Townsend #
<- c("9440910", "9444900")
noaa.air.stations <- data.frame()
air.temp for (i in noaa.air.stations) {
<- query_coops_data(station_id = i,
query.df2 start_date = '20210624',
end_date = '20210701',
data_product = 'air_temperature',
units = "metric",
time_zone = "lst_ldt",
interval = 'h')
<- air.temp %>% bind_rows(., query.df2)
air.temp }
Registered S3 method overwritten by 'httr':
method from
print.cache_info hoardr
## Water Levels ##
# NOAA Water levels from Toke Point, Port Townsend, Neah Bay, and Budd Inlet #
<- c("9440910", "9444900", "9443090", "9446807")
noaa.tide.stations <- data.frame()
water.level for (i in noaa.tide.stations) {
<- query_coops_data(station_id = i,
query.df3 start_date = '20210624',
end_date = '20210701',
data_product = 'predictions',
units = "metric",
datum = "MLLW",
interval = "h",
time_zone = "lst_ldt")
<- water.level %>% bind_rows(., query.df3)
water.level }
Load Gridded climate data
Pull from Daymet 2 X 2 degree surface grid. https://daymet.ornl.gov/getdata
## Olympia ##
<- download_daymet(site = "olympia", lat = 47.064316, lon = -122.910577, start = 1991, end = 2020, internal = TRUE) oly.grid
Downloading DAYMET data for: olympia at 47.064316/-122.910577 latitude/longitude !
Done !
## Port Townsend + Vancouver BC ##
<- download_daymet(site = "port_townsend", lat = 48.1172, lon = -122.789, start = 1991, end = 2020, internal = TRUE) ptv.grid
Downloading DAYMET data for: port_townsend at 48.1172/-122.789 latitude/longitude !
Done !
## Neah Bay ##
<- download_daymet(site = "neah_bay", lat = 48.377, lon = -124.6897, start = 1991, end = 2020, internal = TRUE) nhb.grid
Downloading DAYMET data for: neah_bay at 48.377/-124.6897 latitude/longitude !
Done !
## Toke Point ##
<- download_daymet(site = "toke_point", lat = 46.7499, lon = -124.025, start = 1991, end = 2020, internal = TRUE) tkp.grid
Downloading DAYMET data for: toke_point at 46.7499/-124.025 latitude/longitude !
Done !
## Calvert Island ##
<- download_daymet(site = "calvert_island", lat = 51.6271, lon = -127.645, start = 1991, end = 2020, internal = TRUE) cvi.grid
Downloading DAYMET data for: calvert_island at 51.6271/-127.645 latitude/longitude !
Done !