DrylandEcology/rSFSW2

Aggregation `dailyThermalDrynessStress` fails

Closed this issue · 1 comments

Error in ids_hotcold[[j]] : subscript out of bounds

This error occurred because ids_hotcold is a vector of length isim_time$no.useyr (e.g., here 31) corresponding to the unique years of simTime2$year_ForEachUsedDay as calculated by

ids_hotcold <- tapply(Temp_during_Stress1[, d2],
                  INDEX = simTime2$year_ForEachUsedDay, FUN = fun_kLargest,
                  largest = extreme[ihot], fun = "index", k = 10L, na.rm = TRUE)

However, the code then looped over ids_hotcold with indices from seq_len(simTime2$no.useyr_NSadj) which is here 1:32 (to account for different hemispheric seasons). The correct index to use is isim_time$no.useyr.