Clarification about code lines in functionsWBclim.R file
Hi Nico!
I am working on the functionsWBclim.R file and I need some help clarifying a couple of lines in the code.
- The first one is on line 64:
if ( sunrise_sunset_daylen[3]==0 ) sunrise_sunset_daylen = c(12*3600,12*3600,0)
From this line what I understand is that if the day length is 0 (i.e. no daylight) the object `sunrise_sunset_daylen` will be transformed to 43200, 43200, 0. However, this might cause some troubles when calculating the radiation on line 71:
io <- sapply(timeRelativeToSunset, FUN = function(x) calculate.radiationDiurnalPattern(timeoftheday = x, daylength = sunrise_sunset_daylen[3]))
..this is because the function calculate.radiationDiurnalPattern divides time of the day by day length which will be a division by 0:
w <- ws - (timeoftheday / daylength) * (ws * 2.0)
Is there a bug there?
- The second code line that I need help with is line 68:
timeRelativeToSunset <- TIME_HOUR * 3600 - sunrise_sunset_daylen[1] # time relative to sunset (in seconds)
My confusion with this line is with sunrise_sunset_daylen[1].
Since the comment says "time relative to sunset" I was expecting that the parameter selected would be sunset i.e. sunrise_sunset_daylen[2] and not sunrise_sunset_daylen[1].
Is this fine or is it a bug?
Pura Vida;
Erick