Seasonal encounter rate for the extension template
Source:R/rate-methods.R
projectEncounter.mizerExtensionTemplate.RdApplies a sinusoidal seasonal multiplier on top of the encounter rate computed by lower extensions and the base mizer calculation.
Usage
# S3 method for class 'mizerExtensionTemplate'
projectEncounter(params, n, n_pp, n_other, t = 0, ...)Arguments
- params
A MizerParams object of class
"mizerExtensionTemplate".- n
Species abundance matrix (species × size).
- n_pp
Resource abundance vector (full size grid).
- n_other
Named list of other component states.
- t
Current simulation time (years). The seasonal multiplier is
1 + amplitude * sin(2π t), which peaks att = 0.25and troughs att = 0.75.- ...
Additional arguments passed through the dispatch chain.
Details
This method replaces the setRateFunction() approach used in single-user
scripts. It participates in the S3 dispatch chain so that multiple loaded
extension packages can each modify the encounter rate without overwriting
one another.
Why project* methods instead of setRateFunction()
setRateFunction(params, "Encounter", "myFn") stores a single function
name per rate. If two extension packages both call it for the same rate,
the second silently overwrites the first. S3 dispatch via project*
methods avoids this: each extension defines a method for its own marker
class and calls NextMethod() to pass control down the chain.
Rules for every project* method
Always call
NextMethod()— omitting it silently drops all contributions from lower extensions and the base mizer calculation.Keep the same argument signature as the generic and include
...so extra arguments pass through to lower methods.Do not call
setRateFunction()in your constructor for any rate handled by aproject*method in this package.