Skip to content

Commit

Permalink
Merge #18
Browse files Browse the repository at this point in the history
18: getting ready for broadband RT r=Yujie-W a=Yujie-W

Next step is to add type Leaves to use two-leaf model

Co-authored-by: Yujie Wang <[email protected]>
  • Loading branch information
bors[bot] and Yujie-W authored Jun 24, 2022
2 parents ef62935 + 518304e commit fe76bd4
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClimaCache"
uuid = "781d2db2-48ae-11ec-81d3-0242ac130003"
authors = ["Yujie Wang <[email protected]>"]
version = "0.3.4"
version = "0.3.5"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
15 changes: 7 additions & 8 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.BufferedStreams]]
deps = ["Compat", "Test"]
git-tree-sha1 = "5d55b9486590fdda5905c275bb21ce1f0754020f"
git-tree-sha1 = "bb065b14d7f941b8617bc323063dbe79f55d16ea"
uuid = "e1450e63-4bb3-523b-b2a4-4ffa8c0fd77d"
version = "1.0.0"
version = "1.1.0"

[[deps.CLIMAParameters]]
deps = ["Test"]
Expand Down Expand Up @@ -51,7 +50,7 @@ version = "0.1.3"
deps = ["DocStringExtensions", "LazyArtifacts", "MAT", "PkgUtility", "Statistics", "Test", "UnPack", "WaterPhysics"]
path = ".."
uuid = "781d2db2-48ae-11ec-81d3-0242ac130003"
version = "0.3.4"
version = "0.3.5"

[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
Expand Down Expand Up @@ -275,9 +274,9 @@ uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"

[[deps.OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "ab05aa4cc89736e95915b01e7279e61b1bfe33b8"
git-tree-sha1 = "9a36165cf84cff35851809a40a928e1103702013"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "1.1.14+0"
version = "1.1.16+0"

[[deps.OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
Expand Down Expand Up @@ -382,9 +381,9 @@ version = "1.4.0"

[[deps.StatsBase]]
deps = ["DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
git-tree-sha1 = "8977b17906b0a1cc74ab2e3a05faa16cf08a8291"
git-tree-sha1 = "642f08bf9ff9e39ccc7b710b2eb9a24971b52b1a"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.33.16"
version = "0.33.17"

[[deps.TOML]]
deps = ["Dates"]
Expand Down
11 changes: 7 additions & 4 deletions docs/src/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ HyperspectralAbsorption
HyperspectralAbsorption{FT}(wls::WaveLengthSet = WaveLengthSet{FT}(); opti::String = OPTI_2021) where {FT<:AbstractFloat}
SunSensorGeometry
SunSensorGeometry{FT}(; haa::Number = 0, hsa::Number = 0, saa::Number = 180, sza::Number = 30, vaa::Number = 180, vza::Number = 0) where {FT<:AbstractFloat}
CanopyOpticalProperty
CanopyOpticalProperty{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114) where {FT<:AbstractFloat}
CanopyRadiationProfile
CanopyRadiationProfile{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114) where {FT<:AbstractFloat}
HyperspectralMLCanopyOpticalProperty
HyperspectralMLCanopyOpticalProperty{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114) where {FT<:AbstractFloat}
AbstractCanopyRadiationProfile
BroadbandSLCanopyRadiationProfile
BroadbandSLCanopyRadiationProfile{FT}(; n_incl::Int = 9) where {FT<:AbstractFloat}
HyperspectralMLCanopyRadiationProfile
HyperspectralMLCanopyRadiationProfile{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114) where {FT<:AbstractFloat}
AbstractLIDFAlgorithm
VerhoefLIDF
AbstractCanopy
Expand Down
6 changes: 5 additions & 1 deletion src/plant/leaf_biophysics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ abstract type AbstractLeafBiophysics{FT<:AbstractFloat} end
# Changes to this structure
# General
# 2022-Jun-15: add struct for broadband leaf biophysics
# 2022-Jun-24: add leaf emissivity constant
#
#######################################################################################################################################################################################################
"""
Expand All @@ -40,6 +41,8 @@ mutable struct BroadbandLeafBiophysics{FT} <: AbstractLeafBiophysics{FT}
Α_NIR::FT
"Broadband absorption fraction at the PAR region"
Α_PAR::FT
"Emissivity for longwave radiation"
Ε_LW::FT
end


Expand All @@ -48,6 +51,7 @@ end
# Changes to this constructor
# General
# 2022-Jun-15: add constructor
# 2022-Jun-24: add leaf emissivity constant
#
#######################################################################################################################################################################################################
"""
Expand All @@ -56,7 +60,7 @@ end
Construct a broadband leaf biophysics struct
"""
BroadbandLeafBiophysics{FT}() where {FT<:AbstractFloat} = BroadbandLeafBiophysics{FT}(0.2, 0.8);
BroadbandLeafBiophysics{FT}() where {FT<:AbstractFloat} = BroadbandLeafBiophysics{FT}(0.2, 0.8, 0.97);


#######################################################################################################################################################################################################
Expand Down
49 changes: 24 additions & 25 deletions src/radiation/canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ abstract type AbstractCanopy{FT<:AbstractFloat} end
# General
# 2022-Jun-15: add struct for broadband radiative transfer scheme such as two leaf model
# 2022-Jun-15: add more cache variables
# 2022-Jun-15: add radiation profile
# 2022-Jun-15: remove RATIO_HV to compute the coefficient numerically
# 2022-Jun-16: remove some cache variables
# 2022-Jun-16: add fields: Θ_INCL_BNDS
#
#######################################################################################################################################################################################################
"""
Expand All @@ -87,22 +91,18 @@ mutable struct BroadbandSLCanopy{FT} <: AbstractCanopy{FT}
LIDF::Union{VerhoefLIDF{FT}}
"Inclination angle distribution"
P_INCL::Vector{FT}
"Ratio of average projected areas of canopy elements on horizontal and vertical surfaces"
RAIO_HV::FT
"Canopy radiation profiles"
RADIATION::BroadbandSLCanopyRadiationProfile{FT}
"Mean inclination angles `[°]`"
Θ_INCL::Vector{FT}
"Bounds of inclination angles `[°]`"
Θ_INCL_BNDS::Matrix{FT}

# prognostic variables that change with time
"Clumping index"
ci::FT
"Leaf area index"
lai::FT

# caches to speed up calculations
"Cosine of Θ_INCL"
_COS_Θ_INCL::Vector{FT}
"Sine of Θ_INCL"
_SIN_Θ_INCL::Vector{FT}
end


Expand All @@ -112,6 +112,10 @@ end
# General
# 2022-Jun-15: add constructor
# 2022-Jun-15: add more cache variables
# 2022-Jun-15: add radiation profile
# 2022-Jun-15: remove RATIO_HV to compute the coefficient numerically
# 2022-Jun-16: remove some cache variables
# 2022-Jun-16: add fields: Θ_INCL_BNDS
#
#######################################################################################################################################################################################################
"""
Expand All @@ -126,16 +130,16 @@ BroadbandSLCanopy{FT}(; lai::Number = 3, θ_incl_bnds::Matrix = [collect(0:10:80
_n_incl = size(θ_incl_bnds,1);
_θ_incl = FT[(θ_incl_bnds[_i,1] + θ_incl_bnds[_i,2]) / 2 for _i in 1:_n_incl];
_p_incl = ones(_n_incl) / _n_incl;
_rad = BroadbandSLCanopyRadiationProfile{FT}(n_incl = _n_incl);

return BroadbandSLCanopy{FT}(
VerhoefLIDF{FT}(0,0), # LIDF
_p_incl, # P_INCL
1, # RAIO_HV
_rad, # RADIATION
_θ_incl, # Θ_INCL
θ_incl_bnds, # Θ_INCL_BNDS
1, # ci
lai, # lai
cosd.(_θ_incl), # _COS_Θ_INCL
sind.(_θ_incl) # _SIN_Θ_INCL
lai # lai
)
);

Expand All @@ -151,6 +155,8 @@ BroadbandSLCanopy{FT}(; lai::Number = 3, θ_incl_bnds::Matrix = [collect(0:10:80
# 2022-Jun-07: remove cache variable _cos_θ_azi_raa, _vol_scatter
# 2022-Jun-09: add new field: APAR_CAR, RADIATION, WLSET
# 2022-Jun-13: use Union instead of Abstract... for type definition
# 2022-Jun-15: rename to HyperspectralMLCanopyOpticalProperty and HyperspectralMLCanopyRadiationProfile
# 2022-Jun-16: remove some cache variables
#
#######################################################################################################################################################################################################
"""
Expand Down Expand Up @@ -179,11 +185,11 @@ mutable struct HyperspectralMLCanopy{FT} <: AbstractCanopy{FT}
"Number of canopy layers"
N_LAYER::Int
"Canopy optical properties"
OPTICS::CanopyOpticalProperty{FT}
OPTICS::HyperspectralMLCanopyOpticalProperty{FT}
"Inclination angle distribution"
P_INCL::Vector{FT}
"Canopy radiation profiles"
RADIATION::CanopyRadiationProfile{FT}
RADIATION::HyperspectralMLCanopyRadiationProfile{FT}
"Wave length set used to paramertize other variables"
WLSET::WaveLengthSet{FT}
"Clumping structure a"
Expand All @@ -208,16 +214,10 @@ mutable struct HyperspectralMLCanopy{FT} <: AbstractCanopy{FT}
_1_AZI::Vector{FT}
"Cosine of Θ_AZI"
_COS_Θ_AZI::Vector{FT}
"Cosine of Θ_INCL"
_COS_Θ_INCL::Vector{FT}
"Cosine of Θ_INCL at different azimuth angles"
_COS_Θ_INCL_AZI::Matrix{FT}
"Square of cosine of Θ_INCL"
_COS²_Θ_INCL::Vector{FT}
"Square of cosine of Θ_INCL at different azimuth angles"
_COS²_Θ_INCL_AZI::Matrix{FT}
"Sine of Θ_INCL"
_SIN_Θ_INCL::Vector{FT}
"Cache for level boundary locations"
_x_bnds::Vector{FT}
end
Expand All @@ -236,6 +236,8 @@ end
# 2022-Jun-10: remove n_λ from options and use the N in wls
# 2022-Jun-10: add SIF excitation and fluorescence length control
# 2022-Jun-15: fix documentation
# 2022-Jun-15: rename to HyperspectralMLCanopyOpticalProperty and HyperspectralMLCanopyRadiationProfile
# 2022-Jun-16: remove some cache variables
#
#######################################################################################################################################################################################################
"""
Expand Down Expand Up @@ -264,8 +266,8 @@ HyperspectralMLCanopy{FT}(
_p_incl = ones(_n_incl) / _n_incl;
_θ_azi = collect(FT,5:10:360);
_x_bnds = collect(FT,0:-1/n_layer:-1-eps(FT));
_can_opt = CanopyOpticalProperty{FT}(; n_azi = 36, n_incl = _n_incl, n_layer = n_layer, n_λ = wls.NΛ, n_λe = wls.NΛ_SIFE, n_λf = wls.NΛ_SIF);
_can_rad = CanopyRadiationProfile{FT}(; n_layer = n_layer, n_par = wls.NΛ_PAR, n_λ = wls.NΛ, n_λf = wls.NΛ_SIF);
_can_opt = HyperspectralMLCanopyOpticalProperty{FT}(; n_azi = 36, n_incl = _n_incl, n_layer = n_layer, n_λ = wls.NΛ, n_λe = wls.NΛ_SIFE, n_λf = wls.NΛ_SIF);
_can_rad = HyperspectralMLCanopyRadiationProfile{FT}(; n_layer = n_layer, n_par = wls.NΛ_PAR, n_λ = wls.NΛ, n_λf = wls.NΛ_SIF);
_cos_θ = cosd.(_θ_incl);
_cos²_θ = _cos_θ .^ 2;

Expand All @@ -289,11 +291,8 @@ HyperspectralMLCanopy{FT}(
lai, # lai
ones(FT,36), # _1_AZI
cosd.(_θ_azi), # _COS_Θ_AZI
_cos_θ, # _COS_Θ_INCL
_cos_θ * ones(FT,36)', # _COS_Θ_INCL_AZI
_cos²_θ, # _COS²_Θ_INCL
_cos²_θ * ones(FT,36)', # _COS²_Θ_INCL_AZI
sind.(_θ_incl), # _SIN_Θ_INCL
_x_bnds # _x_bnds
)
);
10 changes: 6 additions & 4 deletions src/radiation/canopy_optics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# 2022-Jun-10: add more fields for sif calculations
# 2022-Jun-13: add more fields for sif calculations
# 2022-Jun-13: remove unnecessary cache variables
# 2022-Jun-15: rename to HyperspectralMLCanopyOpticalProperty
#
#######################################################################################################################################################################################################
"""
Expand All @@ -23,7 +24,7 @@ Structure for Verhoef LIDF algorithm
$(TYPEDFIELDS)
"""
mutable struct CanopyOpticalProperty{FT<:AbstractFloat}
mutable struct HyperspectralMLCanopyOpticalProperty{FT<:AbstractFloat}
# diagnostic variables that change with time
"Backward diffuse->diffuse scatter weight"
ddb::FT
Expand Down Expand Up @@ -181,11 +182,12 @@ end
# 2022-Jun-10: add more fields for sif calculations
# 2022-Jun-13: add more fields for sif calculations
# 2022-Jun-13: remove unnecessary cache variables
# 2022-Jun-15: rename to HyperspectralMLCanopyOpticalProperty
#
#######################################################################################################################################################################################################
"""
CanopyOpticalProperty{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114, n_λe::Int = 45, n_λf::Int = 29) where {FT<:AbstractFloat}
HyperspectralMLCanopyOpticalProperty{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114, n_λe::Int = 45, n_λf::Int = 29) where {FT<:AbstractFloat}
Construct a struct to store canopy optical properties, given
- `n_azi` Number of azimuth angles
Expand All @@ -195,8 +197,8 @@ Construct a struct to store canopy optical properties, given
- `n_λe` Number of SIF excitation wavelength bins
- `n_λf` Number of SIF wavelength bins
"""
CanopyOpticalProperty{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114, n_λe::Int = 45, n_λf::Int = 29) where {FT<:AbstractFloat} = (
return CanopyOpticalProperty{FT}(
HyperspectralMLCanopyOpticalProperty{FT}(; n_azi::Int = 36, n_incl::Int = 9, n_layer::Int = 20, n_λ::Int = 114, n_λe::Int = 45, n_λf::Int = 29) where {FT<:AbstractFloat} = (
return HyperspectralMLCanopyOpticalProperty{FT}(
0, # ddb
0, # ddf
0, # dob
Expand Down
Loading

2 comments on commit fe76bd4

@Yujie-W
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/63038

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.5 -m "<description of version>" fe76bd452accb5610675c5817a5a338199822352
git push origin v0.3.5

Please sign in to comment.