Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/src/walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ We start with the simplest version, in which $G_b$ is calculated empirically bas
the friction velocity ($u_*$) according to Thom 1972:

```@example doc
aerodynamic_conductance!(thas)
aerodynamic_conductance!(thas);
thas[1:3, Cols(:datetime,Between(:zeta,:Ga_CO2))]
```

Expand All @@ -365,7 +365,7 @@ dimension ($D_l$, assumed to be 1cm here), and information on sensor and canopy

```@example doc
aerodynamic_conductance!(thas;Gb_model=Val(:Su_2001),
LAI=thal.zh, zh=thal.zh, d=0.7*thal.zh, zr=thal.zr,Dl=thal.Dl)
LAI=thal.zh, zh=thal.zh, d=0.7*thal.zh, zr=thal.zr, Dl=thal.Dl);
thas[1:3, Cols(:datetime,Between(:zeta,:Ga_CO2))]
```

Expand All @@ -383,8 +383,8 @@ Functin `add_Gb` calculates $G_b$ for other trace gases, provided that the respe
number is known.

```@example doc
compute_Gb!(thas, Val(:Thom_1972)) # adds/modifies column Gb_h and Gb_CO2
add_Gb!(thas, :Gb_O2 => 0.84, :Gb_CH4 => 0.99) # adds Gb_O2 and Gb_CH4
compute_Gb!(thas, Val(:Thom_1972)); # adds/modifies column Gb_h and Gb_CO2
add_Gb!(thas, :Gb_O2 => 0.84, :Gb_CH4 => 0.99); # adds Gb_O2 and Gb_CH4
select(first(thas,3), r"Gb_")
```

Expand All @@ -403,10 +403,10 @@ close to the surface and weaker at greater heights:
using Statistics
wind_heights = 22:2:60.0
d = 0.7 * thal.zh
z0m = roughness_parameters(Val(:wind_profile), thas, thal.zh, thal.zr).z0m
z0m = roughness_parameters(Val(:wind_profile), thas; zh=thal.zh, zr=thal.zr).z0m
wp = map(wind_heights) do z
wind_profile(thas,z,d, z0m; zh=thal.zh, zr=thal.zr)
end
wind_profile(z, thas,d, z0m; zh=thal.zh, zr=thal.zr)
end;
nothing # hide
```
```@setup doc
Expand Down
3 changes: 2 additions & 1 deletion src/Bigleaf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export setinvalid_range!, setinvalid_qualityflag!,
setinvalid_nongrowingseason!, get_growingseason, setinvalid_afterprecip!
export decoupling, surface_conductance, aerodynamic_conductance
export compute_Gb, compute_Gb!, add_Gb, add_Gb!,
Gb_Thom, Gb_Choudhury, Gb_Su, Gb_constant_kB1
Gb_Thom, Gb_Choudhury, Gb_Su, Gb_constant_kB1,
compute_Gb_quantities, compute_Gb_quantities!
export wind_profile
export Monin_Obukhov_length, Monin_Obukhov_length!, stability_parameter,
stability_parameter!, stability_correction, stability_correction!,
Expand Down
24 changes: 14 additions & 10 deletions src/aerodynamic_conductance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,37 @@ function aerodynamic_conductance!(df; Gb_model = Val(:Thom_1972), Ram_model = Va
zr=nothing,zh=nothing, d = isnothing(zh) ? nothing : 0.7*zh ,
z0m=nothing,Dl=nothing,N=2,fc=nothing,LAI=nothing,Cd=0.2,hs=0.01,
leafwidth=nothing,
wind_profile=false,
stab_formulation=Val(:Dyer_1970),
kB_h=nothing,constants=bigleaf_constants()
)
# add zeta
if !isnothing(zr) && !isnothing(d) && !(stab_formulation isa Val{:no_stability_correction})
stability_parameter!(df::AbstractDataFrame; zr,d, constants)
stability_parameter!(df::AbstractDataFrame; z=zr, d, constants)
else
df[!,:zeta] .= missing
end
# adds columns psi_m and psi_h, (:no_stability_correction: just add 0s without using zeta)
stability_correction!(df; stab_formulation, constants)
stability_correction!(df; zeta=df.zeta, stab_formulation, constants)
# pre-estimate z0m to use it in both Gb and Ga
needs_windprofile =
Gb_model isa Union{Val{:Choudhury_1988}, Val{:Su_2001}} ||
Ram_model isa Val{:wind_profile}
if isnothing(z0m) && needs_windprofile
z0m = roughness_parameters(Val(:wind_profile), df, zh, zr; psi_m = df.psi_m).z0m
if needs_windprofile
if isnothing(z0m)
z0m = roughness_parameters(Val(:wind_profile), df; zh, zr, psi_m = df.psi_m).z0m
end
wind_zh = wind_profile(zh, df, d, z0m; zh, zr, stab_formulation, constants)
end
#
# calculate canopy boundary layer conductance (Gb)
Gb_model isa Val{:Thom_1972} && compute_Gb!(df, Gb_model; constants)
Gb_model isa Val{:constant_kB1} && compute_Gb!(df, Gb_model; kB_h, constants)
Gb_model isa Val{:Choudhury_1988} && compute_Gb!(df, Gb_model;
leafwidth, LAI, zh, zr, d, z0m, stab_formulation, constants)
Gb_model isa Val{:Su_2001} && compute_Gb!(df, Gb_model;
Dl, fc, N, Cd, hs, z0m, zh, zr, d, LAI, stab_formulation, constants)
Gb_model isa Val{:Choudhury_1988} && compute_Gb!(
df, Gb_model; leafwidth, LAI, wind_zh, constants)
Gb_model isa Val{:Su_2001} && compute_Gb!(
df, Gb_model; wind_zh, Dl, fc, N, Cd, hs, LAI, constants)
compute_Gb_quantities!(df)
#
# calculate aerodynamic risistance for momentum (Ra_m)
Ram_model isa Val{:wind_profile} && compute_Ram!(df, Ram_model; zr, d, z0m, constants)
Ram_model isa Val{:wind_zr} && compute_Ram!(df, Ram_model)
Expand Down Expand Up @@ -161,7 +166,6 @@ Estimate bulk aerodynamic conductance.

# Arguments
- `ustar` : Friction velocity (m s-1)
- `wind` : wind speed at measurement height (m s-1)
- `df` : DataFrame with above columns
- `zr` : Instrument (reference) height (m)
- `d` : Zero-plane displacement height (-), can be estimated using
Expand Down
Loading