Computes extraterrestrial radiation, daylength and actual sunshine duration from day of year and latitude, following FAO-56.
Usage
param_radiation(
env.data,
day.id = "DOY",
latitude = "LAT",
solarRadiation = NULL,
merge = TRUE,
verbose = TRUE
)Arguments
- env.data
data.frame. A
get_weatheroutput or equivalent.- day.id
character. Column holding day of year. Default
"DOY".- latitude
character. Column holding latitude. Default
"LAT".- solarRadiation
character. Column holding incoming shortwave radiation. Default
"ALLSKY_SFC_SW_DWN".- merge
boolean. Bind results onto
env.data. DefaultTRUE.- verbose
boolean. Print a summary of what was computed.
Value
A data.frame with n (actual sunshine hours), N (daylength, h) and
RTA (extraterrestrial radiation, MJ/m2/day).
Details
Daylength uses Forsythe et al. (1995), consistent with get_weather.
The two functions previously used different formulas that disagreed by up to
0.5 h at high latitude.
The sunset hour angle is clamped so polar day/night yields 0 rather than
NaN. Missing radiation is median-imputed within the supplied data, and
n is bounded to [0, N].
Examples
# \donttest{
env.data <- get_weather(lat = -13.05, lon = -56.05)
#> ---------------------------------------------------------------
#> get_weather -- downloads daily weather from NASA POWER
#> Last updated at 09/27/2026
#> ---------------------------------------------------------------
#> start.day is NULL; matched as 2024-01-26
#> end.day is NULL; matched as 2024-02-25
#> ---------------------------------------------------------------
#> get_weather() - daily weather from NASA POWER
#> https://docs.ropensci.org/nasapower
#> ---------------------------------------------------------------
#> Start .............................. Thu Oct 22 18:34:52 2026
#> Environmental units ................ 1
#> Parallel ........................... [ ]
#> [1/1] env1 downloaded
#> Computing VPD ...................... [ x ]
#> Computing N, RTA ................... [ x ]
#> Computing n ........................ [ x ]
#> Computing TH1 ...................... [ x ]
#> Computing TH2 ...................... [ x ]
#> Computing PAR_TEMP ................. [ x ]
#> Environmental units downloaded ..... 1/1
#> Daily weather features ............. 25
#> Done ............................... Thu Oct 22 18:34:52 2026
#> Total time ......................... 0.9s
param_radiation(env.data)
#> ---------------------------------------------------------------
#> param_radiation -- derives radiation parameters
#> Last updated at 09/27/2026
#> ---------------------------------------------------------------
#> ----------------------------------------------------------------------
#> Extraterrestrial radiation (RTA, MJ/m^2/day)
#> Daylight hours (N, hours)
#> Actual duration of sunshine (n, hours)
#> ----------------------------------------------------------------------
#> env LON LAT YEAR MM DD DOY YYYYMMDD daysFromStart T2M T2M_MAX
#> 1 env1 -56.05 -13.05 2024 1 26 26 2024-01-26 1 27.02 32.35
#> 2 env1 -56.05 -13.05 2024 1 27 27 2024-01-27 2 26.85 32.83
#> 3 env1 -56.05 -13.05 2024 1 28 28 2024-01-28 3 26.85 32.99
#> 4 env1 -56.05 -13.05 2024 1 29 29 2024-01-29 4 26.38 31.29
#> 5 env1 -56.05 -13.05 2024 1 30 30 2024-01-30 5 27.15 33.14
#> 6 env1 -56.05 -13.05 2024 1 31 31 2024-01-31 6 26.98 31.98
#> 7 env1 -56.05 -13.05 2024 2 1 32 2024-02-01 7 27.68 35.01
#> 8 env1 -56.05 -13.05 2024 2 2 33 2024-02-02 8 25.82 29.41
#> 9 env1 -56.05 -13.05 2024 2 3 34 2024-02-03 9 24.92 29.08
#> 10 env1 -56.05 -13.05 2024 2 4 35 2024-02-04 10 23.90 27.20
#> 11 env1 -56.05 -13.05 2024 2 5 36 2024-02-05 11 23.85 26.68
#> 12 env1 -56.05 -13.05 2024 2 6 37 2024-02-06 12 24.70 29.19
#> 13 env1 -56.05 -13.05 2024 2 7 38 2024-02-07 13 26.19 31.14
#> 14 env1 -56.05 -13.05 2024 2 8 39 2024-02-08 14 26.32 31.06
#> 15 env1 -56.05 -13.05 2024 2 9 40 2024-02-09 15 26.46 30.88
#> 16 env1 -56.05 -13.05 2024 2 10 41 2024-02-10 16 26.55 30.83
#> 17 env1 -56.05 -13.05 2024 2 11 42 2024-02-11 17 25.10 27.73
#> 18 env1 -56.05 -13.05 2024 2 12 43 2024-02-12 18 24.88 28.62
#> 19 env1 -56.05 -13.05 2024 2 13 44 2024-02-13 19 25.75 30.60
#> 20 env1 -56.05 -13.05 2024 2 14 45 2024-02-14 20 26.60 31.55
#> 21 env1 -56.05 -13.05 2024 2 15 46 2024-02-15 21 26.90 32.02
#> 22 env1 -56.05 -13.05 2024 2 16 47 2024-02-16 22 26.97 32.18
#> 23 env1 -56.05 -13.05 2024 2 17 48 2024-02-17 23 26.72 32.45
#> 24 env1 -56.05 -13.05 2024 2 18 49 2024-02-18 24 25.11 29.68
#> 25 env1 -56.05 -13.05 2024 2 19 50 2024-02-19 25 25.12 28.54
#> 26 env1 -56.05 -13.05 2024 2 20 51 2024-02-20 26 24.95 29.32
#> 27 env1 -56.05 -13.05 2024 2 21 52 2024-02-21 27 25.66 29.68
#> 28 env1 -56.05 -13.05 2024 2 22 53 2024-02-22 28 25.83 29.85
#> 29 env1 -56.05 -13.05 2024 2 23 54 2024-02-23 29 25.60 29.36
#> 30 env1 -56.05 -13.05 2024 2 24 55 2024-02-24 30 24.89 28.83
#> 31 env1 -56.05 -13.05 2024 2 25 56 2024-02-25 31 26.04 30.94
#> T2M_MIN T2MDEW ALLSKY_SFC_LW_DWN ALLSKY_SFC_SW_DWN ALLSKY_SFC_SW_DNI
#> 1 22.32 22.44 35.30 26.78 25.35
#> 2 21.62 21.64 34.43 28.22 26.59
#> 3 21.87 21.63 35.53 25.32 21.41
#> 4 22.29 22.23 36.41 21.83 13.90
#> 5 22.20 22.26 36.32 23.93 16.35
#> 6 22.93 22.83 36.66 22.36 15.35
#> 7 22.18 23.07 36.21 23.51 16.23
#> 8 23.30 23.31 36.22 17.62 5.43
#> 9 22.35 21.99 35.69 10.93 1.17
#> 10 21.99 22.63 35.98 15.04 2.12
#> 11 21.27 22.35 35.33 19.96 6.61
#> 12 21.02 21.95 35.24 24.17 17.73
#> 13 21.69 22.82 36.01 20.44 11.75
#> 14 21.68 22.32 36.00 21.35 14.15
#> 15 22.39 23.55 36.15 24.04 18.63
#> 16 22.78 23.69 36.90 14.18 4.39
#> 17 23.28 23.71 36.27 16.46 3.98
#> 18 22.39 22.66 35.98 13.06 0.42
#> 19 21.16 22.71 36.25 23.18 15.54
#> 20 21.86 23.19 35.96 24.90 24.11
#> 21 22.10 23.31 36.05 25.94 24.93
#> 22 22.01 23.44 35.96 24.54 18.15
#> 23 22.57 23.20 36.73 15.83 5.74
#> 24 20.63 22.99 36.31 20.02 7.81
#> 25 22.74 23.89 36.44 14.02 1.07
#> 26 21.72 23.16 36.24 16.11 5.01
#> 27 22.44 23.47 36.69 17.04 8.82
#> 28 23.22 23.62 36.82 15.06 5.11
#> 29 22.81 23.48 36.75 12.66 1.80
#> 30 22.58 23.14 36.22 19.14 8.83
#> 31 21.73 23.06 35.68 24.17 20.23
#> ALLSKY_SFC_PAR_TOT ALLSKY_SFC_UVA ALLSKY_SFC_UVB PRECTOT EVPTRNS QV2M RH2M
#> 1 12.65 1.73 0.05 0.98 10.53 17.69 78.25
#> 2 13.09 1.77 0.05 0.04 12.96 16.82 76.13
#> 3 11.90 1.62 0.05 0.02 10.89 16.78 76.02
#> 4 10.52 1.46 0.05 3.89 5.53 17.37 79.65
#> 5 11.43 1.56 0.05 11.19 6.96 17.46 77.67
#> 6 10.80 1.51 0.05 7.07 10.02 18.05 80.10
#> 7 11.21 1.54 0.05 20.72 8.53 18.35 78.88
#> 8 8.67 1.21 0.04 8.17 5.96 18.56 86.85
#> 9 5.53 0.80 0.03 10.30 8.06 17.13 85.02
#> 10 7.65 1.13 0.04 30.84 2.82 17.81 92.81
#> 11 9.76 1.36 0.04 12.36 3.74 17.51 91.65
#> 12 11.59 1.61 0.05 12.10 7.53 17.07 85.54
#> 13 9.97 1.42 0.05 4.50 11.10 18.04 83.04
#> 14 10.35 1.45 0.05 14.02 11.88 17.55 79.76
#> 15 11.55 1.55 0.05 10.55 10.42 18.88 85.29
#> 16 7.05 0.98 0.03 18.91 12.13 19.04 85.42
#> 17 8.17 1.13 0.04 22.32 4.33 19.03 92.31
#> 18 6.52 0.88 0.03 0.93 8.37 17.82 88.18
#> 19 11.21 1.54 0.05 1.49 12.34 17.88 84.44
#> 20 11.90 1.63 0.05 0.76 14.01 18.41 82.96
#> 21 12.34 1.68 0.05 4.73 12.68 18.57 82.17
#> 22 11.68 1.59 0.05 5.48 13.25 18.73 82.63
#> 23 7.84 1.10 0.03 2.97 12.40 18.48 82.71
#> 24 9.74 1.35 0.04 30.18 7.17 18.28 88.88
#> 25 7.00 0.98 0.03 20.53 3.72 19.29 93.09
#> 26 8.02 1.15 0.04 16.51 7.66 18.47 90.46
#> 27 8.46 1.22 0.04 3.54 9.43 18.83 88.61
#> 28 7.53 1.07 0.03 1.73 8.07 18.98 88.46
#> 29 6.43 0.92 0.03 1.51 9.25 18.79 88.82
#> 30 9.42 1.31 0.04 6.72 6.09 18.36 90.64
#> 31 11.56 1.59 0.05 2.25 12.62 18.28 84.88
#> GWETROOT GWETTOP FROST_DAYS WS2M VPD N RTA n TH1
#> 1 0.71 0.73 0 0.38 1.0570758 12.728 40.232 8.020 77.92817
#> 2 0.69 0.70 0 0.35 1.1963363 12.720 40.216 8.410 77.39841
#> 3 0.68 0.68 0 0.43 1.2402607 12.711 40.199 6.770 77.38490
#> 4 0.68 0.68 0 0.34 0.9479085 12.701 40.180 4.394 77.07940
#> 5 0.68 0.72 0 0.42 1.1868980 12.692 40.161 5.167 78.06122
#> 6 0.69 0.75 0 0.46 0.9927726 12.682 40.140 4.850 78.09437
#> 7 0.69 0.77 0 0.34 1.3280358 12.673 40.117 5.127 79.05660
#> 8 0.73 0.80 0 0.46 0.6186276 12.663 40.094 1.715 76.99507
#> 9 0.72 0.75 0 0.49 0.7202045 12.653 40.068 0.369 75.30245
#> 10 0.75 0.89 0 0.50 0.3776662 12.643 40.042 0.669 74.34694
#> 11 0.78 0.85 0 0.49 0.3128784 12.633 40.014 2.087 74.15249
#> 12 0.77 0.83 0 0.40 0.6340613 12.622 39.984 5.597 74.99188
#> 13 0.77 0.80 0 0.46 0.7824328 12.612 39.953 3.709 77.16987
#> 14 0.76 0.82 0 0.39 0.8544113 12.601 39.920 4.467 76.99642
#> 15 0.77 0.82 0 0.41 0.6804262 12.591 39.886 5.881 77.87819
#> 16 0.76 0.84 0 0.45 0.6819151 12.580 39.850 1.386 78.04266
#> 17 0.79 0.89 0 0.53 0.3567582 12.569 39.812 1.257 76.36878
#> 18 0.79 0.80 0 0.69 0.5607959 12.558 39.772 0.133 75.56285
#> 19 0.77 0.78 0 0.57 0.6908651 12.547 39.731 4.908 76.60845
#> 20 0.75 0.76 0 0.56 0.7864117 12.536 39.688 7.615 77.82941
#> 21 0.74 0.77 0 0.48 0.8475449 12.525 39.643 7.877 78.22138
#> 22 0.73 0.76 0 0.54 0.8393412 12.513 39.596 5.736 78.39207
#> 23 0.73 0.75 0 0.46 0.9634764 12.502 39.547 1.815 77.99478
#> 24 0.75 0.86 0 0.55 0.4906680 12.490 39.496 2.470 76.02385
#> 25 0.77 0.85 0 0.58 0.3687032 12.479 39.444 0.339 76.48570
#> 26 0.80 0.88 0 0.66 0.5029901 12.467 39.389 1.586 75.91779
#> 27 0.79 0.81 0 0.64 0.5504202 12.456 39.333 2.793 76.92332
#> 28 0.78 0.80 0 0.43 0.6103149 12.444 39.274 1.619 77.19325
#> 29 0.77 0.78 0 0.51 0.5414807 12.432 39.214 0.571 76.84528
#> 30 0.76 0.80 0 0.46 0.5193414 12.420 39.151 2.801 75.83407
#> 31 0.76 0.78 0 0.58 0.7193274 12.409 39.086 6.423 77.13628
#> TH2 PAR_TEMP n N RTA
#> 1 76.2984 0.4681717 8.472473 12.72843 40.23233
#> 2 75.8404 0.4875233 8.925401 12.71956 40.21623
#> 3 75.8368 0.4432030 8.005939 12.71052 40.19895
#> 4 75.5828 0.3987870 6.900611 12.70132 40.18047
#> 5 76.3636 0.4209945 7.562575 12.69196 40.16073
#> 6 76.3988 0.4002965 7.064811 12.68244 40.13970
#> 7 77.1852 0.4049855 7.426641 12.67278 40.11734
#> 8 75.4116 0.3357862 5.565018 12.66297 40.09360
#> 9 74.0364 0.2219101 3.451534 12.65303 40.06845
#> 10 73.2468 0.3200837 4.748782 12.64295 40.04184
#> 11 73.0960 0.4092243 6.301574 12.63274 40.01374
#> 12 73.8020 0.4692308 7.630124 12.62242 39.98412
#> 13 75.6052 0.3806796 6.452309 12.61197 39.95292
#> 14 75.5552 0.3932371 6.739458 12.60141 39.92012
#> 15 76.1380 0.4365079 7.588719 12.59073 39.88568
#> 16 76.2784 0.2655367 4.476430 12.57996 39.84956
#> 17 74.8356 0.3254980 5.196635 12.56908 39.81174
#> 18 74.2376 0.2620579 4.123710 12.55811 39.77216
#> 19 75.1256 0.4353398 7.320274 12.54704 39.73082
#> 20 76.1484 0.4473684 7.865006 12.53589 39.68766
#> 21 76.4916 0.4587361 8.195451 12.52466 39.64267
#> 22 76.6084 0.4330738 7.755299 12.51334 39.59582
#> 23 76.2720 0.2934132 5.004312 12.50195 39.54707
#> 24 74.5864 0.3878933 6.331199 12.49049 39.49640
#> 25 74.9204 0.2786624 4.435552 12.47896 39.44379
#> 26 74.4876 0.3214429 5.099091 12.46736 39.38922
#> 27 75.3092 0.3296960 5.396158 12.45571 39.33266
#> 28 75.5332 0.2915215 4.771760 12.44400 39.27410
#> 29 75.2528 0.2511719 4.013718 12.43223 39.21352
#> 30 74.4204 0.3784652 6.072062 12.42041 39.15089
#> 31 75.5416 0.4439324 7.673153 12.40855 39.08622
# }
