---
output: 
  html_document:
    css: help.css
    
params:
  compartment: sediment
---

```{r setup, include = FALSE, echo = FALSE}

library(knitr)
knit_engines$set(asis = function(options) {
  if (options$echo && options$eval) knit_child(text = options$code)
})

options(width = 110)

source("report functions.R")

load(file.path("meta analysis objects", "MSTAT investigation.RData"))
assessment <- get(params$compartment)
```

## Screening of MSTAT for `r params$compartment

<p class = "startsmall">
This document is to help examine whether the classification of stations as baseline (B), representative (RH) and impacted (IH) is reasonable.  For the purposes of the MIME assessment:
</p>

<ul type = "disc">
<li>Baseline stations are those that are near-pristine or only subject to diffuse inputs.  Baseline stations will be used in the meta-analyses of status.  However, they will be excluded from the meta-analyses of trend because any trends there are likely to due to different processes than the trends in representative stations.</li>
<li>Impacted stations are those close to a point source. Impacted stations will be removed from the meta-analyses of both status and trend, because they are not representative of contaminants at a regional scale.</li>
<li class = "lastbig">Representative stations are all the rest. We think of stations being representative in the broadest sense./li>
</ul>     

<p class = "startsmall">
Here are all the `r params$compartment` stations for which a parametric model for at least one chemical determinand.  The stations are coloured according to their MSTAT as given in the station dictionary, with the following modifications:

<ul type = "disc">
<li>Missing values are treated as representative</li>
<li>Stations which have ID status (impacted due to dredging) have been turned into representative (because not IH - impacted due to hazardous substances).</li>
<li class = "lastbig">Stations which have RP status (representative due to physical processes) have been turned into RH./li>
</ul>     




The sediment stations are shown below.  They are coloured blue if baseline, green if representative, and red if impacted.  The monitoring area is divided into CP2 reporting regions.  Note that stations part of a stratified fixed sampling strategy have been displayed as a single station (one for each stratum).

```{r, echo = FALSE, message = FALSE, warning = FALSE, fig.width = 7, fig.height = 7}
plotAllStations.CSEMP(sediment)
```

Here is the corresponding map of biota stations:

```{r, echo = FALSE, message = FALSE, warning = FALSE, fig.width = 7, fig.height = 7}
plotAllStations.CSEMP(biota)
```

The numbers of baseline, representative and impacted stations are summarised below:

```{r, echo = FALSE, comment = ""}
wk.biota <- unique(biota$timeSeries[c("station", "MSTAT")])
row.names(wk.biota) <- NULL
wk.biota$compartment <- "biota"

wk.sediment <- unique(sediment$timeSeries[c("station", "MSTAT")])
row.names(wk.sediment) <- NULL
wk.sediment$compartment <- "sediment"

wk.summary <- rbind(wk.biota, wk.sediment)
wk.summary <- within(wk.summary, MSTAT <- factor(MSTAT, levels = c("B", "RH", "IH")))
wk.summary <- wk.summary[with(wk.summary, order(compartment, MSTAT, station)), ]
wk.out <- with(wk.summary, table(compartment, MSTAT))
names(dimnames(wk.out)) <- NULL
wk.out
```


The baseline stations are:

```{r, echo = FALSE, comment = ""}
wk.out <- wk.summary[wk.summary$MSTAT %in% "B", c("compartment", "station")]
print(wk.out, row.names = FALSE)
```

and the impacted stations are:

```{r, echo = FALSE, comment = ""}
wk.out <- wk.summary[wk.summary$MSTAT %in% "IH", c("compartment", "station")]
print(wk.out, row.names = FALSE)
```

