getScheme: Get a Classification 'Field' from a 'Source'

View source: R/getScheme.R

getSchemeR Documentation

Get a Classification Field from a Source

Description

Given a Source object and a Scheme object, return an appropriate spatially/temporal/annually-aggregated Field object with categorical values u based on the classification contained in the Scheme, optionally including spatial, temporal and annual cropping.

Usage

getScheme(
  source,
  scheme,
  first.year,
  last.year,
  year.aggregate.method,
  spatial.extent,
  spatial.extent.id,
  spatial.aggregate.method,
  subannual.resolution,
  subannual.original,
  subannual.aggregate.method,
  sta.info,
  quick.read.file = NULL,
  quick.read.autodelete = FALSE,
  averaged.source,
  verbose = FALSE,
  ...
)

Arguments

source

The Source object for which the Classification Field should be built. A list of Source objects can also be provided, in which case the required Field object derived from each Source in the list (for example LAI or fractional cover) are first averaged, and then do the biome classification. In the case of a list ofSource objects, the averaged.source arguments (see below) must also be supplied so that the averaged data can be written to/read from disk.

scheme

The classification scheme to be used as Scheme object, or the id of a Scheme defined in the package, as a character string.

first.year

The first year (as a numeric) of the data to be return

last.year

The last year (as a numeric) of the data to be return

year.aggregate.method

A character string describing the method by which to annual aggregate the data. Leave blank to apply no annual aggregation. Can currently be "mean", "sum", "max", "min", "mode", "median", "sd" and "var". For technical reasons these need to be implemented in the package in the code however it should be easy to implement more, please just contact the author! Note that this aggregation is done before the Scheme is calculated. See aggregateYears

spatial.extent

An extent in space to which this Field should be cropped, supplied as a raster::extent object or an object from which a raster::extent object can be derived - eg. a Raster* object or another Field object.

spatial.extent.id

A character string to give an identifier for the spatial extent this ModelField covers.

spatial.aggregate.method

A character string describing the method by which to spatially aggregate the data. Leave blank to apply no spatially aggregation. Can currently be "weighted.mean", "w.mean", "mean", "mode", "median", weighted.sum", "w.sum", "sum", "max", "min", "sd" or "var". For technical reasons these need to be implemented in the package in the code however it should be easy to implement more, please just contact the author! Note that this aggregation is done before the Scheme is calculated. See aggregateSpatial

subannual.resolution

A character string specifying the subannual resolution that you want to the data on. Can be "Year", "Month" or "Day".

subannual.original

A character string specifying the subannual you want the data to be on before applying the subannual.aggregate.method. Can be "Year", "Month" or "Day". Currently ignored.

subannual.aggregate.method

A character string specifying the method by which to aggregagte the data subannually, can be "mean", "sum", "max", "min", "mode", "median", "sd" or "var". Note that this aggregation is done before the Scheme is calculated. See aggregateSubannual

sta.info

Optionally an STAInfo object defining the exact spatial-temporal-annual domain over which the data should be retrieved. Can also be a Field object from which the STA info will de derived. If specified the following 9 arguments are ignored (with a warning).

quick.read.file

A character string. If set, the function will look for a file of this name (plus the extension ".RData") in the run directory. If if finds one then it reads that. If it doesn't find the appropriate file, then it reads the raw data, performs whatever cropping and aggregating is necessary, and then saves the data in a file of that name (in the run directory) for use next time. (Note: the function also checks that the specified layers, cropping and aggregating found in the file match that which was requested by the arguments here).

quick.read.autodelete

If TRUE then the file specified by the above "quick.read.file" argument will be deleted, thus ensuring that the raw data will be read afresh (and saved again). Ignored if valid "quick.read.file" argument not supplied.

averaged.source

If a list of Source objects have been supplied to be averaged before the classification, you must supply another Source object to store the averaged results.

verbose

If TRUE give a lot of information for debugging/checking.

...

Other arguments that are passed to the getField function for the specific Format or additional arguements for selecting space/time/years. For all Formats, the followings arguments apply:

  • cover.fraction When selecting gridcells based on a SpatialPolygonsDataFrame (ie from a shapefile) as the spatial.extent argument, this optional argument determines how much of the gridcell needs to be in the the polygon for it to be selected. Should be between 0 and 1.

For the aDGVM(1) Format, the following arguments apply:

  • adgvm.file.type This character string argument specifies from which file to read the data. This can be one of "Yearly", "Sys", "Fire", "Soil" or "Size". The default is "Yearly", which is sensible because the yearly file is always written.

  • adgvm.fire This numeric argument (taking values 0 or 1) specifies to take a run with fire on (1) or off (0). Default is 1.

  • adgvm.climate This numeric argument (taking values 0 or 1) specifies to take a run with constant (0) or transient (1) climate. Default is 0.

  • adgvm.header If your aDGVM run has been has extra columns added to the output tables, use this argument to specify the column names. For the default column names see the source file aDGVM1-Format.

For the aDGVM2 Format, the following arguments apply:

  • adgvm2.scheme This numeric argument defines the aDGVM PFT scheme which can be 1 or 2.

  • adgvm2.daily A logical, set to true to read daily data (only for adgvm2.scheme=1 and if daily data are provided in pop file)

Details

Note that because there are three types of aggregating available, the resulting Field object can a wide select of spatio-temporal dimensions. To check what dimensions you have you can use getDimInfo

Value

A Field.

Author(s)

Matthew Forrest matthew.forrest@senckenberg.de

See Also

aggregateSubannual, aggregateSpatial, aggregateYears, getDimInfo, getField

Examples


 
# In this example we derive and plot the Smith et al 2014 and the 
# Forrest et al 2015 biome classifications    
 
# First define a Source
test.dir <- system.file("extdata", "LPJ-GUESS_Runs", "CentralEurope", package = "DGVMTools")
test.Source <- defineSource(name = "LPJ-GUESS run", dir = test.dir,  format = GUESS)

# Smith et al. 2014
Smith2014.biomes <- getScheme(source = test.Source, scheme = Smith2014BiomeScheme, 
                              year.aggregate.method = "mean")
print(plotSpatial(Smith2014.biomes))

# Forrest et al. 2014
Forrest2015.biomes <- getScheme(source = test.Source, scheme = Forrest2015BiomeScheme, 
                                year.aggregate.method = "mean")
print(plotSpatial(Forrest2015.biomes))



MagicForrest/DGVMTools documentation built on Aug. 23, 2024, 8:05 a.m.