---
title: "`r params$title`"
subtitle: "`r params$subtitle`"
author: "`r params$author`"
date: "`r Sys.Date()`"
output: 
  html_document:
    toc: true
    toc_float: true
    number_sections: true    
runtime: shiny   
---


<style type="text/css">

body{ /* Normal  */
   font-size: 16px;
}
td {  /* Table  */
   font-size: 16px;
}
title { /* title */
 font-size: 26px;
}
h1 { /* Header 1 */
 font-size: 24px;
 color: DarkBlue;
}
h2 { /* Header 2 */
 font-size: 21px;
 color: DarkBlue;
}
h3 { /* Header 3 */
 font-size: 19px;
 color: DarkBlue;
}
code.r{ /* Code block */
  font-size: 16px;
}
pre { /* Code block */
  font-size: 16px
}
</style>




```{r set options, echo = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
knitr::opts_chunk$set(dpi=85)
#options(width = 650)
```

<br>


# About this document

This is a prototype of an automatic report that describes the results of a demonstration COSEWIC risk analysis for the Canadian Department of Fisheries and Oceans. 

<br>


# Performance table

A performance table is produced that provides the probability of stock status in the critical, cautious and healthy zones. Also provided are the A1 and A2 indicators of stock trend and an additional metric determining the probability of dropping below a biomass that takes three mean generation times to recover to half BMSY given zero fishing. 


```{r table,echo=F,warning=F,error=F,message=F}
 tab<-COSEWIC_tab(params$MSEobj)
 COSEWIC_tab_formatted(tab)

```

<br>

```{r thresh,echo=F,warning=F,error=F,message=F}
 Cos_thresh_tab(tab)

```


* P_Cr is the probability of being in the critical zone (less than 20% depletion)
* P_Ct is the probability of being in the cautious zone (between 20% and 40% depletion)
* P_H is the probability of being in the healthy zone (above 40% depletion)
* P_Cr_MSY is the probability of being in the critical zone (less than 40% BMSY)
* P_Ct_MSY is the probability of being in the cautious zone (between 40% and 80% BMSY)
* P_H_MSY is the probability of being in the healthy zone (above 80% BMSY)
* P_A1 is the probability of being designated threatened according to COSEWIC Indicator A1 (Spawning biomass less than 70% that three generation times previously)
* P_A2 is the probability of being designated threatened according to COSEWIC Indicator A2 (Spawning biomass less than 50% that three generation times previously)
* Blow is the probability that the stock is below the biomass for which it takes 3 generation times to reach 50% BMSY with zero fishing

<br>

# Historical biomass trend and current status

These plots show the historical trajectory of Spawning stock biomass relative to unfished levels (upper left hand panel) and relative to MSY levels (upper right hand panel). The current status (the final year of the historical trajectories) is further described in a pair of status box and whisker plots in the lower panels.  


```{r Hplot,echo=F,warning=F,error=F,message=F,fig.width=10,fig.height=8}

 COSEWIC_Hplot(params$MSEobj)

```

<br>


# Projection plot for zero fishing, FMSY fishing and current fishing effort

Future projections of spawning biomass (relative to unfished and MSY levels) are illustrated For three alternarive fishing scenarios.

```{r Pplot,echo=F,warning=F,error=F,message=F,fig.height=10,fig.width=10}
 COSEWIC_Pplot(params$MSEobj)

```

<br>


# Evaluation of trend indicators 

The COSEWIC indicators A1 and A2 characterize changes in spawning biomass over a moving window of three generation times. Here historical (before the vertical black line) and future spawning biomass changes are plotted for each of the three fishing scenarios.  

```{r A1_A2,echo=F,warning=F,error=F,message=F,fig.height=10,fig.width=10}
 COSEWIC_Dplot(params$MSEobj)

```

<br>

# Extinction risk 

It can be difficult to describe a biomass level below which a stock can be considered quantitatively extinct (qualitative extinction being rare in exploited marine fish species). In this case we calculate a biomass Blow, for which it would take three generation times of zero fishing to reach 50% of BMSY. The plot below shows the probability of dropping below Blow over future projections for each of the fishing scenarios. 

```{r Extinction_Blow,echo=F,warning=F,error=F,message=F,fig.height=7,fig.width=9}
 COSEWIC_Blow(params$MSEobj)

```


<br>


# Version Notes

This report is subject to ongoing testing. If you find a bug or a problem please send a report to <t.carruthers@oceans.ubc.ca> so that it can be fixed or report an issue at www.github.com/DLMtool/DLMtool/issues.  

