Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
milesmedina committed Sep 8, 2024
1 parent a15224f commit 92ba089
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 32 deletions.
37 changes: 19 additions & 18 deletions R/cumu_pyro-chl_demo.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,31 @@ pyrodat <- pyro.sub |> group_by(month) |> dplyr::summarise( pyro = max(logval) )
# join pyro and chl data by month
pcdat <- inner_join( pyrodat, chldat, by = 'month' )

# Plot histogram of max pyro assoc with mean chl-a at or below 9.3 ug/L
hist( pcdat$pyro[ which(pcdat$chl <= 9.3) ], breaks = 20, freq = TRUE,
# Plot histogram of max pyro assoc with mean chl-a at or below 8.5 ug/L
hist( pcdat$pyro[ which(pcdat$chl <= 8.5) ], breaks = 20, freq = TRUE,
border = rgb(1,1,1,1), col = rgb(0,0,0,0.4),
main = "", xlab = "", ylab = "", las = 1, xaxt = 'n', xlim = c(1,7)
main = "", xlab = "", ylab = "",
las = 1, xaxt = 'n', xlim = c(1,7)
)
# mtext( expression(atop("(a) Monthly maximum "*italic(P.~bahamense)*" abundance",
# "associated with monthly mean chlorophyll-a \u22649.3 ug/L")),
# "associated with monthly mean chlorophyll-a \u22648.5 ug/L")),
# side = 3, cex = 1.1 )
mtext( expression("(a) Monthly maximum "*italic(P.~bahamense)*" distribution"),
side = 3, line = 1.5, adj = 0 )
mtext( expression(" associated with monthly mean chlorophyll-a \u22649.3 ug/L"),
mtext( expression(" associated with monthly mean chlorophyll-a \u22648.5 ug/L"),
side = 3, line = 0.5, adj = 0 )
mtext( expression(italic(P.~bahamense)*" (cells/L)"),
side = 1, line = 2.5 )
mtext( "Frequency", side = 2, line = 2 )
mtext( "Number of samples", side = 2, line = 2 )
axis( 1, at = 1:7, labels = c( expression(10^1), expression(10^2),
expression(10^3), expression(10^4),
expression(10^5), expression(10^6),
expression(10^7) ) )
abline( v = pcdat$pyro[ which(pcdat$chl <= 9.3) ] |> median(),
abline( v = pcdat$pyro[ which(pcdat$chl <= 8.5) ] |> median(),
col = rgb(1,0.1,0.1,0.6), lwd = 3 )
abline( v = pcdat$pyro[ which(pcdat$chl <= 9.3) ] |> quantile(0.25),
abline( v = pcdat$pyro[ which(pcdat$chl <= 8.5) ] |> quantile(0.25),
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 3 )
abline( v = pcdat$pyro[ which(pcdat$chl <= 9.3) ] |> quantile(0.75),
abline( v = pcdat$pyro[ which(pcdat$chl <= 8.5) ] |> quantile(0.75),
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 3 )

# Define function to summarize pyro distribution
Expand Down Expand Up @@ -115,18 +116,18 @@ polygon( x = c( pyro_chl$min, rev(pyro_chl$max) ),
polygon( x = c( pyro_chl$lwr_iqr, rev(pyro_chl$upr_iqr) ),
y = c( pyro_chl$chl, rev(pyro_chl$chl) ),
col = rgb(0,0.2,0.6,0.2), border = rgb(0,0,0,0) )
segments( x0 = 0, x1 = pyro_chl$upr_iqr[which(pyro_chl$chl==9.3)],
y0 = 9.3,
segments( x0 = 0, x1 = pyro_chl$upr_iqr[which(pyro_chl$chl==8.5)],
y0 = 8.5,
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 3 )
text( x = 2, y = 9, col = rgb(1,0.1,0.1,0.8), labels = "9.3 ug/L", pos = 3 )
segments( x0 = pyro_chl$median[which(pyro_chl$chl==9.3)],
y0 = 0, y1 = 9.3,
text( x = 2, y = 9, col = rgb(1,0.1,0.1,0.8), labels = "8.5 ug/L", pos = 3 )
segments( x0 = pyro_chl$median[which(pyro_chl$chl==8.5)],
y0 = 0, y1 = 8.5,
lty = 1, col = rgb(1,0.1,0.1,0.6), lwd = 3 )
segments( x0 = pyro_chl$lwr_iqr[which(pyro_chl$chl==9.3)],
y0 = 0, y1 = 9.3,
segments( x0 = pyro_chl$lwr_iqr[which(pyro_chl$chl==8.5)],
y0 = 0, y1 = 8.5,
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 3 )
segments( x0 = pyro_chl$upr_iqr[which(pyro_chl$chl==9.3)],
y0 = 0, y1 = 9.3,
segments( x0 = pyro_chl$upr_iqr[which(pyro_chl$chl==8.5)],
y0 = 0, y1 = 8.5,
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 3 )
legend( 'topleft', bty = 'n',
legend = c("Median",
Expand Down
26 changes: 13 additions & 13 deletions R/cumu_pyro-max_chl-mean.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ for( subseg in subsegs ){
polygon( x = c( pyro_chl$lwr_iqr, rev(pyro_chl$upr_iqr) ),
y = c( pyro_chl$chl, rev(pyro_chl$chl) ),
col = rgb(0,0.2,0.6,0.2), border = rgb(0,0,0,0) )
segments( x0 = 0, x1 = pyro_chl$upr_iqr[which(pyro_chl$chl==9.3)],
y0 = 9.3,
segments( x0 = 0, x1 = pyro_chl$upr_iqr[which(pyro_chl$chl==8.5)],
y0 = 8.5,
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 2 )
text( x = 2, y = 9, col = rgb(1,0.1,0.1,0.8),
labels = "9.3 ug/L", pos = 3, cex = 1.3 )
segments( x0 = pyro_chl$median[which(pyro_chl$chl==9.3)],
y0 = 0, y1 = 9.3,
labels = "8.5 ug/L", pos = 3, cex = 1.3 )
segments( x0 = pyro_chl$median[which(pyro_chl$chl==8.5)],
y0 = 0, y1 = 8.5,
lty = 1, col = rgb(1,0.1,0.1,0.6), lwd = 2 )
segments( x0 = pyro_chl$lwr_iqr[which(pyro_chl$chl==9.3)],
y0 = 0, y1 = 9.3,
segments( x0 = pyro_chl$lwr_iqr[which(pyro_chl$chl==8.5)],
y0 = 0, y1 = 8.5,
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 2 )
segments( x0 = pyro_chl$upr_iqr[which(pyro_chl$chl==9.3)],
y0 = 0, y1 = 9.3,
segments( x0 = pyro_chl$upr_iqr[which(pyro_chl$chl==8.5)],
y0 = 0, y1 = 8.5,
lty = 3, col = rgb(1,0.1,0.1,0.6), lwd = 2 )
legend( x = 0.5, y = 26, bty = 'n',
legend = c("Median",
Expand Down Expand Up @@ -140,7 +140,7 @@ for( subseg in subsegs ){
# )
# } # // end i loop
#
# # Plot annual mean chl values with 9.3 ug/L threshold
# # Plot annual mean chl values with 8.5 ug/L threshold
# plot( mean ~ year, data = chl_year, type = 'l', las = 1,
# ylim = c(0,50),
# main = "", ylab = "", xlab = "",
Expand All @@ -159,9 +159,9 @@ for( subseg in subsegs ){
# polygon( x = c( chl_year$year, rev(chl_year$year) ),
# y = c( chl_year$lwr_2sd, rev(chl_year$upr_2sd) ),
# col = rgb(0,0.2,0.6,0.1), border = rgb(0,0,0,0) )
# abline( h = 9.3, lty = 2, col = rgb(1,0.2,0.1,0.7), lwd = 2 )
# # text( x = 2022, y = 9.3,
# # col = 2, labels = "9.3 ug/L", pos = 3 )
# abline( h = 8.5, lty = 2, col = rgb(1,0.2,0.1,0.7), lwd = 2 )
# # text( x = 2022, y = 8.5,
# # col = 2, labels = "8.5 ug/L", pos = 3 )
# points( mean ~ year, data = chl_year )
# legend( 'topright', bty = 'n',
# legend = c("Mean","\u00B11sd","\u00B12sd"), text.font = 2, cex = 1.3,
Expand Down
2 changes: 1 addition & 1 deletion R/ssa_pyro_otb-ne.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ wcor(obj,groups = 1:20) |> plot()
# SSA grouping
##
# Specify signal component groups
grp <- list( c(1,2), c(3,4), c(7,8), c(9,10) )
grp <- list( c(1,2), c(3,4), c(7,8) )

# SSA reconstruction
##
Expand Down
Binary file modified figs/cumu_pyro-chl_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified figs/cumu_pyro-max_chl-mean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 92ba089

Please sign in to comment.