Skip to content

Commit

Permalink
Use PrecompileTools
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyun committed Apr 19, 2024
1 parent d3c9351 commit 99cba03
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ authors = ["Kyungdahm Yun <tomyun@gmail.com>"]
version = "0.1.1-DEV"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Cropbox = "a904b226-abf1-11e9-2713-059ba252a964"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"

[compat]
CSV = "0.10"
Cropbox = "0.3"
DataFrames = "1"
PrecompileTools = "1"
julia = "1.6"
TimeZones = "1"
2 changes: 2 additions & 0 deletions src/SimpleCrop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ include("weather.jl")

export Model

include("precompile.jl")

end
30 changes: 30 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import PrecompileTools

using CSV
using DataFrames
using TimeZones

PrecompileTools.@compile_workload begin
loaddata(f) = CSV.File(joinpath(@__DIR__, "../test/data", f)) |> DataFrame

config = @config (
:Clock => :step => 1u"d",
:Calendar => :init => ZonedDateTime(1987, 1, 1, tz"UTC"),
:Weather => :weather_data => loaddata("weather.csv"),
:SoilWater => :irrigation_data => loaddata("irrigation.csv"),
)

# frequency of printout (days)
FROP = 3u"d"

r = simulate(Model;
config,
stop = :endsim,
#snap = s -> iszero(s.DOY' % FROP),
verbose = false,
)

for backend in (:UnicodePlots, :Gadfly)
visualize(r, :DATE, :LAI; kind = :line, backend)
end
end

0 comments on commit 99cba03

Please sign in to comment.