This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit, I hope it doesn't come back
- Loading branch information
0 parents
commit cc8c435
Showing
29 changed files
with
1,237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^CONDUCT\.md$ | ||
^README\.Rmd$ | ||
^README-.*\.png$ | ||
^\.travis\.yml$ | ||
^appveyor\.yml$ | ||
^codecov\.yml$ | ||
^docs$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r | ||
|
||
language: R | ||
sudo: false | ||
cache: packages | ||
|
||
after_success: | ||
- Rscript -e 'covr::codecov()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX | ||
|
||
StripTrailingWhitespace: Yes | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Contributor Code of Conduct | ||
|
||
As contributors and maintainers of this project, we pledge to respect all people who | ||
contribute through reporting issues, posting feature requests, updating documentation, | ||
submitting pull requests or patches, and other activities. | ||
|
||
We are committed to making participation in this project a harassment-free experience for | ||
everyone, regardless of level of experience, gender, gender identity and expression, | ||
sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. | ||
|
||
Examples of unacceptable behavior by participants include the use of sexual language or | ||
imagery, derogatory comments or personal attacks, trolling, public or private harassment, | ||
insults, or other unprofessional conduct. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject comments, | ||
commits, code, wiki edits, issues, and other contributions that are not aligned to this | ||
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed | ||
from the project team. | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by | ||
opening an issue or contacting one or more of the project maintainers. | ||
|
||
This Code of Conduct is adapted from the Contributor Covenant | ||
(http:contributor-covenant.org), version 1.0.0, available at | ||
http://contributor-covenant.org/version/1/0/0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Package: BOMRang | ||
Type: Package | ||
Title: Fetch Australian Government Bureau of Meteorology Data | ||
Version: 0.0.1-1 | ||
Authors@R: c(person("Adam", "Sparks", role = c("aut", "cre"), | ||
email = "[email protected]"), | ||
person("Keith", "Pembleton", role = "aut", | ||
email = "[email protected]")) | ||
Description: Fetches Fetch Australian Government Bureau of Meteorology Weather | ||
forecasts and returns a tidy data frame of the current and next six days | ||
weather. | ||
URL: https://github.com/adamhsparks/BOMRang | ||
BugReports: https://github.com/adamhsparks/BOMRang/issues | ||
License: MIT + file LICENSE | ||
Depends: | ||
R (>= 3.2.0) | ||
Imports: | ||
dplyr, | ||
foreign, | ||
lubridate, | ||
plyr, | ||
stringr, | ||
tibble, | ||
xml2 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
Suggests: covr | ||
RoxygenNote: 6.0.1 | ||
NeedsCompilation: no | ||
ByteCompile: TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2017 | ||
COPYRIGHT HOLDER: Your name goes here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(get_BOM_forecast) | ||
importFrom(dplyr,"%>%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# BOMRang 0.0.1-1 | ||
|
||
* Added a `NEWS.md` file to track changes to the package. | ||
* New package for fetching BOM forecasts | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#' BOMRang. | ||
#' | ||
#' @name BOMRang | ||
#' @docType package | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
|
||
#' Get BOM Forecast for Queensland | ||
#' | ||
#'Fetch the BOM forecast and create a data frame object that can be used for | ||
#'interpolating. | ||
#' | ||
#' @return | ||
#' Data frame of a Australia BOM forecast for Queensland for max temperature, | ||
#' min temperature and corresponding locations. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' BOM_forecast <- get_BOM_forecast() | ||
#' } | ||
#' @export | ||
#' | ||
#' @importFrom dplyr %>% | ||
get_BOM_forecast <- function() { | ||
# BOM station list - a .dbf file (part of a shapefile of station locations) | ||
# AAC codes can be used to add lat/lon to the forecast | ||
utils::download.file( | ||
"ftp://ftp.bom.gov.au/anon/home/adfd/spatial/IDM00013.dbf", | ||
destfile = paste0(tempdir(), "AAC_codes.dbf"), | ||
mode = "wb" | ||
) | ||
|
||
AAC_codes <- | ||
foreign::read.dbf(paste0(tempdir(), "AAC_codes.dbf"), as.is = TRUE) | ||
AAC_codes <- AAC_codes[, c(2:3, 7:9)] | ||
|
||
# fetch BOM foreast for Qld | ||
xmlforecast <- | ||
xml2::read_xml("ftp://ftp.bom.gov.au/anon/gen/fwo/IDQ11295.xml") | ||
|
||
# extract locations from forecast | ||
areas <- xml2::xml_find_all(xmlforecast, "//forecast/area") | ||
forecast_locations <- | ||
dplyr::bind_rows(lapply(xml2::xml_attrs(areas), as.list)) | ||
|
||
# join locations with lat/lon values for mapping and interpolation | ||
forecast_locations <- dplyr::left_join(forecast_locations, | ||
AAC_codes, | ||
by = c("aac" = "AAC", | ||
"description" = "PT_NAME")) | ||
|
||
# unlist and add the locations aac code | ||
forecasts <- | ||
lapply(xml2::xml_find_all(xmlforecast, "//forecast/area"), | ||
xml2::as_list) | ||
forecasts <- plyr::llply(forecasts, unlist) | ||
names(forecasts) <- forecast_locations$aac | ||
|
||
# get all the <element> and <text> tags (the forecast) | ||
eltext <- xml2::xml_find_all(xmlforecast, "//element | //text") | ||
|
||
# extract and clean (if needed) (the labels for the forecast) | ||
labs <- trimws(xml2::xml_attrs(eltext, "type")) | ||
|
||
# use a loop to turn list of named character elements into a list of dataframes | ||
# with the location aac code for each line of the data frame | ||
y <- vector("list") | ||
for (i in unique(names(forecasts))) { | ||
x <- data.frame( | ||
keyName = names(forecasts[[i]]), | ||
value = forecasts[[i]], | ||
row.names = NULL | ||
) | ||
z <- names(forecasts[i]) | ||
x <- data.frame(rep(as.character(z), nrow(x)), x) | ||
y[[i]] <- x | ||
} | ||
|
||
# combind list into a single dataframe | ||
y <- dplyr::rbind_all(y, fill = TRUE) | ||
|
||
# add the forecast description to the dataframe | ||
forecast <- data.frame(y, labs, rep(NA, length(labs))) | ||
names(forecast) <- c("aac", "keyName", "value", "labs", "element") | ||
|
||
# label for min/max temperature in a new col to use for sorting in next step | ||
forecast$element <- | ||
as.character(stringr::str_match(forecast$labs, | ||
"air_temperature_[[:graph:]]{7}")) | ||
|
||
# convert object to tibble and remove rows we don't need, e.g., precip | ||
# keep only max and min temp | ||
forecast <- | ||
tibble::as_tibble(stats::na.omit(forecast[, c(1, 3, 5)])) | ||
|
||
# add dates to the data frame | ||
forecast$date <- c(Sys.Date(), | ||
rep(seq( | ||
lubridate::ymd(Sys.Date() + 1), | ||
lubridate::ymd(Sys.Date() + 6), | ||
by = "1 day" | ||
), | ||
each = 2)) | ||
|
||
forecast <- | ||
dplyr::left_join(forecast, forecast_locations, by = "aac") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# _BOMRang_: Fetch Australian Government Bureau of Meteorology Data | ||
|
||
[](https://travis-ci.org/) | ||
[](https://ci.appveyor.com/project/adamhsparks/BOMRang) | ||
[)`-brightgreen.svg)](https://github.com/adamhsparks/BOMRang/commits/master) | ||
[)`-brightgreen.svg)](https://cran.r-project.org/) | ||
|
||
Fetches Fetch Australian Government Bureau of Meteorology Weather forecasts and returns a tidy data frame in a _Tibble_ of the current and next six days weather. | ||
|
||
_Limited to Queensland and temperature values only at the moment_ | ||
|
||
## Meta | ||
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
*BOMRang*: Fetch Australian Government Bureau of Meteorology Data | ||
================================================================= | ||
|
||
[](https://travis-ci.org/) [](https://ci.appveyor.com/project/adamhsparks/BOMRang) [](https://github.com/adamhsparks/BOMRang/commits/master) [](https://cran.r-project.org/) | ||
|
||
Fetches Fetch Australian Government Bureau of Meteorology Weather forecasts and returns a tidy data frame in a *Tibble* of the current and next six days weather. | ||
|
||
*Limited to Queensland and temperature values only at the moment* | ||
|
||
Meta | ||
---- | ||
|
||
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# DO NOT CHANGE the "init" and "install" sections below | ||
|
||
# Download script file from GitHub | ||
init: | ||
ps: | | ||
$ErrorActionPreference = "Stop" | ||
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" | ||
Import-Module '..\appveyor-tool.ps1' | ||
install: | ||
ps: Bootstrap | ||
|
||
# Adapt as necessary starting from here | ||
|
||
build_script: | ||
- travis-tool.sh install_deps | ||
|
||
test_script: | ||
- travis-tool.sh run_tests | ||
|
||
on_failure: | ||
- 7z a failure.zip *.Rcheck\* | ||
- appveyor PushArtifact failure.zip | ||
|
||
artifacts: | ||
- path: '*.Rcheck\**\*.log' | ||
name: Logs | ||
|
||
- path: '*.Rcheck\**\*.out' | ||
name: Logs | ||
|
||
- path: '*.Rcheck\**\*.fail' | ||
name: Logs | ||
|
||
- path: '*.Rcheck\**\*.Rout' | ||
name: Logs | ||
|
||
- path: '\*_*.tar.gz' | ||
name: Bits | ||
|
||
- path: '\*_*.zip' | ||
name: Bits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
comment: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2017 | ||
COPYRIGHT HOLDER: Your name goes here |
Oops, something went wrong.