This notebook plots the time-series of the different experiment presented in the paper.

Data preparation

source("utilities.r")
source("variables.r")
require(lubridate)
require(cowplot)
require(openair)
require(ggplot2)
require(RColorBrewer)
require(plotly)
df_ops <- readRDS(ops_file_transformed)
df_sensors <- readRDS(sensors_file)


df_ops$reference <- "OPS"
df_sensors$reference <- "sensors"

Inspecting OPS data

Plot

p <- df_ops %>%
  ggplot() +
  geom_line(aes(x = date, y = Bin.1, colour = "Bin.1")) +
  geom_line(aes(x = date, y = Bin.2, colour = "Bin.2")) +
  geom_line(aes(x = date, y = Bin.3, colour = "Bin.3")) +
  geom_line(aes(x = date, y = Bin.4, colour = "Bin.4")) +
  geom_line(aes(x = date, y = Bin.5, colour = "Bin.5")) +
  geom_line(aes(x = date, y = Bin.6, colour = "Bin.6")) +
  geom_line(aes(x = date, y = Bin.7, colour = "Bin.7")) +
  geom_line(aes(x = date, y = Bin.8, colour = "Bin.8")) +
  geom_line(aes(x = date, y = Bin.9, colour = "Bin.9")) +
  geom_line(aes(x = date, y = Bin.10, colour = "Bin.10")) +
  geom_line(aes(x = date, y = Bin.11, colour = "Bin.11")) +
  geom_line(aes(x = date, y = Bin.12, colour = "Bin.12")) +
  geom_line(aes(x = date, y = Bin.13, colour = "Bin.13")) +
  geom_line(aes(x = date, y = Bin.14, colour = "Bin.14")) +
  geom_line(aes(x = date, y = Bin.15, colour = "Bin.15")) +
  geom_line(aes(x = date, y = Bin.16, colour = "Bin.16")) +
  geom_line(aes(x = date, y = Bin.17, colour = "Bin.17"))
  
ggplotly(p, dynamicTicks = T)

OPS bin sizes mean values for each experiment, source, variation (peak/stable)

df_ops %>%
  group_by(exp, source, variation) %>%
  summarise_all(~mean(., na.rm = T))

Sensors

This section plot the time series of one model of each sensors, for the second set of experiments conducted at 69% relative humidity.

Alphasense OPC-R1

df_sensors_ft <- df_sensors[df_sensors$sensor == "OPCR1-178871501", ] %>%
  dplyr::filter(date>=as.POSIXct("2019-09-05 10:20:00") & date <= as.POSIXct("2019-09-05 11:15:00"))

df_sensors_ft <- df_sensors_ft %>%
                  dplyr::rename(
                    Bin0_035_07 = Bin0,
                    Bin1_07_11 = Bin1,
                    Bin2_11_15 = Bin2,
                    Bin3_15_19 = Bin3,
                    Bin4_19_24 = Bin4,
                    Bin5_24_30 = Bin5,
                    Bin6_30_40 = Bin6,
                    Bin7_40_50 = Bin7,
                    Bin8_50_60 = Bin8,
                    Bin9_60_70 = Bin9,
                    Bin10_70_80 = Bin10,
                    Bin11_80_90 = Bin11,
                    Bin12_90_100 = Bin12,
                    Bin13_100_110 = Bin13,
                    Bin14_110_120 = Bin14,
                    Bin15_120_124 = Bin15
                  )

group.colors <-
  c(
    Bin0_ref = "#A6CEE3",
    Bin1_ref = "#1F78B4",
    Bin2_ref = "#B2DF8A",
    Bin3_ref = "#33A02C",
    Bin4_ref = "#FB9A99",
    Bin5_ref = "#E31A1C",
    `Bin0 - 0.35 to 0.7` = "#FDBF6F",
    `Bin1 - 0.7 to 1.1` = "#FF7F00",
    `Bin2 - 1.1 to 1.5` =  "#CAB2D6",
    `Bin3 - 1.5 to 1.9` =  "#6A3D9A",
    `Bin4 - 1.9 to 2.4` =  "#FFFF99"
  )

p_1 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin0_ref,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin1_ref,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_3 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin2_ref,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin3_ref,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_5 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin4_ref,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend


p <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = Bin0_ref,
    colour = "Bin0 - 0.35 to 0.7\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin1_ref,
    colour = "Bin1 - 0.7 to 1.1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin2_ref,
    colour = "Bin2 - 1.1 to 1.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin3_ref,
    colour = "Bin3 - 1.5 to 1.9\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin4_ref,
    colour = "Bin4 - 1.9 to 2.4\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#A6CEE3",
                                 "#1F78B4",
                                 "#B2DF8A",
                                 "#33A02C",
                                 "#FB9A99")) +
  custom_theme +
    ylab(expression(paste("Particle number concentration (#/",cm^{3},")"))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()

p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))



pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    p_3 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_4 + theme(legend.position = "none"),
    p_5 + ylab(NULL) + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

pl_legend

ggsave(
  filename = "../output/plots/time_series_exp2_opcr1_log10_25um.png",
  pl_legend,
  width = 210,
  units = "mm",
  height = 180
)

Plantower PMS5003

group.colors <-
  c(
    "gr03um" = "#A6CEE3",
    "gr05um" = "#1F78B4",
    "gr10um" = "#B2DF8A",
    "gr25um" = "#33A02C",
    "gr50um" = "#FB9A99"
  )
df_ops$reference <- "OPS"
df_sensors$reference <- "sensors"




df_sensors_ft <-
  df_sensors[df_sensors$sensor == "PMS5003-2019031807850",] %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00"))



p_1 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()




p_3 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr10um_ref,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend

p <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = gr10um_ref,
    colour = "gr10um - 1 to 10\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um - 1 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_color_manual(values = c(
    "#A6CEE3",
    "#1F78B4",
    "#B2DF8A",
    "#33A02C",
    "#FB9A99",
    "#FAFAFA"
  )) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()

p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    p_3 + theme(legend.position = "none"),
    p_4 + ylab(NULL) + theme(legend.position = "none"),
    
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(1, 1),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

ggsave(
  filename = "../output/plots/time_series_exp2_pms5003_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Sensirion SPS30

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "SPS030-60767820-25",] %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00"))
group.colors <- c("n05" = "#E31A1C",
                  "n1" = "#FDBF6F",
                  "n25" = "#FF7F00")
brewer.pal(n = 10, name = "Paired")
##  [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C" "#FDBF6F"
##  [8] "#FF7F00" "#CAB2D6" "#6A3D9A"
p_1 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft, aes(
    x = date,
    y = n05,
    colour = "n05",
    linetype = reference
  )) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n1,
              colour = "n1",
              linetype = reference
            ),
            lwd = 0.4) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p_3 <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()





p <- df_ops %>%
  dplyr::filter(date >= as.POSIXct("2019-09-05 10:20:00") &
                  date <= as.POSIXct("2019-09-05 11:15:00")) %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05 - 0.3 to 0.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n05,
              colour = "n05 - 0.3 to 0.5\u03bcm",
              linetype = reference
            )) +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1 - 0.3 to 1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n1,
      colour = "n1 - 0.3 to 1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25 - 0.3 to 2.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25 - 0.3 to 2.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#E31A1C",
                                 
                                 "#FDBF6F",
                                 
                                 "#FF7F00")) +
  custom_theme +
  ylab("Particle number concentration (#/cm3)") +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()
p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))

ggplotly(p, dynamicTicks = T)
pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_3 + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1))  +
  theme(plot.background = element_rect(fill = "white", colour = NA))


ggsave(
  filename = "../output/plots/time_series_exp2_sps30_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

Other experiments

Alphasense OPC-R1

Exp 1

df_sensors_ft <- df_sensors[df_sensors$sensor == "OPCR1-178871501" & df_sensors$exp == "(1) RH=54%", ]

df_sensors_ft <- df_sensors_ft %>%
                  dplyr::rename(
                    Bin0_035_07 = Bin0,
                    Bin1_07_11 = Bin1,
                    Bin2_11_15 = Bin2,
                    Bin3_15_19 = Bin3,
                    Bin4_19_24 = Bin4,
                    Bin5_24_30 = Bin5,
                    Bin6_30_40 = Bin6,
                    Bin7_40_50 = Bin7,
                    Bin8_50_60 = Bin8,
                    Bin9_60_70 = Bin9,
                    Bin10_70_80 = Bin10,
                    Bin11_80_90 = Bin11,
                    Bin12_90_100 = Bin12,
                    Bin13_100_110 = Bin13,
                    Bin14_110_120 = Bin14,
                    Bin15_120_124 = Bin15
                  )


group.colors <-
  c(
    Bin0_ref = "#A6CEE3",
    Bin1_ref = "#1F78B4",
    Bin2_ref = "#B2DF8A",
    Bin3_ref = "#33A02C",
    Bin4_ref = "#FB9A99",
    Bin5_ref = "#E31A1C",
    `Bin0 - 0.35 to 0.7` = "#FDBF6F",
    `Bin1 - 0.7 to 1.1` = "#FF7F00",
    `Bin2 - 1.1 to 1.5` =  "#CAB2D6",
    `Bin3 - 1.5 to 1.9` =  "#6A3D9A",
    `Bin4 - 1.9 to 2.4` =  "#FFFF99"
  )
p_1 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin0_ref,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin1_ref,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_3 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin2_ref,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin3_ref,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_5 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin4_ref,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend


p <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = Bin0_ref,
    colour = "Bin0 - 0.35 to 0.7\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin1_ref,
    colour = "Bin1 - 0.7 to 1.1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin2_ref,
    colour = "Bin2 - 1.1 to 1.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin3_ref,
    colour = "Bin3 - 1.5 to 1.9\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin4_ref,
    colour = "Bin4 - 1.9 to 2.4\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#A6CEE3",
                                 "#1F78B4",
                                 "#B2DF8A",
                                 "#33A02C",
                                 "#FB9A99")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()

p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    p_3 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_4 + theme(legend.position = "none"),
    p_5 + ylab(NULL) + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

pl_legend

ggsave(
  filename = "../output/plots/time_series_exp1_opcr1_log10_25um.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

Exp 3

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "OPCR1-178871501" &
               df_sensors$exp == "(3) RH=72%",]

df_sensors_ft <- df_sensors_ft %>%
  dplyr::rename(
    Bin0_035_07 = Bin0,
    Bin1_07_11 = Bin1,
    Bin2_11_15 = Bin2,
    Bin3_15_19 = Bin3,
    Bin4_19_24 = Bin4,
    Bin5_24_30 = Bin5,
    Bin6_30_40 = Bin6,
    Bin7_40_50 = Bin7,
    Bin8_50_60 = Bin8,
    Bin9_60_70 = Bin9,
    Bin10_70_80 = Bin10,
    Bin11_80_90 = Bin11,
    Bin12_90_100 = Bin12,
    Bin13_100_110 = Bin13,
    Bin14_110_120 = Bin14,
    Bin15_120_124 = Bin15
  )

group.colors <-
  c(
    Bin0_ref = "#A6CEE3",
    Bin1_ref = "#1F78B4",
    Bin2_ref = "#B2DF8A",
    Bin3_ref = "#33A02C",
    Bin4_ref = "#FB9A99",
    Bin5_ref = "#E31A1C",
    `Bin0 - 0.35 to 0.7` = "#FDBF6F",
    `Bin1 - 0.7 to 1.1` = "#FF7F00",
    `Bin2 - 1.1 to 1.5` =  "#CAB2D6",
    `Bin3 - 1.5 to 1.9` =  "#6A3D9A",
    `Bin4 - 1.9 to 2.4` =  "#FFFF99"
  )
p_1 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin0_ref,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin1_ref,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_3 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin2_ref,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin3_ref,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_5 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin4_ref,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend


p <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = Bin0_ref,
    colour = "Bin0 - 0.35 to 0.7\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin1_ref,
    colour = "Bin1 - 0.7 to 1.1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin2_ref,
    colour = "Bin2 - 1.1 to 1.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin3_ref,
    colour = "Bin3 - 1.5 to 1.9\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin4_ref,
    colour = "Bin4 - 1.9 to 2.4\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#A6CEE3",
                                 "#1F78B4",
                                 "#B2DF8A",
                                 "#33A02C",
                                 "#FB9A99")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()

p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    p_3 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_4 + theme(legend.position = "none"),
    p_5 + ylab(NULL) + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

pl_legend

ggsave(
  filename = "../output/plots/time_series_exp3_opcr1_log10_25um.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

Exp 4

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "OPCR1-178871501" &
               df_sensors$exp == "(4) RH=76%",]

df_sensors_ft <- df_sensors_ft %>%
  dplyr::rename(
    Bin0_035_07 = Bin0,
    Bin1_07_11 = Bin1,
    Bin2_11_15 = Bin2,
    Bin3_15_19 = Bin3,
    Bin4_19_24 = Bin4,
    Bin5_24_30 = Bin5,
    Bin6_30_40 = Bin6,
    Bin7_40_50 = Bin7,
    Bin8_50_60 = Bin8,
    Bin9_60_70 = Bin9,
    Bin10_70_80 = Bin10,
    Bin11_80_90 = Bin11,
    Bin12_90_100 = Bin12,
    Bin13_100_110 = Bin13,
    Bin14_110_120 = Bin14,
    Bin15_120_124 = Bin15
  )

group.colors <-
  c(
    Bin0_ref = "#A6CEE3",
    Bin1_ref = "#1F78B4",
    Bin2_ref = "#B2DF8A",
    Bin3_ref = "#33A02C",
    Bin4_ref = "#FB9A99",
    Bin5_ref = "#E31A1C",
    `Bin0 - 0.35 to 0.7` = "#FDBF6F",
    `Bin1 - 0.7 to 1.1` = "#FF7F00",
    `Bin2 - 1.1 to 1.5` =  "#CAB2D6",
    `Bin3 - 1.5 to 1.9` =  "#6A3D9A",
    `Bin4 - 1.9 to 2.4` =  "#FFFF99"
  )
p_1 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin0_ref,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin1_ref,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_3 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin2_ref,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin3_ref,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_5 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin4_ref,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend


p <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = Bin0_ref,
    colour = "Bin0 - 0.35 to 0.7\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin1_ref,
    colour = "Bin1 - 0.7 to 1.1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin2_ref,
    colour = "Bin2 - 1.1 to 1.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin3_ref,
    colour = "Bin3 - 1.5 to 1.9\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin4_ref,
    colour = "Bin4 - 1.9 to 2.4\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#A6CEE3",
                                 "#1F78B4",
                                 "#B2DF8A",
                                 "#33A02C",
                                 "#FB9A99")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()

p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    p_3 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_4 + theme(legend.position = "none"),
    p_5 + ylab(NULL) + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

pl_legend

ggsave(
  filename = "../output/plots/time_series_exp4_opcr1_log10_25um.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

Exp 5

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "OPCR1-178871501" &
               df_sensors$exp == "(5) RH=79%",]

df_sensors_ft <- df_sensors_ft %>%
  dplyr::rename(
    Bin0_035_07 = Bin0,
    Bin1_07_11 = Bin1,
    Bin2_11_15 = Bin2,
    Bin3_15_19 = Bin3,
    Bin4_19_24 = Bin4,
    Bin5_24_30 = Bin5,
    Bin6_30_40 = Bin6,
    Bin7_40_50 = Bin7,
    Bin8_50_60 = Bin8,
    Bin9_60_70 = Bin9,
    Bin10_70_80 = Bin10,
    Bin11_80_90 = Bin11,
    Bin12_90_100 = Bin12,
    Bin13_100_110 = Bin13,
    Bin14_110_120 = Bin14,
    Bin15_120_124 = Bin15
  )

group.colors <-
  c(
    Bin0_ref = "#A6CEE3",
    Bin1_ref = "#1F78B4",
    Bin2_ref = "#B2DF8A",
    Bin3_ref = "#33A02C",
    Bin4_ref = "#FB9A99",
    Bin5_ref = "#E31A1C",
    `Bin0 - 0.35 to 0.7` = "#FDBF6F",
    `Bin1 - 0.7 to 1.1` = "#FF7F00",
    `Bin2 - 1.1 to 1.5` =  "#CAB2D6",
    `Bin3 - 1.5 to 1.9` =  "#6A3D9A",
    `Bin4 - 1.9 to 2.4` =  "#FFFF99"
  )
p_1 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin0_ref,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin1_ref,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_3 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin2_ref,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin3_ref,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_5 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = Bin4_ref,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#FB9A99"
  ) +
  #scale_colour_manual(values=group.colors) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend


p <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = Bin0_ref,
    colour = "Bin0 - 0.35 to 0.7\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin0_035_07,
      colour = "Bin0 - 0.35 to 0.7\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin1_ref,
    colour = "Bin1 - 0.7 to 1.1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin1_07_11,
      colour = "Bin1 - 0.7 to 1.1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin2_ref,
    colour = "Bin2 - 1.1 to 1.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin2_11_15,
      colour = "Bin2 - 1.1 to 1.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin3_ref,
    colour = "Bin3 - 1.5 to 1.9\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin3_15_19,
      colour = "Bin3 - 1.5 to 1.9\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = Bin4_ref,
    colour = "Bin4 - 1.9 to 2.4\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = Bin4_19_24,
      colour = "Bin4 - 1.9 to 2.4\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#A6CEE3",
                                 "#1F78B4",
                                 "#B2DF8A",
                                 "#33A02C",
                                 "#FB9A99")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()

p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    p_3 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_4 + theme(legend.position = "none"),
    p_5 + ylab(NULL) + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

pl_legend

ggsave(
  filename = "../output/plots/time_series_exp5_opcr1_log10_25um.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

SPS30

Exp 1

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "SPS030-60767820-25" &
               df_sensors$exp == "(1) RH=54%",]
group.colors <- c("n05" = "#E31A1C",
                  "n1" = "#FDBF6F",
                  "n25" = "#FF7F00")
brewer.pal(n = 10, name = "Paired")
##  [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C" "#FDBF6F"
##  [8] "#FF7F00" "#CAB2D6" "#6A3D9A"
p_1 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft, aes(
    x = date,
    y = n05,
    colour = "n05",
    linetype = reference
  )) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n1,
              colour = "n1",
              linetype = reference
            ),
            lwd = 0.4) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p_3 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()





p <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05 - 0.3 to 0.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n05,
              colour = "n05 - 0.3 to 0.5\u03bcm",
              linetype = reference
            )) +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1 - 0.3 to 1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n1,
      colour = "n1 - 0.3 to 1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25 - 0.3 to 2.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25 - 0.3 to 2.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#E31A1C",
                                 
                                 "#FDBF6F",
                                 
                                 "#FF7F00")) +
  custom_theme +
  ylab("Particle number concentration (#/cm3)") +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()
p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))

ggplotly(p, dynamicTicks = T)
pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_3 + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1))  +
  theme(plot.background = element_rect(fill = "white", colour = NA))


ggsave(
  filename = "../output/plots/time_series_exp1_sps30_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Exp 3

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "SPS030-60767820-25" &
               df_sensors$exp == "(3) RH=72%",]
group.colors <- c("n05" = "#E31A1C",
                  "n1" = "#FDBF6F",
                  "n25" = "#FF7F00")
brewer.pal(n = 10, name = "Paired")
##  [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C" "#FDBF6F"
##  [8] "#FF7F00" "#CAB2D6" "#6A3D9A"
p_1 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft, aes(
    x = date,
    y = n05,
    colour = "n05",
    linetype = reference
  )) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n1,
              colour = "n1",
              linetype = reference
            ),
            lwd = 0.4) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p_3 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()





p <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05 - 0.3 to 0.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n05,
              colour = "n05 - 0.3 to 0.5\u03bcm",
              linetype = reference
            )) +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1 - 0.3 to 1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n1,
      colour = "n1 - 0.3 to 1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25 - 0.3 to 2.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25 - 0.3 to 2.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#E31A1C",
                                 
                                 "#FDBF6F",
                                 
                                 "#FF7F00")) +
  custom_theme +
  ylab("Particle number concentration (#/cm3)") +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()
p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))

ggplotly(p, dynamicTicks = T)
pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_3 + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1))  +
  theme(plot.background = element_rect(fill = "white", colour = NA))


ggsave(
  filename = "../output/plots/time_series_exp3_sps30_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Exp 4

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "SPS030-60767820-25" &
               df_sensors$exp == "(4) RH=76%",]
group.colors <- c("n05" = "#E31A1C",
                  "n1" = "#FDBF6F",
                  "n25" = "#FF7F00")
brewer.pal(n = 10, name = "Paired")
##  [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C" "#FDBF6F"
##  [8] "#FF7F00" "#CAB2D6" "#6A3D9A"
p_1 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft, aes(
    x = date,
    y = n05,
    colour = "n05",
    linetype = reference
  )) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n1,
              colour = "n1",
              linetype = reference
            ),
            lwd = 0.4) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p_3 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()





p <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05 - 0.3 to 0.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n05,
              colour = "n05 - 0.3 to 0.5\u03bcm",
              linetype = reference
            )) +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1 - 0.3 to 1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n1,
      colour = "n1 - 0.3 to 1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25 - 0.3 to 2.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25 - 0.3 to 2.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#E31A1C",
                                 
                                 "#FDBF6F",
                                 
                                 "#FF7F00")) +
  custom_theme +
  ylab("Particle number concentration (#/cm3)") +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()
p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))

ggplotly(p, dynamicTicks = T)
pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_3 + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1))  +
  theme(plot.background = element_rect(fill = "white", colour = NA))


ggsave(
  filename = "../output/plots/time_series_exp4_sps30_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Exp 5

df_sensors_ft <-
  df_sensors[df_sensors$sensor == "SPS030-60767820-25" &
               df_sensors$exp == "(5) RH=79%",]
group.colors <- c("n05" = "#E31A1C",
                  "n1" = "#FDBF6F",
                  "n25" = "#FF7F00")
brewer.pal(n = 10, name = "Paired")
##  [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C" "#FDBF6F"
##  [8] "#FF7F00" "#CAB2D6" "#6A3D9A"
p_1 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft, aes(
    x = date,
    y = n05,
    colour = "n05",
    linetype = reference
  )) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n1,
              colour = "n1",
              linetype = reference
            ),
            lwd = 0.4) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p_3 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25",
    linetype = reference
  ), lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = group.colors) +
  #  scale_linetype_manual(values = c(2,2,2,1,1,1)) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()





p <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(aes(
    x = date,
    y = n05_ref,
    colour = "n05 - 0.3 to 0.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(data = df_sensors_ft,
            aes(
              x = date,
              y = n05,
              colour = "n05 - 0.3 to 0.5\u03bcm",
              linetype = reference
            )) +
  geom_line(aes(
    x = date,
    y = n1_ref,
    colour = "n1 - 0.3 to 1\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n1,
      colour = "n1 - 0.3 to 1\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = n25_ref,
    colour = "n25 - 0.3 to 2.5\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = n25,
      colour = "n25 - 0.3 to 2.5\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  scale_colour_manual(values = c("#E31A1C",
                                 
                                 "#FDBF6F",
                                 
                                 "#FF7F00")) +
  custom_theme +
  ylab("Particle number concentration (#/cm3)") +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()
p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))

ggplotly(p, dynamicTicks = T)
pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    NULL,
    p_3 + theme(legend.position = "none"),
    NULL,
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(0.5, 1, 0.5),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1))  +
  theme(plot.background = element_rect(fill = "white", colour = NA))


ggsave(
  filename = "../output/plots/time_series_exp5_sps30_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Plantower PMS5003

Exp 1

group.colors <-
  c(
    "gr03um" = "#A6CEE3",
    "gr05um" = "#1F78B4",
    "gr10um" = "#B2DF8A",
    "gr25um" = "#33A02C",
    "gr50um" = "#FB9A99"
  )
df_ops$reference <- "OPS"
df_sensors$reference <- "sensors"



df_sensors_ft <-
  df_sensors[df_sensors$sensor == "PMS5003-2019031807850" &
               df_sensors$exp == "(1) RH=54%",]




p_1 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()




p_3 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr10um_ref,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend

p <- df_ops[df_ops$exp == "(1) RH=54%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = gr10um_ref,
    colour = "gr10um - 1 to 10\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um - 1 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_color_manual(values = c(
    "#A6CEE3",
    "#1F78B4",
    "#B2DF8A",
    "#33A02C",
    "#FB9A99",
    "#FAFAFA"
  )) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    p_3 + theme(legend.position = "none"),
    p_4 + theme(legend.position = "none"),
    
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(1, 1),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

ggsave(
  filename = "../output/plots/time_series_exp1_pms5003_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Exp 3

group.colors <-
  c(
    "gr03um" = "#A6CEE3",
    "gr05um" = "#1F78B4",
    "gr10um" = "#B2DF8A",
    "gr25um" = "#33A02C",
    "gr50um" = "#FB9A99"
  )
df_ops$reference <- "OPS"
df_sensors$reference <- "sensors"



df_sensors_ft <-
  df_sensors[df_sensors$sensor == "PMS5003-2019031807850" &
               df_sensors$exp == "(3) RH=72%",]




p_1 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()




p_3 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr10um_ref,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend

p <- df_ops[df_ops$exp == "(3) RH=72%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = gr10um_ref,
    colour = "gr10um - 1 to 10\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um - 1 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_color_manual(values = c(
    "#A6CEE3",
    "#1F78B4",
    "#B2DF8A",
    "#33A02C",
    "#FB9A99",
    "#FAFAFA"
  )) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    p_3 + theme(legend.position = "none"),
    p_4 + theme(legend.position = "none"),
    
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(1, 1),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

ggsave(
  filename = "../output/plots/time_series_exp3_pms5003_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Exp 4

group.colors <-
  c(
    "gr03um" = "#A6CEE3",
    "gr05um" = "#1F78B4",
    "gr10um" = "#B2DF8A",
    "gr25um" = "#33A02C",
    "gr50um" = "#FB9A99"
  )
df_ops$reference <- "OPS"
df_sensors$reference <- "sensors"



df_sensors_ft <-
  df_sensors[df_sensors$sensor == "PMS5003-2019031807850" &
               df_sensors$exp == "(4) RH=76%",]




p_1 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()




p_3 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr10um_ref,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend

p <- df_ops[df_ops$exp == "(4) RH=76%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = gr10um_ref,
    colour = "gr10um - 1 to 10\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um - 1 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_color_manual(values = c(
    "#A6CEE3",
    "#1F78B4",
    "#B2DF8A",
    "#33A02C",
    "#FB9A99",
    "#FAFAFA"
  )) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    p_3 + theme(legend.position = "none"),
    p_4 + theme(legend.position = "none"),
    
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(1, 1),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

ggsave(
  filename = "../output/plots/time_series_exp4_pms5003_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend

Exp 5

group.colors <-
  c(
    "gr03um" = "#A6CEE3",
    "gr05um" = "#1F78B4",
    "gr10um" = "#B2DF8A",
    "gr25um" = "#33A02C",
    "gr50um" = "#FB9A99"
  )
df_ops$reference <- "OPS"
df_sensors$reference <- "sensors"



df_sensors_ft <-
  df_sensors[df_sensors$sensor == "PMS5003-2019031807850" &
               df_sensors$exp == "(5) RH=79%",]




p_1 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#A6CEE3"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_2 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#1F78B4"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()




p_3 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr10um_ref,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#B2DF8A"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()


p_4 <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um",
      linetype = reference
    ),
    lwd = 0.4,
    colour = "#33A02C"
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_fill_manual(values = group.colors) +
  #  scale_fill_manual(values = c("#A6CEE3", "#1F78B4","#B2DF8A", "#A6CEE3", "#1F78B4","#B2DF8A")) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  annotation_logticks(sides = "l") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



# Get the legend

p <- df_ops[df_ops$exp == "(5) RH=79%",] %>%
  ggplot() +
  geom_line(
    aes(
      x = date,
      y = gr03um_ref,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr05um_ref,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(aes(
    x = date,
    y = gr10um_ref,
    colour = "gr10um - 1 to 10\u03bcm",
    linetype = reference
  ),
  lwd = 0.4) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr03um,
      colour = "gr03um - 0.3 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr05um,
      colour = "gr05um - 0.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr10um,
      colour = "gr10um - 1 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    aes(
      x = date,
      y = gr25um_ref,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  geom_line(
    data = df_sensors_ft,
    aes(
      x = date,
      y = gr25um,
      colour = "gr25um - 2.5 to 10\u03bcm",
      linetype = reference
    ),
    lwd = 0.4
  ) +
  #scale_color_brewer(palette = "Paired") +
  scale_color_manual(values = c(
    "#A6CEE3",
    "#1F78B4",
    "#B2DF8A",
    "#33A02C",
    "#FB9A99",
    "#FAFAFA"
  )) +
  custom_theme +
  ylab(expression(paste(
    "Particle number concentration (#/", cm ^ {
      3
    }, ")"
  ))) +
  xlab("Time") +
  labs(colour = "Bin sizes", linetype = "Instrument") +
  scale_y_log10()



p

legend <-
  get_legend(p + theme(
    legend.position = "bottom",
    legend.box = "vertical",
    legend.margin = margin()
  ))


pl <- plot_grid(
  plot_grid(
    p_1 + theme(legend.position = "none"),
    p_2 + ylab(NULL) + theme(legend.position = "none"),
    nrow = 1
    #labels = c("(a)", "(b)", "(C)")
  ),
  plot_grid(
    p_3 + theme(legend.position = "none"),
    p_4 + theme(legend.position = "none"),
    
    #labels = c("", "(d)", "(e)", ""),
    rel_widths = c(1, 1),
    nrow = 1
  ),
  nrow = 2
)

pl_legend <- plot_grid(pl,
                       legend,
                       nrow = 2,
                       rel_heights = c(0.9, 0.1)) +
  theme(plot.background = element_rect(fill = "white", colour = NA))

ggsave(
  filename = "../output/plots/time_series_exp5_pms5003_25um_orig.png",
  pl_legend,
  width = 200,
  units = "mm",
  height = 180
)

pl_legend