From 04b3efec254670d9f7248856d515ee2fc39106cb Mon Sep 17 00:00:00 2001 From: Daniel Vedder <daniel.vedder@idiv.de> Date: Fri, 14 Jun 2024 09:56:44 +0200 Subject: [PATCH] Added units to insectbiomass() --- src/Persefone.jl | 3 ++- src/nature/insects.jl | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Persefone.jl b/src/Persefone.jl index af2b38f..12e1faf 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 d9c156d..b8c8306 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 -- GitLab