plotNcIrreg: Plots the time-mean of a variable stored in NetCDF model...

Description Usage Arguments Value Examples

View source: R/plotNcIrreg.R

Description

This function plots the time-mean, spatial-mean, zonal mean, and seasonal cycle of variable stored in NetCDF model output. The function expects data to be on an irregular grid.

Usage

1
2
3
4
5
6
plotNcIrreg(long.name, nc.mod, mod.id, unit.conv.mod, variable.unit,
  timePeriod, outlier.factor = 1000,
  my.projection = "+proj=ob_tran +o_proj=longlat +o_lon_p=83. +o_lat_p=42.5 +lon_0=263.",
  my.xlim = c(-171, 0), my.ylim = c(32, 78), plot.width = 7,
  plot.height = 3.8, numCores = 2, timeInt = "month",
  outputDir = FALSE)

Arguments

long.name

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

nc.mod

A string that gives the path and name of the netcdf file that contains the model output, e.g. '/home/model_gpp.nc'

mod.id

A string that identifies the source of the reference data set, e.g. 'CLASSIC'

unit.conv.mod

A number that is used as a factor to convert the unit of the model data, e.g. 86400

variable.unit

A string that gives the final units using LaTeX notation, e.g. 'gC m$^-2$ day$^-1$'

timePeriod

A string that gies the time period over which to average the data, e.g. c('1980-01', '2017-12')

outlier.factor

A number that is used to define outliers, e.g. 10. Plotting raster objects that contain extreme outliers lead to figures where most grid cells are presented by a single color since the color legend covers the entire range of values. To avoid this, the user may define outliers that will be masked out and marked with a red dot. Outliers are all values that exceed the interquartile range multiplied by the outlier factor defined here.

my.projection

A string that defines the projection of the irregular grid

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

numCores

An integer that defines the number of cores, e.g. 2

timeInt

A string that gives the time interval of the model data, e.g. 'month' or 'year'

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 that show the time-mean, spatial-mean, zonal mean, and seasonal cycle.

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
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/modelRotated', 'gpp_monthly.nc', package = 'amber')
mod.id <- 'CLASSIC' # define a model experiment ID
unit.conv.mod <- 86400*1000 # optional unit conversion for model data
variable.unit <- 'gC m$^{-2}$ day$^{-1}$' # unit after conversion (LaTeX notation)
timePeriod <- c('1980-01', '2017-12')
outlier.factor <- 1

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

plotNcIrreg(long.name, nc.mod, mod.id, unit.conv.mod, variable.unit, timePeriod, outlier.factor)
 #donttest

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