Skip to content

Commit 5a974d8

Browse files
committed
add C3C4 task
1 parent 1d41ced commit 5a974d8

File tree

7 files changed

+59
-20
lines changed

7 files changed

+59
-20
lines changed

Diff for: examples/data_PML_2019.jl

-13
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@ using Ipaper, HydroTools, PML
22
using DataFrames, RTableTools
33
using Test, BenchmarkTools
44

5-
function replace_miss!(df::AbstractDataFrame)
6-
# colnames = names(df)
7-
# num_cols = [name for name in colnames if getDataType(df[!, name]) <: Number]
8-
for col in names(df)
9-
x = df[!, col]
10-
type = getDataType(x)
11-
if type <: AbstractFloat
12-
df[!, col] = drop_missing(x)
13-
end
14-
end
15-
df
16-
end
17-
185
small = false
196
if small
207
f = "D:/GitHub/PML/PMLV2_Kong2019.m/data/INPUT_dt_v2019.csv"

Diff for: examples/ex2_NorthChina_C3C4_calib.jl

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using PML, Ipaper, Test, RTableTools
2+
3+
include("main_pkgs.jl")
4+
data = fread("./Forcing_C3C4_sp2.csv")
5+
replace_miss!(data)
6+
7+
df = data[data.site.=="固城", :]
8+
# df = data[data.site.=="禹城", :]
9+
# df.ET_obs = df.ET_obs ./ 0.9
10+
11+
par = par0
12+
r = PMLV2(df; par)
13+
14+
theta, goal, flag = model_calib(df, par0)
15+
df_out = PMLV2_sites(df; par=theta2par(theta))
16+
# df_out[1:10, :]
17+
sites = unique(df.site)
18+
19+
20+
begin
21+
RES = []
22+
for site in sites
23+
inds = df.site .== site
24+
d_obs = df[inds, :]
25+
d_sim = df_out[inds, :]
26+
27+
gof = [
28+
(; var="ET", GOF(d_obs.ET_obs, d_sim.ET)...),
29+
(; var="GPP", GOF(d_obs.GPP_obs, d_sim.GPP)...)] |> DataFrame
30+
gof = gof[:, [:var, :NSE, :KGE, :R2, :bias_perc, :n_valid]]
31+
push!(RES, gof)
32+
end
33+
RES
34+
end
35+
36+
## PML-ET
37+
# 固城: 0.46
38+
# 禹城: 0.63

Diff for: examples/main_pkgs.jl

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using DataFrames
2+
3+
function replace_miss!(df::AbstractDataFrame)
4+
# colnames = names(df)
5+
# num_cols = [name for name in colnames if getDataType(df[!, name]) <: Number]
6+
for col in names(df)
7+
x = df[!, col]
8+
type = getDataType(x)
9+
if type <: AbstractFloat
10+
df[!, col] = drop_missing(x)
11+
end
12+
end
13+
df
14+
end

Diff for: src/Params.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ $(TYPEDFIELDS)
1919
"initial slope of the CO2 response curve to assimilation rate, (i.e., carboxylation efficiency; `μmol m⁻² s⁻¹ [μmol m⁻² s⁻¹]⁻¹`)"
2020
Thelta::FT = 0.04 | (0.01, 0.07)
2121

22-
"stomatal conductance coefficient"
23-
m ::FT = 10.00 | (2.00, 100.00)
22+
"stomatal conductance coefficient" # 气孔导度斜率参数
23+
g1 ::FT = 10.00 | (2.00, 100.00)
2424

2525
"carbon saturated rate of photosynthesis at 25 °C, `μmol m⁻² s⁻¹`"
2626
Am_25 ::FT = 50.00 | (5.00, 120.00)

Diff for: src/Utilize/model_calib.jl

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ function model_goal(df, theta; IGBPcode=nothing, of_gof=:NSE, verbose=false)
1515
indexes = [:KGE, :NSE, :R2, :RMSE, :bias, :bias_perc]
1616
info_GPP = info_GPP[indexes] |> round2
1717
info_ET = info_ET[indexes] |> round2
18-
# @show info_GPP
19-
# @show info_ET
2018
end
21-
22-
goal = (info_ET[of_gof] + info_GPP[of_gof]) / 2
19+
gof = [info_ET[of_gof], info_GPP[of_gof]]
20+
goal = weighted_mean(gof, [1, 0.5])
2321
goal
2422
end
2523

Diff for: src/main_Ipaper.jl

+2
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ end
6161
# export struct2vec, struct2tuple
6262
export round2;
6363
export movmean2, nanmean2, getDataType, replace_miss
64+
65+
weighted_mean(x::AbstractVector, w::AbstractVector) = sum(x .* w) / sum(w)

Diff for: src/photosynthesis.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function photosynthesis(Tavg::T, Rs::T, VPD::T, LAI::T,
3131
GPP = Ag * 86400 / 10^6 * 12 # [umol m-2 s-1] to [g C m-2 d-1]
3232

3333
f_VPD_gc = 1.0 / (1.0 + VPD / par.D0) # Leuning f_vpd
34-
Gc = par.m * Ag / Ca * f_VPD_gc # canopy conductance for carbon
34+
Gc = par.g1 * Ag / Ca * f_VPD_gc # canopy conductance for carbon
3535

3636
## Convert from mol m-2 s-1 to m s-1
3737
Gc = Gc * 1e-2 / (0.446 * (273 / (273 + Tavg)) * (Pa / 101.3)) # Gc = Gc * mol2m(Tavg, Pa)

0 commit comments

Comments
 (0)