diff --git a/src/core/simulation.jl b/src/core/simulation.jl index 05158aa6590a6e4bcc38941ca6332d45f734b778..b94b521339fd041f63deb044c3b9a94814f830ba 100644 --- a/src/core/simulation.jl +++ b/src/core/simulation.jl @@ -21,7 +21,7 @@ mutable struct AgricultureModel <: SimulationModel date::Date landscape::Matrix{Pixel} weather::Dict{Date,Weather} - crops::Dict{String,CropType} + crops::Dict{String,ALMaSS.CropType} farmers::Vector{Farmer} farmplots::Vector{FarmPlot} animals::Vector{Union{Animal,Nothing}} @@ -117,8 +117,8 @@ function initmodel(settings::Dict{String, Any}) settings["world.weatherfile"]), settings["core.startdate"], settings["core.enddate"]) - crops = readcropparameters(settings["crop.cropfile"], - settings["crop.growthfile"]) + crops = ALMaSS.readcropparameters(settings["crop.cropfile"], + settings["crop.growthfile"]) model = AgricultureModel(settings, StableRNG(settings["core.seed"]), logger, diff --git a/src/crop/crops.jl b/src/crop/crops.jl index 996c6dabd0187189e6dd701e62669598003f4f63..3b4ce0c8b04f55877e06da5ca4836eb535b37aa7 100644 --- a/src/crop/crops.jl +++ b/src/crop/crops.jl @@ -5,6 +5,10 @@ #TODO write tests for input functions +module ALMaSS +using Dates: Date +using CSV: CSV + """ GrowthPhase @@ -119,3 +123,5 @@ function readcropparameters(generalcropfile::String, growthfile::String) end croptypes end + +end # module ALMaSS diff --git a/src/crop/farmplot.jl b/src/crop/farmplot.jl index 359c0c00d53ac50f5614f8cd71f8f3a7faf5ffad..5d95d2f7912c310ee86b1539d1b7b6a23177b4a9 100644 --- a/src/crop/farmplot.jl +++ b/src/crop/farmplot.jl @@ -15,8 +15,8 @@ mutable struct FarmPlot <: ModelAgent #TODO add Unitful const id::Int64 pixels::Vector{Tuple{Int64, Int64}} - croptype::CropType - phase::GrowthPhase + croptype::ALMaSS.CropType + phase::ALMaSS.GrowthPhase growingdegreedays::Float64 height::Float64 LAItotal::Float64 @@ -47,7 +47,7 @@ function initfields!(model::SimulationModel) push!(model.farmplots[objectid].pixels, (x,y)) else #XXX does this phase calculation work out? - month(model.date) < 3 ? phase = janfirst : phase = marchfirst + month(model.date) < 3 ? phase = ALMaSS.janfirst : phase = ALMaSS.marchfirst fp = FarmPlot(length(model.farmplots)+1, [(x,y)], model.crops["natural grass"], phase, 0.0, 0.0, 0.0, 0.0, Vector{Management}()) @@ -75,8 +75,8 @@ function stepagent!(farmplot::FarmPlot, model::SimulationModel) gdd = (maxtemp(model)+mintemp(model))/2 - basetemp gdd > 0 && (farmplot.growingdegreedays += gdd) # update the phase on key dates - monthday(model.date) == (1,1) && (farmplot.phase = janfirst) - monthday(model.date) == (3,1) && (farmplot.phase = marchfirst) + monthday(model.date) == (1,1) && (farmplot.phase = ALMaSS.janfirst) + monthday(model.date) == (3,1) && (farmplot.phase = ALMaSS.marchfirst) # update crop growth growcrop!(farmplot, model) end diff --git a/src/farm/farm.jl b/src/farm/farm.jl index 391b825997502a7fc290c91e4b5b036b753a0adc..ef3d34c89d60bcd794b285f2109da920eb2e890f 100644 --- a/src/farm/farm.jl +++ b/src/farm/farm.jl @@ -13,7 +13,7 @@ mutable struct Farmer <: ModelAgent # farm submodels? (#69) const id::Int64 fields::Vector{FarmPlot} - croprotation::Vector{CropType} + croprotation::Vector{ALMaSS.CropType} #TODO add AES end diff --git a/test/nature_tests.jl b/test/nature_tests.jl index afeab5ea92b0168c134ade932923350d7ec47bef..9f7d11e77bfab03ab796d58aae5b6072af99cd61 100644 --- a/test/nature_tests.jl +++ b/test/nature_tests.jl @@ -49,7 +49,7 @@ end) # end eval model = inittestmodel() model.landscape[6,6] = Pixel(Ps.agriculture, 1) push!(model.farmplots, - FarmPlot(1, [(6,6)], model.crops["winter wheat"], Ps.janfirst, + FarmPlot(1, [(6,6)], model.crops["winter wheat"], Ps.ALMaSS.janfirst, 0.0, 0.0, 0.0, 0.0, Vector{Ps.Management}())) push!(model.animals, Ps.Mermaid(1, Ps.male, (-1,-1), (3,3), Ps.life), diff --git a/test/runtests.jl b/test/runtests.jl index b36a792bd36b7795f1efbe3a8603a2f5c41c63e0..39aef77f760f8f002b0e9541d5d1cfc15d972e78 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -43,8 +43,8 @@ function inittestmodel(smallmap=true) TESTSETTINGS["world.weatherfile"]), TESTSETTINGS["core.startdate"], TESTSETTINGS["core.enddate"]) - crops = Ps.readcropparameters(TESTSETTINGS["crop.cropfile"], - TESTSETTINGS["crop.growthfile"]) + crops = Ps.ALMaSS.readcropparameters(TESTSETTINGS["crop.cropfile"], + TESTSETTINGS["crop.growthfile"]) model = AgricultureModel(TESTSETTINGS, StableRNG(TESTSETTINGS["core.seed"]), global_logger(),