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

Various bug fixes

parent dd85cba2
No related branches found
No related tags found
No related merge requests found
......@@ -14,4 +14,4 @@ changes in farm operations (e.g. through policy changes in the CAP) influence bi
The model is open-source software available on
[Gitlab](https://git.idiv.de/persefone/persefone-model).
*This documentation was last updated on 2025-03-18 for **Persefone.jl v0.7.0** (commit [b1802d1](https://git.idiv.de/persefone/persefone-model/-/commit/b1802d1)).*
*This documentation was last updated on 2025-06-05 for **Persefone.jl v0.7.0** (commit [838cdff](https://git.idiv.de/persefone/persefone-model/-/commit/838cdff)).*
......@@ -179,8 +179,9 @@ include("nature/populations.jl")
include("nature/individuals.jl")
include("nature/ecologicaldata.jl")
include("nature/species/skylark.jl")
include("nature/species/wolpertinger.jl")
include("nature/species/wyvern.jl")
include("nature/species/marbled_white.jl")
#include("nature/species/wolpertinger.jl")
#include("nature/species/wyvern.jl")
include("analysis/makieplots.jl")
......
......@@ -72,8 +72,6 @@ better testing.
"""
function initpopulation!(species::Type, p::PopInitParams, model::SimulationModel)
#XXX this is a pretty complicated function - can we make it simpler?
(p.popsize <= 0 && p.indarea <= 0) && # can be legit if a habitat descriptor is provided
@warn("initpopulation!() called with popsize and indarea both <= 0")
(p.popsize > 0 && p.indarea > 0) && #XXX not sure what this would do
@warn("initpopulation!() called with popsize and indarea both > 0")
# create as many individuals as necessary in the landscape
......@@ -94,9 +92,9 @@ function initpopulation!(species::Type, p::PopInitParams, model::SimulationModel
n += initindividuals!(species, (x,y), p, model)
end
#XXX break randomly to avoid initialising all individuals in a single column?
# Break if a popsize was specified and has been exceeded
(p.popsize > 0 && n >= p.popsize) && break
end
(p.popsize > 0 && n >= p.popsize) && break
end
if lastn == n # prevent an infinite loop - we don't have a Cray...
@warn "There are not enough suitable locations for $(speciesof(species)) in the landscape."
......
......@@ -147,7 +147,7 @@ weather data.
optimality = bounds(1 - (abs(opttemp-@maxtemp()) / (opttemp-self.mintemp)))
stepsremaining::Int64 = Int(round(self.maxstepsperday*optimality))
eggsremaining::Int64 = self.maxeggsperday
if @maxtemp < opttemp || @maxtemp > self.maxtemp
if @maxtemp() < opttemp || @maxtemp() > self.maxtemp
eggsremaining = Int(round(self.maxeggsperday*optimality))
end
# movement
......@@ -232,9 +232,9 @@ random, but I don't have data for that.)
@randn(self.pupatime), @randn(self.adulttime)]
# check whether eclosure is during the flight period, change the larval time if not
if self.enforceflyingperiod
eclose = birthdate + Day(sum(self.daysinphase))
eclose = self.birthdate + Day(sum(self.daysinphase))
if eclose < self.earliesteclosure
diff = self.earliesteclosure - eclose
diff = @thisyear(self.earliesteclosure) - eclose
self.daysinphase[2] += diff.value
@debug("Increased larval time by $(diff) to stay in flying period.")
elseif eclose > self.latesteclosure
......
......@@ -38,7 +38,7 @@ fieldoutfreq = "daily" # output frequency for crop/field data, daily/monthly/yea
[nature]
#targetspecies = ["Wolpertinger", "Wyvern"] # list of target species to simulate - example species
#targetspecies = [] # XXX disable all species for farm model testing
targetspecies = ["Skylark"] # list of target species to simulate
targetspecies = ["MarbledWhite"] #["Skylark"] # list of target species to simulate
#popoutfreq = "never" # output frequency population-level data, daily/monthly/yearly/end/never
#indoutfreq = "never" # output frequency individual-level data, daily/monthly/yearly/end/never
popoutfreq = "daily" # output frequency population-level data, daily/monthly/yearly/end/never
......
......@@ -141,8 +141,8 @@ end
Return the average windspeed in m/s on `date`.
"""
windspeed(weather::Weather, date::Date) = weather.windspeed[daynumber(weather, date)]
windspeed(model::AgricultureModel, date::Date) = windspeed(model.weather, date)
windspeed(model::AgricultureModel) = windspeed(model, model.date)
windspeed(model::SimulationModel, date::Date) = windspeed(model.weather, date)
windspeed(model::SimulationModel) = windspeed(model, model.date)
"""
precipitation(weather, date)
......@@ -152,8 +152,8 @@ windspeed(model::AgricultureModel) = windspeed(model, model.date)
Return the total precipitation in mm on `date`.
"""
precipitation(weather::Weather, date::Date) = weather.precipitation[daynumber(weather, date)]
precipitation(model::AgricultureModel, date::Date) = precipitation(model.weather, date)
precipitation(model::AgricultureModel) = precipitation(model, model.date)
precipitation(model::SimulationModel, date::Date) = precipitation(model.weather, date)
precipitation(model::SimulationModel) = precipitation(model, model.date)
"""
sunshine(weather, date)
......@@ -163,8 +163,8 @@ precipitation(model::AgricultureModel) = precipitation(model, model.date)
Return the sunshine duration in hours on `date`.
"""
sunshine(weather::Weather, date::Date) = weather.sunshine[daynumber(weather, date)]
sunshine(model::AgricultureModel, date::Date) = sunshine(model.weather, date)
sunshine(model::AgricultureModel) = sunshine(model, model.date)
sunshine(model::SimulationModel, date::Date) = sunshine(model.weather, date)
sunshine(model::SimulationModel) = sunshine(model, model.date)
"""
cloudcover(weather, date)
......@@ -174,8 +174,8 @@ sunshine(model::AgricultureModel) = sunshine(model, model.date)
Return the average cloudcover in eigths on `date`.
"""
cloudcover(weather::Weather, date::Date) = weather.cloudcover[daynumber(weather, date)]
cloudcover(model::AgricultureModel, date::Date) = cloudcover(model.weather, date)
cloudcover(model::AgricultureModel) = cloudcover(model, model.date)
cloudcover(model::SimulationModel, date::Date) = cloudcover(model.weather, date)
cloudcover(model::SimulationModel) = cloudcover(model, model.date)
"""
humidity(weather, date)
......@@ -185,8 +185,8 @@ cloudcover(model::AgricultureModel) = cloudcover(model, model.date)
Return today's average vapour pressure in %.
"""
humidity(weather::Weather, date::Date) = weather.humidity[daynumber(weather, date)]
humidity(model::AgricultureModel, date::Date) = humidity(model.weather, date)
humidity(model::AgricultureModel) = humidity(model, model.date)
humidity(model::SimulationModel, date::Date) = humidity(model.weather, date)
humidity(model::SimulationModel) = humidity(model, model.date)
"""
meantemp(weather, date)
......@@ -196,8 +196,8 @@ humidity(model::AgricultureModel) = humidity(model, model.date)
Return the mean temperature in °C on `date`.
"""
meantemp(weather::Weather, date::Date) = weather.meantemp[daynumber(weather, date)]
meantemp(model::AgricultureModel, date::Date) = meantemp(model.weather, date)
meantemp(model::AgricultureModel) = meantemp(model, model.date)
meantemp(model::SimulationModel, date::Date) = meantemp(model.weather, date)
meantemp(model::SimulationModel) = meantemp(model, model.date)
"""
maxtemp(weather, date)
......@@ -207,8 +207,8 @@ meantemp(model::AgricultureModel) = meantemp(model, model.date)
Return the maximum temperature in °C on `date`.
"""
maxtemp(weather::Weather, date::Date) = weather.maxtemp[daynumber(weather, date)]
maxtemp(model::AgricultureModel, date::Date) = maxtemp(model.weather, date)
maxtemp(model::AgricultureModel) = maxtemp(model, model.date)
maxtemp(model::SimulationModel, date::Date) = maxtemp(model.weather, date)
maxtemp(model::SimulationModel) = maxtemp(model, model.date)
"""
mintemp(weather, date)
......@@ -218,8 +218,8 @@ maxtemp(model::AgricultureModel) = maxtemp(model, model.date)
Return the minimum temperature in °C on `date`.
"""
mintemp(weather::Weather, date::Date) = weather.mintemp[daynumber(weather, date)]
mintemp(model::AgricultureModel, date::Date) = mintemp(model.weather, date)
mintemp(model::AgricultureModel) = mintemp(model, model.date)
mintemp(model::SimulationModel, date::Date) = mintemp(model.weather, date)
mintemp(model::SimulationModel) = mintemp(model, model.date)
"""
evapotranspiration(weather, date)
......@@ -229,5 +229,5 @@ mintemp(model::AgricultureModel) = mintemp(model, model.date)
Return the potential evapotranspiration (ETo) on `date`.
"""
evapotranspiration(weather::Weather, date::Date) = weather.evapotranspiration[daynumber(weather, date)]
evapotranspiration(model::AgricultureModel, date::Date) = evapotranspiration(model.weather, date)
evapotranspiration(model::AgricultureModel) = evapotranspiration(model, model.date)
evapotranspiration(model::SimulationModel, date::Date) = evapotranspiration(model.weather, date)
evapotranspiration(model::SimulationModel) = evapotranspiration(model, model.date)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment