-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add chilling hours and clearsky_radiation functions
- Loading branch information
Showing
6 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Calculate the clear sky radiation. | ||
#' | ||
#' This function computes the clear sky radiation using the formula proposed by Allen et al. (1998). | ||
#' | ||
#' @param j numeric. Day of the year. | ||
#' @param lat numeric. Latitude in radians. | ||
#' @param elev numeric. Elevation in meters. | ||
#' | ||
#' @return A numeric value of the clear sky radiation in W/m2/day. | ||
#' | ||
#' @examples | ||
#' # date='2024-03-09' | ||
#' # lat=-30.631261 | ||
#' # elev=80 | ||
#' | ||
#' lat = convert_units(-30.631261, "angle", "deg", "rad") | ||
#' clearsky_radiation(j=69, lat=lat, elev=80) | ||
#' | ||
#' @export | ||
clearsky_radiation = function(j, lat, elev){ | ||
dr = 1 + 0.033 * cos(2 * pi * j / 365) | ||
delta_s = 0.409 * sin((2 * pi * j / 365) - 1.39) | ||
ws = acos(-tan(lat) * tan(delta_s)) | ||
ra = (24 * 60 / pi) * 0.0820 * dr * (ws * sin(lat) * sin(delta_s) + | ||
cos(lat) * cos(delta_s) * sin(ws)) | ||
rso = (0.75 + 0.00002 * elev) * ra | ||
return(rso) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.