library(lubridate)
library(dplyr)
library(tidyr)
library(ggmap)
library(ggplot2)
theme_set(theme_bw())

Raw data file: https://www.dropbox.com/s/vmzxu3vqzqlof3l/EXOHH_Default%20Site_080614_110537.csv

Data preparation includes:

  1. Load file from CSV (skipping metadata headers and assigning simpler column names)
  2. Parse date/times and convert from UTC to US/Eastern
  3. Make longitudes negative (since they are W and must be in E to be plotted)
  4. Remove duplicated rows
  5. Select only the columns of interest
  6. Remove any data points with Depth < 0
df <- read.csv('~/Dropbox/Dissolved Oxygen Surveys/Boat surveys/20140806/EXOHH_Default Site_080614_110537.csv',
               header=FALSE, skip=31, as.is=TRUE,
               col.names=c('DATE', 'TIME', 'TIME_FRAC', 'SITE', 'FAULT_CODE','TEMP',
                           'COND', 'SPCOND', 'TDS', 'SAL',
                           'DO_SAT','DO','PRESS','DEPTH', 'TURB',
                           'TSS','CHLA_RFU','CHLA','BGA_PC_RFU','BGA_PC',
                           'CABLE_PWR','BATTERY_V','LONGITUDE','LATITUDE','BARO'))

df <- mutate(df, DATETIME=paste(DATE, TIME, sep=' ') %>%
                  mdy_hms(tz="UTC") %>%
                  with_tz(tzone="US/Eastern"),
                 LONGITUDE=-LONGITUDE)
df <- df[which(!duplicated(df$DATETIME)),]
df <- select(df, DATETIME, LONGITUDE, LATITUDE, DEPTH, TEMP, SPCOND, SAL,
                 DO_SAT, DO, TURB, CHLA) %>%
  filter(DEPTH > 0)
head(df)
##              DATETIME LONGITUDE LATITUDE DEPTH  TEMP SPCOND  SAL DO_SAT
## 1 2014-08-06 07:05:37    -71.09     42.4 0.279 25.60  952.8 0.47   91.0
## 2 2014-08-06 07:07:59    -71.09     42.4 1.754 24.52 1053.4 0.52   67.0
## 3 2014-08-06 07:09:55    -71.09     42.4 0.275 25.57  951.5 0.47   99.7
## 4 2014-08-06 07:11:20    -71.09     42.4 1.904 24.37 1144.6 0.57   68.9
## 5 2014-08-06 07:14:22    -71.08     42.4 0.270 25.51  979.4 0.48   99.6
## 6 2014-08-06 07:16:13    -71.08     42.4 1.919 24.28 1155.0 0.57   67.8
##     DO TURB  CHLA
## 1 7.42 3.30 15.15
## 2 5.57 6.37 27.04
## 3 8.13 3.19 15.29
## 4 5.74 5.81 24.73
## 5 8.13 3.63 14.54
## 6 5.66 9.89 29.48

Relationships

This figure compares each variable with depth. There are clear relationships for Temperature, DO, and Salinity. The CHLA data show an interesting relationship with the highest values at the medium depths.

gather(df, VAR, VALUE, TEMP:CHLA) %>%
ggplot(aes(DEPTH, VALUE)) +
  geom_point() +
  geom_smooth() +
  geom_hline(yint=0, alpha=0) +
  geom_vline(yint=0, alpha=0) +
  facet_wrap(~VAR, scales='free_y') +
  labs(x="Depth (m)", y="Value")

plot of chunk plot_depth_value

There also appears to be a positive relationship between Chl-a and turbidity, as expected. Note that I am excluding two samples where Turbidity > 50.

filter(df, TURB < 50) %>%
ggplot(aes(TURB, CHLA)) +
  geom_point() +
  geom_smooth() +
  geom_hline(yint=0) +
  geom_vline(yint=0) +
  labs(x="Turbidity (FNU)", y="Chl-a (ug/L)")

plot of chunk plot_turb_chla

To evaluate the presence of a salt wedge, the relationship between salinity and depth suggests salt water presence when depths > 2 m.

ggplot(df, aes(DEPTH, SAL)) +
  geom_point() +
  geom_smooth() +
  geom_hline(yint=0) +
  geom_vline(yint=0) +
  labs(x="Depth (m)", y="Salinity (psu)")

plot of chunk plot_sal_chla

Data Maps

First get the basemap.

map <- get_map(location=c(lon=mean(range(df$LONGITUDE)), lat=mean(range(df$LATITUDE))),
               zoom=15, maptype="satellite", color="bw")
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=42.399375,-71.080909&zoom=15&size=%20640x640&scale=%202&maptype=satellite&sensor=false
## Google Maps API Terms of Service : http://developers.google.com/maps/terms

Depth Map

The following map shows the depth at each location. Note this only includes depths greater than 1 m, which I assume are “bottom” samples. The location farthest up the Malden has a relatively high depth, which is unexpected.

ggmap(map, darken=c(0.25, "white"), extent="device") +
  geom_point(aes(LONGITUDE, LATITUDE, color=DEPTH), data=filter(df, DEPTH>1)) +
  scale_color_gradientn(colours=c('#91cf60', '#ffffbf', '#fc8d59'))

plot of chunk map_depth

DO Map

This shows the DO measurements with Depth > 1. It shows lower DO along the basin shore and in the Malden River.

ggmap(map, darken=c(0.25, "white"), extent="device") +
  geom_point(aes(LONGITUDE, LATITUDE, color=DO), data=filter(df, DEPTH>1)) +
  scale_color_gradientn(colours=c('#91cf60', '#ffffbf', '#fc8d59'))

plot of chunk map_do

Salinity Map

The salinity measurements with Depth > 1 show the highest salinities just above the dam, indicating a small salt wedge.

ggmap(map, darken=c(0.25, "white"), extent="device") +
  geom_point(aes(LONGITUDE, LATITUDE, color=SAL), data=filter(df, DEPTH>1)) +
  scale_color_gradientn(colours=c('#91cf60', '#ffffbf', '#fc8d59'))

plot of chunk map_sal

Chl-a Map

The chlorophyll-a measurements with Depth > 1 show high concentrations in the Malden, which bears further investigation.

ggmap(map, darken=c(0.25, "white"), extent="device") +
  geom_point(aes(LONGITUDE, LATITUDE, color=CHLA), data=filter(df, DEPTH>1) %>% arrange(desc(DEPTH))) +
  scale_color_gradientn(colours=c('#91cf60', '#ffffbf', '#fc8d59'))

plot of chunk map_chla