require(knitr)
  knitr::opts_chunk$set(
    root.dir = data_root,
    echo = FALSE,
    out.width="6.2in",
#     dev.args = list(type = "cairo"),
    fig.retina = 2,
    dpi=192
  )

  # inits and data loading (front load all required data)

  require(aegis)

  year.assessment = params$year.assessment
  year_previous = year.assessment - 1
  p = bio.snowcrab::load.environment( year.assessment=year.assessment )
  SCD = project.datadirectory("bio.snowcrab")
  media_loc = params$media_loc

  # fishery_model_results = file.path( "/home", "jae", "projects", "dynamical_model", "snowcrab", "outputs" )
  fishery_model_results = file.path( SCD, "fishery_model" )

  sn_env = snowcrab_load_key_results_to_memory( year.assessment, debugging=params$debugging, loc_dde=params$loc_dde, return_as_list=TRUE  ) 

  attach(sn_env)

  # predator diet data
  diet_data_dir = file.path( SCD, "data", "diets" )
  require(data.table) # for speed
  require(lubridate)
  require(stringr) 
  require(gt)  # table formatting
  library(janitor)
  require(ggplot2)
  require(aegis) # map-related 
  require(bio.taxonomy)  # handle species codes

  # assimilate the CSV data tables:
  # diet = get_feeding_data( diet_data_dir, redo=TRUE )  # if there is a data update
  diet = get_feeding_data( diet_data_dir, redo=FALSE )
  tx = taxa_to_code("snow crab")  
  # matching codes are 
  #  spec    tsn                  tx                   vern tx_index
  #1  528 172379        BENTHODESMUS           BENTHODESMUS     1659
  #2 2522  98427        CHIONOECETES SPIDER QUEEN SNOW UNID      728
  #3 2526  98428 CHIONOECETES OPILIO        SNOW CRAB QUEEN      729
  # 2 and 3 are correct

  snowcrab_predators = diet[ preyspeccd %in% c(2522, 2526), ]  # n=159 oservations out of a total of 58287 observations in db (=0.28% of all data)
  snowcrab_predators$Species = code_to_taxa(snowcrab_predators$spec)$vern
  snowcrab_predators$Predator = factor(snowcrab_predators$Species)

  counts = snowcrab_predators[ , .(Frequency=.N), by=.(Species)]
  setorderv(counts, "Frequency", order=-1)

  # species composition
  psp = speciescomposition_parameters( yrs=p$yrs, runlabel="1999_present" )
  pca = speciescomposition_db( DS="pca", p=psp )  

  pcadata = as.data.frame( pca$loadings )
  pcadata$vern = stringr::str_to_title( taxonomy.recode( from="spec", to="taxa", tolookup=rownames( pcadata ) )$vern )

  # bycatch summaries
  o_cfaall = observer.db( DS="bycatch_summary", p=p,  yrs=p$yrs, region="cfaall" )
  o_cfanorth = observer.db( DS="bycatch_summary", p=p,  yrs=p$yrs, region="cfanorth" )   
  o_cfasouth = observer.db( DS="bycatch_summary", p=p,  yrs=p$yrs, region="cfasouth" )   
  o_cfa4x = observer.db( DS="bycatch_summary", p=p,  yrs=p$yrs, region="cfa4x" )   

Ecosystem considerations

Connectivity: Oceanic currents {.c}

fn2=file.path( media_loc, "maritimes_currents.png" )
knitr::include_graphics( c(fn2) ) 
# \@ref(fig:movementtracks)  

Connectivity: Movement {.c}

::: columns :::: column

fn1=file.path( media_loc, "movement0.png" )
fn2=file.path( media_loc, "movement.png" )
knitr::include_graphics( c(fn1, fn2) ) 
# \@ref(fig:movementtracks)  

:::: :::: column

fn1=file.path( media_loc, "snowcrab_movement_distances.png" )
fn2=file.path( media_loc, "snowcrab_movement_rates.png" )
knitr::include_graphics( c(fn1, fn2) ) 
# \@ref(fig:movement)  

:::: :::

Bathymetry {.c}

::: columns

:::: column

bathydir = file.path( data_root, 'aegis', 'bathymetry', 'modelled', 'default', 'stmv', 'none_fft', 'z', 'maps', 'SSE' )
knitr::include_graphics( file.path( bathydir, 'bathymetry.z.SSE.png' ) )

:::: :::: column

bathydir = file.path( data_root, 'aegis', 'bathymetry', 'modelled', 'default', 'stmv', 'none_fft', 'z', 'maps', 'SSE' )
knitr::include_graphics( file.path( bathydir, 'bathymetry.b.sdSpatial.SSE.png' ) )

:::: :::

Substrate {.c}

::: columns

:::: column

substrdir = file.path( data_root, 'aegis', 'substrate', 'maps', 'canada.east.highres' )
knitr::include_graphics( file.path(  substrdir, 'substrate.substrate.grainsize.canada.east.highres.png' ) )

:::: :::: column

substrdir = file.path( data_root, 'aegis', 'substrate', 'maps', 'canada.east.highres' )
knitr::include_graphics( file.path( substrdir, 'substrate.s.sdSpatial.canada.east.highres.png' ) )

:::: :::

Bottom Temperature {.c}

::: columns

:::: column \vspace{12mm}

knitr::include_graphics( file.path( SCD, 'assessments', year.assessment, 'timeseries', 'survey', 't.pdf') )
# \@ref(fig:bottom-temperatures-survey)

::::

:::: column

knitr::include_graphics( file.path( SCD, 'assessments', year.assessment, 'timeseries', 'temperature_bottom.pdf') )
# \@ref(fig:bottom-temperatures)

:::: :::

Bottom Temperature ... {.c}

loc = file.path( data_root, 'aegis', 'temperature', 'maps', '1999_present' )
yrsplot =  year.assessment + c(0:-10)
fn10 = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[10], '-0.75',  '.png', sep='') )
fn9  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[9],  '-0.75',  '.png', sep='') )
fn8  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[8],  '-0.75',  '.png', sep='') )
fn7  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[7],  '-0.75',  '.png', sep='') )
fn6  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[6],  '-0.75',  '.png', sep='') )
fn5  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[5],  '-0.75',  '.png', sep='') )
fn4  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[4],  '-0.75',  '.png', sep='') )
fn3  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[3],  '-0.75',  '.png', sep='') )
fn2  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[2],  '-0.75',  '.png', sep='') )
fn1  = file.path( loc, paste( 'Bottom-temperature-',  yrsplot[1],  '-0.75',  '.png', sep='') )
knitr::include_graphics( c( fn3, fn2, fn1) )
# \@ref(fig:bottom-temperatures-map)
# *Spatial variations in bottom temperature estimated from a historical analysis of temperature data for 1 September.*

Bottom Temperature ... {.c}

::: columns :::: column

loc = file.path( data_root, 'aegis', 'temperature', 'maps', '1999_present' )
knitr::include_graphics( file.path( loc, 'Predicted_habitat_probability_persistent_spatial_effect.png') )
# \@ref(fig:bottom-temperatures-spatialeffect)

::::

:::: column

\vspace{12mm}

:::: :::

Species composition

xlab = paste("PC1 (", pca$variance_percent[1], "%)", sep="" )
ylab = paste("PC2 (", pca$variance_percent[2], "%)", sep="" )
plot( PC2 ~ PC1, pcadata, type="n", xlab=xlab, ylab=ylab )
text( PC2 ~ PC1, labels=vern, data=pcadata, cex=0.7, col="slateblue"  )
i = grep("Snow crab", pcadata$vern, ignore.case=TRUE)
points( PC2 ~ PC1, pcadata[i,], pch=19, cex=3.0, col="darkorange" )

Species composition PC1

spc_loc = file.path( data_root, 'aegis', 'speciescomposition', 'maps', '1999_present' )
fn1 = file.path( spc_loc, 'speciescomposition_pca1_spatial_effect.png') 
fn2 = file.path( spc_loc, 'speciescomposition_pca2_spatial_effect.png')
ts_loc = file.path( data_root, 'aegis', 'speciescomposition', 'figures' )
fn3 = file.path( ts_loc, 'pca1_timeseries.png') 
fn4 = file.path( ts_loc, 'pca2_timeseries.png') 
knitr::include_graphics( c(fn1,  fn3  ) ) 
# \@ref(fig:habitat3)  

Species composition PC2

spc_loc = file.path( data_root, 'aegis', 'speciescomposition', 'maps', '1999_present' )
fn1 = file.path( spc_loc, 'speciescomposition_pca1_spatial_effect.png') 
fn2 = file.path( spc_loc, 'speciescomposition_pca2_spatial_effect.png')
ts_loc = file.path( data_root, 'aegis', 'speciescomposition', 'figures' )
fn3 = file.path( ts_loc, 'pca1_timeseries.png') 
fn4 = file.path( ts_loc, 'pca2_timeseries.png') 
knitr::include_graphics( c(fn2,  fn4  ) ) 
# \@ref(fig:habitat3)  

Disease

include_graphics( file.path( SCD, 'output', 'bcd.png') )

Entanglements of large megafauna

region="cfaall"
o = observer.db( DS="bycatch_summary", p=p,  yrs=p$yrs, region=region )   
oss = o$oss  # subset for region of interest
# print("whale entaglements:")
whales = oss[ grep("whale", common, ignore.case=TRUE), ]
# print(whales[, .N, by=.(yr)] )
# print("leatherback entaglements:")
leatherback = oss[ grep("LEATHERBACK", common, ignore.case=TRUE), ]
# print(leatherback[, .N, by=.(yr)])
# print("basking sharks entaglements:")
basking_shark = oss[ grep("BASKING SHARK",  common, ignore.case=TRUE), ]
# print(basking_shark[, .N, by=.(yr)])
plot(lat~-lon, oss, pch=".", col="lightgray", xlim=c(-65.2, -57), ylim=c(42.9,47) )
points(lat~-lon, whales, pch=19, cex=1.5, col="darkred" )
points(lat~-lon, leatherback, pch=18, cex=1.5, col="darkgreen" )
points(lat~-lon, basking_shark, pch=17, cex=1.5, col="slateblue" )

Bycatch Maritimes {.c}

o = o_cfaall    
o$bycatch_table[ o$bycatch_table==0 ] = NA
o$bycatch_table[ is.na(o$bycatch_table) ] = "."
o$bycatch_table_catch[ o$bycatch_table_catch==0 ] = NA
o$bycatch_table_catch[ is.na(o$bycatch_table_catch) ] = "."
plot( o$spec ~ o$bct, xlab = "At sea observed catch rate in snow crab fishery (kg/trap)", ylab="Species", type="p", cex=0.9, pch=19, col="darkorange", xlim=c(0, max(o$bct, na.rm=TRUE)*1.4), yaxt="n" )  
text( o$bct, o$spec,  labels=o$species, pos=4, srt=0 , cex=0.5, col="darkslateblue")
text( max(o$bct, na.rm=TRUE)*0.88, 2.5, labels=paste( "Snow crab CPUE (At sea obs., mean): ", o$bct_sc, " kg/trap"), col="darkred", cex=1.0 )

Bycatch Maritimes ... {.c}

o = o_cfaall    
lookup = bio.taxonomy::taxonomy.recode( from="spec", to="taxa", tolookup=o$specid )$vern
xlab = paste("PC1 (", pca$variance_percent[1], "%)", sep="" )
ylab = paste("PC2 (", pca$variance_percent[2], "%)", sep="" )
plot( PC2 ~ PC1, pcadata, type="n", xlab=xlab, ylab=ylab )
text( PC2 ~ PC1, labels=vern, data=pcadata, cex=0.75, col="slategrey"  )
i = grep("Snow crab", pcadata$vern, ignore.case=TRUE)
points( PC2 ~ PC1, pcadata[i,], pch=19, cex=3.0, col="darkorange" )
j = NULL
for (k in lookup) j = c(j, grep( k, pcadata$vern, ignore.case=TRUE))    
j = unique(j)
points( PC2 ~ PC1, pcadata[j,], pch=19, cex=2.0, col="lightgreen" )
text( PC2 ~ PC1, labels=vern, data=pcadata[j,], cex=0.75, col="darkgreen"  )

Bycatch N-ENS {.c}

\tiny

o = o_cfanorth    
o$bycatch_table = o$bycatch_table[ which(o$bycatch_table$"Average/Moyen" > 10 ),]
o$bycatch_table$"Average/Moyen" = round(o$bycatch_table$"Average/Moyen")
o$bycatch_table[ o$bycatch_table==0 ] = NA
o$bycatch_table[ is.na(o$bycatch_table) ] = "."
gt(o$bycatch_table)

\normalsize

Bycatch N-ENS ... {.c}

o = o_cfanorth    
lookup = bio.taxonomy::taxonomy.recode( from="spec", to="taxa", tolookup=o$specid )$vern
xlab = paste("PC1 (", pca$variance_percent[1], "%)", sep="" )
ylab = paste("PC2 (", pca$variance_percent[2], "%)", sep="" )
plot( PC2 ~ PC1, pcadata, type="n", xlab=xlab, ylab=ylab )
text( PC2 ~ PC1, labels=vern, data=pcadata, cex=0.75, col="slategrey"  )
i = grep("Snow crab", pcadata$vern, ignore.case=TRUE)
points( PC2 ~ PC1, pcadata[i,], pch=19, cex=3.0, col="darkorange" )
j = NULL
for (k in lookup) j = c(j, grep( k, pcadata$vern, ignore.case=TRUE))    
j = unique(j)
points( PC2 ~ PC1, pcadata[j,], pch=19, cex=2.0, col="lightgreen" )
text( PC2 ~ PC1, labels=vern, data=pcadata[j,], cex=0.75, col="darkgreen"  )

Bycatch S-ENS {.c}

\tiny

o = o_cfasouth    
o = observer.db( DS="bycatch_summary", p=p,  yrs=p$yrs, region=region )   
o$bycatch_table = o$bycatch_table[ which(o$bycatch_table$"Average/Moyen" > 10 ),]
o$bycatch_table$"Average/Moyen" = round(o$bycatch_table$"Average/Moyen")
o$bycatch_table[ o$bycatch_table==0 ] = NA
o$bycatch_table[ is.na(o$bycatch_table) ] = "."
gt(o$bycatch_table)

\normalsize

Bycatch S-ENS ... {.c}

o = o_cfasouth
lookup = bio.taxonomy::taxonomy.recode( from="spec", to="taxa", tolookup=o$specid )$vern
xlab = paste("PC1 (", pca$variance_percent[1], "%)", sep="" )
ylab = paste("PC2 (", pca$variance_percent[2], "%)", sep="" )
plot( PC2 ~ PC1, pcadata, type="n", xlab=xlab, ylab=ylab )
text( PC2 ~ PC1, labels=vern, data=pcadata, cex=0.75, col="slategrey"  )
i = grep("Snow crab", pcadata$vern, ignore.case=TRUE)
points( PC2 ~ PC1, pcadata[i,], pch=19, cex=3.0, col="darkorange" )
j = NULL
for (k in lookup) j = c(j, grep( k, pcadata$vern, ignore.case=TRUE))    
j = unique(j)
points( PC2 ~ PC1, pcadata[j,], pch=19, cex=2.0, col="lightgreen" )
text( PC2 ~ PC1, labels=vern, data=pcadata[j,], cex=0.75, col="darkgreen"  )

Bycatch 4X {.c}

\tiny

o = o_cfa4x
o = observer.db( DS="bycatch_summary", p=p,  yrs=p$yrs, region=region )   
o$bycatch_table = o$bycatch_table[ which(as.numeric(o$bycatch_table$"Average/Moyen") > 10 ),]
o$bycatch_table$"Average/Moyen" = round(o$bycatch_table$"Average/Moyen")
o$bycatch_table[ o$bycatch_table==0 ] = NA
o$bycatch_table[ is.na(o$bycatch_table) ] = "."
gt(o$bycatch_table)

\normalsize

Bycatch 4X ... {.c}

o = o_cfa4x
lookup = bio.taxonomy::taxonomy.recode( from="spec", to="taxa", tolookup=o$specid )$vern
xlab = paste("PC1 (", pca$variance_percent[1], "%)", sep="" )
ylab = paste("PC2 (", pca$variance_percent[2], "%)", sep="" )
plot( PC2 ~ PC1, pcadata, type="n", xlab=xlab, ylab=ylab )
text( PC2 ~ PC1, labels=vern, data=pcadata, cex=0.75, col="slategrey"  )
i = grep("Snow crab", pcadata$vern, ignore.case=TRUE)
points( PC2 ~ PC1, pcadata[i,], pch=19, cex=3.0, col="darkorange" )
j = NULL
for (k in lookup) j = c(j, grep( k, pcadata$vern, ignore.case=TRUE))    
j = unique(j)
points( PC2 ~ PC1, pcadata[j,], pch=19, cex=2.0, col="lightgreen" )
text( PC2 ~ PC1, labels=vern, data=pcadata[j,], cex=0.75, col="darkgreen"  )

Prey

::: columns :::: column

xlab = paste("PC1 (", pca$variance_percent[1], "%)", sep="" )
ylab = paste("PC2 (", pca$variance_percent[2], "%)", sep="" )
plot( PC2 ~ PC1, pcadata, type="n", xlab=xlab, ylab=ylab )
text( PC2 ~ PC1, labels=vern, data=pcadata, cex=0.75, col="slategrey"  )
i = grep("Snow crab", pcadata$vern, ignore.case=TRUE)
points( PC2 ~ PC1, pcadata[i,], pch=19, cex=3.0, col="darkorange" )
lookup= c( "echinoderm", "polychaete", "maldane", "nereis", "shrimp", "pandalus", "rock crab", "toad crab", "lesser toad crab", "quahog", "artica islandica", "mollusc", "mytilus", "modiolus", "hiatella", "starfish", "sea anemone", "brittle star", "sea star", "sea anemone", "ophiura", "ophiopholis", "edwardsia", "metridium", "euphasid" )
j = NULL
for (k in lookup) j = c(j, grep( k, pcadata$vern, ignore.case=TRUE))    
j = unique(j)
points( PC2 ~ PC1, pcadata[j,], pch=19, cex=2.0, col="lightgreen" )
text( PC2 ~ PC1, labels=vern, data=pcadata[j,], cex=0.75, col="darkgreen"  )

:::: :::: column - echinoderms - polychaete worms (Maldane, Nereis), worm-like animals - detritus (dead organic matter) - large zooplankton, shrimp - juvenile crab (Rock Crab; Toad Crab; Lesser Toad Crab) - Ocean Quahog (Artica islandica), bivalve molluscs (Mytilus sp, Modiolus, Hiatella) - brittle stars (Ophiura, Ophiopholis) - sea anemones (Edwardsia, Metridium). :::: :::

Predators {.c}

::: columns :::: column

xlab = paste("PC1 (", pca$variance_percent[1], "%)", sep="" )
ylab = paste("PC2 (", pca$variance_percent[2], "%)", sep="" )
plot( PC2 ~ PC1, pcadata, type="n", xlab=xlab, ylab=ylab )
text( PC2 ~ PC1, labels=vern, data=pcadata, cex=0.75, col="slategrey"  )
i = grep("Snow crab", pcadata$vern, ignore.case=TRUE)
points( PC2 ~ PC1, pcadata[i,], pch=19, cex=3.0, col="darkorange" )
lookup= c( "cod", "halibut", "sculpin", "skate", "plaice", "hake", "wolffish", "atlantic cod", "atlantic halibut", "longhorn sculpin", "thorny skate", "striped atlantic wolffish", "haddock", "american plaice", "smooth skate", "winter skate", "white hake", "shorthorn sculpin", "eelpout newfoundland", "squirrel or red hake", "sea raven", "ocean pout", "barndoor skate" )
j = NULL
for (k in lookup) j = c(j, grep( k, pcadata$vern, ignore.case=TRUE))    
j = unique(j)
points( PC2 ~ PC1, pcadata[j,], pch=19, cex=2.0, col="lightgreen" )
text( PC2 ~ PC1, labels=vern, data=pcadata[j,], cex=0.75, col="darkgreen"  )

:::: :::: column

kable( counts[1:11,], format="simple", row.names=FALSE)

:::: :::

Predators {.c}

::: columns :::: column

ggplot() + 
    borders("world", fill = "lightgray", colour = "grey80") + 
    xlim(c( -65.5, -57.1)) + ylim(c(42.1, 47.1)) +
    geom_point(data=snowcrab_predators[year(timestamp) %in% c(2000:2010),], aes(x=slongdd, y=slatdd, colour=Predator ), size=2.5 ) +
    labs(x="", y="", caption="2000-2010") +
    theme(legend.position =c(0.16, 0.65), legend.title=element_blank(), legend.text=element_text(size=7.0) 
) 

::::

:::: column

ggplot() + 
    borders("world", fill = "lightgray", colour = "grey80") + 
    xlim(c( -65.5, -57.1)) + ylim(c(42.1, 47.1)) +
    geom_point(data=snowcrab_predators[year(timestamp) %in% c(2011:2020),], aes(x=slongdd, y=slatdd, colour=Predator ), size=2.5 ) +
    labs(x="", y="", caption="2011-2020") +
    theme(legend.position =c(0.16, 0.725), legend.title=element_blank(), legend.text=element_text(size=7.0) )

:::: :::

Predators - Atlantic cod ... {.c}

loc = file.path( SCD, 'output', 'maps', 'survey', 'snowcrab', 'annual', 'bycatch', 'ms.no.10' )
yrsplot = setdiff( year.assessment + c(0:-9), 2020)
fn4 = file.path( loc, paste( 'ms.no.10', yrsplot[4], 'png', sep='.') )
fn3 = file.path( loc, paste( 'ms.no.10', yrsplot[3], 'png', sep='.') )
fn2 = file.path( loc, paste( 'ms.no.10', yrsplot[2], 'png', sep='.') )
fn1 = file.path( loc, paste( 'ms.no.10', yrsplot[1], 'png', sep='.') )
include_graphics( c(  fn3, fn2, fn1) )
# \@ref(fig:cod-map)  

Predators - Atlantic cod {.c}

include_graphics( file.path( SCD, 'assessments', year.assessment, 'timeseries', 'survey', 'ms.no.10.pdf') )
# \@ref(fig:cod-timeseries)

Predators - Atlantic Halibut {.c}

loc = file.path( SCD, 'output', 'maps', 'survey', 'snowcrab', 'annual', 'bycatch', 'ms.no.30' )
yrsplot = setdiff( year.assessment + c(0:-9), 2020)
fn4 = file.path( loc, paste( 'ms.no.30', yrsplot[4], 'png', sep='.') )
fn3 = file.path( loc, paste( 'ms.no.30', yrsplot[3], 'png', sep='.') )
fn2 = file.path( loc, paste( 'ms.no.30', yrsplot[2], 'png', sep='.') )
fn1 = file.path( loc, paste( 'ms.no.30', yrsplot[1], 'png', sep='.') )
include_graphics( c(  fn3, fn2, fn1) )
# \@ref(fig:halibut-map)  

Predators - Atlantic Halibut ... {.c}

include_graphics( file.path( SCD, 'assessments', year.assessment, 'timeseries', 'survey', 'ms.no.30.pdf') )
# \@ref(fig:halibut-timeseries)

Competitors/Prey - Lesser toad crab ... {.c}

loc = file.path( SCD, 'output', 'maps', 'survey', 'snowcrab', 'annual', 'bycatch', 'ms.no.2521' )
yrsplot = setdiff( year.assessment + c(0:-9), 2020)
fn4 = file.path( loc, paste( 'ms.no.2521', yrsplot[4], 'png', sep='.') )
fn3 = file.path( loc, paste( 'ms.no.2521', yrsplot[3], 'png', sep='.') )
fn2 = file.path( loc, paste( 'ms.no.2521', yrsplot[2], 'png', sep='.') )
fn1 = file.path( loc, paste( 'ms.no.2521', yrsplot[1], 'png', sep='.') )
include_graphics( c( fn3, fn2, fn1) )
# \@ref(fig:lessertoadcrab-map)  

Competitor/Prey - Lesser toad crab {.c}

include_graphics( file.path( SCD, 'assessments', year.assessment, 'timeseries', 'survey', 'ms.no.2521.pdf') )
# \@ref(fig:lessertoadcrab-timeseries)

Competitor/Prey - Northern shrimp {.c}

loc = file.path( SCD, 'output', 'maps', 'survey', 'snowcrab', 'annual', 'bycatch', 'ms.no.2211' )
yrsplot = setdiff( year.assessment + c(0:-9), 2020)
fn4 = file.path( loc, paste( 'ms.no.2211', yrsplot[4], 'png', sep='.') )
fn3 = file.path( loc, paste( 'ms.no.2211', yrsplot[3], 'png', sep='.') )
fn2 = file.path( loc, paste( 'ms.no.2211', yrsplot[2], 'png', sep='.') )
fn1 = file.path( loc, paste( 'ms.no.2211', yrsplot[1], 'png', sep='.') )
include_graphics( c( fn3, fn2, fn1) )
# \@ref(fig:Shrimp-map)  

Competitor/Prey - Northern shrimp ... {.c}

include_graphics( file.path( SCD, 'assessments', year.assessment, 'timeseries', 'survey', 'ms.no.2211.pdf') )
# \@ref(fig:Shrimp-timeseries)

Stock status {.c}

Biomass Density {.c}

\begin{tiny}

loc = file.path( SCD, 'output', 'maps', 'survey', 'snowcrab', 'annual', 'R0.mass')
yrsplot =  setdiff(year.assessment + c(0:-9), 2020 ) 
fn6 = file.path( loc, paste( 'R0.mass', yrsplot[6], 'png', sep='.') )
fn5 = file.path( loc, paste( 'R0.mass', yrsplot[5], 'png', sep='.') )
fn4 = file.path( loc, paste( 'R0.mass', yrsplot[4], 'png', sep='.') )
fn3 = file.path( loc, paste( 'R0.mass', yrsplot[3], 'png', sep='.') )
fn2 = file.path( loc, paste( 'R0.mass', yrsplot[2], 'png', sep='.') )
fn1 = file.path( loc, paste( 'R0.mass', yrsplot[1], 'png', sep='.') )
include_graphics( c(  fn3, fn2, fn1) )

\end{tiny}

Biomass Density ... {.c}

\begin{tiny}

fn = file.path(SCD,'assessments', year.assessment, 'timeseries','survey','R0.mass.pdf')
include_graphics( c(fn) )
#\@ref(fig:fbGMTS)

\end{tiny}

Viable Habitat {.t}

\begin{small} \begin{columns} \begin{column}{.48\textwidth}

fn1=file.path( media_loc, "viable_habitat.png" ) 
knitr::include_graphics( c(fn1  ) ) 
# \@ref(fig:habitat)  

\end{column} \begin{column}{.48\textwidth}

fn2=file.path( media_loc, "viable_habitat_depth_temp.png" )
knitr::include_graphics( c( fn2 ) ) 
# \@ref(fig:habitat2)  

\end{column} \end{columns}s \end{small}

Viable Habitat ... {.c}

loc = file.path( SCD, 'modelled', '1999_present_fb', 'predicted.presence_absence' )
yrsplot =  year.assessment + c(0:-10)
fn10 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[10], '.png', sep='') )
fn9 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[9], '.png', sep='') )
fn8 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[8], '.png', sep='') )
fn7 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[7], '.png', sep='') )
fn6 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[6], '.png', sep='') )
fn5 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[5], '.png', sep='') )
fn4 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[4], '.png', sep='') )
fn3 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[3], '.png', sep='') )
fn2 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[2], '.png', sep='') )
fn1 = file.path( loc, paste( 'Predicted_presence_absence_', yrsplot[1], '.png', sep='') )
include_graphics( c(  fn3, fn2, fn1) )
# \@ref(fig:fb-habitat-map)  
# *Figure XXX. Habitat viability (probability; fishable Snow Crab)* 

Viable Habitat ... {.c}

loc = file.path( SCD, 'modelled', '1999_present_fb', 'aggregated_habitat_timeseries' )
include_graphics( file.path( loc, 'habitat_M0.png') )
# \@ref(fig:fb-habitat-timeseries)

Biomass Index (aggregate)

```r$(t/km$^2$) predicted from the Snow Crab survey.' } loc = file.path( SCD, 'modelled', '1999_present_fb', 'predicted_biomass_densities' ) yrsplot = year.assessment + c(0:-10) fn10 = file.path( loc, paste( 'biomass', yrsplot[10], 'png', sep='.') ) fn9 = file.path( loc, paste( 'biomass', yrsplot[9], 'png', sep='.') ) fn8 = file.path( loc, paste( 'biomass', yrsplot[8], 'png', sep='.') ) fn7 = file.path( loc, paste( 'biomass', yrsplot[7], 'png', sep='.') ) fn6 = file.path( loc, paste( 'biomass', yrsplot[6], 'png', sep='.') ) fn5 = file.path( loc, paste( 'biomass', yrsplot[5], 'png', sep='.') ) fn4 = file.path( loc, paste( 'biomass', yrsplot[4], 'png', sep='.') ) fn3 = file.path( loc, paste( 'biomass', yrsplot[3], 'png', sep='.') ) fn2 = file.path( loc, paste( 'biomass', yrsplot[2], 'png', sep='.') ) fn1 = file.path( loc, paste( 'biomass', yrsplot[1], 'png', sep='.') ) include_graphics( c( fn3, fn2, fn1) )

## Biomass Index (aggregate) ... {.c}

\begin{tiny}
```r
include_graphics( file.path( SCD, 'modelled', '1999_present_fb', 'aggregated_biomass_timeseries' , 'biomass_M0.png') )
# \@ref(fig:fbindex-timeseries)

\end{tiny}

Fishery Model Biomass (pre-fishery){.c}

\begin{tiny}

loc = file.path( SCD, 'fishery_model', year.assessment, 'logistic_discrete_historical' )
fn1 = file.path( loc, 'plot_predictions_cfanorth.pdf' ) 
fn2 = file.path( loc, 'plot_predictions_cfasouth.pdf' ) 
fn3 = file.path( loc, 'plot_predictions_cfa4x.pdf' ) 
include_graphics(c(fn1, fn2, fn3) )
# \@ref(fig:logisticPredictions)

\end{tiny}

Fishing Mortality {.c}

  odir = file.path( fishery_model_results, year.assessment, "logistic_discrete_historical" )
  fn1 = file.path( odir, "plot_fishing_mortality_cfanorth.pdf" ) 
  fn2 = file.path( odir, "plot_fishing_mortality_cfasouth.pdf" ) 
  fn3 = file.path( odir, "plot_fishing_mortality_cfa4x.pdf" ) 
include_graphics(c(fn1, fn2, fn3) )
# \@ref(fig:logisticFishingMortality)

Fishery Model Summary {.c}

| | N-ENS | S-ENS | 4X |
|----- | ----- | ----- | ----- | | | | | | |q | r round(q_north, 3) (r round(q_north_sd, 3)) | r round(q_south, 3) (r round(q_south_sd, 3)) | r round(q_4x, 3) (r round(q_4x_sd, 3)) | |r | r round(r_north, 3) (r round(r_north_sd, 3)) | r round(r_south, 3) (r round(r_south_sd, 3)) | r round(r_4x, 3) (r round(r_4x_sd, 3)) | |K | r round(K_north, 2) (r round(K_north_sd, 2)) | r round(K_south, 2) (r round(K_south_sd, 2)) | r round(K_4x, 2) (r round(K_4x_sd, 2)) | |Prefishery Biomass | r round(B_north[t0], 2) (r round(B_north_sd[t0], 2)) | r round(B_south[t0], 2) (r round(B_south_sd[t0], 2)) | r round(B_4x[t0], 2) (r round(B_4x_sd[t0], 2)) | |Fishing Mortality | r round(FM_north[t0], 3) (r round(FM_north_sd[t0], 3)) | r round(FM_south[t0], 3) (r round(FM_south_sd[t0], 3)) | r round(FM_4x[t0], 3) (r round(FM_4x_sd[t0], 3)) |

\tiny Note: Values in parentheses are Posterior standard deviations. \normalsize

Reference Points {.c}

include_graphics( file.path( params$media_loc, 'harvest_control_rules.png') ) 
# \@ref(fig:ReferencePoints)

Reference Points ... {.c}

  odir = file.path( fishery_model_results, year.assessment, "logistic_discrete_historical" )
  fn1 = file.path( odir, 'plot_hcr_cfanorth.pdf' ) 
  fn2 = file.path( odir, 'plot_hcr_cfasouth.pdf' ) 
  fn3 = file.path( odir, 'plot_hcr_cfa4x.pdf' ) 
  include_graphics(c(fn1, fn2, fn3) )
#  \@ref(fig:logistic-hcr)

Conclusions

The ESS ecosystem is still experiencing a lot of volatility and prudence is wise:

Conclusions: N-ENS

Conclusions: S-ENS

Conclusions: 4X

References

\begin{tiny}

Banerjee, S., Carlin, B. P., and Gelfand, A. E.. 2004. Hierarchical Modeling and Analysis for Spatial Data. Monographs on Statistics and Applied Probability. Chapman and Hall/CRC.

Besag, Julian. 1974. Spatial interaction and the statistical analysis of lattice systems. Journal of the Royal Statistical Society Series B (Methodological) 1974: 192-236.

Canada Gazette. 2022. Regulations Amending the Fishery (General) Regulations. Part II, Volume 156, Number 8.

Canada Gazette. 2016. St. Anns Bank Marine Protected Area Regulations. Canada Gazette, Part I, Vol 150, Issue 51: 4143-4149.

Choi, J.S. 2020. A Framework for the assessment of Snow Crab (Chioneocete opilio) in Maritimes Region (NAFO Div 4VWX) . DFO Can. Sci. Advis. Sec. Res. Doc. 2020/nnn. v + xxx p.

Choi, J.S. 2022. Reconstructing the Decline of Atlantic Cod with the Help of Environmental Variability in the Scotian Shelf of Canada. bioRxiv. https://doi.org/10.1101/2022.05.05.490753.

Choi, J. S., and B. C. Patten. 2001. Sustainable Development: Lessons from the Paradox of Enrichment. Ecosystem Health 7: 163–77.

Choi, Jae S., B. Cameron, K. Christie, A. Glass, and E. MacEachern. 2022. Temperature and Depth Dependence of the Spatial Distribution of Snow Crab. bioRxiv. https://doi.org/10.1101/2022.12.20.520893.

Choi, Jae S. 2023. A Multi-Stage, Delay Differential Model of Snow Crab Population Dynamics in the Scotian Shelf of Atlantic Canada. bioRxiv. https://doi.org/10.1101/2023.02.13.528296.

\end{tiny}

References ...

\begin{tiny}

DFO. 2013. Integrated Fisheries Management Plan for Eastern Nova Scotia and 4X Snow Crab (Chionoecetes Opillio.)

DFO. 2018. Stock Status Update of Atlantic Halibut (Hippoglossus hippoglossus) on the Scotian Shelf and Southern Grand Banks in NAFO Divisions 3NOPs4VWX5Zc. DFO Can. Sci. Advis. Sec. Sci. Resp. 2018/022.

Hebert M, Miron G, Moriyasu M, Vienneau R, and DeGrace P. Efficiency and ghost fishing of Snow Crab (Chionoecetes opilio) traps in the Gulf of St. Lawrence. Fish Res. 2001; 52(3): 143-153. 10.1016/S0165-7836(00)00259-9

Riebler, A., Sørbye, S.H., Simpson D., and Rue, H. 2016. An intuitive Bayesian spatial model for disease mapping that accounts for scaling. Statistical methods in medical research 25: 1145-1165.

Simpson, D., Rue, H., Riebler, A., Martins, T.G., and Sørbye, SH. 2017. Penalising Model Component Complexity: A Principled, Practical Approach to Constructing Priors. Statist. Sci. 32: 1-28.

\end{tiny}

End

Supplemental Information

Stock status {.c}

Geometric mean density by size, sex and maturity

::: columns :::: column

include_graphics(  file.path( SCD, "assessments", year.assessment, "figures", "size.freq", "survey", "male.denl.png" )  )
# \@ref(fig:sizefeq-male)

:::: :::: column

include_graphics(  file.path( SCD, "assessments", year.assessment, "figures", "size.freq", "survey", "female.denl.png" )  )
# \@ref(fig:sizefeq-male)

:::: :::

Mature female maps

Distributions are heterogeneous and often in shallower areas.

```r$(no/km$^2$) from the Snow Crab survey.' } loc = file.path( SCD, "output", "maps", "survey", "snowcrab", "annual", "totno.female.mat" ) yrsplot = setdiff( year.assessment + c(0:-9), 2020) fn4 = file.path( loc, paste( "totno.female.mat", yrsplot[4], "png", sep=".") ) fn3 = file.path( loc, paste( "totno.female.mat", yrsplot[3], "png", sep=".") ) fn2 = file.path( loc, paste( "totno.female.mat", yrsplot[2], "png", sep=".") ) fn1 = file.path( loc, paste( "totno.female.mat", yrsplot[1], "png", sep=".") ) include_graphics( c( fn3, fn2, fn1) )

\@ref(fig:fmat-map)

## Mature female timeseries

```r$(no/km$^2$) from the Snow Crab survey.'  }
include_graphics( file.path( SCD, "assessments", year.assessment, "timeseries", "survey", "totno.female.mat.pdf") )
# \@ref(fig:fmat-timeseries)


jae0/snowcrab documentation built on Feb. 27, 2024, 2:42 p.m.