canopy_factory.crops package¶
Submodules¶
canopy_factory.crops.base module¶
- class canopy_factory.crops.base.ApexComponent(name, param, parent, required=False)[source]¶
Bases:
ComponentBaseApex component.
- property additional_production_conditions¶
Lsystem production rule lines for before ‘else’.
- Type:
list
- class canopy_factory.crops.base.BranchComponent(name, param, parent, required=False)[source]¶
Bases:
ComponentBaseBranch component.
- property additional_production_conditions¶
Lsystem production rule lines for before ‘else’.
- Type:
list
- class canopy_factory.crops.base.BudComponent(name, param, parent, required=False)[source]¶
Bases:
GeometricComponentBaseBud component.
- class canopy_factory.crops.base.ColorPlantParameter(*args, **kwargs)[source]¶
Bases:
SimplePlantParameterClass for color parameters.
- classmethod colorname2component(name)[source]¶
Extract the component name from a color name.
- Parameters:
name (str) – Color name.
- classmethod component2colorname(component, idx)[source]¶
Create a color name based on the component and color index.
- Parameters:
component (str) – Name of component.
idx (int) – Color index.
- class canopy_factory.crops.base.ComponentBase(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameterBase class for generating plant components.
- property additional_production_conditions¶
Lsystem production rule lines for before ‘else’.
- Type:
list
- property component¶
Component that this property belongs to.
- Type:
str
- property homomorphism¶
Lsystem homomorphism rule lines.
- Type:
list
- property production¶
Lsystem production rule lines.
- Type:
list
- class canopy_factory.crops.base.CotyledonComponent(name, param, parent, required=False)[source]¶
Bases:
LeafComponentCotyledon component.
- class canopy_factory.crops.base.CurvePatchPlantParameter(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameterClass for a curve patch parameter.
- classmethod create_curve_patch(curves, knots=None, degree=3)[source]¶
Create a PlantGL NURBS curve patch.
- Parameters:
curves (list) – Set of NurbsCurve instances defining the patch.
knots (list, optional) – Knot list.
degree (int, optional) – The curve degree.
- Returns:
Curve instance.
- Return type:
NurbsPatch
- classmethod sample_curve_patch(p, t, tnorm=None, tmin=None, tmax=None)[source]¶
Sample a curve patch.
- Parameters:
p (NurbsPatch) – Curve patch to sample.
t (float) – Value to sample the patch at.
tnorm (float, optional) – Value to normalize t against.
tmin (float, optional) – Value before which the first patch should be used.
tmax (float, optional) – Value after which the last patch should be used.
- Returns:
Curve corresponding to value t.
- Return type:
NurbsCurve2D
- class canopy_factory.crops.base.CurvePlantParameter(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameterClass for a curve parameter.
- Class Attributes:
_required_curve (list) – Properties required when the curve is not generated from a curve patch.
_required_patch (list) – Properties required when the curve is generated from a curve patch.
_allow_patch (bool) – True if curve patches should be allowed.
- classmethod add_class_defaults(param, **kwargs)[source]¶
Update defaults based on parameters.
- Parameters:
param (ParameterDict) – Parameter set to update.
**kwargs – Additional keyword arguments are added to param.
- classmethod create_curve(points, knots=None, uniform=False, stride=60, degree=3, symmetry=None, closed=False, reverse=False, thickness=None, factor=None, return_points=False, return_area=False)[source]¶
Create a PlantGL NURBS curve.
- Parameters:
points (np.ndarray) – Control points. If points are 2D a NurbsCurve2D instance will be created, otherwise a NurbsCurve instance will be created.
knots (list, optional) – Knot list.
uniform (bool, optional) – If True, the spacing between control points is made to be uniform.
stride (int, optional) – The curve stride.
degree (int, optional) – The curve degree.
symmetry (list, optional) – The indices of axes that the points should be reflected over.
closed (bool, optional) – If True, the curve is closed.
reverse (bool, optional) – If True, the order of the points should be reversed.
thickness (float, optional) – Thickness that should be added to the curve by doubling it back on itself.
factor (float, optional) – Additional scale factor that should be applied to points.
return_points (bool, optional) – If True, the control points for the curve will be returned instead of the curve.
return_area (bool, optional) – If True, return the area contained by the curve.
- Returns:
Curve instance.
- Return type:
NurbsCurve
- classmethod normalize_points(points, closed=False)[source]¶
Normalize a set of points so that the maximum length of the curve (if open) or area inside the polygon (if closed) is 1.
- Parameters:
points (np.ndarray) – Points to scale.
closed (bool, optional) – If True, the curve is closed.
- Returns:
Scaled points.
- Return type:
np.ndarray
- classmethod reflect_points(points_R, axis)[source]¶
Reflect points across an axis.
- Parameters:
points_R (np.ndarray) – Points that should be reflected from the positive side of the specified axis to the negative side.
axis (int) – Index of axis that points should be reflected across.
- Returns:
- Set of points including the original points and
the reflected points.
- Return type:
np.ndarray
- canopy_factory.crops.base.DelayedPlantParameter(name, **kwargs)[source]¶
Class factory for creating a plant parameter class on registration.
- Parameters:
name (str) – Name of the delayed plant parameter class.
**kwargs – Additional keyword arguments are passed to the specialize method for the class.
- Returns:
- Dummy plant parameter class that will access a registered
plant parameter class when it is used to create an instance.
- Return type:
type
- class canopy_factory.crops.base.DistributionPlantParameter(name, param, parent, required=False)[source]¶
Bases:
OptionPlantParameterClass for a distribution.
- classmethod parametrize_dist(values, profile='normal', **kwargs)[source]¶
Parameterize a distribution of values.
- Parameters:
values (pandas.DataFrame, np.ndarray) – Set of values.
profile (str, optional) – Distribution profile that should be parameterized.
**kwargs – Additional keyword arguments are passed to the methods used to determine the distribution parameters.
- Returns:
Set of parameters for the distribution.
- Return type:
tuple
- property profile¶
Distribution profile.
- Type:
str
- classmethod sample_generator_dist(generator, profile='normal', args=None, **kwargs)[source]¶
Sample a distribution using the current random number generator.
- Parameters:
generator (np.random.Generator) – Generator to use.
profile (str) – Name of the profile that should be sampled.
args (tuple, optional) – Positional arguments to pass to the generator method. If not provided, the profile parameters must be provided by kwargs.
**kwargs – Additional keyword arguments are checked for the required profile parameters if args is not provided. Any remaining keyword arguments are passed to the generator method.
- class canopy_factory.crops.base.FlowerComponent(name, param, parent, required=False)[source]¶
Bases:
GeometricComponentBaseFlower component.
- class canopy_factory.crops.base.FruitComponent(name, param, parent, required=False)[source]¶
Bases:
GeometricComponentBaseFruit component.
- class canopy_factory.crops.base.FunctionPlantParameter(name, param, parent, required=False)[source]¶
Bases:
OptionPlantParameterClass for a function.
- property maxvar¶
Variable that contains the maximum value under which the function applies.
- Type:
str
- property minvar¶
Variable that contains the minimum value under which the function applies.
- Type:
str
- property namevar¶
Variable that this function parameter takes as input.
- Type:
str
- normalize(v, func=None)[source]¶
Normalize the independent variable for this function.
- Parameters:
v (object) – Independent variable value to normalize.
- Returns:
Normalized object.
- Return type:
object
- property normvar¶
Variable that should be used to normalize the input.
- Type:
str
- plot(ax, nsample=10)[source]¶
Plot the functional dependence.
- Parameters:
ax (matplotlib.axes.Axes) – Axes to plot in.
nsample (int, optional) – Number of times to sample the function across its range.
- classmethod specialize_var(var, normvar=None, minvar=None, maxvar=None, **kwargs)[source]¶
Created a specialized version of this class.
- Parameters:
var (str) – Name of the variable that the specialized function is dependent on.
normvar (str, optional) – Name of the variable that should be used to normalize the dependent variable.
maxvar (str, optional) – Name of the variable that should be used to cap the values of the dependent variable on which the function should be evaluated.
**kwargs – Additional keyword arguments are passed to the base class’s specialize method.
- class canopy_factory.crops.base.GeometricComponentBase(name, param, parent, required=False)[source]¶
Bases:
ComponentBase,OptionPlantParameterBase class for generating plant component geometries.
- property homomorphism¶
Lsystem homomorphism rule lines.
- Type:
list
- property index_parameters¶
Set of index parameters that this parameter uses.
- Type:
list
- class canopy_factory.crops.base.InternodeComponent(name, param, parent, required=False)[source]¶
Bases:
GeometricComponentBaseInternode component.
- class canopy_factory.crops.base.LeafComponent(name, param, parent, required=False)[source]¶
Bases:
GeometricComponentBaseLeaf component.
- class canopy_factory.crops.base.NodeComponent(name, param, parent, required=False)[source]¶
Bases:
WhorlComponentNode component.
- class canopy_factory.crops.base.OptionPlantParameter(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameterClass for parameter with exclusive options.
- classmethod add_class_defaults(param, **kwargs)[source]¶
Update defaults based on parameters.
- Parameters:
param (ParameterDict) – Parameter set to update.
**kwargs – Additional keyword arguments are added to param.
- classmethod option_parameters(option, unique=False, required=False)[source]¶
Get the set of parameters enabled by an option.
- Parameters:
option (str) – Option value.
unique (bool, optional) – If True, return only those parameters that are unique to the provided option.
- Returns:
Option parameters.
- Return type:
set
- classmethod schema()[source]¶
Create a JSON schema for parsing parameters used by this parameter.
- Returns:
JSON schema.
- Return type:
dict
- classmethod specialize(name, exclude_options=None, **kwargs)[source]¶
Created a specialized version of this class.
- Parameters:
name (str) – Name of the root property for the class.
exclude_options (list, optional) – Set of options to eliminate.
**kwargs – Additional keyword arguments are added as attributes to the resulting class.
- class canopy_factory.crops.base.ParameterCache[source]¶
Bases:
SimpleWrapperContainer for a cache of calculated parameters.
- param¶
Name of parameter being generated.
- Type:
str
- index¶
Index parameters are being generated for.
- Type:
- pop_index()[source]¶
Revert the index to the last index in the stack, discarding the current index.
- Returns:
- Index replaced by the last index in the
stack.
- Return type:
- pop_param()[source]¶
Revert the parameter name to the last name in the stack, discarding the current name.
- Returns:
Parameter name replaced by the last name in the stack.
- Return type:
str
- push_index(idx)[source]¶
Update the index, pushing the current index onto the stack.
- Parameters:
idx (ParameterIndex) – New index.
- push_param(param)[source]¶
Update the parameter name, pushing the current parameter name onto the stack.
- Parameters:
param (str) – New parameter.
- temporary_index(idx)[source]¶
Context with an updated index.
- Parameters:
idx (ParameterIndex) – New index to use within the context.
- temporary_param(param, idx=None)[source]¶
Context with an updated parameter name.
- Parameters:
param (str) – New parameter name to use within the context.
idx (ParameterIndex, optioinal) – New index to use within the context.
- class canopy_factory.crops.base.ParameterCollection(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameterClass for collection of parameters.
- Class Attributes:
_parameters (dict) – Mapping between parameter class names and lists of parameter names that should be included in this collection using that class.
- class canopy_factory.crops.base.ParameterDict(provided=None, **kwargs)[source]¶
Bases:
DictSetClass for managing a set of parameters.
- Parameters:
provided (dict, optional) – Set of user provided parameters.
- add_property_dependency_defaults(cls)[source]¶
Add defaults based on the other properties that are present and the _property_dependencies_defaults attribute of class.
- Parameters:
cls (PlantParameterBase) – Parameter instance that is being updated.
- copy_component_properties(cls)[source]¶
Copy component properties identified by cls.
- Parameters:
cls (PlantParameterBase) – Parameter instance that is being updated.
- copy_external_properties(cls)[source]¶
Copy external properties identified by cls.
- Parameters:
cls (PlantParameterBase) – Parameter instance that is being updated.
- property local_parameters¶
Parameters with the current prefix.
- Type:
dict
- property prefix¶
Current prefix.
- Type:
str
- property storage¶
Destination dictionary for added keys.
- Type:
- temporary_source_prefix(prefix, **kwargs)[source]¶
Temporarily create a context where the source dictionaries have a different prefix than the destination dictionary.
- Parameters:
prefix (str) – Temporary prefix to set for the sources.
**kwargs – Additional keyword arguments are passed to temporary_prefix for each source dictionary.
- Yields:
ParameterDict – Self with temporary prefix applied.
- updating(cls)[source]¶
Context manager for updating the parameters for a class.
- Parameters:
cls (PlantParameterBase) – Parameter instance that is being updated. Default parameters will be added to the current set based on the existing parameters and the class's prefix will be added to the dictionary prefix within the context.
- Yields:
ParameterDict – Self with temporary prefix applied.
- class canopy_factory.crops.base.ParameterIndex(*args, **kwargs)[source]¶
Bases:
SimpleWrapperContainer for index variables.
- Parameters:
time (float, units.Quantity) – Time since planting.
age (float, units.Quantity) – Age.
n (int) – Phytomer number.
b (int) – Branch level.
x (float) – Distance along current component.
w (int) – Index within component whorl.
unit_system (, optional) – Unit system that should be used.
- Class Attributes:
parameter_names (list) – Variables that are used by the index.
- parameter_names = ['Time', 'Age', 'N', 'B', 'X', 'W']¶
- parameter_names_units = {'Age': 'time', 'Time': 'time'}¶
- property tuple¶
Tuple representation of the index.
- Type:
tuple
- universal_param = ['Time', 'Age', 'N', 'B']¶
- class canopy_factory.crops.base.ParameterKey(param=None, idx=None)[source]¶
Bases:
objectContainer for parameter key for caching the current search.
- Parameters:
param (str) – Parameter being generated.
idx (ParameterIndex) – Parameter index.
- class canopy_factory.crops.base.ParameterValues(instance)[source]¶
Bases:
DictSetClass for managing a set of finalized parameter values.
- Parameters:
instance (PlantParameterBase) – Instance responsible for generating a parameter from the member parameters.
- property current_param¶
Current parameter being generated.
- Type:
str
- get(k, default=<class 'canopy_factory.utils.NoDefault'>, return_other=None, return_container=False, **kwargs)[source]¶
Get a parameter value.
- Parameters:
k (str) – Name of parameter to return, without any prefixes.
default (object, optional) – Default to return if the parameter is not set.
return_other (str, optional) – Name of what should be returned instead of the parameter value.
return_container (bool, optional) – If True, return the parameter that contains k.
**kwargs – Additional keyword arguments are passed to any nested calls to get or generate.
- Returns:
Parameter value.
- Return type:
object
- property storage¶
Destination dictionary for added keys.
- Type:
- class canopy_factory.crops.base.PedicelComponent(name, param, parent, required=False)[source]¶
Bases:
PetioleComponentPedicel component.
- class canopy_factory.crops.base.PetioleComponent(name, param, parent, required=False)[source]¶
Bases:
GeometricComponentBasePetiole component.
- class canopy_factory.crops.base.PlantGenerator(param=None, seed=0, verbose=False, verbose_lpy=False, debug=False, debug_param=None, debug_param_prefix=None, unit_system=None, no_class_defaults=False, context=None, **kwargs)[source]¶
Bases:
ParameterCollectionBase class for generating plants.
- Class Attributes:
_plant_name (str) – Name of the plant that this class will generate.
- property crop_class¶
Crop class.
- Type:
str
- property log_prefix_instance¶
Prefix to use for log messages emitted by this instance.
- Type:
str
- property lsystem¶
Lsystem for the generator.
- Type:
str
- class canopy_factory.crops.base.PlantParameterBase(args=None, args_overwrite=None)[source]¶
Bases:
SubparserBaseBase class for managing architecture parameters.
- class canopy_factory.crops.base.ScalarPlantParameter(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameterClass for scalar parameters that will have a spread by default and can have a dependence on age, n, x, or w.
- property index_parameters¶
Set of index parameters that this parameter uses.
- Type:
list
- class canopy_factory.crops.base.SimplePlantParameter(name, param, parent, required=False)[source]¶
Bases:
PlantParameterBaseClass for simple parameters requiring a single value.
- Parameters:
name (str, optional) – Parameter name without prefix.
param (dict, optional) – Parameters (specified via full parameter names with prefixes) that this parameter should take properties from. If not provided and parent is not provided, kwargs will be used.
parent (PlantParameterBase, optional) – Parent parameter that uses this parameter.
defaults (dict, optional) – Defaults (with only this parameter's prefixes) that should be used for parameters missing from param.
seed (int, optional) – Seed that should be used for the random number generator to make geometries reproducible.
verbose (bool, optional) – If True, log messages will be printed describing the generation process.
debug (bool, optional) – If True, pdb break points will be set for debug messages and log messages will be displayed.
debug_param (list, optional) – Parameters (expressed as full names) that debug mode should be turned on for (only exact parameter matches are debugged, not children).
debug_param_prefix (list, optional) – Prefix of parameters that debug mode should be turned on for.
required (bool, optional) – If True, this parameter is required and errors will be raised if it is not fully specified.
**kwargs – Additional keyword arguments are only allowed for root parameters (that don't have a parent) in which case they are treated as param.
- parameters¶
Child parameters used by this parameter.
- Type:
dict
- Class Attributes:
_name (str) – Name that should be used to register the class and be used as the default prefix.
_properties (dict) – Set of properties that control the parameter.
_defaults (dict) – Set of defaults for properties controling the parameter.
_aliases (dict) – Set of aliases mapping between alias names for parameters and the parameters they map to.
_required (list) – Set of properties that are required by this parameter.
_variables (list) – Properties that reference other variables.
_constants (dict) – Properties that should be added to parsed parameters.
_dependencies (list) – Root level properties that this parameter uses.
_subschema_keys (list) – JSON schema properties that contain schemas.
_component_properties (list) – Properties that can be defined for all parameters associated with a component.
_components (list) – Plant components that may be used with _component_properties.
- classmethod add_class_defaults(param, **kwargs)[source]¶
Update defaults based on parameters.
- Parameters:
param (ParameterDict) – Parameter set to update.
**kwargs – Additional keyword arguments are added to param.
- property all_parameters¶
Set of all parameters, including children.
- Type:
dict
- property cache¶
Cache of computed parameters.
- Type:
- property children¶
Child parameter instances.
- Type:
iterable
- property component¶
Component that this property belongs to.
- Type:
- property component_name¶
Name of the component that this property belongs to.
- Type:
str
- property component_parameters¶
Set of variables that this parameter uses from the parent component.
- Type:
list
- property constants_index¶
Set of index variables that this parameter is independent of.
- Type:
list
- property contents¶
The contents of parameters.
- Type:
dict
- property current_index¶
Current parameter index.
- Type:
- property current_param¶
Current parameter being generated.
- Type:
str
- debug(message='', force=False, **kwargs)[source]¶
Set a pdb break point if debugging is active.
- Parameters:
message (str, optional) – Log message to show before setting break point.
force (bool, optional) – If True, the break point will be set even if debugging is not active.
**kwargs – Additional keyword arguments are passed to the log method if it is called.
- property debug_param¶
Parameters that debug mode should be enabled for.
- Type:
list
- property debug_param_prefix¶
Parameters that debug mode should be enabled for.
- Type:
list
- property debugging¶
True if debugging is active.
- Type:
bool
- property dependencies¶
Set of variables that this parameter is dependent on.
- Type:
list
- property dependencies_index¶
Set of index variables that this parameter is dependent on.
- Type:
list
- error(error_cls, message='', debug=False, **kwargs)[source]¶
Raise an error, adding context to the message.
- Parameters:
error_cls (type) – Error class.
message (str, optional) – Error message.
debug (bool, optional) – If True, set a debug break point.
**kwargs – Additional keyword arguments are passed to the parent method.
- property external_parameters¶
Set of variables that this parameter uses from the root generator.
- Type:
list
- property fullname¶
Full name with parent prefix.
- Type:
str
- generate(**kwargs)[source]¶
Generate this parameter, updating the cache as necessary.
- Parameters:
**kwargs – Additional keyword arguments are passed to get and generate calls for nested parameters.
- Returns:
Generated parameter value.
- Return type:
object
- property generator¶
Current random number generator.
- Type:
np.random.Generator
- get(k, default=<class 'canopy_factory.utils.NoDefault'>, **kwargs)[source]¶
Get a parameter value.
- Parameters:
k (str) – Name of parameter to return, without any prefixes.
default (object, optional) – Default to return if the parameter is not set.
**kwargs – Additional keyword arguments are passed to parameters.get.
- Returns:
Parameter value.
- Return type:
object
- classmethod get_class(k, prefix='')[source]¶
Get a parameter class.
- Parameters:
k (str) – Name of parameter to return, without any prefixes.
- Returns:
Parameter class.
- Return type:
- getfull(k, *args, **kwargs)[source]¶
Get a parameter value with the index fully specified as arguments.
- Parameters:
k (str) – Name of parameter to return without any prefixes.
age (float) – Age of the component that the parameter should be returned for.
n (int) – Phytomer count of the component that the parameter should be returned for.
x (float, optional) – Position along the component that the parameter should be returned for.
w (int, optional) – Whorl index of repeated component that the parameter should be returned for.
strip_units (bool, optional) – If True, strip units from quantities after converting to the desired unit system.
**kwargs – Additional keyword arguments are passed to get.
- Returns:
Parameter value.
- Return type:
object
- getold(k, default=<class 'canopy_factory.utils.NoDefault'>, idx=None, cache_key=None, k0=None, return_other=None, **kwargs)[source]¶
Get a parameter value.
- Parameters:
k (str) – Name of parameter to return, without any prefixes.
default (object, optional) – Default to return if the parameter is not set.
idx (ParameterIndex, optional) – Simulation index to get the parameter value for. If not provided, the current index will be used based on the last parameter accessed with an index.
cache_key (tuple, optional) – Key to use to cache any generated values if different than the default.
k0 (str, optional) – Full name of the parameter including any parent prefixes. If not provided, the full name will be created based on the current prefix.
return_other (str, optional) – Name of what should be returned instead of the parameter value.
**kwargs – Additional keyword arguments are passed to any nested calls to get or generate.
- Returns:
Parameter value.
- Return type:
object
- hasmethod(k)[source]¶
Check if there is an explicit method for a parameter.
- Parameters:
k (str) – Parameter name.
- Returns:
True if there is an explicit method, False otherwise.
- Return type:
bool
- property index_parameters¶
Set of index parameters that this parameter uses.
- Type:
list
- initialize_lpy_context(context)[source]¶
Initialize the lpy context for this instance.
- Parameters:
context (lpy.LsysContext) – Context to initialize.
- initialize_lpy_turtle(turtle)[source]¶
Initialize a PglTurtle instance.
- Parameters:
turtle (plantgl.PglTurtle) – Turtle to update.
- property is_debug_param¶
True if this is a parameter being debugged.
- Type:
bool
- classmethod is_enabled(name, param, prefix='', include_defaults=False)[source]¶
Check if a parameter is enabled based on other provided parameters.
- Parameters:
name (str) – Parameter name.
param (dict, object) – Object to retrieve parameter values from.
prefix (str, optional) – Prefix for parameter names.
include_defaults (bool, optional) – Consider defaults when determining if a parameter is enabled.
- Returns:
True if the parameter is enabled, False otherwise.
- Return type:
bool
- property local_index¶
Local parameter index with unused parameters nullified.
- Type:
- log(message='', debug=False, **kwargs)[source]¶
Emit a log message.
- Parameters:
message (str, optional) – Log message.
force (bool, optional) – If True, print the log message even if self.verbose is False.
debug (bool, optional) – If True, set a debug break point if debugging enabled.
**kwargs – Additional keyword arguments are passed to the parent method.
- property log_prefix¶
Prefix to add to messages emitted by this instance.
- Type:
str
- property log_prefix_instance¶
Prefix to use for log messages emitted by this instance.
- Type:
str
- property log_prefix_stack¶
Prefix to use for log messages describing the current stack.
- Type:
str
- lsystem_args(for_rule=False, **kwargs)[source]¶
Get the arguments that should be used for Lsystem rules.
- Parameters:
for_rule (bool, optional) – If True, all parameters are positional.
**kwargs – Additional keyword arguments are checked for increments that should be applied to arguments with keys of the form ‘{name}inc’.
- Returns:
Arguments.
- Return type:
str
- property no_class_defaults¶
- classmethod parameter_names(name, scope='all')[source]¶
Get a list of valid parameter names.
- Parameters:
name (str) – Base name for parameters.
scope (str, optional) –
Scope for parameters that should be returned. Options are:
'all': Return all parameters. 'core': Return parameters only directly allowed by this parameter. 'children': Return parameters only indirectly allowed by child parameters.
- Returns:
Parameter names.
- Return type:
list
- property prefix¶
Prefix that child parameters will have.
- Type:
str
- prefixes(k, use_fullname=False)[source]¶
Check if a string starts with the prefix for this parameter.
- Parameters:
k (str) – String to check.
use_fullname (bool, optional) – If True, the full name should be used as the prefix.
- Returns:
True if k starts with this parameter's prefix.
- Return type:
bool
- remove_prefix(k, use_fullname=False)[source]¶
Remove the current parameter prefix from a string if it matches.
- Parameters:
k (str) – String to remove prefix from.
use_fullname (bool, optional) – If True, the full name should be used as the prefix.
- Returns:
String with the prefix removed.
- Return type:
str
- Raises:
ValueError – If k does not start with the prefix.
- property root¶
Root parameter.
- Type:
- sample_dist(profile, *args, **kwargs)[source]¶
Sample a distribution using the current random number generator.
- Parameters:
profile (str) – Name of the profile that should be sampled.
*args – Additional arguments are passed to the generator method for the specified profile.
**kwargs – Additional keyword arguments are passed to the generator method for the specified profile.
- classmethod schema()[source]¶
Create a JSON schema for parsing parameters used by this parameter.
- Returns:
JSON schema.
- Return type:
dict
- classmethod schema_contains(schema, key, value=None)[source]¶
Check if a schema contains a property corresponding to the provided key.
- Parameters:
schema (dict) – Schema to check.
key (str) – Property to check for.
value (object, optional) – Value associated with the key.
- Returns:
True if schema contains a property for key.
- Return type:
bool
- set(k, value)[source]¶
Set a parameter value.
- Parameters:
k (str) – Name of parameter to set, without any prefixes.
value (object) – Value to set parameter to.
- classmethod specialize(name, exclude=[], **kwargs)[source]¶
Created a specialized version of this class.
- Parameters:
name (str) – Name of the root property for the class.
exclude (list, optional) – Properties that should be excluded.
properties (dict, optional) – Properties that should be added.
defaults (dict, optional) – Defaults that should be added.
property_dependencies (dict, optional) – Property dependencies that should be added.
**kwargs – Additional keyword arguments are added as attributes to the resulting class.
- temporary_index(*args, **kwargs)[source]¶
Context with an updated index.
- Parameters:
*args – Arguments are used to create a ParameterIndex instance for the context.
**kwargs – Keyword arguments are used to create a ParameterIndex instance for the context.
- property variable_parameters¶
Set of external parameters identified by variables.
- Type:
list
- property verbose¶
If True, log messages will be emitted.
- Type:
bool
- class canopy_factory.crops.base.Template1DPlantParameter(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameterClass for loading and scaling a 1D template from a shape file.
- class canopy_factory.crops.base.Template2DPlantParameter(name, param, parent, required=False)[source]¶
Bases:
Template1DPlantParameterClass for loading and scaling a 2D template from a shape file.
- class canopy_factory.crops.base.Template3DPlantParameter(name, param, parent, required=False)[source]¶
Bases:
Template2DPlantParameterClass for loading and scaling a 3D template from a shape file.
- class canopy_factory.crops.base.WhorlComponent(name, param, parent, required=False)[source]¶
Bases:
SimplePlantParameter- property component¶
Component that this property belongs to.
- Type:
str
- property homomorphism¶
Lsystem homomorphism rule lines.
- Type:
list
- property production¶
Lsystem production rule lines.
- Type:
list
canopy_factory.crops.dicot module¶
- class canopy_factory.crops.dicot.DicotGenerator(param=None, seed=0, verbose=False, verbose_lpy=False, debug=False, debug_param=None, debug_param_prefix=None, unit_system=None, no_class_defaults=False, context=None, **kwargs)[source]¶
Bases:
PlantGeneratorClass for generating generic dicot plant geometries.
canopy_factory.crops.maize module¶
- class canopy_factory.crops.maize.MaizeGenerator(**kwargs)[source]¶
Bases:
MonocotGeneratorClass for generating maize plant geometries.
canopy_factory.crops.monocot module¶
- class canopy_factory.crops.monocot.MonocotGenerator(**kwargs)[source]¶
Bases:
PlantGeneratorClass for generating generic monocot plant geometries.
- property unfurl_leaves¶
True if LeafUnfurled set.
- Type:
bool
- update_curve_param(k, other_param, other_is_end=False, patch_param=None)[source]¶
Update a curve parameter to use a patch.
- Parameters:
k (str) – Curve parameter.
other_param (dict) – Parameters for new curve use to create the patch.
other_is_end (bool, optional) – If True, the existing curve is treated as the starting curve and the other_param are used for the end curve.
patch_param (dict, optional) – Patch specific parameters that should be used for the new patch (with non-prefixed patch parameters as keys).
canopy_factory.crops.tomato module¶
- class canopy_factory.crops.tomato.TomatoGenerator(param=None, seed=0, verbose=False, verbose_lpy=False, debug=False, debug_param=None, debug_param_prefix=None, unit_system=None, no_class_defaults=False, context=None, **kwargs)[source]¶
Bases:
DicotGeneratorClass for generating tomato plant geometries.