plotGrid: Plots raster layers of a raster stack object

Description Usage Arguments Value Examples

View source: R/plotGrid.R

Description

This function plots the results from scores.grid.time and scores.grid.notime.

Usage

1
2
3
4
5
plotGrid(long.name, plot.me, irregular = FALSE,
  my.projection = "+proj=longlat +ellps=WGS84",
  shp.filename = system.file("extdata/ne_110m_land/ne_110m_land.shp",
  package = "amber"), my.xlim = c(-180, 180), my.ylim = c(-60, 85),
  plot.width = 8, plot.height = 3.8, outputDir = FALSE)

Arguments

long.name

A string that gives the full name of the variable, e.g. 'Gross primary productivity'

plot.me

A list that is produced by scores.grid.time or scores.grid.notime.

irregular

logical: TRUE if data is on an irregular grid and FALSE if data is on a regular grid

my.projection

A string that gives the projection of the irregular grid

shp.filename

A string that gives the coastline shapefile

my.xlim

An R object that gives the longitude range that you wish to plot, e.g. c(-180, 180)

my.ylim

An R object that gives the longitude range that you wish to plot, e.g. c(-90, 90)

plot.width

Number that gives the plot width, e.g. 8

plot.height

Number that gives the plot height, e.g. 4

outputDir

A string that gives the output directory, e.g. '/home/project/study'. The output will only be written if the user specifies an output directory.

Value

Figures in PDF format. This may include the model data (mean, mod.mean; standard deviation; interannual-variability, mod.iav; month of annual cycle maximum, mod.max.month), the reference data (mean, ref.mean; standard deviation; interannual-variability, ref.iav; month of annual cycle maximum, ref.max.month), statistical metrics (bias, bias; root mean square error, rmse; time difference of the annual cycle maximum, phase), and scores (bias score, bias.score; root mean square error score, rmse.score; inter-annual variability score iav.score; annual cycle score (phase.score).

Examples

 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
# (1) Global plots on a regular grid

library(amber)
library(classInt)
library(doParallel)
library(foreach)
library(Hmisc)
library(latex2exp)
library(ncdf4)
library(parallel)
library(raster)
library(rgdal)
library(rgeos)
library(scico)
library(sp)
library(stats)
library(utils)
library(viridis)
library(xtable)

long.name <- 'Gross primary productivity'
nc.mod <- system.file('extdata/modelRegular', 'gpp_monthly.nc', package = 'amber')
nc.ref <- system.file('extdata/referenceRegular', 'gpp_GBAF_128x64.nc', package = 'amber')
mod.id <- 'CLASSIC' # define a model experiment ID
ref.id <- 'GBAF' # give reference dataset a name
unit.conv.mod <- 86400*1000 # optional unit conversion for model data
unit.conv.ref <- 86400*1000 # optional unit conversion for reference data
variable.unit <- 'gC m$^{-2}$ day$^{-1}$' # unit after conversion (LaTeX notation)

# Short version using default settings:
plot.me <- scores.grid.time(long.name, nc.mod, nc.ref, mod.id, ref.id, unit.conv.mod,
unit.conv.ref, variable.unit)
plotGrid(long.name, plot.me)

plot.me <- scores.grid.time(long.name, nc.mod, nc.ref, mod.id, ref.id, unit.conv.mod,
unit.conv.ref, variable.unit, score.weights = c(1,2,1,1,1), outlier.factor = 1,
irregular = FALSE)
plotGrid(long.name, plot.me)

# (2) Regional plots on a rotated grid
long.name <- 'Gross primary productivity'
nc.mod <- system.file('extdata/modelRotated', 'gpp_monthly.nc', package = 'amber')
nc.ref <- system.file('extdata/referenceRotated', 'gpp_GBAF_rotated.nc', package = 'amber')
mod.id <- 'CLASSIC' # define a model experiment ID
ref.id <- 'GBAF' # give reference dataset a name
unit.conv.mod <- 86400*1000 # optional unit conversion for model data
unit.conv.ref <- 86400*1000 # optional unit conversion for reference data
variable.unit <- 'gC m$^{-2}$ day$^{-1}$' # unit after conversion (LaTeX notation)
my.projection <- '+proj=ob_tran +o_proj=longlat +o_lon_p=83. +o_lat_p=42.5 +lon_0=263.'

plot.me <- scores.grid.time(long.name, nc.mod, nc.ref, mod.id, ref.id, unit.conv.mod,
unit.conv.ref, variable.unit, score.weights = c(1,2,1,1,1), outlier.factor = 10,
irregular = TRUE, my.projection = my.projection)

# Plot results:
irregular <- TRUE # data is on an irregular grid
my.projection <- '+proj=ob_tran +o_proj=longlat +o_lon_p=83. +o_lat_p=42.5 +lon_0=263.'
# shp.filename <- system.file('extdata/ne_50m_admin_0_countries/ne_50m_admin_0_countries.shp',
# package = 'amber')
shp.filename <- system.file("extdata/ne_110m_land/ne_110m_land.shp", package = "amber")
my.xlim <- c(-171, 0) # longitude range that you wish to plot
my.ylim <- c(32, 78) # latitude range that you wish to plot
plot.width <- 7 # plot width
plot.height <- 3.8 # plot height

plotGrid(long.name, plot.me, irregular, my.projection,
shp.filename, my.xlim, my.ylim, plot.width, plot.height)
 #donttest

amber documentation built on Aug. 28, 2020, 5:08 p.m.