Skip to content

Commit d7a0561

Browse files
authored
Merge pull request #22 from bgctw:ET
adapt ET tests to available surface_conductance
2 parents 4e5a0c2 + 60854b1 commit d7a0561

File tree

4 files changed

+169
-213
lines changed

4 files changed

+169
-213
lines changed

docs/src/walkthrough.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,35 +82,39 @@ and temperature always in °C.
8282

8383
## Function arguments
8484

85-
Most functions of `Bigleaf.jl` require a DataFrame, from which the required
86-
variables are extracted. This is usually the first argument of a function.
87-
Most functions further provide default values for their arguments,
88-
such that in many cases it is not necessary to provide them explicitly.
89-
90-
The column names in the DataFrame should correspond to the argument names
91-
of the corresponding method that accespts each input individually.
92-
93-
Methods are usually provided with two forms:
94-
- all required scalar inputs as positional arguments with outputing a NamedTuple
95-
- a mutating DataFrame with columns corresponding to required inputs
96-
where the output columns are added or modified.
85+
`Bigleaf.jl` usually provides functions in two flavours.
86+
- providing all arguments seperately as scalars and output being a single scalar
87+
or a NamedTuple
88+
- providing a DataFrame as first argument with columns corresponding to the inputs and
89+
ouput being the in-place modified DataFrame. Most keyword arguments
90+
accept both, vectors or scalars.
91+
The column names in the DataFrame should correspond to the argument names
92+
of the corresponding method with individual inputs.
9793

9894
We can demonstrate the usage with a simple example:
9995

10096
```@example doc
10197
# explicit inputs
10298
Tair, pressure, Rn, = 14.81, 97.71, 778.17
103-
potential_ET(Tair, pressure, Rn, Val(:PriestleyTaylor))
99+
potential_ET(Val(:PriestleyTaylor), Tair, pressure, Rn)
100+
104101
# DataFrame
105102
potential_ET!(copy(tha), Val(:PriestleyTaylor))
103+
106104
# DataFrame with a few columns overwritten by user values
107105
potential_ET!(transform(tha, :Tair => x -> 25.0; renamecols=false), Val(:PriestleyTaylor))
106+
108107
# varying one input only: scalar form with dot-notation
109108
Tair_vec = 10.0:1.0:20.0
110-
DataFrame(potential_ET.(Tair_vec, pressure, Rn, Val(:PriestleyTaylor)))
109+
DataFrame(potential_ET.(Val(:PriestleyTaylor), Tair_vec, pressure, Rn))
111110
nothing # hide
112111
```
113112

113+
For functions operating only on vectors, e.g. [`roughness_parameters`](@ref) vectors
114+
are provided with the individual inputs. Sometimes, an additional non-mutating DataFrame
115+
variant is provided for convenience, however, the output value of this variant is
116+
not type-stable.
117+
114118
## Ground heat flux and storage fluxes
115119

116120
Many functions require the available energy ($A$), which is defined as ($A = R_n - G - S$,
@@ -463,16 +467,18 @@ evapotranspiration (PET). At the moment, the `Bigleaf.jl` contains two formulati
463467
for the estimate of PET: the Priestley-Taylor equation, and the Penman-Monteith equation:
464468

465469
```@example doc
466-
potential_ET!(thas, Val(:PriestleyTaylor); G = thas.G, infoGS = false)
467-
# TODO need aerodynamci and surface conductance to compute Ga and Gs_mol before
468-
# potential_ET!(thas, Val(:PenmanMonteith); G = thas.G,
469-
# Gs_pot=quantile(skipmissing(thas.Gs_mol),0.95))
470-
select(thas[24:26,:], :datetime, :ET_pot, :LE_pot)
470+
potential_ET!(thas, Val(:PriestleyTaylor); G = thas.G)
471+
472+
# aerodynamic Ga_h and surface conductance Gs_mol must be computed before
473+
potential_ET!(thas, Val(:PenmanMonteith); G = thas.G,
474+
Gs_pot=quantile(skipmissing(thas.Gs_mol),0.95))
475+
thas[24:26, Cols(:datetime, :ET_pot, :LE_pot)]
471476
```
472477

473478
In the second calculation it is important to provide an estimate of aerodynamic
474-
conductance Ga and ``Gs_{pot}``, the potential surface conductance under optimal conditions.
475-
Here, we have approximated ``Gs_{pot}`` with the ``95^{\text{th}}`` percentile of all
479+
conductance, ``G_a``, and the potential surface conductance under optimal conditions,
480+
``G_{s pot}``.
481+
Here, we have approximated ``G_{s pot}`` with the ``95^{\text{th}}`` percentile of all
476482
``G_s`` values of the site.
477483

478484

inst/tha.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function tmpf()
4141
Dl=0.01
4242
aerodynamic_conductance!(thas; Gb_model=Val(:Su_2001),
4343
Dl, LAI=thal.LAI, zh=thal.zh, zr=thal.zr);
44+
surface_conductance!(thas, Val(:PenmanMonteith); G=thas.G);
4445
end
4546

4647
# tha48 and thal see runtests.jl

0 commit comments

Comments
 (0)