function.path <- "../../functions"
read.functions <- function(file) source(file.path(function.path, file))
read.functions("information functions 1_9_3.r")

windowsFonts(HV = windowsFont("Helvetica"))


# biota PAH

# jpeg(file.path("test output", "biota PAH EAC D R.jpg"), width = 900, height = 1300, family = "HV", quality = 100)
# niceStatusResults2(biota[["PAH (parent)"]], "status", "determinand by region", AC = "EAC", 
#   xtck = 3, layout = c(3, 4), ybetween = c(2, 2, 0), panelMinor = 1:9)
# dev.off()
# 
# jpeg(file.path("test output", "biota PAH BAC D R.jpg"), width = 900, height = 1300, family = "HV", quality = 100)
# niceStatusResults2(biota[["PAH (parent)"]], "status", "determinand by region", AC = "BAC", 
#  xtck = 3, layout = c(3, 4), ybetween = c(2, 2, 0), panelMinor = 1:9)
# dev.off()
# 
# # jpeg(file.path("test output", "biota PAH EAC R.jpg"), width = 700, height = 400, family = "HV", quality = 100)
# niceStatusResults2(biota[["PAH (parent)"]], "status", "region", AC = "EAC", xtck = 5)
# dev.off()
# 
# jpeg(file.path("test output", "biota PAH BAC R.jpg"), width = 700, height = 400, family = "HV", quality = 100)
# niceStatusResults2(biota[["PAH (parent)"]], "status", "region", AC = "BAC", xtck = 5)
# dev.off()
# 
# jpeg(file.path("test output", "biota PAH trend D R.jpg"), width = 900, height = 1300, family = "HV", quality = 100)
# niceStatusResults2(biota[["PAH (parent)"]], "trend", "determinand by region", 
#   xtck = 3, layout = c(3, 4), ybetween = c(2, 2, 0), skip = c(F, F, T, F, F, T, rep(F, 4)), panelMinor = 1:7, 
#   panelMajor = c(1, 2, 7))
# dev.off()

# jpeg(file.path("test output", "biota PAH trend R.jpg"), width = 700, height = 400, family = "HV", quality = 100)
# niceStatusResults2(biota[["PAH (parent)"]], "trend", "region", xtck = 5)
# dev.off()



# sediment PAH

# jpeg(file.path("test output", "sediment PAH ERL D R.jpg"), width = 900, height = 950, family = "HV", quality = 100)
# niceStatusResults2(sediment[["PAH (parent)"]], "status", "determinand by region", AC = "ERL", 
#   xtck = 3, layout = c(3, 3), ybetween = c(2, 2), skip = c(F, T, T, F, F, T, F, F, F), panelMajor = c(1, 3, 6))
# dev.off()
# 
# jpeg(file.path("test output", "sediment PAH BAC D R.jpg"), width = 900, height = 950, family = "HV", quality = 100)
# niceStatusResults2(sediment[["PAH (parent)"]], "status", "determinand by region", AC = "BAC", 
#   xtck = 5, layout = c(3, 3), ybetween = c(2, 2), skip = c(F, T, T, F, F, T, F, F, F), panelMajor = c(1, 3, 6))
# dev.off()
# 
# # jpeg(file.path("test output", "sediment PAH ERL R.jpg"), width = 700, height = 350, family = "HV", quality = 100)
# # niceStatusResults2(sediment[["PAH (parent)"]], "status", "region", AC = "ERL", xtck = 5)
# dev.off()
# 
# jpeg(file.path("test output", "sediment PAH BAC R.jpg"), width = 700, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["PAH (parent)"]], "status", "region", AC = "BAC", xtck = 5)
# dev.off()
# 
# jpeg(file.path("test output", "sediment PAH trend D R.jpg"), width = 900, height = 950, family = "HV", quality = 100)
# niceStatusResults2(sediment[["PAH (parent)"]], "trend", "determinand by region", 
#   xtck = 5, layout = c(3, 3), ybetween = c(2, 2), skip = c(F, T, T, F, F, T, F, F, F), panelMajor = c(1, 3, 6))
# dev.off()
# 
# jpeg(file.path("test output", "sediment PAH trend R.jpg"), width = 700, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["PAH (parent)"]], "trend", "region", xtck = 5)
# dev.off()


# PCB biota

# jpeg(file.path("test output", "biota CB EAC D R.jpg"), width = 900, height = 1350, family = "HV", quality = 100)
# niceStatusResults2(biota[["Chlorobiphenyls"]], "status", "determinand by region", AC = "EAC", 
#   xtck = 3, layout = c(3, 5), ybetween = c(2, 2, 0, 2), skip = c(F, F, T, rep(F, 8), T, F), 
#   panelMinor = c(1:8, 11), panelMajor = c(1, 2, 5))
# dev.off()
# 
# # jpeg(file.path("test output", "biota CB BAC R.jpg"), width = 700, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Chlorobiphenyls"]], "status", "region", AC = "BAC", xtck = 5)
# dev.off()

# jpeg(file.path("test output", "biota CB trend R.jpg"), width = 700, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Chlorobiphenyls"]], "trend", "region", xtck = 5)
# dev.off()




# PCB sediment

# jpeg(file.path("test output", "sediment CB EAC D R.jpg"), width = 900, height = 950, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Chlorobiphenyls"]], "status", "determinand by region", AC = "EAC", 
#   xtck = 3, layout = c(3, 3), ybetween = c(2, 2), skip = c(F, T, T, F, F, T, F, F, F), panelMajor = c(1, 3, 6))
# dev.off()
# 
# # jpeg(file.path("test output", "sediment CB trend R.jpg"), width = 700, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Chlorobiphenyls"]], "trend", "region", xtck = 5)
# dev.off()



# metal biota

# jpeg(file.path("test output", "biota metal EC R D.jpg"), width = 900, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Metals"]], "status", "region by determinand", AC = "EC", xtck = 3, greenID = "orange")
# dev.off()
# 
# jpeg(file.path("test output", "biota metal BAC R D.jpg"), width = 900, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Metals"]], "status", "region by determinand", AC = "BAC", xtck = 3, greenID = "orange")
# dev.off()

# jpeg(file.path("test output", "biota metal trend R D.jpg"), width = 900, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Metals"]], "trend", "region by determinand", xtck = 5)
# dev.off()



# metal sediment

# jpeg(file.path("test output", "sediment metal ERL R D.jpg"), width = 900, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Metals"]], "status", "region by determinand", AC = "ERL", xtck = 3, greenID = "orange")
# dev.off()
# 
# jpeg(file.path("test output", "sediment metal BAC R D.jpg"), width = 900, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Metals"]], "status", "region by determinand", AC = "BAC", xtck = 3, greenID = "orange")
# dev.off()

# jpeg(file.path("test output", "sediment metal trend R D.jpg"), width = 900, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Metals"]], "trend", "region by determinand", xtck = 5)
# dev.off()



# PBDE

# need to add in units

# jpeg(file.path("test output", "biota PBDE R.jpg"), width = 700, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Organo-bromines"]], "status", "region", AC = "CONC", xtck = 5,
#   xlab = expression("Mean concentration in final year" ~ paste("(", mu, "g") ~ kg^-1 ~ "ww)"))
# dev.off()
# 
# jpeg(file.path("test output", "sediment PBDE R.jpg"), width = 700, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Organo-bromines"]], "status", "region", AC = "CONC", xtck = 5,
#   xlab = expression("Mean concentration in final year" ~ paste("(", mu, "g") ~ kg^-1 ~ "dw)"))
# dev.off()

# jpeg(file.path("test output", "biota PBDE trend R.jpg"), width = 700, height = 350, family = "HV", quality = 100)
# niceStatusResults2(biota[["Organo-bromines"]], "trend", "region", xtck = 5)
# dev.off()

# jpeg(file.path("test output", "sediment PBDE trend R.jpg"), width = 700, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Organo-bromines"]], "trend", "region", xtck = 5)
# dev.off()


# Organotin

# jpeg(file.path("test output", "sediment organotin trend R.jpg"), width = 500, height = 350, family = "HV", quality = 100)
# niceStatusResults2(sediment[["Organo-metals"]], "trend", "determinand", xtck = 5)
# dev.off()


# VDS

# jpeg(file.path("test output", "biota VDS EAC R.jpg"), width = 700, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Imposex"]], "status", "region", AC = "EAC", xtck = 5, 
#   responseLabel = "VDS", imposexAt = c(0, 0.2, 0.5, 1, 2, 5))
# dev.off()
# 
# jpeg(file.path("test output", "biota VDS BAC R.jpg"), width = 700, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Imposex"]], "status", "region", AC = "BAC", xtck = 5, 
#   responseLabel = "VDS", imposexAt = c(0, 0.2, 0.5, 1, 2, 5))
# dev.off()

# jpeg(file.path("test output", "biota VDS trend R.jpg"), width = 700, height = 450, family = "HV", quality = 100)
# niceStatusResults2(biota[["Imposex"]], "trend", "region", AC = "EAC", xtck = 5, 
#   responseLabel = "VDS", imposexAt = c(0, 0.2, 0.4, 0.6, 0.8, 1.0), 
#   xlab = c("VDS trend: odds of exceeding EAC this year relative to last"))
# dev.off()





# big files

# metal sediment

jpeg(file.path("test output big", "sediment metal BAC R D.jpg"), width = 900 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["Metals"]], "status", "region by determinand", AC = "BAC", xtck = 3,
  greenID = "orange", expand = 5)
dev.off()

jpeg(file.path("test output big", "sediment metal ERL R D.jpg"), width = 900 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["Metals"]], "status", "region by determinand", AC = "ERL", xtck = 3, 
  greenID = "orange", expand = 5)
dev.off()

jpeg(file.path("test output big", "sediment metal trend R D.jpg"), width = 900 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["Metals"]], "trend", "region by determinand", xtck = 5, expand = 5)
dev.off()


# imposex



# metal biota

jpeg(file.path("test output big", "biota metal BAC R D.jpg"), width = 900 * 5, height = 450 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(biota[["Metals"]], "status", "region by determinand", AC = "BAC", xtck = 3, 
  greenID = "orange", expand = 5)
dev.off()


# PAH biota

jpeg(file.path("test output big", "biota PAH EAC R.jpg"), width = 700 * 5, height = 400 * 5, family = "HV", 
  quality = 100)
niceStatusResults2(biota[["PAH (parent)"]], "status", "region", AC = "EAC", xtck = 5, expand = 5)
dev.off()

jpeg(file.path("test output big", "biota PAH trend R.jpg"), width = 700 * 5, height = 400 * 5, family = "HV", 
  quality = 100)
niceStatusResults2(biota[["PAH (parent)"]], "trend", "region", xtck = 5, expand = 5)
dev.off()


# PAH sediment

jpeg(file.path("test output big", "sediment PAH ERL R.jpg"), width = 700 * 5, height = 350 * 5, family = "HV", 
  quality = 100)
niceStatusResults2(sediment[["PAH (parent)"]], "status", "region", AC = "ERL", xtck = 5, expand = 5)
dev.off()

jpeg(file.path("test output big", "sediment PAH trend R.jpg"), width = 700 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["PAH (parent)"]], "trend", "region", xtck = 5, expand = 5)
dev.off()



# CB biota

jpeg(file.path("test output big", "biota CB EAC D R.jpg"), width = 900 * 5, height = 1350 * 5, family = "HV", 
  quality = 100)
niceStatusResults2(biota[["Chlorobiphenyls"]], "status", "determinand by region", AC = "EAC",
  xtck = 3, layout = c(3, 5), ybetween = c(2, 2, 0, 2), skip = c(F, F, T, rep(F, 8), T, F),
  panelMinor = c(1:8, 11), panelMajor = c(1, 2, 5), expand = 5)
dev.off()


# CB sediment

jpeg(file.path("test output big", "sediment CB EAC D R.jpg"), width = 900 * 5, height = 950 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["Chlorobiphenyls"]], "status", "determinand by region", AC = "EAC", 
  xtck = 3, layout = c(3, 3), ybetween = c(2, 2), skip = c(F, T, T, F, F, T, F, F, F), 
  panelMajor = c(1, 3, 6), expand = 5)
dev.off()
 
jpeg(file.path("test output big", "sediment CB trend R.jpg"), width = 700 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["Chlorobiphenyls"]], "trend", "region", xtck = 5, expand = 5)
dev.off()


# PBDE

jpeg(file.path("test output big", "biota PBDE trend R.jpg"), width = 700 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(biota[["Organo-bromines"]], "trend", "region", xtck = 5, expand = 5)
dev.off()

jpeg(file.path("test output big", "sediment PBDE trend R.jpg"), width = 700 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["Organo-bromines"]], "trend", "region", xtck = 5, expand = 5)
dev.off()


# organotin

jpeg(file.path("test output big", "sediment organotin trend D.jpg"), width = 500 * 5, height = 350 * 5, 
  family = "HV", quality = 100)
niceStatusResults2(sediment[["Organo-metals"]], "trend", "determinand", xtck = 5, expand = 5)
dev.off()


# VDS

jpeg(file.path("test output big", "biota VDS EAC R.jpg"), width = 700 * 5, height = 450 * 5, family = "HV", 
  quality = 100)
niceStatusResults2(biota[["Imposex"]], "status", "region", AC = "EAC", xtck = 5,
  responseLabel = "VDS", imposexAt = c(0, 0.2, 0.5, 1, 2, 5), expand = 5)
dev.off()
 
jpeg(file.path("test output big", "biota VDS trend R.jpg"), width = 700 * 5, height = 450 * 5, family = "HV", 
  quality = 100)
niceStatusResults2(biota[["Imposex"]], "trend", "region", AC = "EAC", xtck = 5,
  responseLabel = "VDS", imposexAt = c(0, 0.2, 0.4, 0.6, 0.8, 1.0),
  xlab = c("VDS trend: odds of exceeding EAC this year relative to last"), expand = 5)
dev.off()
