Skip to content

Commit

Permalink
Merge pull request #8 from poissonconsulting/f-degree
Browse files Browse the repository at this point in the history
degree C
  • Loading branch information
joethorley authored Apr 23, 2024
2 parents f95d013 + 4a04d20 commit 7e83810
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 23 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Imports:
chk,
dplyr,
dttr2,
latex2exp,
purrr,
rlang,
stringr,
Expand Down
6 changes: 4 additions & 2 deletions R/gss-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#' @export
#'
#' @examples
#' gss_plot(gsdd::temperature_data)
#' \dontrun{
#' gss_plot(gsdd::temperature_data)
#' }
gss_plot <- function(
x,
start_date = as.Date("1972-03-01"),
Expand Down Expand Up @@ -100,7 +102,7 @@ gss_plot <- function(
alpha = 1/2) +
ggplot2::geom_line(ggplot2::aes(x = .data$dayte, y = .data$temperature, group = .data$series, color = .data$series)) +
ggplot2::scale_x_date("Date", date_labels = "%b", date_breaks = "month") +
ggplot2::scale_y_continuous("Water Temperature (C)") +
ggplot2::scale_y_continuous(latex2exp::TeX("Water Temperature $($$^{\\circ}C)$")) +
ggplot2::scale_linetype_manual("Threshold", values = c("dotdash", "dashed")) +
ggplot2::scale_color_manual("Mean", values = c("#3063A3", "black")) +
ggplot2::expand_limits(x = c(start_dayte, end_dayte), y = 0) +
Expand Down
16 changes: 8 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ knitr::opts_chunk$set(
`gsdd` is an R package to calculate Growing Season Degree Days (GSDD), Growing Degree Days (GDD) and Growing Seasons (GSS) from water temperature data.

GSSD is a water temperature metric that is a useful predictor of age-0 trout size at the beginning of winter.
It is the accumulated thermal units (in C) during the growing season based on the mean daily water temperature values.
It is the accumulated thermal units (in &deg;C) during the growing season based on the mean daily water temperature values.
GDD is the GSSD to a particular date.

The GSDD is calculated across the longest consecutive sequence of non-missing values.
Expand All @@ -36,7 +36,7 @@ If the user chooses to ignore truncation then the returned value(s) are very lik
The default values and implementation of the growing season are based on Coleman and Fausch (2007) who stated that

> We defined the start of the growing season as the beginning of the first week that average stream temperatures exceeded and
remained above 5C for the season; the end of the growing season was defined as the last day of the first week that average stream temperature dropped below 4C.
remained above 5&deg;C for the season; the end of the growing season was defined as the last day of the first week that average stream temperature dropped below 4&deg;C.

For the purposes of the calculation week refers to a seven day rolling average as opposed to the calendar week.
If there are multiple growing 'seasons' within the same year then by default the returned value is the sum of the GSDD values for `"all"` seasons.
Expand Down Expand Up @@ -64,16 +64,16 @@ gsdd(data)
gdd(data)
gss(data)
```
It also provides a function to calculate GSDD from a vector.
It also provides a function to plot water temperature data.

```{r}
x <- gsdd::temperature_data$temperature
gsdd_vctr(x)
gss_plot(data)
```

And to plot water temperature data.
And to calculate GSDD from a vector.

```{r}
gss_plot(data)
x <- gsdd::temperature_data$temperature
gsdd_vctr(x)
```
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ temperature data.

GSSD is a water temperature metric that is a useful predictor of age-0
trout size at the beginning of winter. It is the accumulated thermal
units (in C) during the growing season based on the mean daily water
units (in °C) during the growing season based on the mean daily water
temperature values. GDD is the GSSD to a particular date.

The GSDD is calculated across the longest consecutive sequence of
Expand All @@ -34,9 +34,9 @@ Coleman and Fausch (2007) who stated that

> We defined the start of the growing season as the beginning of the
> first week that average stream temperatures exceeded and remained
> above 5C for the season; the end of the growing season was defined as
> above 5°C for the season; the end of the growing season was defined as
> the last day of the first week that average stream temperature dropped
> below 4C.
> below 4°C.
For the purposes of the calculation week refers to a seven day rolling
average as opposed to the calendar week. If there are multiple growing
Expand Down Expand Up @@ -84,19 +84,19 @@ gss(data)
#> 1 2019 1971-03-20 1971-11-07 3899. none
```

It also provides a function to calculate GSDD from a vector.
It also provides a function to plot water temperature data.

``` r
x <- gsdd::temperature_data$temperature

gsdd_vctr(x)
#> [1] 3898.806
gss_plot(data)
```

And to plot water temperature data.
![](man/figures/README-unnamed-chunk-3-1.png)<!-- -->

And to calculate GSDD from a vector.

``` r
gss_plot(data)
```
x <- gsdd::temperature_data$temperature

![](man/figures/README-unnamed-chunk-4-1.png)<!-- -->
gsdd_vctr(x)
#> [1] 3898.806
```
Binary file added man/figures/README-unnamed-chunk-3-1.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 removed man/figures/README-unnamed-chunk-4-1.png
Binary file not shown.
4 changes: 3 additions & 1 deletion man/gss_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e83810

Please sign in to comment.