Skip to content

Commit

Permalink
scallop.rmd
Browse files Browse the repository at this point in the history
- added effort plots
- added selected ports
- lined up output with groundfish rmd
  • Loading branch information
andybeet committed Jul 24, 2024
1 parent 7dee1e6 commit cad10a9
Showing 1 changed file with 164 additions and 34 deletions.
198 changes: 164 additions & 34 deletions vignettes/scallops.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ sca |> dplyr::distinct(GEARCAT,GEARCODE) |>
DT::datatable()
```

## Landings
## Landings (All species)

The landings of Scallop trips with associated bycatch

Expand All @@ -75,27 +75,21 @@ speciesLanded <- landings |>
dplyr::filter(nyrs > 1) |>
dplyr::pull(Functional_Group)
landings |>
p <- landings |>
dplyr::filter(Functional_Group %in% speciesLanded) |>
ggplot2::ggplot() +
ggplot2::geom_line(ggplot2::aes(x=Year,y=landed)) +
ggplot2::facet_wrap(~Functional_Group) +
ggplot2::ylab("Metric Tons") +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90))
```
suppressMessages(print(p))
## Total scallop landings compared to bycatch

```{r plotcompare, echo = F}
landings <- sca |>
dplyr::filter(Code == "SCA") |>
dplyr::group_by(Year,STATEABB) |>
dplyr::summarise(landed = round(sum(InsideLANDED),digits=2),
.groups = "drop")
```

## Total scallop landings compared to bycatch

```{r plotland2, echo =F}
sca |>
Expand Down Expand Up @@ -158,6 +152,43 @@ landings |>
```

```{r portland4b, echo=F}
ports <- sca |>
dplyr::group_by(newport,STATEABB,PORTID,lat,lon) |>
dplyr::summarise(mt = sum(InsideLANDED),
.groups = "drop") |>
dplyr::mutate(lat = round(lat,digits=2),
lon = round(lon,digits = 2)) |>
dplyr::arrange(desc(mt)) |>
dplyr::mutate(cummt = cumsum(mt),
percent = round(cummt/sum(mt),digits=2))
DT::datatable(ports)
```


## Select the main ports {#sel}

The following ports three main ports are selected. Other smaller ports (listed under main port) are combined with main ports. hese ports comprise ~ 90% of total landings.

* MASSACHUSETTS
* NEW BEDFORD (240403)
* FAIRHAVEN (242203)
* NEW JERSEY
* CAPE MAY (330309)
* LONG BEACH (331627)
* POINT PLEASANT (330127)
* VIRGINIA
* NEWPORT NEWS (490910)
* SEAFORD (490869)
* HAMPTON (490118)

```{r mainports, echo = F}
mainPortsIDs = c(240403,330309,490910)
associatedPorts = data.frame(main=c(240403,330309,330309,490910,490910),associated=c(242203,331627,330127,490869,490118))
threshold1 <- .99
```


## Landings by Atlantis Box
compared to model output from v2.2.0
Expand Down Expand Up @@ -242,19 +273,19 @@ NEFSCspatial::Neus_atlantis |>
Boxes that contribute 95% of landings `r landings |> dplyr::pull(Box) |> sort()`


## Landings (data) by box spatially for 3 main ports
## Landings (data) by box spatially for main ports

```{r plotland7, echo =F}
# pick out 3 busiest ports based on landings
portids <- unique(c(mainPortsIDs,associatedPorts$associated))
ports <- sca |>
dplyr::group_by(newport,PORTID,lat,lon) |>
dplyr::group_by(newport,STATEABB,PORTID,lat,lon) |>
dplyr::summarise(landed = sum(InsideLANDED),
.groups = "drop") |>
dplyr::arrange(desc(landed)) |>
dplyr::slice(1:3)
portids <- ports |> dplyr::pull(PORTID)
dplyr::filter(PORTID %in% portids)
landings <- sca |>
dplyr::filter(Code == "SCA",PORTID %in% portids) |>
Expand Down Expand Up @@ -322,46 +353,145 @@ for (iport in portids) {
```

## Location of ports
## Aggregate remaining data as "other" fleet

Location of ports that land scallops
The remaining ports (other than the ports listed above) make up ~10% of total landings. All trips associated with these ports will be combined to form one fleet which will fish in the footprint below. This maintains the communities at sea idea for the main ports but takes into account all remaining landings to satisfy model requirements

```{r ports1, echo =F}
ports <- sca |>
dplyr::group_by(newport,PORTID,lat,lon) |>
```{r otherfleet,echo = F}
ports <- unique(c(mainPortsIDs,associatedPorts$associated))
otherFleet <- sca |>
dplyr::filter(!(PORTID %in% ports)) |>
dplyr::group_by(Year,Area) |>
dplyr::summarise(landed = sum(InsideLANDED),
.groups = "drop") |>
dplyr::arrange(desc(landed))
.groups = "drop") |>
tidyr::separate(col=Area,into = c("text","Box"),sep = "ID_") |>
dplyr::mutate(Box = as.numeric(Box)) |>
dplyr::select(-text)
otherFleetLandings <- sum(otherFleet$landed)
timerange <- range(otherFleet$Year)
otherFleetBox <- otherFleet |>
dplyr::group_by(Box) |>
dplyr::summarise(landed = sum(landed),
.groups = "drop")
# select boxes which account fo 95% of landings
p <- NEFSCspatial::Neus_atlantis |>
dplyr::left_join(otherFleetBox,by = c("BOX_ID"="Box")) |>
ggplot2::ggplot() +
ggplot2::geom_sf(ggplot2::aes(fill = landed)) +
#ggplot2::scale_fill_continuous(limits=c(0, maxBoxLandings))+
ggplot2::geom_sf_text(ggplot2::aes(label = BOX_ID),
size=3) +
ggplot2::ggtitle("Other Fleet") +
ggplot2::coord_sf(xlim = c(-80,-62))
suppressWarnings(print(p))
```

Total Landings over `r paste(timerange,collapse="-")` = `r round(otherFleetLandings)` metric tons

Time series of landings by box of other fleet


```{r otherfleettime, echo = F, message=F}
otherFleetBoundary <-
otherFleet |>
dplyr::mutate(boundary = dplyr::case_when(!(Box %in% boundaryBoxes) ~ "NEUS domain",
.default = "Boundary Box"))
p <- otherFleetBoundary |>
ggplot2::ggplot() +
ggplot2::geom_line(ggplot2::aes(x=Year,y=landed,color = factor(boundary)))+
ggplot2::facet_wrap(~Box) +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90)) +
ggplot2::ylab("Metric Tons") +
ggplot2::labs(color=" ")
suppressMessages(print(p))
```


## Effort

The effort variable is Days at sea (DAS) and is a crude metric. Only integer values and rounded up to the nearest whole day. It is the length of the trip. Note: For each record of a trip (multiple records based on the species caught) the DAS is replicated, so to calculate the true DAS we need to find distinct Trip-DAS

After aggregating the top ports based on the decisions found in this section {#sel} and combining all remaining ports into an "other fleet" we can look at the total effort by fleet in units: days at sea


```{r effort1, echo =F}
ports <- unique(c(mainPortsIDs,associatedPorts$associated))
effort <- sca |>
dplyr::group_by(Year,newport) |>
dplyr::summarise(effort = sum(InsideDAS),
landed = sum(InsideLANDED),
.groups = "drop") |>
dplyr::filter(newport %in% ports10)
# |>
# tidyr::pivot_longer(-c(Year,PORTLANDED),names_to = "type",values_to = "value")
effortByBox <- get_effort(sca,ports,associatedPorts)
annualEffort <- effortByBox |>
dplyr::group_by(Year,newport,STATEABB) |>
dplyr::summarise(effort = sum(effort),
.groups="drop")
ggplot2::ggplot(effort) +
ggplot2::ggplot(annualEffort) +
ggplot2::geom_line(ggplot2::aes(x=Year,y=effort)) +
ggplot2::facet_wrap(~as.factor(newport)) +
ggplot2::ylab("Effort (Days)") +
ggplot2::ggtitle("Effort by port for top 10 productive ports") +
ggplot2::ggtitle("Effort by port") +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90))
```

## Effort by box (Time series)

Partition effort by box.

Note: In atlantis effort is entered as as daily effort (days of effort per day). This equates to dividing the annual effort by 365 days. Here we show the effort by box for the top ports (by landings)

```{r effort2, echo =F}
port3 <-effortByBox |>
dplyr::distinct(newport) |>
dplyr::pull()
boxEffort <- effortByBox |>
dplyr::filter(newport %in% port3)
for (aport in port3) {
p <- ggplot2::ggplot(boxEffort |> dplyr::filter(newport == aport)) +
ggplot2::geom_line(ggplot2::aes(x=Year,y=effort)) +
ggplot2::facet_wrap(~as.factor(Box)) +
ggplot2::ylab("Effort (Days)") +
ggplot2::ggtitle(aport) +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90))
suppressMessages(print(p))
}
```

## Landings by box (Time series)

```{r landingsboxtime, echo =F}
boxEffort <- effortByBox |>
dplyr::filter(newport %in% port3)
for (aport in port3) {
p <- ggplot2::ggplot(boxEffort |> dplyr::filter(newport == aport)) +
ggplot2::geom_line(ggplot2::aes(x=Year,y=landings)) +
ggplot2::facet_wrap(~as.factor(Box)) +
ggplot2::ylab("Metric Tons") +
ggplot2::ggtitle(aport) +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90))
suppressMessages(print(p))
}
```


0 comments on commit cad10a9

Please sign in to comment.