Create a MizerParams object using the extension template
Source:R/constructor.R
newExtensionTemplateParams.RdThis constructor demonstrates all five extension mechanisms available in mizer. Read the inline comments to understand what each block does and how to adapt it for your own extension.
Usage
newExtensionTemplateParams(
species_params,
season_amplitude = 0.2,
extra_food_coef = 0.1,
background_mort_coef = 0.05,
plankton_rate = 0.5,
info_level = default_info_level(),
...
)Arguments
- species_params
A data frame of species parameters passed directly to
mizer::newMultispeciesParams().- season_amplitude
Amplitude of the sinusoidal seasonal variation in the encounter rate, as a fraction of the base rate.
0disables the effect; the default0.2gives ±20 % variation over the year.- extra_food_coef
Coefficient for the allometric extra food source added via
setExtEncounter(). Set to0to disable.- background_mort_coef
Coefficient for background mortality added via
setExtMort(). Set to0to disable.- plankton_rate
Intrinsic growth rate of the plankton component (yr⁻¹). Higher values make the plankton respond faster to depletion.
- info_level
How much
mizer::newMultispeciesParams()should say about the defaults it fills in, forwarded unchanged. This template defaults to0only to keep its own examples quiet; your own constructor will usually wantinfo_level = default_info_level(), mizer's exported default, so that it follows themizer_info_leveloption as mizer's own constructors do. Either way, take the argument explicitly rather than hard-coding a value in the call, or a user passinginfo_levelwould hit "formal argument \"info_level\" matched by multiple actual arguments".- ...
Additional arguments passed to
mizer::newMultispeciesParams().
Details
Extension mechanisms demonstrated
setExtEncounter()/setExtMort()— add fixed, species × size arrays to encounter or mortality without any dynamics.project*S3 method — seasonal encounter multiplier implemented inprojectEncounter.mizerExtensionTemplate(), replacing thesetRateFunction()approach.setComponent()— a dynamical plankton component with its own time-evolution and an encounter contribution. Defined incomponent-functions.R.S3 generic overrides —
getBiomass.mizerExtensionTemplate()andgetBiomass.mizerExtensionTemplateSim()add the plankton biomass to the standard output.signal_info()/with_info_level()— reporting a choice made on the user's behalf through mizer's own mechanism, so that it obeysinfo_leveland themizer_info_leveloption along with everything else mizer says. See the block at the end of this function.
Metadata-only vs. dispatching extensions
This constructor creates a dispatching extension: the returned object
has class "mizerExtensionTemplate" so that mizer's generic functions
dispatch to the S3 methods defined in this package. No class declaration or
load hook is needed. recordExtension() adds this extension to the object's
own metadata, and coerceToExtensionClass() builds the ordinary S3 class
vector from that record. For a metadata-only extension (one that does
not override any generic), omit the coerceToExtensionClass() call but keep
the recordExtension() call so the dependency remains reproducible.