-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding two leaf irradience model #245
base: develop
Are you sure you want to change the base?
Changes from 1 commit
cc90b94
20b58b9
0ec30c2
3da610e
f7022a0
b67ef47
707b5f7
f6e94ba
219e0c3
ec6725d
e83a94e
06d69d3
1a569a7
0fc6984
5c77794
c384586
4cba1f2
5905b40
9cf9b0a
bbd93ca
6b9e8f3
c928f56
4911eec
d9a1434
1844bac
337e3fd
fd225bf
16e631f
bad57d5
40b18c4
4747cfb
5a0db3c
100f1a4
e57bc11
8b04a38
b6b83a1
4c96406
2e24adc
c6f2099
f0b09f9
71f478f
dc7cf66
16c2251
4d627f8
8b6a5dd
b683b51
3fe4bdc
87b2f49
b5c20e7
0a8ed70
0f55afe
9434fd2
1874eeb
92e6fb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""To do.""" | ||
|
||
from dataclasses import dataclass | ||
|
||
import numpy as np | ||
|
||
from pyrealm.constants import ConstantsClass | ||
|
||
|
||
@dataclass(frozen=True) | ||
class TwoLeafConst(ConstantsClass): | ||
"""Pyrealm two leaf canopy model constants dataclass.""" | ||
|
||
# two leaf canopy model constants | ||
|
||
k_fa: float = 0.426 # needs citation | ||
"""scattering coefficient of PAR in the atmosphere, dimensionless""" | ||
k_sigma: float = 0.15 # needs citation | ||
"""leaf scattering coefficient of PAR (relections and transmissivity), | ||
dimensionless""" | ||
k_rho_cd: float = 0.036 # needs citation | ||
"""canopy reflection coefficient for diffuse PAR, dimensionless""" | ||
k_kd_prime: float = 0.719 # needs citation | ||
"""diffuse and scattered diffuse PAR extinction coefficient, dimensionless""" | ||
|
||
k_sol_obs_angle: float = np.deg2rad(1) # needs a citation | ||
""" solar obscurity angle, radians""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""To do.""" | ||
|
||
import numpy as np | ||
from numpy.typing import NDArray | ||
|
||
|
||
class TwoLeafIrradience: | ||
"""Calculates two-leaf irradience.""" | ||
|
||
def __init__(self, beta_angle: NDArray, PPFD: NDArray, LAI: NDArray, PATM: NDArray): | ||
|
||
self.beta_angle: NDArray = beta_angle | ||
|
||
|
||
def beta_angle(lat: NDArray, d: NDArray, h: NDArray) -> NDArray: | ||
"""Calculates solar beta angle. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reference for this is page 554 of this: I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added pysolar alternatives in the latest commit which calculate solar elevation directly from latitude, longitude and date time. However, they don't take array inputs natively so you need to use and enumerate operation, so there will be a speed accuracy trade. The best pysolar solar elevation implementation includes atmospheric distortion, but they also have a faster/simpler version which is the same as the first version I wrote. Because the first version uses numpy vectorisation it may well be faster but I've included the pysolar fast version anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will move these calcs into the core solar library in a sec |
||
|
||
Calculates solar beta angle using Eq A13 of dePury & Farquhar (1997). | ||
|
||
Args: | ||
lat: array of latitudes (rads) | ||
d: array of declinations (rads) | ||
h: array of hour angle (rads) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've adopted Keith's short variable names in my rough and ready translation to Python, but we should shift to longer names ( |
||
|
||
Returns: | ||
beta: array of solar beta angles | ||
""" | ||
|
||
beta = np.sin(lat) * np.sin(d) + np.cos(lat) * np.cos(d) * np.cos(h) | ||
|
||
return beta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although these variable names are acronyms, I think we should stick to lower case variable names:
ppfd
,lai
,patm
(and arguably longer -leaf_area_index
, although I know I'm guilty of usingpatm
andtc
elsewhere.We could do with a sweep to standardise /check variable names, really!