```{css zoom-lib-src, echo = FALSE}
script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"
```

```{js zoom-jquery, echo = FALSE}
 $(document).ready(function() {
    $('body').prepend('<div class=\"zoomDiv\"><img src=\"\" class=\"zoomImg\"></div>');
    // onClick function for all plots (img's)
    $('img:not(.zoomImg)').click(function() {
      $('.zoomImg').attr('src', $(this).attr('src')).css({width: '100%'});
      $('.zoomDiv').css({opacity: '1', width: 'auto', border: '1px solid white', borderRadius: '5px', position: 'fixed', top: '50%', left: '50%', marginRight: '-50%', transform: 'translate(-50%, -50%)', boxShadow: '0px 0px 50px #888888', zIndex: '50', overflow: 'auto', maxHeight: '100%'});
    });
    // onClick function for zoomImg
    $('img.zoomImg').click(function() {
      $('.zoomDiv').css({opacity: '0', width: '0%'}); 
    });
  });
```

```{r setup, include=FALSE}
assessment_dir <- normalizePath(
  file.path(dirname(knitr::current_input(dir = TRUE)), "..", "..", "assessment"),
  winslash = "/"
)
knitr::opts_knit$set(root.dir = assessment_dir)
knitr::opts_chunk$set(warning=F, message=F, echo=F, results=F,fig.width=6, fig.height=5)
```

```{r}
library(jjmR)
library(tidyverse)
library(kableExtra)
library(ggthemes)
library(patchwork)
library(here)

geth <- function(mod,h=hyp) paste0(h,"_", mod)

```

# Chile's New Age Data ("Validacion")

Model      | Description
-----------|--------------
**Models 0.x**| **Data introductions**
1.01     | As 1.00 but use revised data series "antiguo" of age composition and weight at age data for both Chilean fisheries and both Chilean acoustic surveys (assessment/NewAgeData/AgeDataInAssessment.csv)
1.02     | As 1.01 but incorporate revised (validated) age data for surveys and fleets with M and maturity updated (M=0.35) (NOT RUN)
1.03     | As 1.02 but M=0.45 (NOT RUN)



```{r}
dat.surv <- read_csv2(file.path("data", "Catch_num_Survey_2001-2021.csv")) %>%
              janitor::clean_names()

dat.fish <- read_csv2(file.path("data", "Catch_num_Fleet_1980-2021.csv")) %>%
              janitor::clean_names()

```

* Macrozona is for the fleet?


## Data Exploration


## Single-stock hypothesis {.tabset}
### Biomass
```{r}
plot(Validacion,combine=T,what="biomass",stack=F,main="Biomass")
```

### Recruitment
```{r}
plot(Validacion,combine=T,what="recruitment",stack=F,main="Recruitment")
```

### Fishing Mortality
```{r }
plot(Validacion,combine=T,what="ftot",stack=F,main="Total Fishing Mortality")
```

## Two-stock hypothesis {.tabset}
### Biomass
```{r}
Validacion <- compareModels(geth(mods2compare,"h2"))

plot(Validacion,combine=T,what="biomass",stack=F,main="Biomass")
```

### Recruitment
```{r}
plot(Validacion,combine=T,what="recruitment",stack=F,main="Recruitment")
```

### Fishing Mortality
```{r}
plot(Validacion,combine=T,what="ftot",stack=F,main="Total Fishing Mortality")
```

# Things Missing
* Maturity-at-age estimates
* An overall population weight at age
* Some years of data seem to be missing
