make.siteinfo {Rglimclim}R Documentation

To convert site information from a data frame

Description

To extract site information from a data frame and produce a siteinfo object suitable for passing to GLCfit.

Usage

make.siteinfo(site.data, coord.cols = NULL, site.codes = NULL, 
              site.names = NULL, region.col=NULL, attr.cols = NULL, 
              attr.names = NULL, regions = NULL)
## S3 method for class 'siteinfo'
print(x,...)

Arguments

site.data

A data frame containing information on the attributes of each site to be defined and, optionally, site names and short 4-character identification codes. There should be one row for each site. See GLCdemo for an example).

coord.cols

A numeric vector containing at most two elements, identifying the number(s) of the column(s) in site.data that contain spatial co-ordinates of the sites. If unspecified, the first two columns that do not contain names or site codes are taken as the spatial co-ordinates (if there is just one candidate column, this is taken as a single spatial co-ordinate).

site.codes

Either a character vector of short site identifiers, or a single number indicating which column of site.data contains these identifiers. Each identifier should be exactly 4 characters long (including spaces if necessary). The default is to take rownames(site.data): in this case the the row names should themselves be 4 characters in length. The codes are used to identify observations when reading data files.

site.names

Either a character vector of site names, or a single number indicating which column of site.data contains the site names. This must be supplied and is used to label software output.

region.col

A single number indicating which (if any) column of site.data contains the numbers of the regions in which each site is located (codes should correspond to regions defined via read.regiondef or define.regions). Default is not to associate sites with any region except the entire area.

attr.cols

Numeric vector indicating which columns of site.data contain site attribute information. Default is all columns that do not contain site codes, site names or region codes.

attr.names

Character vector of descriptive text for each of the site attributes being defined. The default is to take the corresponding column names of site.data.

regions

An optional data frame giving names of regions or subareas, in the format returned by read.regiondef or define.regions.

x

For the print method, an object of class siteinfo.

...

Additional arguments to the print method (not used here).

Details

There is no limit to the number of sites that can be defined, or to the number of attributes that can be defined for each site.

Value

The function returns a list result of class siteinfo, with components

Nsites

The number of sites defined in file site.data

Site.names

A vector of character strings giving the names of the sites (i.e. the values of site.names)

Site.codes

A vector of 4-character identifiers for each site (this is used to identify observations when reading data files)

Regions

A numeric vector indicating the region in which each site is located (codes correspond to regions defined via define.regions) or read.regiondef. Contains zeroes for sites where no region information is given. Regions are defined solely for the purpose of producing regional summary statistics from simulated weather sequences.

Region.names

A character vector giving the names of the regions. Again, this is used only for labelling simulation output.

Nattr

The number of attributes defined for each site.

Attribute.names

A vector of character strings describing each attribute (this is used for labelling model output). The attributes corresponding to coord.cols are listed first.

Attribute.values

A matrix containing the attribute values for each site: rows correspond to sites (labelled using Site.codes) and columns to attributes (labelled using truncated Attribute.names). The attributes corresponding to coord.cols appear first.

The print method shows what attributes have been defined and in what order.

Author(s)

Richard Chandler (richard@stats.ucl.ac.uk)

See Also

read.siteinfo to define sites based on an old GLIMCLIM site definition file, GLCdemo, GLCfit

Examples

require(Rglimclim)
#
#       Load example data and view the Ashdown.sites dataframe
#
data(GLCdemo)
print(Ashdown.sites)
#
#       Convert the data frame to the required format, taking the 
#       site names from the first column, the region definitions
#       from the second (and, by default, taking the 
#       remaining columns as site attributes) and defining
#       some extended descriptive text for each of the 
#       attributes.
#       
siteinfo <- make.siteinfo(Ashdown.sites,site.names=1,region.col=2,
                          attr.names=c(
               "Eastings (inches from left of 11\" wide map)",
               "Northings (inches from bottom of 8\" high map)"))
print(siteinfo)                 # Brief summary on screen
print(unclass(siteinfo))        # To see the gory details

[Package Rglimclim version 1.2-2 Index]