Skip to content

Commit 9c2c810

Browse files
vignettes cleaned up and rebuilt
1 parent cd32c8b commit 9c2c810

14 files changed

+285
-48
lines changed

man/makeNetCDF_file.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/A_Make_data_grids.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Make and update source data grids"
2+
title: "Make source data grids"
33
description: >
44
This vignette shows how to build the netCDF data file and then
55
update it to new start and end dates.
@@ -10,7 +10,7 @@ vignette: >
1010
%\usepackage[utf8]{inputenc}
1111
---
1212

13-
``` r
13+
```{r setup}
1414
library(AWAPer, warn.conflicts = FALSE)
1515
```
1616
This example shows how to build the required data files and then update them.

vignettes/A_Make_data_grids.Rnw

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Make and update source data grids"
2+
title: "Make source data grids"
33
description: >
44
This vignette shows how to build the netCDF data file and then
55
update it to new start and end dates.
@@ -10,7 +10,7 @@ vignette: >
1010
%\usepackage[utf8]{inputenc}
1111
---
1212

13-
``` r
13+
```{r setup}
1414
library(AWAPer, warn.conflicts = FALSE)
1515
```
1616
This example shows how to build the required data files and then update them.

vignettes/B_Point_rainfall.Rmd

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ The first step is to create the netCDF files. Here only one netCDF file is creat
2626

2727
The netCDF file contains grids of daily rainfall for all of Australia and is used below to extract data at points of interest. Often users run _makeNetCDF_file_ once to build netCDF data files that contain all variables over the entire record length (which requires ~5GB disk storage) and then use the netCDFs grids for multiple projects, rather than re-building the netCDF for each project. Also, if _makeNetCDF_file_ is run with the the netCDF file names pointing to existing files and _updateFrom=NA_ then the netCDF files will be updated to yesterday.
2828

29+
To start to create the grids, the file name for the netCDF grids need to be defined. Here we'll just use temporary files. You should change this to a non-temporary file name and folder.
2930
```{r}
30-
fnames = makeNetCDF_file(ncdfFilename ='AWAP_demo.nc',
31+
# Set names for netCDF files (in the system temp. directory).
32+
ncdfFilename = tempfile(fileext='.nc')
33+
```
34+
35+
```{r}
36+
fnames = makeNetCDF_file(ncdfFilename = ncdfFilename,
3137
updateFrom=as.Date("2010-08-01","%Y-%m-%d"),
3238
updateTo=as.Date("2010-10-01","%Y-%m-%d"),
3339
urlTmin=NA, urlTmax=NA, urlVprp=NA, urlSolarrad=NA)
@@ -50,7 +56,7 @@ Extract the daily precipitation at the two locations. The data is extracted from
5056

5157
The other AWAPer variables are not extracted because _getTmin_, _getTmax_, _getVprp_, _getSolarrad_ and _getET_ are set to _F_. Note the netCDF file _ncdfFilename_ must be in the working directory or the full file path must be given.
5258
```{r}
53-
climateData.data = extractCatchmentData(ncdfFilename='AWAP_demo.nc',
59+
climateData.data = extractCatchmentData(ncdfFilename=ncdfFilename,
5460
extractFrom=as.Date("2010-08-01","%Y-%m-%d"),
5561
extractTo=as.Date("2010-10-01","%Y-%m-%d"),
5662
locations=coordinates.data,
@@ -60,7 +66,7 @@ climateData.data = extractCatchmentData(ncdfFilename='AWAP_demo.nc',
6066
## Plot the daily precipitation at each site
6167
Plot time series of the etracted daily precipitation.
6268

63-
```{r}
69+
```{r, fig.width= 8, fig.heght=8}
6470
for (i in 1:nrow(coordinates.data)){
6571
filt = climateData.data$CatchmentID.ID == coordinates.data$ID[i]
6672
@@ -77,8 +83,9 @@ legend('topright',legend=c('Bore-10084446','Rain-63005'),lty=2:3)
7783
```
7884

7985
## Check AWAPer data against precipitation gauge date
80-
Use the following observed precipitation (from gauge_63005) to check the AWAPer data. Note, the observed data is hardcoded in and sourced from the Australian Bureau of Meteorology.
86+
Use the following observed precipitation (from gauge_63005) to check the AWAPer data.
8187

88+
First let's hard-code in and sourced from the Australian Bureau of Meteorology.
8289
```{r}
8390
obsPrecip <- data.frame(
8491
year= c(2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
@@ -91,16 +98,21 @@ obsPrecip <- data.frame(
9198
precip_mm = c(0.6, 5.2, 0.8, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 15.8, 15.6, 7.6, 0.7, 0.4, 1.4, 1.0, 0.0, 0.0, 30.4, 1.0, 0.0,
9299
0.0, 5.0, 2.2, 0.3, 0.8, 13.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 13.8, 15.2, 0.4, 0.2, 0.0, 0.0, 12.4, 0.9,
93100
0.0, 0.0, 0.1, 13.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.0, 0.0, 0.0, 0.0))
101+
```
102+
Now let's compare the extracted rainfall against the gauge rainfall data.
103+
104+
The left plot shows that the gauge and extracted data plot along the 1:1. This shows that the extracted data is unbiased. The scatter does, however, show that there is some difference in the estimates. This arises because the source grids are at a 0.05 degree resolution, or about 5 km x 5 km, and this introduces some error with the gauge is not at the centre of the grid cell and the location to be extracted is not also at the centre.
105+
106+
```{r, fig.width= 8, fig.heght=8}
107+
par(mfrow = c(1, 2))
94108
95-
# Plot the observed vs AWAPer rainfall at gauge ID 63005
96109
filt2 = climateData.data$CatchmentID.ID=='Rain-63005'
97110
plot(obsPrecip$precip_mm,climateData.data$precip_mm[filt2],
98111
xlim = c(0,35),ylim = c(0,35),
99112
main='Obs. vs. AWAPer precip.',
100113
xlab='Obs. [mm/d]', ylab='AWAPer [mm/d]', cex=0.2)
101114
abline(0,1, col='grey', lty=2)
102115
103-
# Plot the cumulative observed vs AWAPer rainfall at gauge ID 63005
104116
plot(cumsum(obsPrecip$precip_mm),cumsum(climateData.data$precip_mm[filt2]),
105117
xlim = c(0,175),ylim = c(0,175),
106118
main='Cum. obs. vs. AWAPer precip.',

vignettes/B_Point_rainfall.Rnw

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ The first step is to create the netCDF files. Here only one netCDF file is creat
2626
2727
The netCDF file contains grids of daily rainfall for all of Australia and is used below to extract data at points of interest. Often users run _makeNetCDF_file_ once to build netCDF data files that contain all variables over the entire record length (which requires ~5GB disk storage) and then use the netCDFs grids for multiple projects, rather than re-building the netCDF for each project. Also, if _makeNetCDF_file_ is run with the the netCDF file names pointing to existing files and _updateFrom=NA_ then the netCDF files will be updated to yesterday.
2828
29+
To start to create the grids, the file name for the netCDF grids need to be defined. Here we'll just use temporary files. You should change this to a non-temporary file name and folder.
2930
```{r}
30-
fnames = makeNetCDF_file(ncdfFilename ='AWAP_demo.nc',
31+
# Set names for netCDF files (in the system temp. directory).
32+
ncdfFilename = tempfile(fileext='.nc')
33+
```
34+
35+
```{r}
36+
fnames = makeNetCDF_file(ncdfFilename = ncdfFilename,
3137
updateFrom=as.Date("2010-08-01","%Y-%m-%d"),
3238
updateTo=as.Date("2010-10-01","%Y-%m-%d"),
3339
urlTmin=NA, urlTmax=NA, urlVprp=NA, urlSolarrad=NA)
@@ -50,7 +56,7 @@ Extract the daily precipitation at the two locations. The data is extracted from
5056
5157
The other AWAPer variables are not extracted because _getTmin_, _getTmax_, _getVprp_, _getSolarrad_ and _getET_ are set to _F_. Note the netCDF file _ncdfFilename_ must be in the working directory or the full file path must be given.
5258
```{r}
53-
climateData.data = extractCatchmentData(ncdfFilename='AWAP_demo.nc',
59+
climateData.data = extractCatchmentData(ncdfFilename=ncdfFilename,
5460
extractFrom=as.Date("2010-08-01","%Y-%m-%d"),
5561
extractTo=as.Date("2010-10-01","%Y-%m-%d"),
5662
locations=coordinates.data,
@@ -60,7 +66,7 @@ climateData.data = extractCatchmentData(ncdfFilename='AWAP_demo.nc',
6066
## Plot the daily precipitation at each site
6167
Plot time series of the etracted daily precipitation.
6268
63-
```{r}
69+
```{r, fig.width= 8, fig.heght=6}
6470
for (i in 1:nrow(coordinates.data)){
6571
filt = climateData.data$CatchmentID.ID == coordinates.data$ID[i]
6672
@@ -77,8 +83,9 @@ legend('topright',legend=c('Bore-10084446','Rain-63005'),lty=2:3)
7783
```
7884
7985
## Check AWAPer data against precipitation gauge date
80-
Use the following observed precipitation (from gauge_63005) to check the AWAPer data. Note, the observed data is hardcoded in and sourced from the Australian Bureau of Meteorology.
86+
Use the following observed precipitation (from gauge_63005) to check the AWAPer data.
8187
88+
First let's hard-code in and sourced from the Australian Bureau of Meteorology.
8289
```{r}
8390
obsPrecip <- data.frame(
8491
year= c(2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010, 2010,
@@ -91,16 +98,21 @@ obsPrecip <- data.frame(
9198
precip_mm = c(0.6, 5.2, 0.8, 0.4, 0.0, 0.0, 0.0, 0.0, 0.0, 15.8, 15.6, 7.6, 0.7, 0.4, 1.4, 1.0, 0.0, 0.0, 30.4, 1.0, 0.0,
9299
0.0, 5.0, 2.2, 0.3, 0.8, 13.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 13.8, 15.2, 0.4, 0.2, 0.0, 0.0, 12.4, 0.9,
93100
0.0, 0.0, 0.1, 13.0, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.0, 0.0, 0.0, 0.0))
101+
```
102+
Now let's compare the extracted rainfall against the gauge rainfall data.
103+
104+
The left plot shows that the gauge and extracted data plot along the 1:1. This shows that the extracted data is unbiased. The scatter does, however, show that there is some difference in the estimates. This arises because the source grids are at a 0.05 degree resolution, or about 5 km x 5 km, and this introduces some error with the gauge is not at the centre of the grid cell and the location to be extracted is not also at the centre.
105+
106+
```{r, fig.width= 8, fig.heght=6}
107+
par(mfrow = c(1, 2))
94108
95-
# Plot the observed vs AWAPer rainfall at gauge ID 63005
96109
filt2 = climateData.data$CatchmentID.ID=='Rain-63005'
97110
plot(obsPrecip$precip_mm,climateData.data$precip_mm[filt2],
98111
xlim = c(0,35),ylim = c(0,35),
99112
main='Obs. vs. AWAPer precip.',
100113
xlab='Obs. [mm/d]', ylab='AWAPer [mm/d]', cex=0.2)
101114
abline(0,1, col='grey', lty=2)
102115
103-
# Plot the cumulative observed vs AWAPer rainfall at gauge ID 63005
104116
plot(cumsum(obsPrecip$precip_mm),cumsum(climateData.data$precip_mm[filt2]),
105117
xlim = c(0,175),ylim = c(0,175),
106118
main='Cum. obs. vs. AWAPer precip.',

0 commit comments

Comments
 (0)