Given a data table with multiple years of data, this function derives the tercile category per year.
It first derives terciles for the data and then returns, for each row, a -1 if the data falls into
the lowest tercile, 0 if it falls between 1st and second tercile, and +1 if it falls above the third tercile.
Allows grouping by levels (e.g. months and location-coordinates): Tercile categories are derived separately
for each level.