-
Notifications
You must be signed in to change notification settings - Fork 0
/
Figure A4_RH_DHT22.Rmd
130 lines (103 loc) · 4.74 KB
/
Figure A4_RH_DHT22.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
---
title: "Figure A4. RH and temperature from DHT22"
output: html_notebook
---
Figure A4. Evolution of the relative humidity and temperature during the five experiments comparing
the readings of the DHT22, and the four SHT35 in each of the air quality monitors.
```{r setup}
source("utilities.R")
source("variables.R")
require(ggforce)
require(dplyr)
require(ggplot2)
require(plotly)
df_rht<-readRDS(dht22_file) %>%
flag_cdt_data(cdt)
df<-readRDS(sensor_raw_file)
df_sht <- df %>%
filter(sensor == "SHT35")
```
```{r}
require(forcats)
x<-factor(df_sht$site)
df_sht$site<-fct_recode(x, "SHT35 lab-1" = "lab-1", "SHT35 lab-2" = "lab-2", "SHT35 lab-3" ="lab-3", "SHT35 lab-4" = "lab-4")
p_temp<-df_rht %>%
filter(date >= as.POSIXct("2019-09-05 07:00:00", tz="UTC"), date<= as.POSIXct("2019-09-05 12:33:49", tz = "UTC")) %>%
ggplot() +
annotate("rect", xmin = as.POSIXct("2019-09-05 07:44:21",tz = "UTC"),
xmax = as.POSIXct("2019-09-05 08:02:33", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#66C2A5", alpha=0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 08:02:33",tz = "UTC"),
xmax = as.POSIXct("2019-09-05 08:18:20", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#FC8D62", alpha = 0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 09:24:27",tz = "UTC"),
xmax = as.POSIXct("2019-09-05 09:42:43", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#66C2A5", alpha = 0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 09:43:12",tz="UTC"),
xmax = as.POSIXct("2019-09-05 09:56:10", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#FC8D62", alpha = 0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 10:17:58",tz = "UTC"),
xmax = as.POSIXct("2019-09-05 10:37:03", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#66C2A5", alpha = 0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 10:37:03",tz="UTC"),
xmax = as.POSIXct("2019-09-05 10:52:00", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#FC8D62", alpha=0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 11:06:38",tz="UTC"),
xmax = as.POSIXct("2019-09-05 11:22:33", tz="UTC"),
ymin = -Inf, ymax = +Inf, fill = "#66C2A5", alpha=0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 11:22:33",tz="UTC"),
xmax = as.POSIXct("2019-09-05 11:34:53", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#FC8D62", alpha=0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 11:56:21",tz="UTC"),
xmax = as.POSIXct("2019-09-05 12:15:04", tz="UTC"),
ymin = -Inf, ymax = +Inf, fill = "#66C2A5", alpha=0.2) +
annotate("rect", xmin = as.POSIXct("2019-09-05 12:15:04",tz="UTC"),
xmax = as.POSIXct("2019-09-05 12:33:34", tz = "UTC"),
ymin = -Inf, ymax = +Inf, fill = "#FC8D62", alpha=0.2) +
geom_line(aes(x = date, y = temperature, color = "DHT22")) +
geom_line(data = df_sht, aes(x = date, y = temperature, group = site, colour = site)) + xlab("Time") +
ylab(expression('Temperature ('*~degree*C*')')) +
theme_bw() +
theme(legend.position = "bottom", legend.title = )
p_pm_legend <- get_legend(p_temp)
require(cowplot)
pl_assembled<-plot_grid(p,p_temp,align = "v",ncol = 1)
#ggsave(plot = pl_assembled, filename = "evolution_rht_SHT35_DHT22.svg")
pl_assembled
```
```{r}
df_rht %>%
filter(exp!="") %>%
group_by(exp) %>%
summarise(temp = mean(temperature, na.rm = TRUE),
temp_median = median(temperature, na.rm = TRUE),
temp_min = min(temperature, na.rm = TRUE),
temp_max = max(temperature, na.rm = TRUE),
temp_sd = sd(temperature, na.rm = TRUE),
rh = mean(rh, na.rm = TRUE),
rh_median = median(rh, na.rm = TRUE),
rh_min = min(rh, na.rm = TRUE),
rh_max = max(rh, na.rm = TRUE),
rh_sd = sd(rh, na.rm= TRUE),
temp_q_75 = quantile(rh, c(0.75)),
temp_q_25 = quantile(rh, c(0.25)),
rh_mad_threshold = 2.5*mad(rh, na.rm = TRUE),
temp_mad_threshold = 2.5*mad(temperature, na.rm = TRUE)) ->summary_rh_temp
ggplot(filter(df_rht, exp!="")) + geom_line(aes(x=date, y =rh, color =exp))
summary_rh_temp
exp1<-filter(df_rht, exp=="(1) RH=54%")
median(exp1$rh, na.rm=TRUE)
range(exp1$rh, na.rm = TRUE)
exp2<-filter(df_rht, exp=="(2) RH=69%")
median(exp2$rh, na.rm=TRUE)
range(exp2$rh, na.rm = TRUE)
exp3<-filter(df_rht, exp=="(3) RH=72%")
median(exp3$rh, na.rm=TRUE)
range(exp3$rh, na.rm = TRUE)
exp4<-filter(df_rht, exp=="(4) RH=76%")
median(exp4$rh, na.rm=TRUE)
range(exp4$rh, na.rm = TRUE)
exp5<-filter(df_rht, exp=="(5) RH=79%")
median(exp5$rh, na.rm=TRUE)
range(exp5$rh, na.rm = TRUE)
```