diff --git a/src/Persefone.jl b/src/Persefone.jl index af2b38fdabe09670a594e93efe37bab614e1c2dc..12e1fafe252c2bfa96b1d79bf06cd3978f4d97a9 100644 --- a/src/Persefone.jl +++ b/src/Persefone.jl @@ -100,12 +100,13 @@ export loadmodelobject ## Import and define units and dimensions -import Unitful: cm, m, km, ha, Length, Area +import Unitful: cm, m, km, ha, mg, g, kg, Length, Area, Mass const m² = m^2 const km² = km^2 import Base./ # enable division with different length/area unit types /(x::S,y::T) where {S<:Length, T<:Length} = (upreferred(x)/m) / (upreferred(y)/m) /(x::S,y::T) where {S<:Area, T<:Area} = (upreferred(x)/m²) / (upreferred(y)/m²) +/(x::S,y::T) where {S<:Mass, T<:Mass} = (upreferred(x)/g) / (upreferred(y)/g) """ SimulationModel diff --git a/src/nature/insects.jl b/src/nature/insects.jl index d9c156d95747d66d2a9f98338dc614122bdeb105..b8c830644e656033d2f62291dade07fb91a9e1c2 100644 --- a/src/nature/insects.jl +++ b/src/nature/insects.jl @@ -28,8 +28,8 @@ function insectbiomass(pixel::Pixel, model::SimulationModel)::Float64 ## if no factors are configured, insect abundance defaults to 300 mg/m², ## a value in the upper range of insect biomass density in agricultural landscapes - baseline = 300 - seasonfactor = 0.0 + baseline = 300mg/m² + seasonfactor = 0.0mg/m² habitatfactor = 1.0 weatherfactor = 1.0 pesticidefactor = 1.0 @@ -73,5 +73,5 @@ function insectbiomass(pixel::Pixel, model::SimulationModel)::Float64 ## calculate biomass using a parabolic equation in the vertex form biomass = seasonfactor+baseline*habitatfactor*pesticidefactor*weatherfactor - biomass > 0 ? biomass/1000 : 0.0 # convert mg to g + biomass > 0mg/m² ? biomass |> g/m² : 0.0g/m² # convert mg to g end