Skip to content

Commit

Permalink
Merge branch 'main' into dev-andy
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-edwards committed Oct 1, 2024
2 parents 9a4a490 + b2e7c74 commit 687267f
Show file tree
Hide file tree
Showing 23 changed files with 207 additions and 70 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data-raw/*
R/plot-buoy-sst.R
^R/plot-buoy-sst\.R$
R/plot-buoy-sst*.R
^R-temp/$

notes/*
^README\.Rmd$
Expand Down
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Authors@R: c(
email = "chris.rooper@dfo-mpo.gc.ca",
role = c("aut"),
comment = c(ORCID = "0000-0003-2315-1269")),
person(c("K.", "L."), "Flynn",
email = "kelsey.flynn@dfo-mpo.gc.ca",
role = c("aut")),
person("Kelsey", "Flynn",
role = c("ctb")),
person("Jessica", "Nephin ",
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ Developers: for some general tips for writing good bullets see https://style.tid

## Updates by date

* 2024-09-25 Update citation info (increment year to 2024, add Kelsey Flynn as
co-author) and obtain a DOI. See README or run `citation("pacea")`.

* 2024-09-20 Monthly updates for: `buoy_sst`, and indices `ao`, `mei`, `npgo`, `oni`, `pdo`, and `soi`.

* 2024-08-21 Monthly update for: `oisst_7day` and `oisst_month`.

* 2024-08-06 Monthly update for: `oisst_7day`, `oisst_month` (both updated two
weeks earlier), `buoy_sst`, and indices `ao`, `oni`, `pdo`, and `soi`.

* 2024-06-10 Monthly update for May: `oisst_7day`, `oisst_month` (both updated 2024-05-20), `buoy_sst`, and indices `ao`, `oni`, `pdo`, and `soi`.

* 2024-05-08 Added Pacific Herring stock assessment results, including new
plotting functions (see `populations` vignette linked from README).

Expand Down
102 changes: 102 additions & 0 deletions R-temp/ecosystem-summary.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
##' Some example ideas for a species-specific Ecosystem Summary. Currently
##' ignored in .Rbuildignore as developing.
##'
##' Doing a herring example for now, based on Jennifer's manuscript.
##' Figure 11 gives the indicators that were identified in one or more
##' pressure-respose model. The ones we already have in pacea are:
##' * PDO
##' * SST_Spring - Mar-May, 1982-2019. Satellite measured sea surface temperature,
##' from AVHRR satellite
##' https://www.avl.class.noaa.gov/release/data_available/avhrr/index.htm -
##' website not working, 24/9/24.
##' ##' * SST_Summer - Apr-Jul, 1982-2019
##' * SST_Fall - Sept-Nov, 1981-2019

##' * Upwelling (maybe not)
##'
##'
##' Do not have
##' * copepdods and total zooplankton in HG
##' * humpback whales
##' * Steller SeaLion
##' * hakeAcoustic_B - could get
##' * Arrowtooth, dogfish, cod, IPHC catch rates
##' * herring-related
##' @param species species of interest, might need stock also. Could save the
##' list of desired variables as a data list object, to then apply to the
##' relevant calculation and plotting functions.
##' @return
##' @export
##' @author Andrew Edwards
##' @examples
##' \dontrun{
##'
##' }
ecosystem_summary <- function(species = "herring-example"){

par(mfcol = c(4, 2))
years <- range(dplyr::filter(herring_recruitment,
region == "HG") %>%
select(year))

x_lim = c(lubridate::dmy(paste0("0101", min(years))), # day-month-year
lubridate::dmy(paste0("0101", max(years))))

plot(herring_recruitment,
region = "HG",
xlim = x_lim)

plot(pdo,
xlim = x_lim)

# For quickness for now, let's just look at buoy data for buoys within the
# study area defined in the manuscript.
# For now just eyeballing which buoys to use, easiest to id by names:
names_hg <- c("Central Dixon Entrance",
"South Moresby", # is maybe just outside, but relevant?
"North Hecate Strait",
"South Hecate Strait",
"West Sea Otter",
"East Dellwood Knolls") # also maybe just outside

stn_id_hg <- dplyr::filter(buoy_metadata,
name %in% names_hg)$stn_id # not necessarily in
# same order as stn_id_hg. Though think
# will be given how I first listed the
# names above. TODO

buoy_sst_hg <- dplyr::filter(buoy_sst,
stn_id %in% stn_id_hg) # generalise variable
# names at some point to not be HG
# specific TODO

# Usual style of plot:
#for(i in 1:length(stn_id_hg)){
# plot(buoy_sst_hg,
# stn_id = stn_id_hg[1]) %>% print()
#}

# Want to calculate mean for each time period
buoy_sst_hg_spring <- list()
for(i in 1:length(stn_id_hg)){
buoy_sst_hg_spring[[i]] <-
dplyr::filter(buoy_sst_hg,
stn_id %in% stn_id_hg[i],
lubridate::month(date) %in% c(3, 4, 5)) %>%
dplyr::mutate(year = lubridate::year(date)) %>%
dplyr::group_by(year) %>%
summarise(mean = mean(sst,
na.rm = TRUE))

# TODO add a check for how many days in the period, like in quality control
# for buoy_sst.

plot(buoy_sst_hg_spring[[i]],
xlim = range(years),
main = paste0("Mean spring SST, ",
names_hg[i]),
type = "o")

}

}
24 changes: 16 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ output: github_document

<!--
README.md is generated from README.Rmd. Please edit that file. Build with
-->

```{r, include = FALSE, eval = FALSE}
load_all()
rmarkdown::render("README.Rmd")
```
<!--
which builds the .html that can be viewed locally (but isn't pushed to GitHub;
GitHub uses README.md to make the page you see on GitHub).
Expand All @@ -30,6 +33,7 @@ library(tibble)
<!-- badges: start -->
[![R-CMD-check](https://github.com/pbs-assess/pacea/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pbs-assess/pacea/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/pbs-assess/pacea/graph/badge.svg?token=93afkFJUVL)](https://codecov.io/gh/pbs-assess/pacea)
[![DOI](https://zenodo.org/badge/417554147.svg)](https://zenodo.org/doi/10.5281/zenodo.13840804)
![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fpbs-assess%2Fpacea&label=VISITORS&countColor=%23263759&style=flat&labelStyle=lower)
<!-- badges: end -->

Expand Down Expand Up @@ -345,15 +349,19 @@ This work is strongly motivated by, and based on, the [GSLea](https://github.com

## Citation

If you use `pacea` in your work then please cite it as
If you use `pacea` in your work then please cite it as (NOTE this has been
updated since the original release):

Edwards A.M., Tai T.C., Watson J., Peña M.A., Hilborn A., Hannah C.G., and Rooper
C.N. (2023). "pacea: An R package of Pacific ecosystem information to
help facilitate an ecosystem approach to fisheries management."
<https://github.com/pbs-assess/pacea>.
Edwards A.M., Tai T.C., Watson J., Peña M.A., Hilborn A., Hannah C.G., Rooper
C.N., and Flynn K.L. (2024). pacea: An R package of Pacific ecosystem information to
help facilitate an ecosystem approach to fisheries management.
<https://github.com/pbs-assess/pacea>, <https://zenodo.org/doi/10.5281/zenodo.13840804>

You may wish to add the date you installed it (using `pacea_installed()`). Use
`citation("pacea")` to get a version for LaTeX and R Markdown bibliographies.
`citation("pacea")` to get a version for LaTeX and R Markdown
bibliographies. Although the DOI badge at the top of this page ends in ...805,
the ...804 DOI is preferable because that will not change with any future
updates to the GitHub tag. So ...804 seems simpler and more consistent to use (thanks!).

Also let us know of any applications. This will help us devote effort into
maintaining `pacea`.
Expand All @@ -366,7 +374,7 @@ and Oceans Canada (project 21-FS-03-13).
We thank the following for contributing ideas, example code for ROMS output, model output,
and/or helping with ideas and coding issues:

- Kelsey Flynn, Jessica Nephin, Lindsay Davidson, Strahan Tucker,
- Jessica Nephin, Lindsay Davidson, Strahan Tucker,
Brianna Wright, Patrick Thompson, Matt Grinnell, Sean Anderson, Philina
English, Chris Grandin, Jennifer Boldt, Kelly Young, and others.

Expand Down
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

<!--
README.md is generated from README.Rmd. Please edit that file. Build with
load_all()
rmarkdown::render("README.Rmd")
-->
<!--
which builds the .html that can be viewed locally (but isn't pushed to GitHub;
GitHub uses README.md to make the page you see on GitHub).
Expand All @@ -18,6 +16,7 @@ the .png file. See notes below (and Issue #44).

[![R-CMD-check](https://github.com/pbs-assess/pacea/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pbs-assess/pacea/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/pbs-assess/pacea/graph/badge.svg?token=93afkFJUVL)](https://codecov.io/gh/pbs-assess/pacea)
[![DOI](https://zenodo.org/badge/417554147.svg)](https://zenodo.org/doi/10.5281/zenodo.13840804)
![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fpbs-assess%2Fpacea&label=VISITORS&countColor=%23263759&style=flat&labelStyle=lower)
<!-- badges: end -->

Expand All @@ -42,7 +41,7 @@ to get you started.

Currently, pacea contains:

- 205,179 calculations of daily sea surface temperature based on data
- 206,901 calculations of daily sea surface temperature based on data
from 19 buoys. **Updated monthly.**

- outputs from the spatial British Columbia continental margin (BCCM)
Expand Down Expand Up @@ -70,7 +69,7 @@ Currently, pacea contains:
record, that incorporates observations from different platforms
(satellites, ships, buoys, and Argo floats):

- provided as weekly and monthly means from Sep 1981 to Apr 2024.
- provided as weekly and monthly means from Sep 1981 to Jul 2024.
**Updated monthly.**

- 9 climatic and oceanographic indices, such as the Pacific Decadal
Expand Down Expand Up @@ -201,7 +200,7 @@ example:

``` r
oni
#> # A tibble: 890 × 4
#> # A tibble: 895 × 4
#> year month value anomaly
#> <dbl> <dbl> <dbl> <dbl>
#> 1 1950 1 24.7 -1.53
Expand All @@ -214,7 +213,7 @@ oni
#> 8 1950 8 26.0 -0.42
#> 9 1950 9 25.8 -0.39
#> 10 1950 10 25.6 -0.44
#> # ℹ 880 more rows
#> # ℹ 885 more rows
```

**What climatic and oceanographic indices are currently available, and
Expand Down Expand Up @@ -339,16 +338,21 @@ colleagues for the Gulf of St Lawrence.

## Citation

If you use `pacea` in your work then please cite it as
If you use `pacea` in your work then please cite it as (NOTE this has
been updated since the original release):

Edwards A.M., Tai T.C., Watson J., Peña M.A., Hilborn A., Hannah C.G.,
and Rooper C.N. (2023). “pacea: An R package of Pacific ecosystem
information to help facilitate an ecosystem approach to fisheries
management.” <https://github.com/pbs-assess/pacea>.
Rooper C.N., and Flynn K.L. (2024). pacea: An R package of Pacific
ecosystem information to help facilitate an ecosystem approach to
fisheries management. <https://github.com/pbs-assess/pacea>,
<https://zenodo.org/doi/10.5281/zenodo.13840804>

You may wish to add the date you installed it (using
`pacea_installed()`). Use `citation("pacea")` to get a version for LaTeX
and R Markdown bibliographies.
and R Markdown bibliographies. Although the DOI badge at the top of this
page ends in …805, the …804 DOI is preferable because that will not
change with any future updates to the GitHub tag. So …804 seems simpler
and more consistent to use (thanks!).

Also let us know of any applications. This will help us devote effort
into maintaining `pacea`.
Expand All @@ -361,10 +365,9 @@ Fisheries and Oceans Canada (project 21-FS-03-13).
We thank the following for contributing ideas, example code for ROMS
output, model output, and/or helping with ideas and coding issues:

- Kelsey Flynn, Jessica Nephin, Lindsay Davidson, Strahan Tucker,
Brianna Wright, Patrick Thompson, Matt Grinnell, Sean Anderson,
Philina English, Chris Grandin, Jennifer Boldt, Kelly Young, and
others.
- Jessica Nephin, Lindsay Davidson, Strahan Tucker, Brianna Wright,
Patrick Thompson, Matt Grinnell, Sean Anderson, Philina English,
Chris Grandin, Jennifer Boldt, Kelly Young, and others.

And a big thanks to Carley Colclough for expertly designing the pacea
logo.
Expand Down
3 changes: 3 additions & 0 deletions data-raw/buoys/buoy-sst.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ dfo_data # 3.666 million rows when removing pre-1991 . Every few minutes h
# so keeping with with_tz.
# 9/11/2023 update: 3.797 million rows
# 29/1/2024 update: 3.811 million rows
# 6/8/2024 update: 3.839 million rows
# 20/9/2024 update: 3.845 million rows

summary(dfo_data) # Earliest is 1987, so not adding tons of data, yet not really worth
# excluding 1987-1991 for our purposes (Andrea did since
Expand Down Expand Up @@ -174,6 +176,7 @@ dfo_daily_mean
# 158,012 rows up to 2023-08-23
# 158,638 2023-11-09
# 159,407 2023-02-17 # max(dfo_daily_mean$date)
# 160,467 2024-07-30

# Before doing two-hour quality control had less, not sure how many (can test by
# changing num_two_hour_intervals_required)
Expand Down
17 changes: 13 additions & 4 deletions data-raw/coastwide-indices/coastwide-indices.R
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,17 @@ if(check_index_changed(soi, soi_new)){

#NGPO
# Useful background:
# http://www.o3d.org/npgo/
download.file("http://www.o3d.org/npgo/npgo.php",
# http://www.o3d.org/npgo/ # Timed out on 10-06-2024, no time to dig
# into. Did once on 6-08-2024 then worked the second time (had looked on
# browser also, though doubt that mattered). Did download but looks like format
# has changed: download file is just html. But 'Download Index' link from https://www.o3d.org/npgo/ has not
# been updated since the latest already in pacea, though that isn't exactly
# what we used. So something has changed, but don't worry now as looks like
# data not updated anyway.
# 20-09-2024: changing filename to "https://www.o3d.org/npgo/data/NPGO.txt"
# which has been updated to August 2024. It used to be "http://www.o3d.org/npgo/npgo.php"

download.file("http://www.o3d.org/npgo/data/NPGO.txt",
destfile="npgo.txt",
mode="wb",
quiet = FALSE)
Expand All @@ -480,7 +489,7 @@ npgo_new <-read.table("npgo.txt",
stopifnot(npgo_new[1, 1:2] == c(1950, 1)) # Check still starts in January 1950

class(npgo_new) <- c("pacea_index",
class(npgo_new))
class(npgo_new))

attr(npgo_new, "axis_name") <- "North Pacific Gyre Oscillation"

Expand All @@ -496,7 +505,6 @@ if(check_index_changed(npgo, npgo_new)){
npgo <- npgo_new
usethis::use_data(npgo,
overwrite = TRUE)
plot(npgo) # TODO maybe update when plotting functions finalised
}

# ENSO MEI https://www.psl.noaa.gov/enso/mei
Expand Down Expand Up @@ -605,6 +613,7 @@ tail(ao)
tail(ao_new)

check_index_changed(ao, ao_new)

if(check_index_changed(ao, ao_new)){
expect_equal(ao,
ao_new[1:nrow(ao), ]) # See note at top if fails. Not tested
Expand Down
Binary file modified data/ao.rda
Binary file not shown.
Binary file modified data/buoy_sst.rda
Binary file not shown.
Binary file modified data/mei.rda
Binary file not shown.
Binary file modified data/npgo.rda
Binary file not shown.
Binary file modified data/oisst_7day.rda
Binary file not shown.
Binary file modified data/oisst_month.rda
Binary file not shown.
Binary file modified data/oni.rda
Binary file not shown.
Binary file modified data/pdo.rda
Binary file not shown.
Binary file modified data/soi.rda
Binary file not shown.
7 changes: 4 additions & 3 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ citHeader("To cite pacea in publications please use:")
bibentry(
bibtype = "misc",
title = "pacea: An R package of Pacific ecosystem information to help facilitate an ecosystem approach to fisheries management",
author = "A. M. Edwards and T. C. Tai and J. Watson and M. A. Peña and A. Hilborn and C. G. Hannah and C. N. Rooper",
url = "https://github.com/pbs-assess/pacea",
year = "2023"
author =
"A. M. Edwards and T. C. Tai and J. Watson and M. A. Peña and A. Hilborn and C. G. Hannah and C. N. Rooper and K. L. Flynn",
url = "https://github.com/pbs-assess/pacea, https://zenodo.org/doi/10.5281/zenodo.13840804",
year = "2024"
)
Binary file modified man/figures/README-north-hecate-temp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-oni.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-pdo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions vignettes/buoys.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ knitr::include_graphics(paste0(here::here(),

(built with code in data-raw/buoys/buoys-map.R), and also
shown at
https://github.com/IOS-OSD-DPG/Pacific_SST_Monitoring#eccc-buoy-data .
[https://github.com/IOS-OSD-DPG/Pacific_SST_Monitoring#eccc-buoy-data](https://github.com/IOS-OSD-DPG/Pacific_SST_Monitoring#eccc-buoy-data).

Some of the recent data are also plotted on that website, by Andrea Hilborn,
Charles Hannah and Lu Guan, which is automatically updated roughly every
Expand Down Expand Up @@ -98,7 +98,7 @@ Plot data from a single buoy for all years, the default is for buoy C46205:
plot(buoy_sst)
```

The red lines gives the current year. Since `buoy_sst` has class `pacea_buoy`,
The red line gives the current year. Since `buoy_sst` has class `pacea_buoy`,
`plot(buoy_sst)` function calls our tailored `plot.pacea_buoy()` function.
The gap in the red line at the start of the year indicates missing data (or days
that get excluded due to our protocols).
Expand Down
67 changes: 31 additions & 36 deletions vignettes/buoys.html

Large diffs are not rendered by default.

0 comments on commit 687267f

Please sign in to comment.