Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
60dc9894
Commit
60dc9894
authored
2 months ago
by
Marco Matthies
Browse files
Options
Downloads
Patches
Plain Diff
Simple linear height estimation
parent
79c11757
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/crop/aquacrop.jl
+14
-1
14 additions, 1 deletion
src/crop/aquacrop.jl
test/crop_tests.jl
+3
-1
3 additions, 1 deletion
test/crop_tests.jl
with
17 additions
and
2 deletions
src/crop/aquacrop.jl
+
14
−
1
View file @
60dc9894
...
@@ -5,9 +5,11 @@ module AquaCropWrapper
...
@@ -5,9 +5,11 @@ module AquaCropWrapper
const
CROPFILE
=
"crop_data.csv"
const
CROPFILE
=
"crop_data.csv"
import
AquaCrop
import
AquaCrop
using
AquaCrop
:
ton
import
CSV
import
CSV
using
Dates
:
Date
using
Dates
:
Date
using
DataFrames
:
DataFrame
using
DataFrames
:
DataFrame
using
Unitful
:
@u_str
using
Persefone
:
using
Persefone
:
AbstractCropState
,
AbstractCropState
,
...
@@ -183,7 +185,13 @@ end
...
@@ -183,7 +185,13 @@ end
croptype
(
cs
::
CropState
)
=
cs
.
croptype
croptype
(
cs
::
CropState
)
=
cs
.
croptype
cropname
(
cs
::
CropState
)
=
cropname
(
croptype
(
cs
))
cropname
(
cs
::
CropState
)
=
cropname
(
croptype
(
cs
))
cropheight
(
cs
::
CropState
)
=
cs
.
height
# TODO: calculate from AquaCrop state info
function
cropheight
(
cs
::
CropState
)
biomass
=
get_aquacrop_biomass
(
cs
)
# TODO: linear model, fixed params
a
=
20
cm
b
=
18
u
"cm * ha"
/
ton
return
a
+
b
*
biomass
end
cropcover
(
cs
::
CropState
)
=
AquaCrop
.
canopycover
(
cs
.
cropstate
)
cropcover
(
cs
::
CropState
)
=
AquaCrop
.
canopycover
(
cs
.
cropstate
)
cropyield
(
cs
::
CropState
)
=
AquaCrop
.
dryyield
(
cs
.
cropstate
)
# TODO: there is also freshyield
cropyield
(
cs
::
CropState
)
=
AquaCrop
.
dryyield
(
cs
.
cropstate
)
# TODO: there is also freshyield
function
isharvestable
(
cs
::
CropState
)
function
isharvestable
(
cs
::
CropState
)
...
@@ -204,6 +212,11 @@ function get_aquacrop_stage(cs::CropState)
...
@@ -204,6 +212,11 @@ function get_aquacrop_stage(cs::CropState)
length
(
stages
)
>
0
?
last
(
stages
)
:
missing
length
(
stages
)
>
0
?
last
(
stages
)
:
missing
end
end
function
get_aquacrop_biomass
(
cs
::
CropState
)
biomasses
=
cs
.
cropstate
.
dayout
.
Biomass
length
(
biomasses
)
>
0
?
last
(
biomasses
)
:
missing
end
"""
"""
stepagent!(cropstate, model)
stepagent!(cropstate, model)
...
...
This diff is collapsed.
Click to expand it.
test/crop_tests.jl
+
3
−
1
View file @
60dc9894
...
@@ -70,7 +70,9 @@ end
...
@@ -70,7 +70,9 @@ end
@test
fp
.
cropstate
isa
PsAC
.
CropState
@test
fp
.
cropstate
isa
PsAC
.
CropState
@test
croptype
(
fp
)
isa
PsAC
.
CropType
@test
croptype
(
fp
)
isa
PsAC
.
CropType
@test
cropname
(
fp
)
isa
String
@test
cropname
(
fp
)
isa
String
@test
cropheight
(
fp
)
isa
Length
{
Float64
}
# TODO: better testing for cropheight
ch
=
cropheight
(
fp
)
@test
ismissing
(
ch
)
||
Unitful
.
dimension
(
ch
)
==
Unitful
.
𝐋
@test
cropcover
(
fp
)
isa
Float64
@test
cropcover
(
fp
)
isa
Float64
@test
Unitful
.
dimension
(
cropyield
(
fp
))
==
Unitful
.
𝐌
*
Unitful
.
𝐋
^-
2
@test
Unitful
.
dimension
(
cropyield
(
fp
))
==
Unitful
.
𝐌
*
Unitful
.
𝐋
^-
2
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment