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

Added units to insectbiomass()

parent b5189ba0
No related branches found
No related tags found
No related merge requests found
......@@ -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^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)/) / (upreferred(y)/)
/(x::S,y::T) where {S<:Mass, T<:Mass} = (upreferred(x)/g) / (upreferred(y)/g)
"""
SimulationModel
......
......@@ -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/
seasonfactor = 0.0mg/
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/ ? biomass |> g/ : 0.0g/ # convert mg to g
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment