Skip to content
Snippets Groups Projects
Commit a3ce5121 authored by xo30xoqa's avatar xo30xoqa
Browse files

Renamed EventType to Management

parent 04b3efec
Branches
Tags
No related merge requests found
...@@ -22,7 +22,7 @@ mutable struct FarmPlot <: ModelAgent ...@@ -22,7 +22,7 @@ mutable struct FarmPlot <: ModelAgent
LAItotal::Float64 LAItotal::Float64
LAIgreen::Float64 LAIgreen::Float64
#biomass::Float64 #XXX I need to figure out how to calculate this #biomass::Float64 #XXX I need to figure out how to calculate this
events::Vector{EventType} events::Vector{Management}
end end
""" """
...@@ -50,7 +50,7 @@ function initfields!(model::SimulationModel) ...@@ -50,7 +50,7 @@ function initfields!(model::SimulationModel)
month(model.date) < 3 ? phase = janfirst : phase = marchfirst month(model.date) < 3 ? phase = janfirst : phase = marchfirst
fp = FarmPlot(length(model.farmplots)+1, [(x,y)], fp = FarmPlot(length(model.farmplots)+1, [(x,y)],
model.crops["natural grass"], phase, model.crops["natural grass"], phase,
0.0, 0.0, 0.0, 0.0, Vector{EventType}()) 0.0, 0.0, 0.0, 0.0, Vector{Management}())
push!(model.farmplots, fp) push!(model.farmplots, fp)
model.landscape[x,y].fieldid = fp.id model.landscape[x,y].fieldid = fp.id
convertid[rawid] = fp.id convertid[rawid] = fp.id
......
...@@ -38,7 +38,7 @@ function insectbiomass(pixel::Pixel, model::SimulationModel)::Float64 ...@@ -38,7 +38,7 @@ function insectbiomass(pixel::Pixel, model::SimulationModel)::Float64
## based on fig. 3a in Paquette et al. (2013) ## based on fig. 3a in Paquette et al. (2013)
if "season" in @param(nature.insectmodel) if "season" in @param(nature.insectmodel)
calendarday = dayofyear(model.date) calendarday = dayofyear(model.date)
seasonfactor = -0.085(calendarday-187)^2 seasonfactor = (-0.085(calendarday-187)^2)mg/
end end
## habitat dependence of insect biomass, ## habitat dependence of insect biomass,
......
...@@ -31,9 +31,9 @@ At the moment, this implementation is still in development. ...@@ -31,9 +31,9 @@ At the moment, this implementation is still in development.
""" """
@species Skylark begin @species Skylark begin
# species parameters # species parameters
const eggtime::Int64 = 11 # 11 days from laying to hatching const eggtime::Int64 = 11 # days from laying to hatching
const nestlingtime::UnitRange{Int64} = 7:11 # 7-11 days from hatching to leaving nest const nestlingtime::UnitRange{Int64} = 7:11 # days from hatching to leaving nest
const fledglingtime::UnitRange{Int64} = 25:30 # 25-30 days from hatching to independence const fledglingtime::UnitRange{Int64} = 25:30 # days from hatching to independence
const eggpredationmortality::Float64 = 0.03 # per-day egg mortality from predation const eggpredationmortality::Float64 = 0.03 # per-day egg mortality from predation
const nestharvestmortality::Float64 = 0.9 # egg/nestling mortality after a harvest event (XXX guess) const nestharvestmortality::Float64 = 0.9 # egg/nestling mortality after a harvest event (XXX guess)
...@@ -45,8 +45,8 @@ At the moment, this implementation is still in development. ...@@ -45,8 +45,8 @@ At the moment, this implementation is still in development.
const nestingbegin::Tuple{Int64,Int64} = (April, 10) # begin nesting in the middle of April const nestingbegin::Tuple{Int64,Int64} = (April, 10) # begin nesting in the middle of April
const nestbuildingtime::UnitRange{Int64} = 4:5 # 4-5 days needed to build a nest (doubled for first nest) const nestbuildingtime::UnitRange{Int64} = 4:5 # 4-5 days needed to build a nest (doubled for first nest)
const eggsperclutch::UnitRange{Int64} = 2:5 # 2-5 eggs laid per clutch const eggsperclutch::UnitRange{Int64} = 2:5 # eggs laid per clutch
const breedingdelay::Int64 = 18 # wait 18 days after hatching to start a new brood const breedingdelay::Int64 = 18 # days after hatching before starting a new brood
const nestingend::Int64 = July # last month of nesting const nestingend::Int64 = July # last month of nesting
const habitats::Function = skylarkhabitat const habitats::Function = skylarkhabitat
...@@ -221,11 +221,14 @@ Do lots of foraging (not yet implemented). ...@@ -221,11 +221,14 @@ Do lots of foraging (not yet implemented).
# if all young have fledged, move to nonbreeding (if it's July) or breed again # if all young have fledged, move to nonbreeding (if it's July) or breed again
if isempty(self.clutch) if isempty(self.clutch)
self.nest = () self.nest = ()
month(model.date) >= self.nestingend ? if month(model.date) >= self.nestingend
@setphase(nonbreeding) : self.territory = []
@setphase(nonbreeding)
else
@setphase(nestbuilding) @setphase(nestbuilding)
end end
end end
end
""" """
migrationdates(skylark, model) migrationdates(skylark, model)
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
"The land cover classes encoded in the Mundialis Sentinel data." "The land cover classes encoded in the Mundialis Sentinel data."
@enum LandCover nodata forest grass water builtup soil agriculture @enum LandCover nodata forest grass water builtup soil agriculture
"The types of landscape event that can be simulated" "The types of management event that can be simulated"
@enum EventType tillage sowing fertiliser pesticide harvesting @enum Management tillage sowing fertiliser pesticide harvesting
#XXX rename to Management or similar? #XXX rename to Management or similar?
""" """
...@@ -21,7 +21,7 @@ in a single object. The model landscape consists of a matrix of pixels. ...@@ -21,7 +21,7 @@ in a single object. The model landscape consists of a matrix of pixels.
mutable struct Pixel mutable struct Pixel
landcover::LandCover landcover::LandCover
fieldid::Union{Missing,Int64} fieldid::Union{Missing,Int64}
events::Vector{EventType} events::Vector{Management}
animals::Vector{Int64} animals::Vector{Int64}
end end
...@@ -32,7 +32,7 @@ A data structure to define a landscape event, giving its type, ...@@ -32,7 +32,7 @@ A data structure to define a landscape event, giving its type,
spatial extent, and duration. spatial extent, and duration.
""" """
mutable struct FarmEvent mutable struct FarmEvent
etype::EventType management::Management
pixels::Vector{Tuple{Int64,Int64}} pixels::Vector{Tuple{Int64,Int64}}
duration::Int64 duration::Int64
end end
...@@ -82,7 +82,7 @@ function updateevents!(model::SimulationModel) ...@@ -82,7 +82,7 @@ function updateevents!(model::SimulationModel)
if event.duration <= 0 if event.duration <= 0
push!(expiredevents, e) push!(expiredevents, e)
for p in event.pixels for p in event.pixels
i = findnext(x -> x == event.etype, model.landscape[p...].events, 1) i = findnext(x -> x == event.management, model.landscape[p...].events, 1)
deleteat!(model.landscape[p...].events, i) deleteat!(model.landscape[p...].events, i)
end end
end end
...@@ -96,7 +96,7 @@ end ...@@ -96,7 +96,7 @@ end
Add a farm event to the specified pixels (a vector of position tuples) for a given duration. Add a farm event to the specified pixels (a vector of position tuples) for a given duration.
""" """
function createevent!(model::SimulationModel, pixels::Vector{Tuple{Int64,Int64}}, function createevent!(model::SimulationModel, pixels::Vector{Tuple{Int64,Int64}},
name::EventType, duration::Int64=1) name::Management, duration::Int64=1)
push!(model.events, FarmEvent(name, pixels, duration)) push!(model.events, FarmEvent(name, pixels, duration))
for p in pixels for p in pixels
push!(model.landscape[p...].events, name) push!(model.landscape[p...].events, name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment