Löndunarhraði tegundanna er sýndur fyrir landanir fiskveiðiárs og almanaksárs (innan landhelgi). Gögnin að baki myndunum eru sótt í ‘lóðsinn’, gagnagrunn Fiskistofu um landanir og byggja á afla upp úr sjó. Ráðgjöf á yfirstandandi fiskveiðiári er sýndur sem lárétt, blá lína þar sem það á við. Ráðgjöf síðasta fiskveiðiárs er sýnd sem lárétt grá lína. Núverandi fiskveiði- og almanaksár eru sýnd sem bláir ferlar, sem hægt er að bera saman við nýliðin ár, sýnd sem gráir ferlar. Gögnin eru uppfærð daglega.
---
title: "Landanir"
output:
flexdashboard::flex_dashboard:
orientation: rows
source_code: embed
logo: img/hafro.jpg
---
<style>
.navbar {
background-color:white;
border-color:black;
}
.navbar-brand {
color:black;
}
</style>
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE,
fig.width = 10)
# hafro-logo hex: 0076a8
```
```{r cronjob}
#library(DBI, lib.loc = "/usr/local/lib/R/site/4.0/x86_64/library")
library(ROracle) #, lib.loc = "/usr/local/lib/R/site/4.0/x86_64/library")
library(tidyverse)
library(lubridate)
library(patchwork)
library(mar)
con <- connect_mar()
```
```{r}
current_tac_dates <- function() {
td <- lubridate::today()
t1 <- ymd(paste0(ifelse(month(td) <= 8, year(td) - 1 , year(td)), "-09-01"))
t2 <- t1 + years(1) - days(1)
return(c(t1, t2))
}
q0 <- current_tac_dates()
q1 <- q0 - years(1)
y0 <- c(floor_date(today(), "year"), floor_date(today(), "year") + years(1) - days(1))
y1 <- y0 - years(1)
T1 <- min(q1, y1)
LN <-
#omar::ln_catch(con) %>%
omar::ln_agf(con, trim = FALSE) |>
filter(date >= to_date(T1, "YYYY:MM:DD")) %>%
# blue whiting and mackerel - all catch
filter((veidisvaedi == "IS" & !sid %in% c(34, 36)) | sid %in% c(34, 36)) %>%
collect(n = Inf) %>%
filter(!vid %in% 3700:4999) |>
group_by(date, sid) %>%
summarise(catch = sum(wt) / 1e3,
.groups = "drop") %>%
#mutate(catch = ifelse(sid %in% c(30, 31, 34), catch / 1e3, catch / 1e6)) %>%
arrange(sid, date)
lnQ <-
expand_grid(sid = LN %>% pull(sid) %>% unique() %>% sort(),
date = seq(q1[1], today(), by = 'days')) %>%
mutate(year = year(date),
qyear = ifelse(month(date) <= 8,
paste0(year - 1, "/", year),
paste0(year, "/", year + 1))) %>%
left_join(LN) %>%
mutate(catch = replace_na(catch, 0)) %>%
group_by(sid, qyear) %>%
mutate(cqyear = cumsum(catch)) %>%
ungroup() %>%
mutate(cqyear = round(cqyear, 3),
qs = dense_rank(desc(qyear)),
date = date %m+% years((qs-1)))
lnY <-
expand_grid(sid = LN %>% pull(sid) %>% unique() %>% sort(),
date = seq(y1[1], today(), by = 'days')) %>%
mutate(year = year(date)) %>%
left_join(LN) %>%
mutate(catch = replace_na(catch, 0)) %>%
group_by(sid, year) %>%
mutate(cyear = cumsum(catch)) %>%
ungroup() %>%
mutate(cyear = round(cyear, 3),
ys = dense_rank(desc(year)),
date = date %m+% years((ys-1)))
tacs <-
omar::tac(con) |>
collect() |>
filter(qyear %in% c("2022/2023", "2023/2024")) %>%
mutate(tac = tac / 1e3)
# tacs |> spread(qyear, tac) |> knitr::kable()
lh <- function(SID = 1, no_tac = TRUE) {
#if(!no_tac) {
tacssid <-
tacs %>%
filter(sid == SID)
notac <- ifelse(nrow(tacssid) == 0, TRUE, FALSE)
if(!notac) {
tacssid <-
tacssid |>
mutate(date = min(lnQ$date) + weeks(c(2, 9)))
}
#}
d1 <-
lnQ %>%
filter(sid == SID)
d1.last <-
d1 %>%
filter(qs == 1) %>%
filter(date == max(date))
d2 <-
lnY %>%
filter(sid == SID)
d2.last <-
d2 %>%
filter(year == max(year)) %>%
filter(date == max(date))
ymax <- max(c(d1$cqyear, d2$cyear, tacssid$tac), na.rm = TRUE)
p1 <-
d1 %>%
ggplot(aes(date, cqyear)) +
theme_bw(base_size = 13) +
geom_step(aes(colour = factor(qyear)),
lwd = 1) +
geom_text(data = d1.last, aes(label = paste(cqyear, " ")),
hjust = 1,
colour = "#0076a8") +
scale_colour_manual(values = c("grey", "#0076a8")) +
labs(title = "Fiskveiðiár",
x = NULL,
y = "Landaður afli [tonn]",
colour = NULL) +
theme(legend.position = c(0.97, 0.03),
legend.justification = c(1, 0),
plot.title = element_text(colour = "#0076a8")) +
scale_x_datetime(date_breaks = "1 month", date_labels = "%b") +
coord_cartesian(ylim = c(0, ymax))
if(!no_tac) {
if(!notac) {
p1 <-
p1 +
geom_hline(data = tacssid,
aes(yintercept = tac, colour = factor(qyear))) +
geom_label(data = tacssid,
aes(x = date, y = tac, label = tac, colour = factor(qyear)),
size = 3)
}
}
p2 <-
d2 %>%
ggplot(aes(date, cyear)) +
theme_bw(base_size = 13) +
geom_step(aes(colour = factor(year)),
lwd = 1) +
geom_text(data = d2.last, aes(label = paste(cyear, " ")),
hjust = 1,
colour = "#0076a8") +
scale_colour_manual(values = c("grey", "#0076a8")) +
labs(title = "Almanaksár",
x = NULL,
y = NULL,
colour = NULL,
caption = paste("Gögn: Fiskistofa, síðast uppfært:", today())) +
theme(legend.position = c(0.97, 0.03),
legend.justification = c(1, 0),
plot.title = element_text(colour = "#0076a8")) +
scale_x_datetime(date_breaks = "1 month", date_labels = "%b") +
coord_cartesian(ylim = c(0, ymax))
print(p1 + p2)
}
```
Row {.tabset .tabset-fade}
-------------------------------------
### Þorskur
```{r}
lh(1)
```
### Ýsa
```{r}
lh(2)
```
### Ufsi
```{r}
lh(3)
```
### Gullkarfi
```{r}
lh(5)
```
### Djúpkarfi
```{r}
lh(61)
```
### Langa
```{r}
lh(6)
```
### Blálanga
```{r}
lh(7)
```
### Keila
```{r}
lh(8)
```
### Steinbítur
```{r}
lh(9)
```
### Hlýri
```{r}
lh(13)
```
### Skötuselur
```{r}
lh(14)
```
### Gulllax
```{r}
lh(19)
```
### Lúða
```{r}
lh(21)
```
### Grálúða
```{r}
lh(22)
```
### Skarkoli
```{r}
lh(23)
```
### Þykkvalúra
```{r}
lh(24)
```
### Langlúra
```{r}
lh(25)
```
### Stórkjafta
```{r}
lh(26)
```
### Sandkoli
```{r}
lh(27)
```
### Skrápflúra
```{r}
lh(28)
```
### Síld
```{r}
lh(30)
```
### Loðna
```{r}
lh(31)
```
### Kolmunni
```{r}
lh(34)
```
### Makríll
```{r}
lh(36)
```
### Humar
```{r}
lh(40)
```
### Litli karfi
```{r}
lh(60)
```
### UPPLÝSINGAR
Löndunarhraði tegundanna er sýndur fyrir landanir fiskveiðiárs og almanaksárs (innan landhelgi). Gögnin að baki myndunum eru sótt í 'lóðsinn', gagnagrunn Fiskistofu um landanir og byggja á **afla upp úr sjó**. Ráðgjöf á yfirstandandi fiskveiðiári er sýndur sem lárétt, blá lína þar sem það á við. Ráðgjöf síðasta fiskveiðiárs er sýnd sem lárétt grá lína. Núverandi fiskveiði- og almanaksár eru sýnd sem bláir ferlar, sem hægt er að bera saman við nýliðin ár, sýnd sem gráir ferlar. Gögnin eru uppfærð daglega.