-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvignette.Rmd
154 lines (126 loc) · 3.91 KB
/
vignette.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
---
title: "waterQUAC:: Water Data Quality Control"
author: "Cameron Roberts"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
# Introduction
This R library has been developed as a tool-set for processing high frequency water quality and quantity data. It features easy API data extraction functions from common endpoints:
- [eagle.IO](https://eagle.io/)
- *Common online data repository for remote telemetered datasets*
- Queensland Governments [Water Monitoring Information Portal](https://water-monitoring.information.qld.gov.au/)
- *Source for much of Queenslands hydrometric data*
- Queensland Governments [Long Paddock](https://www.longpaddock.qld.gov.au/)
- *Source for climate data from the Queensland Government*
- [OpenWeatherMap](https://www.longpaddock.qld.gov.au/)
```{r}
#remotes::install_github("https://github.com/UncleCamsWaterPlans/waterQUAC")
library(waterQUAC)
library(plotly)
# import discharge data from WMIP (Herbert River at Ingham - 1160001F)
discharge <- waterQUAC::wmip_hist("116001F",
"discharge",
"AT",
"20220701",
"20230630")
# extract gridded weather obs data from that locaiton (SILO)
rain <- waterQUAC::silo_grid(lat = "-18.62831",
long = "146.16486",
start = "20220701",
finish = "20230630",
username = "[email protected]")
#plot daily rainfall against stream discharge
discharge %>%
plot_ly() %>%
add_trace(
x = ~ time,
y = ~ value,
mode = "lines",
name = "Stream Discharge (m^3/s)",
type = "scatter",
fill = "tozeroy",
line = list(
color = "tozeroy",
width = 2.5,
dash = 'solid'
),
connectgaps = TRUE
) %>%
add_trace(
x = ~ rain$Date,
y = ~ rain$Rain,
type = 'bar',
yaxis = "y3",
name = "Daily Rainfall",
marker = list(
color = "darkblue",
opacity = 0.3,
size = 10
)
) %>%
layout(
legend = list(orientation = 'h'),
xaxis = list(title = FALSE,
showgrid = FALSE,
domain=c(0,0.85)),
yaxis = list(
title = list(text = "<b>Stream Level</b> (m)", font = list(size = 15)),
showgrid = FALSE,
side = "right"
),
yaxis3 = list(
tickfont = list(color = "darkblue"),
showgrid = FALSE,
overlaying = "y",
side = "right",
anchor = "free",
position = 0.92,
autorange = "reversed",
title = list(text = "<b>Rainfall</b> (mm)", font = list(size = 15))
)
) %>%
#Add modebar buttons
config(
modeBarButtonsToAdd = list(
'drawline',
'drawopenpath',
'drawclosedpath',
'drawcircle',
'drawrect',
'eraseshape'
)
)
```
## Time series quality coding
```{r}
#example Total Suspended Solids dataframe
df <- waterQUAC::TSS_data
#overwritable QC codes, all else are retained. In this case, all codes will be overwritten
manual_codes = c(1:4000)
#upper and lower limits for the sensor uses (Trios Opus)
sensorMin = 0
sensorMax = 650
tst <- ts_anom(df = df,
overwrite = manual_codes,
sensorMin = 0,
sensorMax = 650)
tst |>
plotly::plot_ly() |>
plotly::add_markers(
x = ~ ts,
y = ~ Value,
type = "scatter",
color = ~ Quality
)
```
Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette.