-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
125 lines (96 loc) · 3.37 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, set-up, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.align = "center",
out.width = "100%"
)
pkgload::load_all()
```
# Australian weather data
This package produces graphs of temperatures in summer and winter for Australian
locations using data downloaded from the
[Australian Bureau of Meteorology](http://www.bom.gov.au/?ref=logo) (BoM).
Daily maximum and minimum temperature measurements can be downloaded for weather
stations in Australia from the
[Climate Data Online section](http://www.bom.gov.au/climate/data/) of the BoM
website.
The package includes pre-downloaded datasets for the main airport location in
the capital city of each Australian state and territory:
* Adelaide
* Brisbane
* Canberra
* Darwin
* Hobart
* Melbourne
* Perth
* Sydney
These can be loaded via `data('Adelaide')`, for example. Otherwise, use
`download_temperatures()` to download the most recent temperatures for these
cities or for other locations.
## Installation
You can install the development version of `austemp` from
[GitHub](https://github.com/a-s-russo/austemp.git) with:
``` r
# install.packages("devtools")
devtools::install_github("a-s-russo/austemp")
```
## Example
Download summer and winter data for Adelaide:
(The approximate download date & time of this example is
`r format(Sys.time(), "%d %b %Y @ %l%p %Z")`.)
```{r example-download, message=FALSE}
# Load the package
library(austemp)
# Download temperature data
station <- '023034' # Station number for Adelaide Airport
product_max <- '122' # Product number for maximum temperatures
product_min <- '123' # Product number for minimum temperatures
URLpart1 <-
'http://www.bom.gov.au/jsp/ncc/cdio/weatherData/av?p_nccObsCode='
URLpart2 <-
'&p_display_type=dailyDataFile&p_startYear=&p_c=&p_stn_num='
max_temp_URL <- paste0(URLpart1, product_max, URLpart2, station)
min_temp_URL <- paste0(URLpart1, product_min, URLpart2, station)
Adelaide <-
download_temperatures(URLs = c(max_temp_URL, min_temp_URL))
```
(Alternatively, use the pre-downloaded dataset for Adelaide via
`data('Adelaide')` as mentioned above.)
The downloaded data can then be graphed:
```{r example-plot-summer, message=FALSE, out.height="100%", out.width="100%"}
# Graph summer temperatures
plot_temperatures(
data = Adelaide,
season = 'summer',
location = 'Adelaide Airport',
thresholds = c(30, 35, 40),
start_year = 2001,
end_year = 2024
)
```
(Although the requested ending year is 2024, temperatures for 2025 appear since
the summer months span consecutive years, and likewise for the requested
starting year. There are some missing temperatures in 2024 given the download
date above. There are also no temperatures for 29 February in non-leap years
obviously.)
```{r example-plot-winter, message=FALSE, out.height="100%", out.width="100%"}
# Graph winter temperatures
plot_temperatures(
data = Adelaide,
season = 'winter',
location = 'Adelaide Airport',
thresholds = c(0, 3, 5),
start_year = 2000,
end_year = 2024
)
```
(Temperatures for 2024 do not appear despite being requested since there are no
temperatures at all for 2024 yet given the download date above. That is, the
winter months do not span consecutive years, and so a winter season is contained
entirely within a single year.)