Photosynthesis Reduction Factor (PRFT)#
Photosynthesis Reduction Factor (PRFT) is a quadratic equation1 is used to calculate the temperature reduction factor that affects photosynthesis (Ritchie et al., 1998):
\(\ PRFT = 1 - 0.0025 * (T_{day} - T_{opt})^2\)
Code for PRFT:
def calcPRFT(TDay, TOpt=18):
''' Estimate Photosynthesis reduction factor (PRFT)
Parameters:
TDay (float): Number or array of Day Temperatures
TOpt (float): Optimum Temperature. Default value 18
Returns:
(float): A number or array of PRFT
'''
PRFT = 0
if (TDay > 0):
PRFT = 1 - 0.0025 * (TDay - TOpt) ** 2
return PRFT
# -----------------------------------------------------------------
# The code below, allows run calculations faster using a NDVIA GPU
# or available CPU cores to run in parallel.
# -----------------------------------------------------------------
@guvectorize([(float64[:], float64[:], float64[:])], '(n), ()->(n)')
def PRFT_gu(Tday, Topt, res):
for i in range(Tday.shape[0]):
res[i] = 1 - 0.0025*(Tday[i]-Topt[0])**2 if Tday[i] > 0.0 else 0.0
@numba.vectorize([float64(float64, float64)])
def getPRFT(Tday, Topt):
prft = 1 - 0.0025*(Tday-Topt)**2 if Tday > 0.0 else 0.0
return prft
@numba.jit(parallel=True)
def apply_PRFT(Tday, Topt=18):
n = len(Tday)
result = np.zeros(n, dtype="float64")
for i in range(n):
result[i] = getPRFT(Tday[i], Topt)
return result
def calculatePRFT(Tday, Topt=18):
''' Estimate Photosynthesis reduction factor (PRFT) in parallel.
Parameters:
Tday (float): Number or array of Day Temperatures
Topt (float): Optimum Temperature. Default value 18
Returns:
(float): A number or array of PRFT
'''
if (Tday is None):
print("Day Temperature parameter is not valid")
return
result = []
try:
result = apply_PRFT(Tday, Topt)
except:
print("Error calculating photosynthesis reduction factor (PRFT)")
return result #pd.Series(result, index=w.index, name="PRFT") int(GDD)
Check the API reference to know how to use it.
# Function to calculate the Photosynthetic Reduction Factor (PRFT)
calculatePRFT <- function(Tday, Topt){
prft <- 0
if (Tday > 0){
prft <- 1.0 - 0.0025*(Tday-Topt)^2
}
return(prft)
}
calculatePRFT_wrap <- function(Tday, Topt){
prft <- vector("numeric", length (Tday))
for (i in 1:length(Tday)) {
prft[[i]] <- calculatePRFT(Tday=Tday[[i]], Topt)
}
return(prft)
}
The whole R code can be found in the Github repository at Rcode
folder.
-
hyperbola with two parameters ↩