|
| 1 | +using DocStringExtensions: TYPEDFIELDS |
| 2 | +using DataFrames: DataFrame |
| 3 | + |
| 4 | +# include("../SPAC/SPAC.jl") |
| 5 | + |
| 6 | +export s_coszs, lai2, VCmax |
| 7 | +export fill_meteo!, meteo_pack_jl |
| 8 | +export snow_density |
| 9 | + |
| 10 | +include("Leaf.jl") |
| 11 | +include("list.jl") |
| 12 | +include("lai2.jl") |
| 13 | +include("VCmax.jl") |
| 14 | +include("snow_density.jl") |
| 15 | +include("helper.jl") |
| 16 | +include("BEPS_helper.jl") |
| 17 | + |
| 18 | +""" |
| 19 | + s_coszs(jday::Int, j::Int, lat::Float64, lon::Float64) |
| 20 | +
|
| 21 | +# Example |
| 22 | +```julia |
| 23 | +jday, hour, lat, lon = 20, 12, 20., 120. |
| 24 | +s_coszs(jday, hour, lat, lon) |
| 25 | +``` |
| 26 | +""" |
| 27 | +function s_coszs(jday::Int, hour::Int, lat::Float64, lon::Float64) |
| 28 | + Delta = 0.006918 - 0.399912 * cos(jday * 2π / 365.0) + 0.070257 * sin(jday * 2π / 365.0) - |
| 29 | + 0.006758 * cos(jday * 4π / 365.0) + 0.000907 * sin(jday * 4π / 365.0) |
| 30 | + # delta is the declination angle of sun. |
| 31 | + |
| 32 | + hr = hour + lon / 15.0 # UTC time |
| 33 | + # hr =j*24.0/RTIMES; # local time |
| 34 | + hr > 24 && (hr = hr - 24) |
| 35 | + hr < 0 && (hr = 24 + hr) |
| 36 | + |
| 37 | + Lat_arc = π * lat / 180.0 |
| 38 | + Hsolar1 = (hr - 12.0) * 2.0 * π / 24.0 # local hour angle in arc. |
| 39 | + |
| 40 | + # sin(h) |
| 41 | + CosZs = cos(Delta) * cos(Lat_arc) * cos(Hsolar1) + sin(Delta) * sin(Lat_arc) |
| 42 | + return CosZs |
| 43 | +end |
| 44 | + |
| 45 | +function meteo_pack_jl(Ta::FT, RH::FT) where {FT<:Real} |
| 46 | + ρₐ::FT = 1.292 # ρ_air, kg/m3 |
| 47 | + es::FT = cal_es(Ta) |
| 48 | + ea::FT = es * RH / 100 |
| 49 | + VPD::FT = es - ea |
| 50 | + |
| 51 | + q::FT = ea2q(ea) |
| 52 | + cp::FT = cal_cp(q) |
| 53 | + |
| 54 | + λ::FT = cal_lambda(Ta) |
| 55 | + Δ::FT = cal_slope(Ta) # slope of es |
| 56 | + γ::FT = 0.066 # kPa/K, |
| 57 | + # lambda = cal_lambda(Ta) # J kg-1 |
| 58 | + # psy = cp * 101.13 / (0.622 * lambda) |
| 59 | + (; ρₐ, cp, VPD, λ, Δ, γ, es, ea, q) |
| 60 | +end |
0 commit comments