Learn R Programming

YplantQMC (version 0.6-3)

replaceangles: Modify Yplant input files.

Description

Reads a plant file (a Yplant input file with extension .p, known as a pfile), and writes a new pfile, by modifying angles, internode lengths, or segment diameters. The function modifypfile is a general function that can be used to modify any variable in a pfile. The following variables can be changed in a pfile : [object Object],[object Object],[object Object],[object Object],[object Object] The function replaceangles is a specialized version for replacing leaf angles (and do some specific error checking, or sampling from leaf angle distributions). The function changeinternodes is a special function for lengths of woody segments (technically not quite the same as internodes!). For replaceangles, an object of class angledist can be constructed with the angledist function in package LeafAngle (See Example below) or from fitting to a sample with fitdistribution. If angles are provided but the vector is too short, the vector will be sampled with replacement.

Usage

replaceangles(whichangle = "An.3", pfile = NA, outputfile = NA,
  newangles = NULL, distobj = NULL)

modifypfile(pfile = NA, whichvar = NA, outputfile = "tmp.p",
  newvalues = NULL)

changeinternodes(pfile = NA, outputfile = "tmp.p", method = c("perc",
  "constant"), changeperc = 50, consvalue = NA)

Arguments

whichangle
By default the leaf angle, or one of the other angles (see Details).
pfile
Name of the .p file.
outputfile
Name of the new file.
newangles
A vector of angles to be used in the new p file (optional, in stead of distobj).
distobj
An object of class angledist, that is a leaf angle distribution (See examples).
whichvar
Name of variable in p file to modify (see readp for list of variables.
newvalues
Vector of new values for the variable that is to be replaced.
method
for changeinternodes, a percentage change ("perc") or a new constant value ("constant").
changeperc
If method="perc", change the internodes by this percentage of their orginal value.
consvalue
If method="constant", change all internodes to this constant value.

Value

  • A new pfile is created, by default with the name "tmp.p", unless the argument outputfile is set.

See Also

readp, fitdistribution, readl, constructplant

Examples

Run this code
# Replace angles by sampling from an ellipsoidal distribution:
mydist <- angledist("ellipsoid", distpars=0.7)
replaceangles(pfile="someplant.p", distobj=mydist)

# Make constant angles:
replaceangles(pfile="someplant.p", newangles=45)

# Change new file name:
replaceangles(pfile="someplant.p", outputfile="someplant 45degrees.p", newangles=45)

# Change petiole orientation, choose pfile with dialog box:
replaceangles("Az.2", newangles=runif(300, 0, 360))

# Modify various variables in a pfile, until we end up with an artificial plant,
# useful for testing.
# Order of changes, in this case (although it does not matter!):
# Leaf azimuth, leaf orientation, leaf angle, petiole length, petiole angle.
modifypfile("originalplant.p", whichvar="Az.3", outputfile="testplant.p", newvalues=45)
modifypfile("testplant.p", whichvar="Or", outputfile="testplant.p", newvalues=45)
modifypfile("testplant.p", whichvar="An.3", outputfile="testplant.p", newvalues=-45)
modifypfile("testplant.p", whichvar="L.2", outputfile="testplant.p", newvalues=10)
modifypfile("testplant.p", whichvar="An.2", outputfile="testplant.p", newvalues=45)

Run the code above in your browser using DataLab