Introduction

  • First, load the required packages
library(tidyverse)
library(lubridate)
library(ggplot2)
library(tidyr)
library(viridis)

The Data

The dataset under analysis originates from the World Ozone and Ultraviolet Radiation Data Centre (WOUDC), encompassing a comprehensive collection of UV radiation measurements across various global locations. It captures key metrics such as the hourly average of the UV index, geographical coordinates (latitude and longitude), and the timestamp of each observation, alongside metadata including the platform and instrument used for measurements, and the participating country (all data is Canadian).

The main strucutre of this report presents an in-depth analysis of UV radiation trends across Canada, utilizing datasets from 1989-1995 and 2008-2016. My objective is to evaluate changes in UV exposure over time, pinpoint locations with the highest UV levels, identify peak exposure times, and understand seasonal variations. The purpose is to shed light on UV radiation patterns, offering insights critical for environmental health and safety.

  • Load the data
uv_1989_1995 <- read_csv(file="uv_90s.csv",show_col_types = FALSE)
uv_2008_2016 <- read_csv(file="uv_10s.csv", show_col_types = FALSE)

Main Objectives

  • Assess the year-over-year variability in UV index levels for each dataset to identify any significant fluctuations or trends in UV radiation exposure.

  • Investigate which locations experienced the most extreme UV index readings in each dataset and whether some areas are consistently more prone to high UV levels.

  • Explore how UV index levels change with the seasons within each dataset to understand seasonal impacts on UV exposure.

  • Interannual Consistency of High UV Index Locations – are the trends the same between years?

Objective I: Assessing UV Radiation Increase Over the Years

# Extracting the years for each dataset
uv_1989_1995$year <- year(as.Date(uv_1989_1995$instance_datetime, "%Y/%m/%d"))
uv_2008_2016$year <- year(as.Date(uv_2008_2016$instance_datetime, "%Y-%m-%d"))

# Calculating the yearly average UV index for each dataset

avg_uv_1989_1995 <- uv_1989_1995 %>%
  group_by(year) %>%
  summarise(avg_uv_index = mean(uv_index_hourly_average, na.rm = TRUE)) %>%
  mutate(dataset = "1989-1995")

avg_uv_2008_2016 <- uv_2008_2016 %>%
  group_by(year) %>%
  summarise(avg_uv_index = mean(uv_index_hourly_average, na.rm = TRUE)) %>%
  mutate(dataset = "2008-2016")

combined_data <- bind_rows(avg_uv_1989_1995, avg_uv_2008_2016)

# Plotting

trends <- ggplot(combined_data, aes(x = year, y = avg_uv_index, color = dataset)) +
  geom_line() +
  geom_point() +
  facet_wrap(~dataset, scales = "free_x") +
  theme_minimal() +
  labs(title = "Average UV Index Over Years by Year Interval",
       x = "Year",
       y = "Average UV Index") +
  scale_color_manual(values = c("1989-1995" = "blue", "2008-2016" = "red"))

trends

The faceted line graphs reveal distinct UV index trends over the two periods studied. The earlier years (1989-1995) show relatively stable but higher UV levels with a sudden drop in the final year, while the later years (2008-2016) show a consistent decline in UV radiation. The disparity between the two periods suggests potential changes in atmospheric conditions, data collection methods, or environmental policies, warranting further investigation to understand the underlying factors influencing these observations.

A faceted line plot is ideal for comparison as it clearly displays separate trends side-by-side within the same visual context, making it easier to discern differences and similarities in the data across different time periods.

Objective II: Highest UV Levels by Location

Here, I will aim to identify the locations (in Canada) experiencing the highest UV radiation levels to pinpoint regions requiring increased awareness and protective measures.

# Aggregating data for the highest average UV index by location

highest_uv_1989_1995 <- uv_1989_1995 %>%
  group_by(platform_name) %>%
  summarise(avg_uv_index = mean(uv_index_hourly_average, na.rm = TRUE)) %>%
  arrange(desc(avg_uv_index))

highest_uv_2008_2016 <- uv_2008_2016 %>%
  group_by(platform_name) %>%
  summarise(avg_uv_index = mean(uv_index_hourly_average, na.rm = TRUE)) %>%
  arrange(desc(avg_uv_index))


# Add a 'dataset' column to each data frame to indicate the time interval
highest_uv_1989_1995 <- highest_uv_1989_1995 %>%
  mutate(dataset = '1989-1995')

highest_uv_2008_2016 <- highest_uv_2008_2016 %>%
  mutate(dataset = '2008-2016')

# Combine the top 10 locations from each dataset into a single data frame
top_uv_locations <- bind_rows(
  highest_uv_1989_1995[1:10, ],
  highest_uv_2008_2016[1:10, ]
)

top_uv_locations <- top_uv_locations %>% 
  filter(!is.na(platform_name))

# Facetted bar plot
highest_uv_location <- ggplot(top_uv_locations, aes(x = reorder(platform_name, avg_uv_index), y = avg_uv_index, fill = dataset)) +
  geom_col(show.legend = FALSE) +
  coord_flip() + # Flips the axes
  facet_wrap(~ dataset, scales = "free", ncol = 1) +
  scale_fill_manual(values = c('1989-1995' = 'steelblue', '2008-2016' = 'coral')) +
  labs(title = "UV Index by Location Comparison",
       x = "Location (Platform)",
       y = "UV Index (level)") +
  theme_minimal(base_size = 12) + # Adjust base_size to increase readability
  theme(
    axis.text.y = element_text(size = 7), # Adjust text size for Y axis to prevent overlapping
    panel.grid.major = element_blank(), # Remove major grid lines for a cleaner look
    panel.grid.minor = element_blank(), # Remove minor grid lines
    panel.background = element_rect(fill = "aliceblue"), # Change background color for fun
    plot.background = element_rect(fill = "lavender", color = NA), # Change plot background color
    strip.background = element_rect(fill = "lightblue") # Change facet label background color
  )

highest_uv_location

The faceted bar chart displays the top locations with the highest average UV index for two distinct time periods. In the 1989-1995 interval, Winnipeg, Montreal, and Saturna Island lead with the highest UV indices, whereas for 2008-2016, Saturna Island, Edmonton, and Churchill top the list. Notably, Saturna Island consistently appears among the highest for both periods, underscoring its persistent exposure to higher UV levels. The two datasets show some overlap but also some unique entries, indicating possible shifts in UV radiation patterns or changes in environmental conditions over the years.

Objective III: Peak UV Times by Season Comparison (1989-1995 vs 2008-2016)

# Define a new function to process the data and include the 'season' and 'dataset' information
process_data_with_season <- function(data, datetime_format, dataset_label) {
  data %>%
    mutate(
      date = as.Date(instance_datetime, format = datetime_format),
      month = month(date),
      season = case_when(   # Define which month number goes to which season
        month %in% c(3, 4, 5) ~ "Spring",
        month %in% c(6, 7, 8) ~ "Summer",
        month %in% c(9, 10, 11) ~ "Autumn",
        TRUE ~ "Winter"
      ),
      dataset = dataset_label
    ) %>%
    select(-instance_datetime, -date, -month) %>%
    mutate(across(where(is.numeric), as.character)) # Convert all numeric columns to character
}

# Apply the function to both datasets
uv_1989_1995_processed <- process_data_with_season(uv_1989_1995, "%Y/%m/%d %H:%M:%S", "1989-1995")
uv_2008_2016_processed <- process_data_with_season(uv_2008_2016, "%Y-%m-%d %H:%M:%S", "2008-2016")

# Combine the datasets
uv_combined <- bind_rows(uv_1989_1995_processed, uv_2008_2016_processed)

# Convert `uv_index_hourly_average` back to numeric for analysis
uv_combined$uv_index_hourly_average <- as.numeric(uv_combined$uv_index_hourly_average)

# Calculate the average UV index per season for each dataset
avg_uv_by_season <- uv_combined %>%
  group_by(season, dataset) %>%
  summarise(avg_uv_index = mean(uv_index_hourly_average, na.rm = TRUE), .groups = "drop")

# Define colors for each season
season_colors <- c("Spring" = "#60D394", "Summer" = "#FACF5A", "Autumn" = "#F79460", "Winter" = "#69A2B0")

# Create the faceted plot
season_plot <- ggplot(avg_uv_by_season, aes(x = season, y = avg_uv_index, fill = season)) +
  geom_bar(stat = "identity", position = "dodge") +
  facet_wrap(~ dataset) +
  theme_minimal() +
  labs(title = "Seasonal Variation in UV Index Across Datasets",
       x = "Season",
       y = "Average UV Index") +
  scale_fill_manual(values = season_colors)

season_plot

The faceted bar chart illustrates the seasonal variation in UV index for the two distinct time intervals, 1989-1995 and 2008-2016. In both datasets, the UV index peaks during the summer, suggesting the highest potential for UV exposure and the greatest need for protective measures against UV radiation. Conversely, winter months show the lowest UV index, indicating minimal UV exposure. The spring and autumn seasons exhibit moderate UV levels, with a slight increase observed in spring.

This pattern is consistent across both time periods, demonstrating a clear seasonal impact on UV radiation levels in Canada, however, we can see an overall decline in UV index in the later year interval (2008-2016). Interesting!

Objective IV: Interannual Consistency of High UV Index Locations

The fourth objective seeks to explore the interannual consistency of UV index readings at the highest-risk locations. By examining the frequency and distribution of high UV index days, we can determine if certain locations consistently experience high levels of UV radiation year after year, which could indicate a sustained risk for adverse health effects related to UV exposure.

For visualization, I will use something called a “bubble heatmap”.

# Define a threshold for what we consider a high UV index, e.g., the top 75th percentile
high_uv_threshold <- quantile(uv_combined$uv_index_hourly_average, probs = 0.75, na.rm = TRUE)

# Create a new dataframe for high UV index readings
high_uv_days <- uv_combined %>% # Use the uv_combined from earlier
  filter(uv_index_hourly_average >= high_uv_threshold) %>%
  count(platform_name, year) %>%
  arrange(platform_name, year)

# Now create a bubble heatmap
bubble_heatmap <- ggplot(high_uv_days, aes(x = year, y = platform_name, size = n, fill = n)) +
  geom_point(shape = 21, alpha = 0.7) + # Use shape 21 for filled bubbles
  scale_size(range = c(2, 12)) + # Adjust the size range for bubbles
  scale_fill_viridis(option = "C", direction = -1,
                     guide = guide_colourbar(title.position = "top",title.hjust = 0.5,label.position = "bottom"
                     )) + # Viridis color scale too look more fun
  theme_minimal() +
  labs(title = "Interannual Consistency of High UV Index Days",
       x = "Year",
       y = "Location",
       size = "Number of High UV Days",
       fill = "Number of High UV Days") +
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1), # Rotate x axis labels for better readability
    plot.margin = margin(t = 10, r = 55, b = 10, l = 10),
    legend.position = "bottom", #Moves legend to bottom of plot
    legend.direction = "horizontal",
    legend.title = element_text(size = 8),
    legend.text = element_text(size = 6),
    legend.key.size = unit(0.5, "cm"),
    plot.title = element_text(size = 14, hjust = 0.5),
    axis.title = element_text(size = 12)
  )

bubble_heatmap

The bubble heatmap reveals an intriguing pattern of interannual UV index variability across different Canadian locations. Most notably, locations like Toronto and Winnipeg exhibit a higher frequency of days with high UV index levels throughout the years, with particularly large bubbles indicating a greater number of high UV days. This suggests that certain geographic areas may be subject to consistently higher UV exposure over time. On the other hand, some locations show significant variation from year to year, which could be influenced by environmental changes or data collection discrepancies.

Next Steps and Future Research

The comparative analyses of UV index data across two separate time periods provide valuable insights into UV radiation trends in Canada. The persistent high UV exposure in specific locations raises questions about the possible environmental factors contributing to these patterns. Moreover, the seasonal fluctuations confirm expected peaks during summer months, but the variability between years and locations suggests that additional factors, possibly including atmospheric composition changes or shifts in weather patterns, could be influencing UV intensity.

To build upon these findings, further research could investigate the environmental and climatic elements affecting UV radiation. This could include studies on ozone concentration changes, cloud coverage patterns, and their correlations with UV index levels. Additionally, exploring the long-term health impacts of sustained high UV exposure in certain regions could inform public health initiatives and prevention strategies. Moreover, examining the influence of solar cycles and climate change on UV radiation could yield insights into future trends and adaptation needs. Overall, the findings warrant a multidisciplinary approach, combining climatology, environmental sciences, and public health to fully understand and address the implications of UV radiation exposure in Canada.