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 :
Az, An
Azimuth and angle of stem sections
Or
Orientation angle of the midrib of the leaf
Az.1, An.1
Branch sections
Az.2, An.2
Petioles
Az.3, An.3
Leaves
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.
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.
Author(s)
Remko Duursma
See Also
readp, fitdistribution,
readl, constructplant
Examples
## Not run:
# 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)
## End(Not run)