Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new regional weather #293

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: portalr
Title: Create Useful Summaries of the Portal Data
Version: 0.4.0
Version: 0.4.1
Authors@R:
c(person(given = c("Glenda", "M."),
family = "Yenni",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Version numbers follow [Semantic Versioning](https://semver.org/).

# [portalr 0.4.1](https://github.com/weecology/portalr/releases/tag/v0.4.1)
*2023-08-223*

### Regional weather filling includes more stations

# [portalr 0.4.0](https://github.com/weecology/portalr/releases/tag/v0.4.0)
*2023-04-21*

Expand Down
24 changes: 1 addition & 23 deletions R/Weather.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,7 @@ fill_missing_weather <- function(weather, path = get_default_data_path())
dplyr::filter(.data$date >= "1980-01-01") %>%
dplyr::rename(precipitation = "prcp")

rustys <- read.csv(file.path(path, 'PortalData/Weather/Rustys_regional_weather.csv'),
na.strings = c(""), header = TRUE, stringsAsFactors = FALSE) %>%
dplyr::group_by(.data$year, .data$month, .data$day) %>%
dplyr::summarize(mintemp = min(.data$templow),
maxtemp = max(.data$temphigh),
meantemp = mean(.data$tempavg),
precipitation = sum(.data$preciptotal)) %>%
dplyr::select(dplyr::all_of(c("year", "month", "day", "mintemp", "maxtemp", "meantemp","precipitation"))) %>%
dplyr::arrange(.data$year,.data$month, .data$day)

rodeo <- read.csv(file.path(path, 'PortalData/Weather/Rodeo_regional_weather.csv'),
region1 <- read.csv(file.path(path, 'PortalData/Weather/Rodeo_regional_weather.csv'),
na.strings = c(""), header = TRUE, stringsAsFactors = FALSE) %>%
dplyr::group_by(.data$year, .data$month, .data$day) %>%
dplyr::summarize(mintemp = min(.data$templow),
Expand All @@ -197,18 +187,6 @@ fill_missing_weather <- function(weather, path = get_default_data_path())
dplyr::select(dplyr::all_of(c("year", "month", "day", "mintemp", "maxtemp", "meantemp","precipitation"))) %>%
dplyr::arrange(.data$year,.data$month, .data$day)

region1 <- dplyr::full_join(rodeo, rustys, by = c("year", "month", "day")) %>%
dplyr::group_by(.data$year, .data$month, .data$day) %>%
dplyr::rowwise() %>%
dplyr::mutate(mintemp = mean(c(.data$mintemp.y, .data$mintemp.x), na.rm=TRUE),
maxtemp = mean(c(.data$maxtemp.y, .data$maxtemp.x), na.rm=TRUE),
meantemp = mean(c(.data$meantemp.y, .data$meantemp.x), na.rm=TRUE),
precipitation = mean(c(.data$precipitation.y, .data$precipitation.x), na.rm=TRUE)) %>%
dplyr::ungroup() %>%
dplyr::filter(!(is.na(.data$mintemp) & is.na(.data$maxtemp) &
is.na(.data$meantemp) & is.na(.data$precipitation))) %>%
dplyr::select(dplyr::all_of(c("year", "month", "day", "precipitation", "mintemp", "maxtemp", "meantemp")))

region2 <- dplyr::full_join(portal4sw, sansimon, by = c("date", "year", "month", "day")) %>%
dplyr::group_by(.data$year, .data$month, .data$day, .data$date) %>%
dplyr::rowwise() %>%
Expand Down
15 changes: 7 additions & 8 deletions R/portalr-package.R
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
#' @keywords internal
#' @title Creates summaries of the Portal data
#'
#' @description This package is designed to be an interface to the Portal data, which resides online at \url{https://github.com/weecology/portalData}. Its contains a set of functions to download, clean, and summarize the data.
#'
#' @name portalr
#' @docType package
#' @keywords package
#'
#' @importFrom lubridate "%m+%"
#' @importFrom rlang "!!" "!!!" ":=" .data
#' @importFrom utils head download.file read.csv unzip read.table tail
#' @importFrom stats median na.omit
#' @importFrom httr content GET stop_for_status

NULL
"_PACKAGE"

## quiets concerns of R CMD check re: variables used in NSE functions
if (getRversion() >= "2.15.1") utils::globalVariables(
c(".", "n")
)
c(".", "n")
)

#' @title Return Citation for Portal Data
#'
#' @return An object of class "citation". For more details, see `citation()`
#' @export
get_dataset_citation <- function()
{
path <- system.file("CITATION-PORTAL-DATA",
package = "portalr", mustWork = TRUE)
utils::readCitationFile(path)
path <- system.file("CITATION-PORTAL-DATA",
package = "portalr", mustWork = TRUE)
utils::readCitationFile(path)
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library(portalr)
<!-- badges: start -->
[![R-CMD-check](https://github.com/weecology/portalr/workflows/R-CMD-check/badge.svg)](https://github.com/weecology/portalr/actions)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/weecology/portalr/main/LICENSE)
[![Coverage status](https://codecov.io/gh/weecology/portalr/branch/main/graph/badge.svg)](https://codecov.io/github/weecology/portalr?branch=main)
[![Coverage status](https://codecov.io/gh/weecology/portalr/branch/main/graph/badge.svg)](https://app.codecov.io/github/weecology/portalr?branch=main)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/portalr)](https://CRAN.R-project.org/package=portalr)

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1429290.svg)](https://doi.org/10.5281/zenodo.1429290)
Expand Down
4 changes: 2 additions & 2 deletions man/load_datafile.Rd

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

33 changes: 32 additions & 1 deletion man/portalr.Rd

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