Skip to content
Open
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
51 changes: 51 additions & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [master, main, testing]
pull_request:

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ HURDAT.code-workspace
doc
docs
Meta
.DS_Store
/doc/
/Meta/
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.0.9000] - Unreleased
## [0.2.3.3]

### Added
- NA

### Changed
- Updated to comply with CRAN policies

## [0.2.0.9000] - Unreleased

### Added
- NA
Expand Down
9 changes: 3 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Package: HURDAT
Type: Package
Title: Hurricane Re-Analysis Project
Version: 0.2.3.2
Version: 0.2.3.3
Authors@R: c(
person("Tim", "Trice", email = "tim.trice@gmail.com", role = c("aut", "cre")),
person("Chris", "Landsea", email = "Chris.Landsea@noaa.gov",
Expand All @@ -23,15 +22,13 @@ Imports:
purrr,
readr,
rlang,
rvest,
tidyr,
xml2
tidyr
Suggests:
covr,
devtools,
knitr,
testthat,
rmarkdown
VignetteBuilder: knitr
RoxygenNote: 7.1.1
RoxygenNote: 7.3.2
Encoding: UTF-8
3 changes: 3 additions & 0 deletions R/globalvars.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Setting global variables to avoid R CMD check notices
utils::globalVariables(c('DateTime', 'Key', 'Lat', 'LatHemi', 'Lines', 'Lon', 'LonHemi', 'NW64', 'Name', 'Record', 'Status',
'Wind'))
35 changes: 9 additions & 26 deletions R/hurdat.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,10 @@
#' \href{https://www.aoml.noaa.gov/hrd/hurdat/submit_re-analysis.html}{as
#' explained on the HRD website}.
#'
#' @docType package
#' @name HURDAT
NULL

#' @importFrom rlang .data

.onLoad <- function(libname, pkgname) {
op <- options()
op.hurdat <- list(
hurdat.url.al = "http://www.aoml.noaa.gov/hrd/hurdat/hurdat2.html",
hurdat.url.ep = "http://www.aoml.noaa.gov/hrd/hurdat/hurdat2-nepac.html"
)
toset <- !(names(op.hurdat) %in% names(op))
if (any(toset)) options(op.hurdat[toset])
invisible()
}

#' HURDAT audit
#' @name HURDAT
#'
#' Run an audit on the HURDAT dataset and identifies duplicate records of `Key`
#' and `DateTime`.
#' @details Run an audit on the HURDAT dataset and identifies duplicate records of `Key` and `DateTime`.
#'
#' @param df Dataframe, parsed HURDAT dataset
#'
Expand Down Expand Up @@ -190,7 +173,7 @@ parse_hurdat <- function(x) {
)

# Fill headers down
hurdat <- tidyr::fill(data = hurdat, .data$Key, .data$Name, .data$Lines)
hurdat <- tidyr::fill(data = hurdat, Key, Name, Lines)

# Remove original header rows
hurdat <- hurdat[-header_rows, ]
Expand Down Expand Up @@ -260,10 +243,10 @@ parse_hurdat <- function(x) {
hurdat <- dplyr::mutate(
.data = hurdat,
Lat = dplyr::if_else(
.data$LatHemi == "N", .data$Lat * 1, .data$Lat * -1
LatHemi == "N", Lat * 1, Lat * -1
),
Lon = dplyr::if_else(
.data$LonHemi == "E", .data$Lon * 1, .data$Lon * -1
LonHemi == "E", Lon * 1, Lon * -1
)
)

Expand All @@ -275,8 +258,8 @@ parse_hurdat <- function(x) {

hurdat <- dplyr::select(
.data = hurdat,
.data$Key, .data$Name, .data$DateTime, .data$Record:.data$Lat,
.data$Lon, .data$Wind:.data$NW64
Key, Name, DateTime, Record:Lat,
Lon, Wind:NW64
)

hurdat <- unique(hurdat)
Expand All @@ -299,8 +282,8 @@ parse_hurdat <- function(x) {
dplyr::mutate_at(
.tbl = hurdat,
.vars = dplyr::vars(
.data$Key:.data$Status,
.data$Wind:.data$NW64
Key:Status,
Wind:NW64
),
.funs = ~replace(
x = .,
Expand Down
70 changes: 70 additions & 0 deletions R/hurdatsum.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# http://arctic.som.ou.edu/tburg/products/realtime/tropical/
# https://deepmind.google.com/science/weatherlab

library(tidyverse)
library(HURDAT)
al <- get_hurdat(basin = "AL")

al |> filter(Status=='HU') -> hu
hu |> group_by(Key) |> slice_min(DateTime, n=1) -> hu
hu |> filter(DateTime >= as.Date('1994-01-01')) -> hu
hu$month=month(hu$DateTime)
hu$yr=year(hu$DateTime)

# Distribution of all hurricanes: 16%
hu |> group_by(month) |> summarize(share=n()/nrow(hu)) |> ungroup()

# other approach
hu |> group_by(yr, month) |> summarize(num=n()) -> monthly
monthly |> group_by(yr) |> mutate(yrtotal=sum(num)) -> monthly
monthly |> filter(yrtotal >= 10) -> monthly
monthly |> mutate(sh=num/yrtotal) -> monthly



join_df <- expand.grid(yr = unique(monthly$yr),
month=unique(monthly$month))

full_join(join_df, monthly, by = c("yr", "month")) |>
tidyr::replace_na(list(sh = 0)) |>
arrange(yr, month) -> monthly

monthly |> group_by(yr) |> mutate(yrtotal=sum(num, na.rm = T)) -> monthly
monthly |> replace_na(list(num=0)) -> monthly
monthly |> group_by(yr) |> mutate(yrcum=cumsum(num)) -> monthly

# Years >=10 monthly: 21%
monthly |> ungroup() |> group_by(month) |> summarize(m=median(sh))
monthly |> ungroup() |> group_by(month) |> summarize(m=mean(sh))


# years with 8 hurricanes by sep-end ->. 2/5 had 11+ 40%
monthly |> filter(month==9, yrcum==8) |> pull(yr) -> eightsep
monthly |> filter(yr %in% eightsep) |> filter(yrtotal>=11)

# years with 9 hurricanes by oct-end -> none had 11+
monthly |> filter(month==10, yrcum==10) |> pull(yr) -> tenoct
monthly |> filter(yr %in% tenoct) |> filter(yrtotal>=11)


# Probability Oct = 34%
monthly |> filter(month==10) -> october
october |> filter(num>2) |> nrow()/nrow(october)

# Probability Nov = 34%
monthly |> filter(month==11) -> november
november |> filter(!is.na(num)) |> nrow()/nrow(december)


# naive > 8
(hu |> group_by(yr) |> tally() |> filter(n>8) |> nrow())/(hu |> group_by(yr) |> tally() |> nrow())
hu |> group_by(yr) |> tally() |> summarize(sum(p=ifelse(n>8,1,0))/n())

## Tropical Storms
al |> filter(Status=='TS') -> ts
ts |> group_by(Key) |> slice_min(DateTime, n=1) -> ts
ts |> filter(DateTime >= as.Date('1960-01-01')) -> ts
ts$month=month(ts$DateTime)
ts$yr=year(ts$DateTime)


10 changes: 10 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.onLoad <- function(libname, pkgname) {
op <- options()
op.hurdat <- list(
hurdat.url.al = "https://www.aoml.noaa.gov/hrd/hurdat/hurdat2.html",
hurdat.url.ep = "https://www.aoml.noaa.gov/hrd/hurdat/hurdat2-nepac.html"
)
toset <- !(names(op.hurdat) %in% names(op))
if (any(toset)) options(op.hurdat[toset])
invisible()
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ install.packages("HURDAT")

## Built With

* [R 3.4.0](https://www.r-project.org/) - The R Project for Statistical Computing
* [R 4.4.1](https://www.r-project.org/) - The R Project for Statistical Computing

## Contributing

Expand Down
72 changes: 0 additions & 72 deletions appveyor.yml

This file was deleted.

Loading