-
Notifications
You must be signed in to change notification settings - Fork 0
/
Phytoplankton.Rmd
133 lines (101 loc) · 2.6 KB
/
Phytoplankton.Rmd
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
title: "Phytoplankton dynamics"
author: "Jens Daniel Müller"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output:
workflowr::wflow_html:
number_sections: true
toc_depth: 3
toc_float:
collapsed: false
editor_options:
chunk_output_type: console
---
```{r global_options, include = FALSE}
knitr::opts_chunk$set(warning=FALSE, message=FALSE)
```
```{r packages}
library(tidyverse)
```
```{r ggplot_theme, include = FALSE}
theme_set(theme_bw())
```
```{r read_parameters, include = FALSE}
parameters <-
read_rds(here::here("data",
"parameters.rds"))
```
# Phytoplankton cell counts
## Data preparation
```{r read_prepare_sensor_data}
tp <- read_csv(
here::here("data/intermediate/_summarized_data_files",
"tp.csv"),
col_types = cols(ID = col_character())
)
cruise_dates <-
read_csv(
here::here(
"data/intermediate/_summarized_data_files",
"cruise_date.csv"
),
col_types = cols(ID = col_character())
)
#### calculate mean total phytoplanton biomass in different water depth intervals
tp <- tp %>%
filter(
station %in% parameters$stations_in_phytoplankton,
class == parameters$class_in_phytoplankton,
Species != "Nodulariadead"
) %>%
mutate(ID = if_else(ID == "180722", "180723", ID))
tp <- tp %>%
mutate(dep_grid = cut(
dep,
breaks = c(-1, parameters$surface_dep, parameters$max_dep),
labels = c("0-6", "6-25")
)) %>%
drop_na()
tp_ID_grid <- tp %>%
group_by(ID, dep_grid, Species) %>%
summarise(value = mean(value, na.rm = TRUE)) %>%
ungroup()
tp_ID_grid <- full_join(cruise_dates, tp_ID_grid)
```
```{r convert_biomass_unit}
tp_ID_grid <- tp_ID_grid
```
```{r phytoplankton_time_series, fig.asp=0.8}
tp_ID_grid %>%
filter(Species != "total") %>%
ggplot(aes(date_time_ID, value, col = dep_grid)) +
geom_point() +
geom_line() +
facet_wrap(~ Species, ncol=1) +
scale_color_brewer(palette = "Set1", name = "Depth (m)") +
scale_x_datetime(breaks = "week", date_labels = "%d %b") +
scale_y_continuous(sec.axis = sec_axis(~ . * 0.16 / 12,
name = expression(Biomass ~ (mu~mol-C / kg)))) +
labs(y = expression(Biomass ~ (mg / m ^ 3))) +
theme(axis.title.x = element_blank())
ggsave(
here::here(
"output/Plots/Figures_publication/appendix",
"Phytoplankton_mean_total_biomass.pdf"
),
width = 180,
height = 120,
dpi = 300,
units = "mm"
)
ggsave(
here::here(
"output/Plots/Figures_publication/appendix",
"Phytoplankton_mean_total_biomass.png"
),
width = 180,
height = 120,
dpi = 300,
units = "mm"
)
```