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
56023b37
Commit
56023b37
authored
8 months ago
by
Marco Matthies
Browse files
Options
Downloads
Patches
Plain Diff
AquaCrop: remove height field, and some cosmetics
parent
b7a40304
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
+10
-11
10 additions, 11 deletions
src/crop/aquacrop.jl
src/crop/cropmodels.jl
+1
-1
1 addition, 1 deletion
src/crop/cropmodels.jl
with
11 additions
and
12 deletions
src/crop/aquacrop.jl
+
10
−
11
View file @
56023b37
...
...
@@ -11,29 +11,29 @@ cropname(ct::AquaCropType) = ct.name
mutable struct
AquaCropState
croptype
::
AquaCropType
height
::
Length
{
Float64
}
# TODO: remove height field, supply from cropstate
cropstate
::
AquaCrop
.
AquaCropField
acfield
::
AquaCrop
.
AquaCropField
function
AquaCropState
(
croptype
::
AquaCropType
,
height
::
Length
{
Float64
}
=
0.0
cm
)
function
AquaCropState
(
croptype
::
AquaCropType
)
# TODO: allow setting height on initialisation?
runtype
=
AquaCrop
.
TomlFileRun
()
parentdir
=
AquaCrop
.
test_toml_dir
# TODO: hardcoded croptype
ac
_crop
field
,
all_ok
=
AquaCrop
.
start_cropfield
(;
parentdir
,
runtype
)
acfield
,
all_ok
=
AquaCrop
.
start_cropfield
(;
parentdir
,
runtype
)
if
!
all_ok
.
logi
error
(
"AquaCrop.start_cropfield() failed, status =
$
all_ok"
)
end
AquaCrop
.
setup_cropfield!
(
ac
_crop
field
,
all_ok
;
runtype
=
runtype
)
AquaCrop
.
setup_cropfield!
(
acfield
,
all_ok
;
runtype
=
runtype
)
if
!
all_ok
.
logi
error
(
"AquaCrop.setup_cropfield!() failed, status =
$
all_ok"
)
end
return
new
(
croptype
,
height
,
ac_crop
field
)
return
new
(
croptype
,
ac
field
)
end
end
croptype
(
cs
::
AquaCropState
)
=
cs
.
croptype
cropname
(
cs
::
AquaCropState
)
=
cropname
(
croptype
(
cs
))
cropheight
(
cs
::
AquaCropState
)
=
cs
.
height
# TODO: use AquaCrop state info
cropcover
(
cs
::
AquaCropState
)
=
AquaCrop
.
canopycover
(
cs
.
cropstate
)
cropyield
(
cs
::
AquaCropState
)
=
AquaCrop
.
dryyield
(
cs
.
cropstate
)
# TODO: there is also freshyield
cropheight
(
cs
::
AquaCropState
)
=
0.0
cm
# TODO: use AquaCrop state info
cropcover
(
cs
::
AquaCropState
)
=
AquaCrop
.
canopycover
(
cs
.
acfield
)
cropyield
(
cs
::
AquaCropState
)
=
AquaCrop
.
dryyield
(
cs
.
acfield
)
# TODO: there is also freshyield
isharvestable
(
cs
::
AquaCropState
)
=
true
# TODO: implement this correctly
"""
...
...
@@ -42,7 +42,7 @@ isharvestable(cs::AquaCropState) = true # TODO: implement this correctly
Update a crop state by one day.
"""
function
stepagent!
(
cs
::
AquaCropState
,
model
::
SimulationModel
)
AquaCrop
.
dailyupdate!
(
cs
.
cropstate
)
AquaCrop
.
dailyupdate!
(
cs
.
acfield
)
end
"""
...
...
@@ -52,7 +52,6 @@ Change the cropstate to sow the specified crop.
"""
function
sow!
(
cs
::
AquaCropState
,
model
::
SimulationModel
,
cropname
::
String
)
cs
.
croptype
=
model
.
crops
[
cropname
]
cs
.
height
=
0.0
cm
# TODO: other things needed for AquaCrop?
end
...
...
This diff is collapsed.
Click to expand it.
src/crop/cropmodels.jl
+
1
−
1
View file @
56023b37
...
...
@@ -82,7 +82,7 @@ function makecropstate(model::SimulationModel)
0.0
m
)
elseif
@param
(
crop
.
cropmodel
)
==
"aquacrop"
cs
=
AquaCropState
(
model
.
crops
[
"natural grass"
]
,
0.0
cm
)
cs
=
AquaCropState
(
model
.
crops
[
"natural grass"
])
else
Base
.
error
(
"Unhandled crop model '
$
(@param(crop.cropmodel))' in makecropstate()."
)
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