stock_env: Compile ECSA Data.

Description Usage Arguments Details Value Examples

View source: R/stock_env.R

Description

This function aggregates data for stock-specific ecosystem context reporting. Data that can be accessed include surface and bottom temperature and salinity, chlorophyll concentration, zooplankton abundance, and occupancy probability for the US Northeast Shelf.

Usage

1
2
stock_env(variable, type = NULL, season, genus = NULL, svspp,
  mask_type, xlab, interpo = F, ylab, ylim = NULL, plt = F)

Arguments

variable

Can be "chlorophyll", "temperature", "salinity", "zooplankton", "occupancy hab", or "occupancy prob".

type

Specific to temperature and salinity variables. Either "bottom" or "surface".

season

Either "spring" or "fall".

genus

Specific to zooplankton. Can be one of "centropages", "temora", or "pseudocalanus".

svspp

Input svspp code for species of interest.

mask_type

Specifies raster masking behavior. Can be one of "nes", "gom", "gbk", "sne", or "unit". If mask is "unit", then returned time series reflect stock boundaries drawn from depth strata.

xlab

Plot labels if plt = T.

interpo

Logical. If missing values should be interpolated linearly. Current not functional.

ylab

Plot y label if plt = T.

ylim

Vector in the form of c(min,max) to specifiy y limits if plt = T.

plt

Plots output rather than returning a data frame of results.

Details

Data for this function are currently limited to american lobster (svspp = 301), summer flounder (svspp = 103), and jonah crab (svspp = 312). Occupancy habitat is limited to summer flounder only.

Value

If plt = F, a data frame containing time series of compiled data is returned.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#USAGE --------------------------------------------------------------------------

sf1 <- stock_env(variable = "salinity",type = "surface",
                  season = "spring", svspp = 103, mask_type = "unit")
ss1 <- stock_env(variable = "salinity",type = "surface",
                 season = "fall", svspp = 103, mask_type = "unit")

bf1 <- stock_env(variable = "salinity",type = "bottom",
                 season = "spring", svspp = 103, mask_type = "unit")
bs1 <- stock_env(variable = "salinity",type = "bottom",
                 season = "fall", svspp = 103, mask_type = "unit")
                 
#Plotting example ---------------------------------------------------------------
surface <- rbind(sf1, ss1)
bottom <- rbind(bf1, bs1)

xmin <- rbind(min(surface$Time),min(bottom$Time))
xmin <- min(xmin)

#Y scales can be adjusted by adding 'scales' argument to facet_wrap.
library(ggplot2);library(gridExtra)
s_plt <- ggplot(data = surface, aes(x = Time, y = Value)) +
  ylab("Surface Salinity (PSU)") +
  xlab("") +
  xlim(xmin, NA) +
  geom_line() +
  geom_point() +
  facet_wrap(Season ~., nrow = 1, scale = 'free_y') +
  theme_bw() +
  theme(plot.title = element_blank(),
        strip.background = element_blank(),
        strip.text.x = element_blank()) +
  annotate("text", label = c("A","B"), x = xmin, y = Inf, vjust = 1.5, size = 5)

b_plt <- ggplot(data = bottom, aes(x = Time, y = Value)) +
  ylab("Bottom Salinity (PSU)") +
  xlab("Year") +
  xlim(xmin, NA) +
  geom_line() +
  geom_point() +
  facet_wrap(Season ~., nrow = 1, scale = 'free_y') +
  theme_bw() +
  theme(plot.title = element_blank(),
        strip.background = element_blank(),
        strip.text.x = element_blank()) +
  annotate("text", label = c("C","D"), x = xmin, y = Inf, vjust = 1.5, size = 5)

grid.arrange(s_plt, b_plt, nrow = 2)

#Do not include "type" when calling CHL, zooplankton, or occupancy:
#CHL-----------------------------------------------------------------------------
cs1 <- stock_env(variable = "chlorophyll",
                 season = "spring", svspp = svspp, mask_type = "unit")
cf1 <- stock_env(variable = "chlorophyll",
                 season = "fall", svspp = svspp, mask_type = "unit")
chl <- rbind(cs1, cf1)
xmin <- rbind(min(chl$Time),min(chl$Time))
xmin <- min(xmin)
ggplot(data = chl, aes(x = Time, y = Value)) +
    ylab("Chlorophyll mg m^-3") +
    xlab("") +
    xlim(xmin, NA) +
    geom_line() +
    geom_point() +
    facet_wrap(Season ~., nrow = 1, scale = 'free_y') +
    theme_bw() +
    theme(plot.title = element_blank(),
        strip.background = element_blank(),
        strip.text.x = element_blank()) +
    annotate("text", label = c("A","B"), x = xmin, y = Inf, vjust = 1.5, size = 5)
    
#Zooplankton --------------------------------------------------------------------
ct1 <- stock_env(variable = "zooplankton", genus = "centropages",
                 season = "spring", svspp = 103, mask_type = "unit")

ct2 <- stock_env(variable = "zooplankton", genus = "centropages",
                 season = "fall", svspp = 103, mask_type = "unit")

t1 <- stock_env(variable = "zooplankton", genus = "temora",
                 season = "spring", svspp = 103, mask_type = "unit")

t2 <- stock_env(variable = "zooplankton", genus = "temora",
                 season = "fall", svspp = 103, mask_type = "unit")

ps1 <- stock_env(variable = "zooplankton", genus = "pseudocalanus",
                season = "spring", svspp = 103, mask_type = "unit")

ps2 <- stock_env(variable = "zooplankton", genus = "pseudocalanus",
                season = "fall", svspp = 103, mask_type = "unit")

NOAA-EDAB/ECSA documentation built on Oct. 24, 2020, 2:21 p.m.