Package 'pRecipe'

Title: Precipitation R Recipes
Description: An open-access tool/framework to download, validate, visualize, and analyze multi-source precipitation data. More information and an example of implementation can be found in Vargas Godoy and Markonis (2023, <doi:10.1016/j.envsoft.2023.105711>).
Authors: Mijael Rodrigo Vargas Godoy [aut, cre] , Yannis Markonis [aut, ths]
Maintainer: Mijael Rodrigo Vargas Godoy <[email protected]>
License: GPL-3
Version: 3.0.2
Built: 2024-12-07 20:35:30 UTC
Source: CRAN

Help Index


Download various precipitation data products

Description

The function download_data downloads the selected data product.

Usage

download_data(
  dataset = "all",
  path = ".",
  domain = "raw",
  timestep = "monthly"
)

Arguments

dataset

a character string with the name(s) of the desired data set. Suitable options are:

  • "all" for all of the below listed data sets (default),

  • "20cr" for 20CR v3,

  • "chirps" for CHIRPS v2.0,

  • "cmap" for CMAP standard version,

  • "cmorph" for CMORPH,

  • "cpc" for CPC-Global,

  • "cru-ts" for CRU_TS v4.06,

  • "em-earth" for EM-EARTH,

  • "era20c" for ERA-20C,

  • "era5" for ERA5,

  • "fldas" for FLDAS,

  • "ghcn" for GHCN-M v2,

  • "gldas-clsm" for GLDAS CLSM,

  • "gldas-noah" for GLDAS NOAH,

  • "gldas-vic" for GLDAS VIC,

  • "gpcc" for GPCC v2020,

  • "gpcp" for GPCP v2.3,

  • "gpm_imerg" for GPM IMERGM Final v06,

  • "jra55" for JRA-55,

  • "merra2" for MERRA-2,

  • "mswep" for MSWEP v2.8,

  • "ncep-doe" for NCEP/DOE,

  • "ncep-ncar" for NCEP/NCAR,

  • "persiann" for PERSIANN-CDR,

  • "precl" for PREC/L,

  • "terraclimate" for TerraClimate,

  • "trmm-3b43" for TRMM 3B43 v7,

  • "udel" for UDEL v501.

path

a character string with the path where the database will be downloaded.

domain

a character string with the desired domain data set. Suitable options are:

  • "raw" for default available spatial coverage,

  • "global" for data sets with global (land and ocean) coverage,

  • "land" for data sets with land only coverage,

  • "ocean", for data sets with ocean only coverage.

timestep

a character string with the desired time resolution. Suitable options are:

  • "monthly",

  • "yearly".

Value

No return value, called to download the required data sets.

Examples

download_data("gldas-vic", tempdir(), timestep = "yearly")

Boxplot ggplot

Description

Convenient and aesthetic visualization of data in a boxplot.

Usage

plot_box(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'Raster'
plot_box(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'data.table'
plot_box(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'character'
plot_box(x, var = "Precipitation", unit = "mm")

Arguments

x

Raster* object; data.table (see details); filename (character, see details)

var

character (see details)

unit

character (see details)

Details

If 'x' is a data.table, its columns should be named: "lon", "lat", "date", and "value"

If 'x' is a filename, it should point to a *.nc file.

'var' is a character string describing the variable to be used for the plot title

'unit' is a character string describing the unit of measurement to be used for the plot title

Value

ggplot object

Examples

## Not run: 
download_data("gldas-vic", tempdir(), timestep = "yearly")
r <- raster::brick(paste0(tempdir(),
"/gldas-vic_tp_mm_land_194801_201412_025_yearly.nc"))
s <- plot_box(r)

## End(Not run)

Histogram ggplot

Description

Convenient and aesthetic visualization of data in a histogram.

Usage

plot_density(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'Raster'
plot_density(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'data.table'
plot_density(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'character'
plot_density(x, var = "Precipitation", unit = "mm")

Arguments

x

Raster* object; data.table (see details); filename (character, see details)

var

character (see details)

unit

character (see details)

Details

If 'x' is a data.table, its columns should be named: "lon", "lat", "date", and "value"

If 'x' is a filename, it should point to a *.nc file.

'var' is a character string describing the variable to be used for the axis title

'unit' is a character string describing the unit of measurement to be used for the axis title

Value

ggplot object

Examples

## Not run: 
download_data("gldas-vic", tempdir(), timestep = "yearly")
r <- raster::brick(paste0(tempdir(),
"/gldas-vic_tp_mm_land_194801_201412_025_yearly.nc"))
s <- plot_density(r)

## End(Not run)

Heatmap ggplot

Description

Convenient and aesthetic visualization of data in a heatmap.

Usage

plot_heatmap(x, unit = "mm")

## S4 method for signature 'Raster'
plot_heatmap(x, unit = "mm")

## S4 method for signature 'data.table'
plot_heatmap(x, unit = "mm")

## S4 method for signature 'character'
plot_heatmap(x, unit = "mm")

Arguments

x

Raster* object; data.table (see details); filename (character, see details)

unit

character (see details)

Details

If 'x' is a data.table, its columns should be named: "lon", "lat", "date", and "value"

If 'x' is a filename, it should point to a *.nc file.

'unit' is a character string describing the unit of measurement to be used for the axis title

Value

ggplot object

Examples

## Not run: 
download_data("gldas-vic", tempdir(), timestep = "yearly")
r <- raster::brick(paste0(tempdir(),
"/gldas-vic_tp_mm_land_194801_201412_025_yearly.nc"))
s <- plot_heatmap(r)

## End(Not run)

Line ggplot

Description

Convenient and aesthetic visualization of data in a line plot.

Usage

plot_line(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'Raster'
plot_line(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'data.table'
plot_line(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'character'
plot_line(x, var = "Precipitation", unit = "mm")

Arguments

x

Raster* object; data.table (see details); filename (character, see details)

var

character (see details)

unit

character (see details)

Details

If 'x' is a data.table, its columns should be named: "lon", "lat", "date", and "value"

If 'x' is a filename, it should point to a *.nc file.

'var' is a character string describing the variable to be used for the axis title

'unit' is a character string describing the unit of measurement to be used for the axis title

Value

ggplot object

Examples

## Not run: 
download_data("gldas-vic", tempdir(), timestep = "yearly")
r <- raster::brick(paste0(tempdir(),
"/gldas-vic_tp_mm_land_194801_201412_025_yearly.nc"))
s <- plot_line(r)

## End(Not run)

Map ggplot

Description

Convenient and aesthetic visualization of data in a map

Usage

plot_map(x, layer = 1, unit = "mm", timestamp = TRUE)

## S4 method for signature 'Raster'
plot_map(x, layer = 1, unit = "mm", timestamp = TRUE)

## S4 method for signature 'data.table'
plot_map(x, layer = 0, unit = "mm", timestamp = TRUE)

## S4 method for signature 'character'
plot_map(x, layer = 1, unit = "mm", timestamp = TRUE)

Arguments

x

Raster* object; data.table (see details); filename (character, see details)

layer

numeric

unit

character

timestamp

logical

Details

If 'x' is a data.table, its columns should be named: "lon", "lat", "date", and "value"

If 'x' is a filename, it should point to a *.nc file.

'unit' is a character string describing the unit of measurement to be used for the legend title

'layer' is the layer number to be plotted.

‘timestamp' if TRUE (default) the plot title is the layer’s date

Value

ggplot object


Summary ggplot

Description

Convenient and aesthetic visualization of data in a summary plot.

Usage

plot_summary(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'Raster'
plot_summary(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'data.table'
plot_summary(x, var = "Precipitation", unit = "mm")

## S4 method for signature 'character'
plot_summary(x, var = "Precipitation", unit = "mm")

Arguments

x

Raster* object; data.table (see details); filename (character, see details)

var

character (see details)

unit

character (see details)

Details

If 'x' is a data.table, its columns should be named: "lon", "lat", "date", and "value"

If 'x' is a filename, it should point to a *.nc file.

'var' is a character string describing the variable to be used for the axis title

'unit' is a character string describing the unit of measurement to be used for the axis title

Value

ggplot object

Examples

## Not run: 
download_data("gldas-vic", tempdir(), timestep = "yearly")
r <- raster::brick(paste0(tempdir(),
"/gldas-vic_tp_mm_land_194801_201412_025_yearly.nc"))
s <- plot_summary(r)

## End(Not run)

Taylor diagram

Description

Convenient and aesthetic visualization of data in a Taylor diagram.

Usage

plot_taylor(x, y, groups = "default", ...)

Arguments

x

data.table

y

data.table

groups

character

...

see details

Details

'x' columns should be named: "lon", "lat", "date", "value", "dataset", and "source".

'y' columns should be named: "lon", "lat", "date", "value", "dataset", and "source".

'groups' character to define panels. Suitable options are:

  • "default" (only one panel)

  • "source"

  • "seasons" (only works properly with monthly data)

'...' extra arguments passed on to openair::TaylorDiagram

Value

plot object