# Set knitr options
knitr::opts_chunk$set(echo = FALSE,          # echo code so reader can see what is happening
                      warning = FALSE,
                      message = FALSE,
                      fig_caption = TRUE,
                      fig_height = 6,        # default, make it bigger to stretch vertical axis
                      fig_width = 8,
                      fig_width = 8,         # full width
                      tidy = TRUE)           # tidy up code in case echo = TRUE
# Load Packages ----
rmdLibs <- c("openair", "skimr")

dkUtils::loadLibraries(rmdLibs)

# Adjust knitr options if required
knitr::opts_chunk$set(echo = TRUE)

# Log compile time:
myParams$startTime <- proc.time()

# Parameters ----
# set xlim for plotly to reduce plot size & load speed
myParams$xlimMinDateTime <- lubridate::as_datetime("2018-01-01 00:00:00")
myParams$xlimMaxDateTime <- lubridate::as_datetime("2020-06-01 00:00:00")
myParams$xlimMinDate <- lubridate::as_date("2018-01-01")
myParams$xlimMaxDate <- lubridate::as_date("2020-06-01")

myParams$oneYearAgo <- lubridate::as_datetime(now() - (365*24*60*60))

# set values for annotations
myParams$lockDownStartDate <- as.Date("2020-03-24")
myParams$lockDownStartDateTime <- lubridate::as_datetime("2020-03-24 00:00:00")
myParams$lockDownEndDate <- lubridate::today()
myParams$lockDownEndDateTime <- lubridate::now()

myParams$recentCutDate <- lubridate::as_date("2020-03-01")

myParams$gamCap <- "Trend line = Generalized additive model (gam) with integrated smoothness estimation"
myParams$lockdownCap <- "\nColoured rectangle = UK covid lockdown to date"
myParams$weekendCap <- "\nShaded rectangle = weekends"

myParams$myAlpha <- 0.1
myParams$vLineAlpha <- 0.4
myParams$vLineCol <- "red" # http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/#a-colorblind-friendly-palette
myParams$myTextSize <- 4

About

Code

Citation

If you wish to refer to any of the material from this report please cite as:

Report circulation:

This work is (c) r format(Sys.time(), format = "%Y") the University of Southampton.

Disclaimer

I usually do energy demand research but in the absence of access to real time energy demand data on lockdown (unlike during the World Cup), I'm looking at other things.

Introduction

We use the excellent openair package [@openair] to download the AURN data and create the wind and pollution roses for each of the following Southampton sites:

Year and site is given in the legend label.

This analysis uses data for Southampton downloaded from:

The data supplied to AURN by UK monitoring sites such as the ones in Southampton is ratified to check for outliers and instrument/measurement error. However, AURN data less than six months old has not undergone this process. Be warned.

Data

Downloaded from AURN.

sites <- c("SA33", "SOUT")

# use:
# windRose(mydata, type = "year", layout = c(4, 2))
# https://www.rdocumentation.org/packages/openair/versions/2.7-0


  # wide form
    df_SA33 <- openair::importAURN(
      site = "SA33",
      year = 2000:2020,
      pollutant = "all",
      hc = FALSE,
      to_narrow = FALSE, # produces wide form data
      verbose = TRUE
    )

    df_SOUT <- openair::importAURN(
      site = "SOUT",
      year = 2000:2020,
      pollutant = "all",
      hc = FALSE,
      to_narrow = FALSE, # produces wide form data
      verbose = TRUE
    )

Site: SA33

A33 - near docks: map

skimr::skim(df_SA33)

Wind roses

# make a compass rose for this site for this year
openair::windRose(df_SA33, type = "year", 
                              key.header = paste0("Southampton site: ", s),
                              layout = c(3,2))

Pollution roses

# make a compass rose for this site for this year
openair::pollutionRose(df_SA33, type = "year", 
                              key.header = paste0("Southampton site: ", s),
                              layout = c(3,2))

Site: SOUT

City centre: map

skimr::skim(df_SOUT)

Wind roses

# make a compass rose for this site for this year
openair::windRose(df_SOUT, type = "year", 
                              key.header = paste0("Southampton site: ", s),
                              layout = c(3,2))

Pollution roses

# make a compass rose for this site for this year
openair::pollutionRose(df_SOUT, type = "year", 
                              key.header = paste0("Southampton site: ", s),
                              layout = c(3,2))

Runtime

Report generated using knitr in RStudio with r R.version.string running on r R.version$platform (r Sys.info()[3]).

t <- proc.time() - myParams$startTime

elapsed <- t[[3]]

Analysis completed in r elapsed seconds ( r round(elapsed/60,2) minutes).

R packages used:

References



CfSOtago/airQual documentation built on Nov. 13, 2020, 8:08 a.m.