Brisbane

Row

Maximum Temperature in Brisbane - Over The Years

Maximum Temperature in Brisbane - Trend

Row

Minimum Temperature in Brisbane - Over The Years

Minimum Temperature in Brisbane - Trend

Sydney

Row

Maximum Temperature in Sydney - Over The Years

Maximum Temperature in Sydney - Trend

Row

Minimum Temperature in Sydney - Over The Years

Minimum Temperature in Sydney - Trend

Perth

Row

Maximum Temperature in Perth - Over The Years

Maximum Temperature in Perth - Trend

Row

Minimum Temperature in Perth - Over The Years

Minimum Temperature in Perth - Trend

Analysis and Questions

Analysis of Weather Station Data

Station Data : Brisbane, Sydney & Perth

The Australian Bureau of Meteorology provides historical weather data, some of which can be freely downloaded. For the purpose of this analysis of weather data, data was collected from two weather stations in Brisbane: the Brisbane Regional Office weather station (latitude 27.466 degrees south, longitude 153.0270 degrees east, and elevation of 38 metres) with data available from 1887 January until 1986 March and the Brisbane weather station (latitude 27.4808 degrees south, longitude 153.0389 degrees east, and elevation of 8 metres) with data available from 1999 December until 2020 January. We look at monthly maximum temperature (the highest temperature recorded in the 24 hours from 9 am) and the monthly (the lowest temperature recorded in the 24 hours to 9 am). The ground minimum temperature (lowest overnight temperature measured at ground level.)

Sydney (Observatory Hill) weather station (latitude 33.8607 degrees south, longitude 151.2050 degrees east, and elevation of 39 metres) has a continuous collection of data from 1859 until 2020

Perth Airport weather station (latitude 31.9275 degrees south, longitude 115.9764 degrees east, and elevation of 15 metres) has a continuous collection of data from 1944 until 2020.

Questions to Ponder

What is this temperature really and why does it matter?

The temperature of air is a measure of the average thermal energy of the molecules in the air - the higher the temperature, the higher the energy of the molecules. Historically, the most common instrument used has been a liquid-in-glass thermometer mounted in a Stevenson screen. Modern automatic weather stations generally use an electronic sensor. The daily maximum (highest) and minimum (lowest) temperature are generally recorded once each day at 9 am local time, while instantaneous measurements of air temperature may be made at various times throughout the day.

Does the location of weather station matter?

Multi-station approach to weather data:

Visual Crossing by default takes the 3 nearest weather stations to the location entered to compute the accurate weather at your location. The distance to the weather stations are weighted by distance for the final result. If your location is 10, 40, 50 miles away from weather stations, they will be weighted by these distances. It greatly helps areas that are far from weather stations to both determine through interpolation the most accurate values.

Additionally Visual Crossing uses the multiple station approach to cleanse inaccurate or missing data. On rare occasions, data for a specific location may be missing or incorrect. By comparing data across stations, a more accurate report can be determined by eliminating empty values and values that outside of reasonable ranges.

---
title: "ANLY 512 - Data Exploration and Analysis Laboratory"
author: "PN"
output: 
  flexdashboard::flex_dashboard:
    theme:
      version: 4
      bg: "#ecf2e6"
      fg: "#1c1f1b" 
      primary: "#4b4f4c"
      navbar-bg: "#ace3b2"
      base_font: 
        google: Prompt
      heading_font:
        google: Sen
      code_font:
        google: 
          # arguments to sass::font_google() 
          family: JetBrains Mono
          local: false
    orientation: rows
    #vertical_layout: fill
    source_code: embed
editor_options: 
  chunk_output_type: console
---

```{r}
library(tidyverse)
library(reshape2)
library(cowplot)
library(magrittr)

library(flexdashboard)
library(ggplot2)
library(dygraphs)
library(plotly)
library(dplyr)
library(rnoaa)
library(ggthemes)
library(plyr)
library(dplyr)
library(dygraphs)
```

```{r}
read_data <- function(file){
  read_csv(file) %>%
    rename_all(funs(replace(., values = c("product_code", "station_number", "year", "month", "mean_max", "quality")))) %>%
    mutate(month = factor(month.name[as.integer(month)], levels = month.name)) %>%
    filter(quality == "Y")
}
 
# load file directly from my web server
bris_reg_max <- read_data(file = "https://davetang.org/weather/IDCJAC0002_040214_Data1.csv")
bris_reg_min <- read_data(file = "https://davetang.org/weather/IDCJAC0004_040214_Data1.csv")
bris_max <- read_data(file = "https://davetang.org/weather/IDCJAC0002_040913_Data1.csv")
bris_min <- read_data(file = "https://davetang.org/weather/IDCJAC0004_040913_Data1.csv")

bris_reg_max %<>% filter(year >= 1910)
bris_reg_min %<>% filter(year >= 1910)
```

```{r}
theme_set(theme_bw())
 
get_colour <- function(df){
  colfunc <- colorRampPalette(c("blue", "red"))
  my_colour <- colfunc(12)
   
  df %>%
    group_by(month) %>%
    mutate(month_mean = mean(mean_max)) %>%
    arrange(month_mean) %>%
    pull(month) %>%
    as.integer() -> my_order
   
  my_colour[match(1:12, my_order)]
}
```

```{r}
my_colour <- get_colour(bris_max)
a <- ggplot(bris_max, aes(year, mean_max, colour = month)) +
  geom_point(size = 0.5) +
  geom_smooth(method = "loess") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 6),
        axis.title.x = element_blank(),
        legend.position = "none") +
  scale_color_manual(values = my_colour) +
  labs(title = "Monthly mean maximum temperature", subtitle = "Brisbane: December 1999 - November 2019", y = "Degrees Celsius") +
  facet_wrap(~month) +
  NULL
 
my_colour <- get_colour(bris_min)
b <- ggplot(bris_min, aes(year, mean_max, colour = month)) +
  geom_point(size = 0.5) +
  geom_smooth(method = "loess") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 6),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        legend.position = "none") +
  scale_color_manual(values = my_colour) +
  labs(title = "Monthly mean minimum temperature", subtitle = "Brisbane: December 1999 - November 2019") +
  facet_wrap(~month) +
  NULL
 
#plot_grid(a, b)
```

```{r}
tempo <- 
  bris_max %>%
  group_by(year) %>%
  dplyr::summarise(
    n = n(),
    year_mean = mean(mean_max), 
    .groups = "keep")
  
```

```{r}
c <- bris_reg_max %>%
  filter(year != 1986) %>%
  group_by(year) %>%
  dplyr::summarise(year_mean = mean(mean_max)) %>%
  ggplot(., aes(year, year_mean)) +
    geom_point() +
    geom_line() +
    geom_smooth(method = "loess") +
    theme(axis.title.x = element_blank(),
          legend.position = "none") +
    labs(title = "Annual mean maximum temperature", subtitle = "Brisbane Regional Office: 1910 - 1985", y = "Degrees Celsius") +
    NULL
 
d <- bris_reg_min %>%
  filter(year != 1986) %>%
  group_by(year) %>%
  dplyr::summarise(year_mean = mean(mean_max)) %>%
  ggplot(., aes(year, year_mean)) +
    geom_point() +
    geom_line() +
    geom_smooth(method = "loess") +
    theme(axis.title.x = element_blank(),
          axis.title.y = element_blank(),
          legend.position = "none") +
    labs(title = "Annual mean minimum temperature", subtitle = "Brisbane Regional Office: 1910 - 1985") +
    NULL
 
#plot_grid(a, NULL, b, nrow = 1, rel_widths = c(1, 0.05, 1))
```

```{r}
syd_max <- read_data(file = "https://davetang.org/weather/IDCJAC0002_066062_Data1.csv")
syd_min <- read_data(file = "https://davetang.org/weather/IDCJAC0004_066062_Data1.csv")
syd_max %<>% filter(year >= 1910)
syd_min %<>% filter(year >= 1910)
```

```{r}
my_colour <- get_colour(syd_max)
a2 <- ggplot(syd_max, aes(year, mean_max, colour = month)) +
  geom_point(size = 0.5) +
  geom_smooth(method = "loess") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
        axis.title.x = element_blank(),
        legend.position = "none") +
  scale_color_manual(values = my_colour) +
  labs(title = "Monthly mean maximum temperature", subtitle = "Sydney: January 1910 - November 2019", y = "Degrees Celsius") +
  facet_wrap(~month) +
  NULL
 
my_colour <- get_colour(syd_min)
b2 <- ggplot(syd_min, aes(year, mean_max, colour = month)) +
  geom_point(size = 0.5) +
  geom_smooth(method = "loess") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        legend.position = "none") +
  scale_color_manual(values = my_colour) +
  labs(title = "Monthly mean minimum temperature", subtitle = "Sydney: January 1910 - November 2019") +
  facet_wrap(~month) +
  NULL
 
#plot_grid(a, b)
```

```{r}
c2 <- syd_max %>%
  filter(year != 2019) %>%
  group_by(year) %>%
  dplyr::summarise(year_mean = mean(mean_max)) %>%
  ggplot(., aes(year, year_mean)) +
    geom_point() +
    geom_line() +
    geom_smooth(method = "loess") +
    theme(axis.title.x = element_blank(),
          legend.position = "none") +
    labs(title = "Annual mean maximum temperature", subtitle = "Sydney: 1910 - 2018", y = "Degrees Celsius") +
    NULL
 
d2 <- syd_min %>%
  filter(year != 2019) %>%
  group_by(year) %>%
  dplyr::summarise(year_mean = mean(mean_max)) %>%
  ggplot(., aes(year, year_mean)) +
    geom_point() +
    geom_line() +
    geom_smooth(method = "loess") +
    theme(axis.title.x = element_blank(),
          axis.title.y = element_blank(),
          legend.position = "none") +
    labs(title = "Annual mean minimum temperature", subtitle = "Sydney: 1910 - 2018") +
    NULL
 
#plot_grid(c, NULL, d, nrow = 1, rel_widths = c(1, 0.05, 1))

```

```{r}
per_max <- read_data(file = "https://davetang.org/weather/IDCJAC0002_009021_Data1.csv")
per_min <- read_data(file = "https://davetang.org/weather/IDCJAC0004_009021_Data1.csv")
```

```{r}
my_colour <- get_colour(per_max)
a3 <- ggplot(per_max, aes(year, mean_max, colour = month)) +
  geom_point(size = 0.5) +
  geom_smooth(method = "loess") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
        axis.title.x = element_blank(),
        legend.position = "none") +
  scale_color_manual(values = my_colour) +
  labs(title = "Monthly mean maximum temperature", subtitle = "Perth: June 1944 - November 2019", y = "Degrees Celsius") +
  facet_wrap(~month) +
  NULL
 
my_colour <- get_colour(per_min)
b3 <- ggplot(per_min, aes(year, mean_max, colour = month)) +
  geom_point(size = 0.5) +
  geom_smooth(method = "loess") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        legend.position = "none") +
  scale_color_manual(values = my_colour) +
  labs(title = "Monthly mean minimum temperature", subtitle = "Perth: June 1944 - November 2019") +
  facet_wrap(~month) +
  NULL
 
#plot_grid(a3, b3)
```

```{r}
c3 <- per_max %>%
  filter(year != 1944, year != 2019) %>%
  group_by(year) %>%
  dplyr::summarise(year_mean = mean(mean_max)) %>%
  ggplot(., aes(year, year_mean)) +
    geom_point() +
    geom_line() +
    geom_smooth(method = "loess") +
    theme(axis.title.x = element_blank(),
          legend.position = "none") +
    labs(title = "Annual mean maximum temperature", subtitle = "Perth: 1945 - 2018", y = "Degrees Celsius") +
    NULL
 
d3 <- per_min %>%
  filter(year != 1944, year != 2019) %>%
  group_by(year) %>%
  dplyr::summarise(year_mean = mean(mean_max)) %>%
  ggplot(., aes(year, year_mean)) +
    geom_point() +
    geom_line() +
    geom_smooth(method = "loess") +
    theme(axis.title.x = element_blank(),
          axis.title.y = element_blank(),
          legend.position = "none") +
    labs(title = "Annual mean minimum temperature", subtitle = "Perth: 1945 - 2018") +
    NULL
 
#plot_grid(c3, NULL, d3, nrow = 1, rel_widths = c(1, 0.05, 1))
```

# Brisbane

## Row

### Maximum Temperature in Brisbane - Over The Years

```{r}
a
```

### Maximum Temperature in Brisbane - Trend

```{r}
c
```

## Row

### Minimum Temperature in Brisbane - Over The Years

```{r}
b
```

### Minimum Temperature in Brisbane - Trend

```{r}
d
```

# Sydney

## Row

### Maximum Temperature in Sydney - Over The Years

```{r}
a2
```

### Maximum Temperature in Sydney - Trend

```{r}
c2
```

## Row

### Minimum Temperature in Sydney - Over The Years

```{r}
b2
```

### Minimum Temperature in Sydney - Trend

```{r}
d2
```

# Perth

## Row

### Maximum Temperature in Perth - Over The Years

```{r}
a3
```

### Maximum Temperature in Perth - Trend

```{r}
c3
```

## Row

### Minimum Temperature in Perth - Over The Years

```{r}
b3
```

### Minimum Temperature in Perth - Trend

```{r}
d3
```

# Analysis and Questions

### Analysis of Weather Station Data

**Station Data : Brisbane, Sydney & Perth**

The Australian Bureau of Meteorology provides historical weather data, some of which can be freely downloaded. For the purpose of this analysis of weather data, data was collected from two weather stations in Brisbane: the Brisbane Regional Office weather station (latitude 27.466 degrees south, longitude 153.0270 degrees east, and elevation of 38 metres) with data available from 1887 January until 1986 March and the Brisbane weather station (latitude 27.4808 degrees south, longitude 153.0389 degrees east, and elevation of 8 metres) with data available from 1999 December until 2020 January. We look at monthly maximum temperature (the highest temperature recorded in the 24 hours from 9 am) and the monthly (the lowest temperature recorded in the 24 hours to 9 am). The ground minimum temperature (lowest overnight temperature measured at ground level.)

Sydney (Observatory Hill) weather station (latitude 33.8607 degrees south, longitude 151.2050 degrees east, and elevation of 39 metres) has a continuous collection of data from 1859 until 2020

Perth Airport weather station (latitude 31.9275 degrees south, longitude 115.9764 degrees east, and elevation of 15 metres) has a continuous collection of data from 1944 until 2020.

### Questions to Ponder

**What is this temperature really and why does it matter?**

The temperature of air is a measure of the average thermal energy of the molecules in the air - the higher the temperature, the higher the energy of the molecules. Historically, the most common instrument used has been a liquid-in-glass thermometer mounted in a Stevenson screen. Modern automatic weather stations generally use an electronic sensor. The daily maximum (highest) and minimum (lowest) temperature are generally recorded once each day at 9 am local time, while instantaneous measurements of air temperature may be made at various times throughout the day.

**Does the location of weather station matter?**

*Multi-station approach to weather data:*

Visual Crossing by default takes the 3 nearest weather stations to the location entered to compute the accurate weather at your location. The distance to the weather stations are weighted by distance for the final result. If your location is 10, 40, 50 miles away from weather stations, they will be weighted by these distances. It greatly helps areas that are far from weather stations to both determine through interpolation the most accurate values.

Additionally Visual Crossing uses the multiple station approach to cleanse inaccurate or missing data. On rare occasions, data for a specific location may be missing or incorrect. By comparing data across stations, a more accurate report can be determined by eliminating empty values and values that outside of reasonable ranges.