-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
138 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# BEPS | ||
|
||
```{julia} | ||
# import RTableTools: fread | ||
# d = fread("examples/input/p1_meteo") | ||
``` | ||
|
||
```{julia} | ||
using BEPS | ||
d = deserialize("data/p1_meteo") | ||
lai = readdlm("examples/input/p1_lai.txt")[:] | ||
par = (lon=120.5, lat=30.5, landcover=25, clumping=0.85, | ||
soil_type=8, Tsoil=2.2, | ||
soilwater=0.4115, snowdepth=0.0) | ||
``` | ||
|
||
```{julia} | ||
@time df_jl, df_ET_jl = besp_main(d, lai, par; version="julia"); | ||
@time df_c, df_ET_c = besp_main(d, lai, par; version="c"); | ||
sum(df_jl) | ||
sum(df_c) | ||
df_diff = abs.(df_jl .- df_c) | ||
df_diff_perc = abs.(df_jl .- df_c) ./ df_c .* 100 | ||
# df_diff = abs.(df_ET_jl .- df_ET_c) | ||
# fwrite(df_diff, "a-3.csv") | ||
max(df_diff) | ||
max(df_diff_perc) # SH, 1.48%的误差 | ||
``` | ||
|
||
# 绘图展示结果 | ||
```{julia} | ||
using Plots | ||
using Ipaper | ||
function plot_var(var=:SH) | ||
n = size(df_jl, 1) | ||
inds = 1:n | ||
y_jl = df_jl[inds, var] | ||
y_c = df_c[inds, var] | ||
diff_perc = (y_jl .- y_c) ./ y_c .* 100 | ||
plot(diff_perc; title="$var", label="bias (%)") # | ||
end | ||
vars = names(df_jl)[[1:4; 8; 12:16]] | ||
ps = map(plot_var, vars) | ||
plot(ps..., layout=(3, 4), size=(1400, 800)) | ||
# write_fig("images/Figure1_bias_of_julia-version.png", 15, 8; show=false) | ||
``` | ||
|
||
```{julia} | ||
# using ProfileView | ||
# @time df_jl, df_ET_jl = besp_main(d, lai, par; version="julia"); | ||
# @profview df_jl, df_ET_jl = besp_main(d, lai, par; version="julia"); | ||
@profview_allocs df_jl, df_ET_jl = besp_main(d, lai, par; version="julia"); | ||
@profview df_jl, df_ET_jl = besp_main(d, lai, par; version="julia"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ using BEPS: path_proj | |
|
||
|
||
|
||
include("test-readparam.jl") | ||
include("test-clang.jl") | ||
include("test-soil.jl") | ||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Test | ||
using BEPS | ||
|
||
@testset "readparam" begin | ||
lcs = [1, 2, 6, 9, 13, 40, -1] | ||
for lc = lcs | ||
par1 = readparam(lc) | ||
par2 = clang.readparam(lc) | ||
@test maximum(abs.(par1 .- par2)) == 0 | ||
end | ||
end | ||
|
||
@testset "readcoef" begin | ||
lcs = [1, 6, 13, -1] | ||
stxts = 1:11 | ||
|
||
for lc = lcs, stxt = stxts | ||
coef1 = readcoef(lc, stxt) | ||
coef2 = clang.readcoef(lc, stxt) | ||
@test maximum(abs.(coef1 .- coef2)) == 0 | ||
end | ||
end | ||
|
||
@testset "aerodynamic_conductance" begin | ||
canopyh_o = 2.0 | ||
canopyh_u = 0.2 | ||
height_wind_sp = 2.0 | ||
clumping = 0.8 | ||
Ta = 20.0 | ||
wind_sp = 2.0 | ||
GH_o = 100.0 | ||
pai_o = 4.0 | ||
pai_u = 2.0 | ||
|
||
ra_o, ra_u, ra_g, Ga_o, Gb_o, Ga_u, Gb_u = | ||
aerodynamic_conductance_jl(canopyh_o, canopyh_u, height_wind_sp, clumping, Ta, wind_sp, GH_o, | ||
pai_o, pai_u) | ||
r1 = (; ra_o, ra_u, ra_g, Ga_o, Gb_o, Ga_u, Gb_u) | ||
|
||
ra_o, ra_u, ra_g, Ga_o, Gb_o, Ga_u, Gb_u = | ||
clang.aerodynamic_conductance_c(canopyh_o, canopyh_u, height_wind_sp, clumping, Ta, wind_sp, GH_o, | ||
pai_o, pai_u) | ||
r2 = (; ra_o, ra_u, ra_g, Ga_o, Gb_o, Ga_u, Gb_u) | ||
|
||
@test maximum(abs.(values(r1) .- values(r2))) <= 1e-8 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters