Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f830e14
Run usethis::use_tidy_style
timtrice Jun 21, 2019
d3e10a8
Remove tracking_chart functions
timtrice Jun 22, 2019
1a30c60
gis_download now downloads zips to specified dir
timtrice Jun 22, 2019
8661338
Minor reformatting
timtrice Jun 22, 2019
e1f43ae
Removed shp_file (see commit 8661338)
timtrice Jun 22, 2019
5204566
Remove unused `reports` dir
timtrice Jun 22, 2019
a6acf04
Update GIS vignettes
timtrice Jun 22, 2019
85a5910
Add drat repos
timtrice Jun 22, 2019
0eab183
Update pkgdown docs
timtrice Jun 22, 2019
38c3bfc
Add travis deploy for pkgdown
timtrice Jun 22, 2019
ac435cb
Attempt to install in lib
timtrice Jun 22, 2019
77365ee
Add covr::codecov yaml
timtrice Jun 22, 2019
c72c347
Rearrange build script order
timtrice Jun 22, 2019
5ed1516
Use remotes::install_github
timtrice Jun 22, 2019
08c09e9
Ignore codecov yaml
timtrice Jun 22, 2019
e373fd6
Update instructions for rrricanesdata
timtrice Jun 22, 2019
e330fff
Specify deploy build on master, develop branch
timtrice Jun 22, 2019
ffb7bbd
Install ropenscilabs/travis in Docker
timtrice Jun 22, 2019
b88345a
When IDE autocomplete lets you down
timtrice Jun 22, 2019
5c50daf
Add HURDAT for vignette
timtrice Jun 22, 2019
adb1d79
Add gganimate to Suggests
timtrice Jun 22, 2019
2944150
Add gganimate to Suggests
timtrice Jun 22, 2019
7ec21d3
Merge branch 'develop' of github.com:ropensci/rrricanes into develop
timtrice Jun 22, 2019
e9e297a
Add R magick pkg
timtrice Jun 22, 2019
e8ad807
Remove pkgdown docs dir
timtrice Jun 22, 2019
1e55510
Add navbar to website
timtrice Jun 22, 2019
b42cb8b
Correct links to articles
timtrice Jun 22, 2019
216003e
Add docsearch to navbar
timtrice Jun 23, 2019
fbae2a1
Add Google Analytics ID
timtrice Jun 23, 2019
69e677e
Remove travis R pkg for oldrelease
timtrice Jun 23, 2019
27d79db
Skip get_storm_list test on appveyor
timtrice Jun 23, 2019
e601a19
Update rrricanesdata from rrricanes
timtrice Jun 24, 2019
77a7911
Remove incomplete script line
timtrice Jun 24, 2019
755bd87
Remove env vars
timtrice Jun 25, 2019
d311e21
Filter out empty list elements
timtrice Jun 25, 2019
76a31e1
Building script moved to rrricanesdata
timtrice Jun 25, 2019
a4913a8
Remove unused scripts
timtrice Jun 25, 2019
83b1ddd
Remove unused scripts
timtrice Jun 25, 2019
c70649a
Merge branch 'develop' into feature/113
Jun 25, 2019
1ba1c6b
Read storm list straight to read_csv
timtrice Jun 26, 2019
7bc3d8d
Add subtitle
timtrice Jun 26, 2019
3a56c39
Add ropensci footer img
timtrice Jul 2, 2019
77991c4
Add Docker, rstudio.cloud badge
timtrice Jul 3, 2019
f7e2162
Merge branch 'develop' of https://github.com/ropensci/rrricanes into …
elinw Mar 15, 2022
5be6af6
Merge branch 'master' into develop
elinw Mar 16, 2022
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
6 changes: 3 additions & 3 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
^\.Rproj\.user$
^\.rstudio$
^_pkgdown\.yml$
^doc$
^docker$
^CHANGELOG\.md$
^codecov.yml$
^data-raw$
^datasets/
^deploy\.sh$
^docs$
^Meta$
^NEWS\.md$
^README\.Rmd$
^reports$
^rrricanes\.code-workspace
^doc$
^Meta$
^vignettes/accumulated_cyclone_energy.Rmd$
^vignettes/forecast_advisory.Rmd$
^vignettes/probabilistic_storm_surge.Rmd$
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ datasets
inst/doc
rrricanes.code-workspace
rrricanes.Rcheck
rrricanes.wiki/
doc
docs
Meta
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ project adheres to [Semantic Versioning](http://semver.org/).
- `get_storm_list` returns dataframe of all known cyclones. (#114)

### Changed
- `gis_download` and `gis_latest` can accept parameters for rgdal::readOGR
(#104).
- `gis_latest` can accept parameters for rgdal::readOGR (#104).

- `gis_download` modified to download zip files and extract contents
returning a vector of files within the zip.

- `ep_prblty_stations` now returns all stations.

- `al_prblty_stations`, `cp_prblty_stations` and `ep_prblty_stations`
datasets were modified with additional columns. Changes are documented.

### Removed
- NA
- `tracking_chart`, `al_tracking_chart`, and `ep_tracking_chart` all removed
in favor of using `rnaturalearth` and associated data packages, or other
mapping packages.

- `shp_to_df` removed; users can use `sf::st_read`

### Deprecated
- NA
Expand Down
7 changes: 6 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ Imports:
Suggests:
covr,
devtools,
gganimate,
HURDAT,
knitr,
magick,
rmarkdown,
rnaturalearthhires,
rrricanesdata,
scales,
sf,
sp,
testthat
RoxygenNote: 6.1.1
VignetteBuilder: knitr
Expand Down
4 changes: 0 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(al_prblty_stations)
export(al_tracking_chart)
export(cp_prblty_stations)
export(ep_prblty_stations)
export(ep_tracking_chart)
export(get_discus)
export(get_fstadv)
export(get_ftp_storm_data)
Expand All @@ -29,14 +27,12 @@ export(knots_to_mph)
export(mb_to_in)
export(nm_to_sm)
export(saffir)
export(shp_to_df)
export(status_abbr_to_str)
export(tidy_adv)
export(tidy_fcst)
export(tidy_fcst_wr)
export(tidy_fstadv)
export(tidy_wr)
export(tracking_chart)
export(twoal)
export(twoep)
importFrom(magrittr,"%>%")
Expand Down
9 changes: 7 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ rrricanes Unreleased (yyyy-mm-dd)

* Allow parameters for rgdal::readOGR (#104)

* Add `tidy_adv` to replace `tidy_fstadv`; `tidy_fstadv` will be removed in
release 0.2.2 (#103)
* Add `tidy_adv` to replace `tidy_fstadv`; `tidy_fstadv` will be removed in release 0.2.2 (#103)

* `al_prblty_stations` and `cp_prblty_stations` updated
to accomodate new dataset. (#46)

* `ep_prblty_stations` now returns dataset of east Pacific stations. (#46)

* `tracking_chart` and associated functions have been removed in favor of rnaturalearth and related packages. See `vignette("gis_data", package = "rrricanes") for details.

* `gis_download` no longer reads in the shapefiles; only downloads and extracts the zip files.

* `shp_to_df` also removed in favor of built-in `sf` and `ggplot2` functions.

### BUG FIXES

* `tidy_fcst` only returned forecasts for hours 12:96. Now returns 120. (#107)
Expand Down
57 changes: 28 additions & 29 deletions R/base.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
#' To install \code{rrricanesdata}, run
#'
#' \code{
#' install.packages("rrricanesdata",
#' repos = "https://timtrice.github.io/drat/",
#' type = "source")
#' remotes::install_github("ropensci/rrricanesdata")
#' }
#'
#' See \code{vignette("installing_rrricanesdata", package = "rrricanes")} for
Expand All @@ -83,11 +81,6 @@
#' \code{\link{gis_download}} will download the datasets from the above
#' functions.
#'
#' Some GIS datasets will need to be converted to dataframes to plot geoms. Use
#' \code{\link{shp_to_df}} to convert SpatialLinesDataFrames and
#' SpatialPolygonsDataFrames. SpatialPointsDataFrames can be converted using
#' \code{tibble::as_data_frame} targeting the @data object.
#'
#' @section Package Options:
#'
#' \code{dplyr.show_progress} displays the dplyr progress bar when scraping raw
Expand Down Expand Up @@ -141,13 +134,15 @@ hasData <- function(has_data = .pkgenv$has_data) {
}
}

utils::globalVariables(c("Date", "Hour", "Minute", "Lat", "LatHemi", "Lon",
"LonHemi", "Wind", "Gust", "Month", "Year", "FcstDate",
"WindField34", "WindField50", "WindField64", "lat",
"long", "group", ".", "NW34", "name", "data", "Basin",
stringr::str_c(c("NE", "SE", "SW", "NW", "64")),
stringr::str_c(c("NE", "SE", "SW", "NW", "50")),
stringr::str_c(c("NE", "SE", "SW", "NW", "34"))))
utils::globalVariables(c(
"Date", "Hour", "Minute", "Lat", "LatHemi", "Lon",
"LonHemi", "Wind", "Gust", "Month", "Year", "FcstDate",
"WindField34", "WindField50", "WindField64", "lat",
"long", "group", ".", "NW34", "name", "data", "Basin",
stringr::str_c(c("NE", "SE", "SW", "NW", "64")),
stringr::str_c(c("NE", "SE", "SW", "NW", "50")),
stringr::str_c(c("NE", "SE", "SW", "NW", "34"))
))

#' @title extract_year_archive_link
#' @description Extracts the year from the archive link.
Expand All @@ -156,7 +151,7 @@ utils::globalVariables(c("Date", "Hour", "Minute", "Lat", "LatHemi", "Lon",
#' @keywords internal
extract_year_archive_link <- function(link) {
# Year is listed in link towards the end surrounded by slashes.
as.numeric(stringr::str_match(link, '/([:digit:]{4})/')[,2])
as.numeric(stringr::str_match(link, "/([:digit:]{4})/")[, 2])
}

#' @title get_url_contents
Expand All @@ -167,7 +162,6 @@ extract_year_archive_link <- function(link) {
#' @param link URL to download
#' @keywords internal
get_url_contents <- function(links) {

download_text <- function(grouped_links) {

# Create a new Async object with `grouped_links`
Expand All @@ -177,21 +171,24 @@ get_url_contents <- function(links) {
results <- grouped_links$get()

# Do we have any bad `grouped_links`?
bad_results_ind <- which(purrr::map(results, ~.$success()) == FALSE)
bad_results_ind <- which(purrr::map(results, ~ .$success()) == FALSE)
if (length(bad_results_ind) > 0) {
warning(sprintf("URL %s was unsuccesful.\n",
purrr::map(results[bad_results_ind], ~.$url)),
call. = FALSE)
warning(sprintf(
"URL %s was unsuccesful.\n",
purrr::map(results[bad_results_ind], ~ .$url)
),
call. = FALSE
)
# Remove bad `grouped_links`
results <- results[-bad_results_ind]
}
purrr::map_chr(results, ~.$parse("UTF-8"))
purrr::map_chr(results, ~ .$parse("UTF-8"))
}

# Create groups of links divisible by 80. We are to allow no more than 80
# requests every 10 seconds. If length of `link` is less than 80, then will
# only have one group and should have no delay.
groups <- ceiling(seq_along(1:length(links))/80)
groups <- ceiling(seq_along(1:length(links)) / 80)
links <- split(links, groups)

# Set progress bar
Expand All @@ -200,14 +197,14 @@ get_url_contents <- function(links) {
contents <-
links %>%
purrr::imap(.f = function(x, y) {

if (as.numeric(y) != length(links)) {
# Send group of links to `download_txt`
txt <- download_text(x)
# We are not in the last group; apply a delay
p$tick()$print()
if (getOption("rrricanes.working_msg"))
if (getOption("rrricanes.working_msg")) {
message("Waiting 10 seconds to retrieve large numbers of links.")
}
p$pause(10)
txt
} else {
Expand All @@ -218,7 +215,6 @@ get_url_contents <- function(links) {
})

purrr::flatten_chr(contents)

}

#' @title get_nhc_link
Expand All @@ -228,8 +224,9 @@ get_url_contents <- function(links) {
#' @param protocol https or http
#' @keywords internal
get_nhc_link <- function(withTrailingSlash = TRUE, protocol = "https") {
if (withTrailingSlash)
if (withTrailingSlash) {
return(sprintf("%s://www.nhc.noaa.gov/", protocol))
}
sprintf("%s://www.nhc.noaa.gov", protocol)
}

Expand All @@ -238,8 +235,9 @@ get_nhc_link <- function(withTrailingSlash = TRUE, protocol = "https") {
#' @inheritParams get_nhc_link
#' @keywords internal
get_nhc_ftp_link <- function(withTrailingSlash = TRUE) {
if (withTrailingSlash)
if (withTrailingSlash) {
return("ftp://ftp.nhc.noaa.gov/")
}
"ftp://ftp.nhc.noaa.gov"
}

Expand Down Expand Up @@ -272,8 +270,9 @@ mb_to_in <- function(x) {
#' @keywords internal
month_str_to_num <- function(m) {
abbr <- which(month.abb == stringr::str_to_title(m))
if (purrr::is_empty(abbr))
if (purrr::is_empty(abbr)) {
stop(sprintf("%s is not a valid month abbreviation.", m))
}
abbr
}

Expand Down
8 changes: 3 additions & 5 deletions R/discus.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ get_discus <- function(links) {
#' @seealso \code{\link{get_discus}}
#' @keywords internal
discus <- function(contents) {

status <- scrape_header(
contents = contents,
# The "SPECIAL" pattern has to be left here; moving it under
Expand All @@ -43,12 +42,11 @@ discus <- function(contents) {
key <- scrape_key(contents)

tibble::tibble(
Status = status[,1],
Name = status[,2],
Adv = as.numeric(status[,3]),
Status = status[, 1],
Name = status[, 2],
Adv = as.numeric(status[, 3]),
Date = issue_date,
Key = key,
Contents = contents
)

}
5 changes: 3 additions & 2 deletions R/filters.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ filter_posest <- function(links) {
#' @keywords internal
filter_public <- function(links) {
grep("/pub/P(AL|EP)|/pub/PA(AL|EP)|/pub/PB(AL|EP)|public",
x = links,
value = TRUE)
x = links,
value = TRUE
)
}

#' @title filter_prblty
Expand Down
Loading