-
Notifications
You must be signed in to change notification settings - Fork 0
/
site-info.Rmd
255 lines (193 loc) · 7.67 KB
/
site-info.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
---
output:
word_document:
reference_docx: styles.docx
html_document:
df_print: paged
params:
site.code: JOTR_P_BLA0045
visit.date: ALL
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(desertsprings)
library(tidyverse)
library(pool)
library(dbplyr)
library(devtools)
library(lubridate)
#Load data into environment
## Uncomment LoadDesertSprings() if trying to knit within this document.
LoadDesertSprings()
db <- GetRawData()
# Get spring info from database
spring.info <- db$Visit %>%
filter(SiteCode == params$site.code) %>%
arrange(desc(VisitDate))
sensorRet.info <- db$SensorRetrievalAttempts %>%
filter(SiteCode == params$site.code) %>%
arrange(desc(RetrievalDate))
sensorAllDep.info <- db$SensorsAllDeployments %>%
filter(SiteCode == params$site.code) %>%
arrange(desc(VisitDate))
sensorDep.info <- db$SensorsCurrentlyDeployed %>%
filter(SiteCode == params$site.code) %>%
arrange(desc(VisitDate))
waterQual.info <- db$VisitActivity %>%
filter(SiteCode == params$site.code) %>%
arrange(desc(VisitDate))
channelChar.info <- db$DischargeFlowCondition %>%
filter(SiteCode == params$site.code) %>%
arrange(desc(VisitDate))
site.info <- db$Site %>%
filter(SiteCode == params$site.code)
pH.info <- db$WaterQualitypH %>%
filter(SiteCode == params$site.code)
SpCond.info <- db$WaterQualitySpCond %>%
filter(SiteCode == params$site.code)
# Split spring info into most recent visit-level info...
visit.info <- spring.info %>%
filter(VisitDate == max(VisitDate))
waterQualVisit.info <- db$VisitActivity %>%
filter(SiteCode == params$site.code) %>%
filter(VisitDate == max(VisitDate))
channelCharVisit.info <- channelChar.info %>%
filter(VisitDate == max(VisitDate))
pHVisit.info <- pH.info %>%
filter(VisitDate == max(VisitDate))
SpCondVisit.info <- SpCond.info %>%
filter(VisitDate == max(VisitDate))
if(nrow(sensorDep.info) != 0){
sensorDepVisit.info <- sensorDep.info %>%
filter(VisitDate == max(VisitDate))
}else{
sensorDepVisit.info <- sensorDep.info
sensorDepVisit.info[nrow(sensorDepVisit.info) + 1, ] <- NA
sensorDepVisit.info$Notes <- "None"
}
# ...and photo-level info
photo_mostrecent <- db$Photo %>%
filter(SiteCode == params$site.code, PhotoSOP == 'RPT') %>%
filter(VisitDate == max(VisitDate))
photo.info <- photo_mostrecent %>%
select(PhotoType, RenamedFilePath, Notes) %>%
mutate(RenamedFilePath = sub("\\\\\\\\INPLAKEMOJNDB\\\\ORG", "M:", RenamedFilePath))
photo.types <- c('SOURCE', 'UPSTR', 'DNSTR', 'SENSOR')
photo.info %<>%
mutate(PhotoType = factor(PhotoType, levels = photo.types)) %>%
arrange(PhotoType)
show_section <- if_else(params$visit.date == 'ALL', TRUE, FALSE)
```
---
title: `r visit.info$SiteCode`
author: `r visit.info$SiteName`
date: Last visited `r visit.info$VisitDate` (WY `r visit.info$FieldSeason`)
---
**Spring type: ** `r visit.info$SpringType`
**Sample frame: ** `r visit.info$SampleFrame`
**Site description: ** `r site.info$SiteDescription`
**Ecological description: ** `r site.info$EcologicalDescription`
**Logistical description: ** `r site.info$LogisticalDescription`
**Drive description: ** `r site.info$DriveDescription`
**Hike description: ** `r site.info$HikeDescription`
**Hike distance (m): ** `r site.info$HikeDistance_m`
**Hike Time (min): ** `r site.info$HikeTime_min`
**Most Recent pH: ** `r pHVisit.info$pH` **Max pH: ** `r max(pH.info$pH, na.rm = TRUE)` **Min pH: ** `r min(pH.info$pH, na.rm = TRUE)`
**Most Recent SpCond: ** `r format(SpCondVisit.info$SpecificConductance_microS_per_cm, scientific=FALSE)` **Max SpCond: ** `r format(max(SpCond.info$SpecificConductance_microS_per_cm, na.rm = TRUE), scientific = FALSE)` **Min SpCond: ** `r format(min(SpCond.info$SpecificConductance_microS_per_cm, na.rm = TRUE), scientific = FALSE)`
# General Visit Notes
```{r include = FALSE}
visitsother.section <- NULL
for(row in 1:nrow(spring.info)){
visits <- spring.info[row,]
visits.date <- visits$VisitDate
#visits.notes <- if_else(is.na(visits$Notes), "", paste0(": ", visits$Notes))
visits.notes <- visits$Notes
visitsother.section <- c(visitsother.section, knitr::knit_expand("visitsother-info.rmd"), collapse = '\n')
}
```
`r if_else((show_section == TRUE), {paste(knitr::knit(text = visitsother.section), collapse = '\n')}, visit.info$Notes)`
# Current Deployments
```{r include=FALSE}
dep.section <- NULL
for(row in 1:nrow(sensorDep.info)) {
dep <- sensorDep.info[row,]
dep.serialnumber <- dep$SerialNumber
dep.visitdate <- dep$VisitDate
#dep.notes <- if_else(is.na(dep$Notes), "", paste0(": ", dep$Notes))
dep.notes <- dep$Notes
dep.section <- c(dep.section, knitr::knit_expand("deployment-info.rmd"), collapse = '\n')
}
```
`r if_else((show_section == TRUE), {paste(knitr::knit(text = dep.section), collapse = '\n')}, sensorDepVisit.info$Notes)`
# All Deployments
```{r include = FALSE}
allDep.section <- NULL
for(row in 1:nrow(sensorAllDep.info )) {
allDep <- sensorAllDep.info[row,]
allDep.serialnumber <- allDep$SerialNumber
allDep.visitdate <- allDep$VisitDate
allDep.notes <- allDep$Notes
allDep.section <- c(allDep.section, knitr::knit_expand("allDeployment-info.rmd"), collapse = '\n')
}
```
`r paste(knitr::knit(text = allDep.section), collapse = '\n')`
# Retrievals
```{r include = FALSE}
ret.section <- NULL
for(row in 1:nrow(sensorRet.info)) {
ret <- sensorRet.info[row,]
ret.serialnumber <- ret$SerialNumber
ret.visitdate <- ret$RetrievalDate
ret.notes <- ret$Notes
ret.section <- c(ret.section, knitr::knit_expand("retrieval-info.rmd"), collapse = '\n')
}
```
`r paste(knitr::knit(text = ret.section), collapse = '\n')`
# Discharge Flow Condition
```{r include = FALSE}
dischargeFlow.section <- NULL
for(row in 1:nrow(channelChar.info)) {
dis <- channelChar.info[row,]
dis.visitdate <- dis$VisitDate
#dis.notes <- if_else(is.na(dis$Notes), "", paste0(": ", dis$Notes))
dis.notes <- dis$Notes
dischargeFlow.section <- c(dischargeFlow.section, knitr::knit_expand("dischargeFlow-info.rmd"), collapse = '\n')
}
```
`r if_else((show_section == TRUE),{paste(knitr::knit(text = dischargeFlow.section), collapse = '\n')}, channelCharVisit.info$Notes)`
# Channel Characteristics
```{r include = FALSE}
channelChar.section <- NULL
for(row in 1:nrow(channelChar.info)) {
channel <- channelChar.info[row,]
channel.visitdate <- channel$VisitDate
#channel.notes <- if_else(is.na(channel$SpringbrookNotes), "", paste0(": ", channel$SpringbrookNotes))
channel.notes <- channel$SpringbrookNotes
channelChar.section <- c(channelChar.section, knitr::knit_expand("channelChar-info.rmd"), collapse = '\n')
}
```
`r if_else((show_section == TRUE),{paste(knitr::knit(text = channelChar.section), collapse = '\n')}, channelCharVisit.info$SpringbrookNotes)`
# Water Quality
``` {r include = FALSE}
waterQual.section <- NULL
for(row in 1:nrow(waterQual.info)){
water <-waterQual.info[row,]
water.visitdate <- water$VisitDate
#water.notes <- if_else(is.na(water$WaterQualityNotes), "", paste0(": ", water$WaterQualityNotes))
water.notes <- water$WaterQualityNotes
waterQual.section <- c(waterQual.section, knitr::knit_expand("waterQual-info.rmd"), collapse = '\n')
}
```
`r if_else((show_section == TRUE),{paste(knitr::knit(text = waterQual.section), collapse = '\n')}, waterQualVisit.info$WaterQualityNotes)`
# Photos
```{r include=FALSE}
photo.section <- NULL
for(row in 1:nrow(photo.info)) {
photo <- photo.info[row,]
photo.path <- photo$RenamedFilePath
photo.type <- photo$PhotoType
photo.notes <- if_else(is.na(photo$Notes), "", paste0(": ", photo$Notes))
photo.section <- c(photo.section, knitr::knit_expand("photo-info.rmd"), collapse = '\n')
}
```
`r paste(knitr::knit(text = photo.section), collapse = '\n')`