This Rmarkdown file grabs the noise pollution data I collected while walking around DC and plots it. For what it’s worth, here’s the recording device I used:

And below is the math I used to calculate the Ldn value.

First, make some conservative assumptions about the average noise level that I’m exposed to at different points throughout the day. Door-to-door for my morning commute, the average noise level was just above 72 dBA.

To keep the numbers simple, let’s assume my total, round-trip commute is an hour (30 minutes each way) and round down to 70 dBA. We can further assume that my apartment is 30 dBA at night (it’s actually higher than this; my window AC unit is just over 40 dBA). For simplicity, let’s assume my workday is about 40 dBA (I’m in a lot of meetings), and my waking time at home is 35 dBA. Here’s a table:

And here’s the formula, with the numbers plugged in:

This gives an Ldn value of 56.3.

Below is the rest of my math.

knitr::opts_chunk$set(echo = TRUE, warning=FALSE)
knitr::opts_chunk$set(fig.width=14, fig.height=7) 

# load packages we'll need
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
load_data <- function(url) {
  ## a function that just loads the decibel data
  df <- read.csv(url)
  # convert date time variable to date:
  df$date_time <- as.POSIXct(df$Time, "%d/%m/%Y %H:%M:%S", tz='America/New_York')
  
  return(df)
}

make_basic_graph <- function(df, title, y_min, y_max=95, include_notes=TRUE) {
  p <-
    ggplot(data=df, aes(x=Record, y=Noise_dB)) +
    geom_line() +
    scale_y_continuous(breaks = seq(y_min, y_max, by = 5)) +
    scale_x_continuous(breaks=df$Record[seq(1, length(df$Record), 600)], 
                       label=substr(x = df$Time[seq(1, length(df$Time), 600)], start = 10, stop = 14)) + 
    theme_minimal() +
    xlab('') +
    ylab('Decibel level') +
    ggtitle(title) +
    theme(axis.title = element_text(size=12))
  
  if (include_notes) {
    p <-
      p +
      geom_point(data=df[df$Notes_simple != "",], aes(x=Record, y=Noise_dB, color=as.factor(Notes_simple)), size=2) +
      labs(color='Noise source') 
  }
  
  return(p)
}

line_color = 'black'
alpha = .6
line_style = 1

# mean_val <- round(mean(df$Noise_dB), 2)  # linear mean
calc_log_mean <- function(input_data) {
  mean_val = 10*log(x = sum(10^(input_data / 10)) * 1/length(input_data), base = 10)
  return(mean_val)
}

Ontario Road and Columbia data

Location: 38.92424395477514, -77.04016100977317

df <- load_data("https://docs.google.com/spreadsheets/d/e/2PACX-1vT7ItfiE7AaBTt7wPTzEjR6jFpCJAJ3XV_jeg2xS7IuR8bqwfQJ0mDb8wlOvNpxaz7ehhIzm1oY7kwi/pub?gid=2043751314&single=true&output=csv")

# remove data sampled when I was walking to the spot at Columbia Rd and Ontario NW.
# It would be interesting to record in my neighborhood but that is not the point right now.
df <- df[200:nrow(df),]


mean_val <- calc_log_mean(df$Noise_dB) # log mean


make_basic_graph(df, 
                      'Noise levels at bus stop 1001862 on Columbia Road on a July weeknight', 
                      y_min = 45) +
  geom_hline(aes(yintercept=mean_val), color=line_color, alpha=alpha, linewidth=1) +
    annotate("text", x = max(df$Record)-120, y = 95,
               size=4,
           color='black',
               label = paste0('log mean: ', round(mean_val, 1), ' dBA'))

Bus stop near the Kenilworth Expressway data

Location: 38.90348142163074, -76.94311706948615

df <- load_data('https://docs.google.com/spreadsheets/d/e/2PACX-1vT7ItfiE7AaBTt7wPTzEjR6jFpCJAJ3XV_jeg2xS7IuR8bqwfQJ0mDb8wlOvNpxaz7ehhIzm1oY7kwi/pub?gid=1763293624&single=true&output=csv')

p <- make_basic_graph(df,
                      'Noise levels at bus stop 1001274 near Kenilworth Expressway on a Sunday',
                      include_notes = F,
                      y_min = 45)

freeway_start = 110
freeway_end   = 685
freeway_y_val = calc_log_mean(df$Noise_dB[df$Record > freeway_start & df$Record < freeway_end])

car_start = 777
car_end   = 1435
car_y_val = calc_log_mean(df$Noise_dB[df$Record > car_start & df$Record < car_end])

q <- p +
  geom_segment(aes(x = freeway_start, y = freeway_y_val, xend = freeway_end, yend = freeway_y_val), 
               colour = line_color, linetype=line_style, size=1, alpha=alpha) +
  annotate("text", x = freeway_start + 250, y = min(df$Noise_dB)-10, label = "Bus stop near freeway") +
  
  geom_segment(aes(x = car_start, y = car_y_val, xend = car_end, yend = car_y_val), 
               colour = line_color, linetype=line_style, size=1, alpha=alpha) +
  annotate("text", x = car_start + 200, y = min(df$Noise_dB)-10, label = "In the car driving") + 
  
  annotate("text", x = car_end + 200, y = min(df$Noise_dB)-10, label = "Back home") +

   coord_cartesian(ylim = c(min(df$Noise_dB), max(df$Noise_dB)), clip="off") +
   geom_segment(aes(x = freeway_start,
                   y = min(df$Noise_dB)-8,
                   xend = freeway_end,
                   yend = min(df$Noise_dB)-8),
                size=1
                ) +
  geom_segment(aes(x = car_start,
                   y = min(df$Noise_dB)-8,
                   xend = car_end,
                   yend = min(df$Noise_dB)-8),
                size=1
                ) +
    geom_segment(aes(x = car_end+60,
                   y = min(df$Noise_dB)-8,
                   xend = max(df$Record),
                   yend = min(df$Noise_dB)-8),
                size=1
                ) +
  theme(plot.margin = unit(c(2,1,2,0), "lines"))

q

Commute to work

df <- load_data('https://docs.google.com/spreadsheets/d/e/2PACX-1vT7ItfiE7AaBTt7wPTzEjR6jFpCJAJ3XV_jeg2xS7IuR8bqwfQJ0mDb8wlOvNpxaz7ehhIzm1oY7kwi/pub?gid=560260845&single=true&output=csv')

p <- 
  make_basic_graph(df, include_notes = F, 'Noise levels on my morning commute on a Tuesday', y_min=25) +
  coord_cartesian(ylim = c(min(df$Noise_dB), max(df$Noise_dB)), clip="off") +
  theme(plot.margin = unit(c(1,1,1,0), "lines"))

text <- c("Lanier Hts", "Conn Ave", "Metro", "Downtown")
ii <- 1
pairs_list <- list(c(1, 425), c(425, 931), c(931, 2161), c(2161, 2822))
for (id_pairs in pairs_list) {
  mean_val = calc_log_mean(df$Noise_dB[df$Record >= id_pairs[1] & df$Record <= id_pairs[2]])
  p <-
    p +
       annotate("segment", x = id_pairs[1], y = mean_val, xend = id_pairs[2], yend = mean_val, 
                colour = line_color, linetype=line_style, alpha=alpha, linewidth=1) +
    annotate("text", x = id_pairs[1]+200, y = min(df$Noise_dB)-11, label = text[ii])
  
  ii <- ii + 1
}

line_ht <- 9
gap <- 30
q <- p +
    annotate(geom = 'segment', x = pairs_list[[1]][1],
                   y = min(df$Noise_dB)-line_ht,
                   xend = pairs_list[[1]][2]-gap,
                   yend = min(df$Noise_dB)-line_ht,
                size=1
                ) +
    annotate(geom = 'segment', x = pairs_list[[2]][1],
                   y = min(df$Noise_dB)-line_ht,
                   xend = pairs_list[[2]][2]-gap,
                   yend = min(df$Noise_dB)-line_ht,
                size=1
                ) +
  annotate(geom = 'segment', x = pairs_list[[3]][1],
                   y = min(df$Noise_dB)-line_ht,
                   xend = pairs_list[[3]][2]-gap,
                   yend = min(df$Noise_dB)-line_ht,
                size=1
                ) +
  annotate(geom = 'segment', x = pairs_list[[4]][1],
                   y = min(df$Noise_dB)-line_ht,
                   xend = pairs_list[[4]][2],
                   yend = min(df$Noise_dB)-line_ht,
                size=1
                )
  
q

calc_log_mean(df$Noise_dB[df$Record >= 1 & df$Record <= 2822])
## [1] 72.02816

Comparing noise levels at streeteries on 14th and 17th st

df <- load_data('https://docs.google.com/spreadsheets/d/e/2PACX-1vT7ItfiE7AaBTt7wPTzEjR6jFpCJAJ3XV_jeg2xS7IuR8bqwfQJ0mDb8wlOvNpxaz7ehhIzm1oY7kwi/pub?gid=515952561&single=true&output=csv')

df <-
  df %>%
  filter(
    (Notes == "Location=17st in front of Annie's Steaks" & Record < 615) |
      (Notes == "Location=14st, in front of Rice Market")
    )

p <-
ggplot(data=df, aes(x=Record, y=Noise_dB, color=as.factor(Notes))) +
  geom_line() +
  scale_y_continuous(breaks = seq(35, 95, by = 5)) +
  scale_x_continuous(breaks=seq(1, 660, 60),
                     label=round(seq(1, 660, 60) / 60, 0) ) + 
  theme_minimal() +
  xlab('Time in minutes') +
  ylab('Decibel level') +
  labs(color='Location') +
  ggtitle("Less traffic noise on 17th St than 14th St") +
  annotate("segment", 
           x = 1, y = calc_log_mean(df$Noise_dB[df$Notes ==  "Location=14st, in front of Rice Market" ]), 
           xend = max(df$Record), yend = calc_log_mean(df$Noise_dB[df$Notes ==  "Location=14st, in front of Rice Market" ]), 
           colour = line_color, alpha=alpha) +
  annotate("segment", 
           x = 1, y = calc_log_mean(df$Noise_dB[df$Notes ==  "Location=17st in front of Annie's Steaks" ]), 
           xend = max(df$Record), yend = calc_log_mean(df$Noise_dB[df$Notes ==  "Location=17st in front of Annie's Steaks" ]), 
           colour = line_color, alpha=alpha) +
   scale_color_manual(labels = c("14th St near Rice Bar", "17th St near Annie's"), values = c("#F07167", "#0081A7"))
  
p