Skip to content

Commit

Permalink
model_gof passed
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Sep 24, 2024
1 parent 292186f commit bfd2d7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Utilize/model_gof.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ function map_df_tuple(fun::Function, lst::GroupedDataFrame{DataFrame}, args...;
end

## 统计每种植被类型的模拟效果
function model_gof(df_out::DataFrame)
function model_gof(df_out::DataFrame; all=true)
fun_et(d) = GOF(d.ET_obs, d.ET)
fun_gpp(d) = GOF(d.GPP_obs, d.GPP)

lst = groupby(df_out, :IGBP)

res = map_df_tuple(fun_et, lst)
push!(res, (; IGBP="ALL", fun_et(df_out)...))
all && push!(res, (; IGBP="ALL", fun_et(df_out)...))
gof_et = DataFrame(res)

res = map_df_tuple(fun_gpp, lst)
push!(res, (; IGBP="ALL", fun_gpp(df_out)...))
all && push!(res, (; IGBP="ALL", fun_gpp(df_out)...))
gof_gpp = DataFrame(res)
(; ET=gof_et, GPP=gof_gpp)
end
Expand Down
10 changes: 9 additions & 1 deletion test/test-PMLV2.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using PML, Test, Ipaper
using PML, Test, Ipaper, DataFrames

function build_data()
param = fread("data/CRO/PARAM.csv")
Expand Down Expand Up @@ -56,3 +56,11 @@ end
goal = model_goal(df, _theta; verbose=true)
@test goal > 0.55 # mean(KGE_GPP, KGE_ET)
end

@testset "model_gof" begin
d = DataFrame(; IGBP=["CRO", "CRO", "CRO"],
ET_obs=[1.0, 2, 3], ET=[0.5, 0.6, 0.7],
GPP_obs=[1.0, 2, 3], GPP=[1, 1.5, 2.0])
@test size(model_gof(d).ET, 1) == 2
@test size(model_gof(d; all=false).ET, 1) == 1
end

0 comments on commit bfd2d7f

Please sign in to comment.