Skip to content

Commit 736f99b

Browse files
committed
Manuscript revisions
1 parent 8395de2 commit 736f99b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1542
-677
lines changed

R/CTD.R

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,3 +1005,69 @@ plot.CTD.survey.path <- function(CTD_meta, split_dates=TRUE, color_time=FALSE){
10051005
}
10061006
return(path_plot)
10071007
}
1008+
1009+
1010+
############################
1011+
# Plot mean for CTD survey #
1012+
############################
1013+
CTD.plot.survey.mean <- function(CTD, survey_id,
1014+
salt_range=NULL, temp_range=NULL){
1015+
data <- CTD$data
1016+
meta <- CTD$meta
1017+
# Pre filter data
1018+
data <- data[data$survey_id %in% survey_id,]
1019+
1020+
# aggregate data
1021+
data <- data[,c('depth','temperature','salinity','survey_id')]
1022+
data$depth <- round(data$depth)
1023+
if (length(survey_id) > 1){
1024+
data <- aggregate(data, by=list(data$depth, data$survey_id), mean)[,c(2:5)]
1025+
names(data)[1] <- 'survey_id'
1026+
} else {
1027+
data[,c('depth','temperature','salinity')]
1028+
data <- aggregate(data, by=list(data$depth), mean)[,c(2:4)]
1029+
}
1030+
1031+
# Rescale salinity
1032+
if (!is.null(salt_range)){
1033+
salt_rescale <- scales::rescale(c(salt_range[1], data$salinity, salt_range[2]),
1034+
to=c(min(data$temperature),
1035+
max(data$temperature)))
1036+
data$salt_rescale <- salt_rescale[2:(length(salt_rescale)-1)]
1037+
} else {
1038+
data$salt_rescale <- scales::rescale(data$salinity,
1039+
to=c(min(data$temperature),
1040+
max(data$temperature)))
1041+
salt_range <- c(min(data$salinity), max(data$salinity))
1042+
}
1043+
# make title
1044+
if (length(survey_id) == 1){
1045+
title <- survey_id
1046+
}
1047+
1048+
1049+
# Set colours
1050+
colors <- c("T" = "darkred", "S" = "darkgreen")
1051+
1052+
# make the plot
1053+
p <- ggplot(data=data, aes(x=depth)) +
1054+
geom_path(aes(y=temperature, color='T'), size=1, alpha=.8) +
1055+
geom_point(aes(y=temperature), size=1, alpha=.8, col='darkred') +
1056+
geom_path(aes(y=salt_rescale, color='S'), size=1, alpha=.8) +
1057+
geom_point(aes(y=salt_rescale), size=1, alpha=.8, col='darkgreen') +
1058+
ylab('Temperature (\u00B0C)') + xlab('Depth (m)') +
1059+
scale_color_manual(values = colors) + labs(color=NULL) +
1060+
scale_y_continuous(sec.axis = sec_axis(~scales::rescale(., to=salt_range),
1061+
name="Salinity (PSU)")) +
1062+
coord_flip() +
1063+
scale_x_reverse()
1064+
if (length(survey_id) > 1){
1065+
p <- p + facet_wrap(~survey_id)
1066+
}
1067+
1068+
if (!is.null(temp_range)){
1069+
p <- p + ylim(temp_range)
1070+
}
1071+
1072+
return(p)
1073+
}

R/CTD_profiles.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# CTD profiles
2+
source("R/CTD.R")
3+
CTD <- cast.reader()
4+
surveys <- unique(CTD$meta$survey_id)
5+
CTD.plot.survey.mean(CTD, c("2015_S1"))
6+
CTD.plot.survey.mean(CTD, surveys) + facet_wrap(~survey_id, scales="free")
7+
8+
# mean for all years
9+
mean.df <- aggregate(CTD$data[,c('temperature', 'salinity')], by=list(CTD$data$id), mean)
10+
# put survey back in
11+
mean.df$survey_id <- sapply(mean.df$Group.1, function(id) CTD$meta$survey_id[CTD$meta$file_name == id])
12+
13+
# mean for surveys
14+
mean.df <- aggregate(mean.df[,c('temperature', 'salinity')], by=list(mean.df$survey_id), mean)
15+
names(mean.df)[1] <- 'survey_id'
16+
17+
summary(mean.df)

R/EACpanel.R

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# make map panel
2+
library(rgdal)
3+
library(stringr)
4+
library(ggplot2)
5+
library(ggpubr)
6+
library(maps)
7+
library(sp)
8+
library(maptools)
9+
source('R/eudyptula.R')
10+
11+
# load df.sst.EAC from bubble plot script
12+
13+
#####################################################
14+
# EAC panel 2 #
15+
#####################################################
16+
# --- Data Prep --- #
17+
# Load in transect data
18+
transect.lines <- read.csv('data/transects/transect_lines.csv')
19+
# stations
20+
stations <- read.csv('data/transects/transect_df.csv')
21+
moorings <- read.csv('data/surveys/moorings.csv')
22+
# Reshape for ggplot
23+
transect.lines1 <- transect.lines[,1:3]
24+
transect.lines2 <- transect.lines[,c(1,4,5)]
25+
names(transect.lines2) <- names(transect.lines1)
26+
transect.lines <- rbind(transect.lines1, transect.lines2)
27+
# Load in coastline shapefile
28+
fn = './assets/shp/NSW-coastline/edited/polygon/NSW-coastline_WGS84'
29+
landShp <- readOGR(dsn=path.expand(str_sub(fn,1,-(nchar(basename(fn)))-1)),
30+
layer=basename(fn))
31+
32+
# --- Plot Map --- #
33+
xlim <- c(150.04, 150.33)
34+
ylim <- c(-36.47, -36.15)
35+
summary(df.sst.EAC)
36+
station_labels <- stations[stations$station == 1,]
37+
station_labels$id <- paste0("T",station_labels$transect)
38+
# plot
39+
p.panel <- ggplot() +
40+
# SST
41+
geom_tile(mapping=aes(x=lon, y=lat, fill=sst),
42+
data=df.sst.EAC,
43+
inherit.aes = F) +
44+
scale_fill_cmocean(name='thermal', limits=c(12, 28)) +
45+
# transects
46+
geom_line(data=transect.lines, mapping=aes(x=lon1, y=lat1, group=transect),
47+
size=.5, linetype='dashed') +
48+
# stations
49+
geom_point(data=stations, mapping=aes(x=lon, y=lat),
50+
color='black', fill='grey', size=4, shape=21) +
51+
geom_point(data=stations, mapping=aes(x=lon, y=lat),
52+
color='black', size=1.5, shape=1) +
53+
# moorings
54+
geom_point(data=moorings, mapping=aes(x=lon, y=lat),
55+
color='black', fill="green", size=4, shape=23) +
56+
# coastline
57+
geom_polygon(data=landShp, aes(x=long, y=lat, group=group),
58+
fill='grey', col='#636363', size=.4) +
59+
# station labels
60+
geom_text(data=station_labels, mapping=aes(x=lon, y=lat, label=id), size=3,
61+
nudge_x=-.005, nudge_y=.008, fontface='bold') +
62+
# Mooring labels
63+
geom_label(data=moorings, mapping=aes(x=lon, y=lat, label=id), size=2.7,
64+
fill="green", alpha=0.4, nudge_x=0, nudge_y=-.011) +
65+
# settings
66+
coord_map(xlim=xlim, ylim=ylim) +
67+
theme_bw() + grids(linetype = "dashed") +
68+
theme(legend.position = "none") +
69+
labs(x=NULL, y=NULL, alpha=NULL, size=NULL, fill=NULL) +
70+
theme(text = element_text(size=14)) +
71+
theme(axis.title.x=element_blank(),
72+
axis.text.x=element_blank(),
73+
axis.title.y=element_blank(),
74+
axis.text.y=element_blank())
75+
76+
# Save files
77+
ggsave(p.panel, filename='figures/Map/panel2.png',
78+
bg="transparent",dpi=300, width=2000/300, height=2000/300)
79+
80+

0 commit comments

Comments
 (0)